lcgdm-1.8.7/0000755000175000017500000000000012202120644012146 5ustar ellertellertlcgdm-1.8.7/test/0000755000175000017500000000000012202120643013124 5ustar ellertellertlcgdm-1.8.7/test/perl/0000755000175000017500000000000012202120643014066 5ustar ellertellertlcgdm-1.8.7/test/perl/lfc/0000755000175000017500000000000012202120643014632 5ustar ellertellertlcgdm-1.8.7/test/perl/lfc/UI_validation_tests.pl0000755000175000017500000000113510567336044021163 0ustar ellertellert#!/usr/bin/perl -w use strict; use lfc; # stat an existing entry in the LFC and print the FILEID my ($name,$stat,$fileid,$res); $name = "/grid/dteam"; # $stat = new lfc::lfc_filestatg(); $stat = lfcc::new_lfc_filestatg(); $res = lfc::lfc_statg($name,undef,$stat); if ($res == 0) { $fileid = lfcc::lfc_filestatg_fileid_get($stat); print "[OK] The FILEID for $name is $fileid\n"; } else { my $err_num = $lfc::serrno; my $err_string = lfc::sstrerror($err_num); print "[ERROR] There was an error while looking for $name: Error $err_num ($err_string)\n"; exit(1); } lfcc::delete_lfc_filestatg($stat); lcgdm-1.8.7/test/Imakefile0000644000175000017500000000237711763665646015002 0ustar ellertellertCOMM @(#)$RCSfile: Imakefile,v $ $Revision: 1.4 $ $Date: 2008/09/24 11:25:01 $ CERN IT-GD/CT Jean-Philippe Baud COMM COMM Copyright (C) 1999-2008 by CERN/IT/GD/CT & CNRS/IN2P3/LAL COMM All rights reserved COMM COMM Make DPM tests #include SUBDIRS = $(NSDIR) $(DPMDIR) $(SRMV1DIR) $(SRMV2DIR) $(SRMV2_2DIR) MakeSubdirs(all,$(SUBDIRS)) MakeSubdirs(clean,$(SUBDIRS)) MakeSubdirs(clobber,$(SUBDIRS)) MakeSubdirs(install,$(SUBDIRS)) MakeSubdirs(install.man,$(SUBDIRS)) #if defined(_WIN32) Makefiles: @for %i in ( $(SUBDIRS) ) \ do @(echo test\\%i - & cd %i & \ imake -Ui386 -I../../config ;\ $(MAKE) $(MFLAGS) $@ & cd .. ) depend: @echo Not supported on this platform #else Makefiles: @. ../setosflags ;\ for i in $(SUBDIRS) ;\ do (if [ -d $$i ] ;\ then \ (echo " $$i:" ; cd $$i ;\ imake -I../../config -DOSMajorVersion="$$OSMAJNO" -DOSMinorVersion="$$OSMINNO" ;\ $(MAKE) $(MFLAGS) $@) ;\ else \ (echo "ERROR : No directory $$i" ;\ exit 1) ;\ fi )\ done ; depend: for i in $(SUBDIRS) ;\ do (if [ -d $$i ] ;\ then \ (echo " test/$$i:" ; cd $$i ;\ $(MAKE) $(MFLAGS) $@) ;\ else \ (echo "ERROR : No directory $$i" ;\ exit 1) ;\ fi )\ done ; #endif lcgdm-1.8.7/test/.cvsignore0000644000175000017500000000001410173760603015132 0ustar ellertellertCounterFile lcgdm-1.8.7/test/srmv2.2/0000755000175000017500000000000012202120643014335 5ustar ellertellertlcgdm-1.8.7/test/srmv2.2/srm2_testSetPermission.c0000644000175000017500000001561210542043011021153 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testSetPermission.c,v 1.1 2006/12/19 20:05:29 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbgroups = 0; int nbusers = 0; //static enum ns1__TRequestType rtypes[] = {PrepareToGet, PrepareToPut, Copy}; //static enum ns1__TPermissionType rtypes[] = {ADD, REMOVE, CHANGE}; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmSetPermissionResponse_ rep; struct ns1__srmSetPermissionRequest req; struct ns1__TGroupPermission *reqfilep; struct ns1__TUserPermission *requserp; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; static enum ns1__TPermissionMode permod[] = { NONE, X, W, WX, R, RX, RW, RWX, }; if (argc < 5) { fprintf (stderr, "usage: %s PermT OwnP OthP SURL nbGr nbUs [ [ [group1 perm1] [group2 perm2] [...] ] | [ [user1 perm1] [user2 perm2] [...] ] ]\n", argv[0]); exit (1); } if (parsesurl (argv[4], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.permissionType = soap_malloc (&soap, sizeof(struct ns1__TPermissionType))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.permissionType = atoi(argv[1]); if ( strcmp(argv[2], "-") ) { /* if ((req.ownerPermission = //soap_malloc (&soap, sizeof(struct ns1__TOwnerPermission))) == NULL) { soap_malloc (&soap, sizeof(struct ns1__TPermissionMode))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ //req.ownerPermission->mode = &permod[atoi(argv[2])]; //req.ownerPermission->mode = atoi(argv[2]); req.ownerPermission = &permod[atoi(argv[2])]; } if ( strcmp(argv[3], "-") ) { /* if ((req.otherPermission = //soap_malloc (&soap, sizeof(struct ns1__TOtherPermission))) == NULL) { soap_malloc (&soap, sizeof(struct ns1__TPermissionMode))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ //req.otherPermission->mode = &permod[atoi(argv[3])]; //req.otherPermission->mode = atoi(argv[3]); req.otherPermission = &permod[atoi(argv[3])]; } /* To set the Group Permissions ... */ if ( strcmp(argv[5], "-") ) { nbgroups = atoi(argv[5]); if ((req.arrayOfGroupPermissions = soap_malloc (&soap, sizeof(struct ns1__ArrayOfTGroupPermission))) == NULL || (req.arrayOfGroupPermissions->groupPermissionArray = soap_malloc (&soap, nbgroups * sizeof(struct ns1__TGroupPermission *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } for (i = 0; i < nbgroups; i++) { if ((req.arrayOfGroupPermissions->groupPermissionArray[i] = soap_malloc (&soap, sizeof(struct ns1__TGroupPermission))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } req.arrayOfGroupPermissions->__sizegroupPermissionArray = nbgroups; for (i = 0; i < nbgroups; i++) { reqfilep = req.arrayOfGroupPermissions->groupPermissionArray[i]; /* if ((reqfilep->mode = soap_malloc (&soap, sizeof(struct ns1__TPermissionMode))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ //reqfilep->mode = &permod[atoi(argv[2*i+8])]; reqfilep->mode = atoi(argv[2*i+8]); //reqfilep->groupID = argv[2*i+7]; /* if ((reqfilep->groupID = soap_malloc (&soap, sizeof(struct ns1__TGroupID))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ /* if ((reqfilep->groupID->value = soap_strdup (soap, argv[2*i+7])) == NULL) repfilep->owner = NULL; */ reqfilep->groupID = argv[2*i+7]; /* GG special tests */ /* if ( i == 0 ) //CRASHreqfilep->groupID->value = NULL; //CRASHreqfilep->groupID = NULL; //GOODreq.groupPermission->groupPermissionArray[i] = NULL; //BAD-CLIENTSEGFAULTreq.groupPermission = NULL; */ } } /* GG special tests */ //GOODreq.groupPermission = NULL; /* To set the User Permissions ... */ if ( strcmp(argv[6], "-") ) { nbusers = atoi(argv[6]); if ((req.arrayOfUserPermissions = soap_malloc (&soap, sizeof(struct ns1__ArrayOfTUserPermission))) == NULL || (req.arrayOfUserPermissions->userPermissionArray = soap_malloc (&soap, nbusers * sizeof(struct ns1__TUserPermission *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } for (i = 0; i < nbusers; i++) { if ((req.arrayOfUserPermissions->userPermissionArray[i] = soap_malloc (&soap, sizeof(struct ns1__TUserPermission))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } req.arrayOfUserPermissions->__sizeuserPermissionArray = nbusers; for (i = 0; i < nbusers; i++) { requserp = req.arrayOfUserPermissions->userPermissionArray[i]; //requserp->mode = &permod[atoi(argv[2*i+8])]; requserp->mode = atoi(argv[2*i+8]); /* if ((requserp->userID = soap_malloc (&soap, sizeof(struct ns1__TUserID))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ requserp->userID = argv[2*i+7]; /* GG special tests */ /* if ( i == 0 ) //CRASHrequserp->userID->value = NULL; //CRASHrequserp->userID = NULL; //GOODreq.userPermission->userPermissionArray[i] = NULL; //BAD-CLIENTSEGFAULTreq.userPermission = NULL; */ } /* GG special tests */ //GOODreq.userPermission = NULL; } /* To set the SURL path ... */ #if 0 if ((req.SURL = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL /* || (req.SURL->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } #endif req.SURL = argv[4]; req.storageSystemInfo = NULL; printf("Step 1\n"); /* To send the request ... */ if (soap_call_ns1__srmSetPermission (&soap, srm_endpoint, "SetPermission", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmSetPermissionResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testResumeRequest.c0000644000175000017500000000431710542043011021160 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testResumeRequest.c,v 1.1 2006/12/19 20:05:28 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmResumeRequestResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmResumeRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.requestToken = argv[1]; if (soap_call_ns1__srmResumeRequest (&soap, srm_endpoint, "ResumeRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmResumeRequestResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srmv2Suite0000755000175000017500000035117610717450012016370 0ustar ellertellert#!/usr/bin/perl -w ########################################################################################## # # srmv2Suite[.pl] # # A Perl script to test the srmV2.2 interface to the DPM # # Author: Gilbert Grosdidier, LAL (Universite Paris-Sud, Orsay) # Creation Date: 03/11/2004 # Last rev: 18/07/2007 (GG) + 16/11/2007 # ########################################################################################## ### ### Copyright (C) 2004-2007 by CNRS/IN2P3/LAL ### All rights reserved ### # $Id: srmv2Suite,v 1.20 2007/11/17 02:20:58 grodid Exp $ ## Usage : nohup time srmv2Suite lxb1727.cern.ch 8446 grodid fil103926c44 dteam optsubtree > & /tmp/suite-SLC3-lxb1727-sec.lis1244 & ## First : cd /afs/cern.ch/project/gd/grodid/SLC3-srmtester/srmv2.2-t002 ## Usage : nohup time srmv2Suite lxb1727.cern.ch 8446 grodid fil103926s707 dteam subdir7s > & suite-SLC3-lxb1727-sec.lis1707 & use strict; use IO::Handle; ##09use File::CounterFile; no strict 'refs'; use DBI; use POSIX qw(strftime); use Env; STDOUT->autoflush(1); STDERR->autoflush(1); my @glinfo = split /\s+/, `ls -l /proc/$$/fd | grep ' 1 -> ' 2>&1`; my $glogName = $glinfo[-1]; my $gcmd = "nohup $0 @ARGV "."\>\&"." $glogName "."\&"; print STDERR " GCMD: $gcmd \n\n"; print STDOUT " GCMD: $gcmd \n\n"; system("voms-proxy-info -all"); my $target = shift; my $portnum = shift; my $tstNAME = shift; my $sfileH = shift; my $voname = shift; my $subTree = shift; my $pxGRP; my $pxDN; my $Counter; my $value; my $valinc; my $short; my $sfile; my $xCount = 0; my $usage; my $dateST; my $dateSTZ; chomp(my $dday = `date '+%j'`); my $otStart = time(); if ( ! $sfileH ) { require File::CounterFile; $Counter = File::CounterFile->new("./CounterFile", 1000+$dday); $value = $Counter->value(); $valinc = $Counter->inc(); $sfile = "fil$valinc"; $sfileH = $sfile; print " Counter Start Value: $sfile \n"; $sfile = "${sfileH}A0"; # exit 0; } else { print " Counter Start Value: $sfileH \n"; $sfile = "${sfileH}A0"; } #my $stat26 = "26"; my $stat26 = "0"; ## For the new status code values my $rfioSW; ## Run this with something like: ## srmv2Suite full_nodename port_number username some_filename voname [dir_subtree] ##BAD$target =~ m/(\w*?)\.(.*)/; $target =~ m/([-\w]*?)\.(.*)/; my $mach = $1; my $site_domain = $2; chomp(my $fullname = `hostname -f`); if ( ! $target || ! $tstNAME || ! $site_domain ) { print STDERR " Wrong ARGS ! \n"; print STDERR " Usage: $0 Target_FullNodeName Port_Number UserName Unique_FileName VOname [Dir_Subtree]\n"; exit 1; } else { print STDOUT " The target Host is: $target \n"; print STDOUT " The target Domain is: $site_domain \n"; print STDOUT " The current Host is: $fullname \n"; } my $fmach = "$mach.$site_domain"; $ENV{DPNS_HOST} = $fmach; $ENV{DPM_HOST} = $fmach; print STDOUT " Target Servers: DPNS: $ENV{DPNS_HOST} DPM, srmV2: $ENV{DPM_HOST} \n"; chomp(my $day = `date '+%b%d'`); # my $u_token = "gilbert_${day}_v$valinc"; ##my $u_token = "gilbert_${day}_A${sfileH}"; my $u_token = "gilbert_${day}_U${sfileH}"; my $s_token = "gilbert_${day}_S${sfileH}"; my $d_token = "gilbert_${day}_D${sfileH}"; my $mkdir_t = "dir22_${d_token}"; ##19my $endPoint = "https://lxb1901.cern.ch:8444"; my $endPoint = "https://${target}:${portnum}"; my $db1; ##my $shandle1; if ( $target eq 'lxb1727.cern.ch' ) { eval { require DBD::mysql; }; if ( ! $@ ) { my ($userI, $userP) = split /\s+/, `head -1 $HOME/private/Grid/DPMCONFIG/lxb1727`; $db1 = DBI->connect('DBI:mysql:cns_db_alt5:lxb1727', "$userI", "$userP"); } else { print STDOUT "\n WARNING: DBD::mysql NOT available: $@ \n\n"; } ## $shandle1 = $db1->prepare("select ltime,sfn from Cns_file_replica where sfn like ?"); } elsif ( $target eq 'lxb1902.cern.ch' ) { ## $ENV{ORACLE_HOME} = '/usr/lib/oracle/10.1.0.3/client'; $ENV{ORACLECLIENT} = 'libclntsh.so.10.1'; ## $ENV{TWO_TASK} = 'T:accdb'; ## $ENV{TNS_ADMIN} = '/opt/lcg/etc/.tnsadmin'; ## $ENV{TNS_ADMIN} = '/afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-142gk/LCG-DM/test/srmv2.2.8/.tnsadmin'; $ENV{ORACLE_CERN}='/afs/cern.ch/project/oracle'; $ENV{ORACLE_MOUNT}='/afs/cern.ch/project/oracle/@sys'; $ENV{TNS_ADMIN}='/afs/cern.ch/project/oracle/admin'; $ENV{ORACLE_HOME}='/afs/cern.ch/project/oracle/@sys/10103'; $ENV{TWO_TASK}='accdb'; eval { require DBD::Oracle; }; if ( ! $@ ) { my ($userI, $userP) = split /\s+/, `head -1 $HOME/private/Grid/DPMCONFIG/lxb1902`; $db1 = DBI->connect('DBI:Oracle:', "$userI", "$userP"); } else { print STDOUT "\n WARNING: DBD::Oracle NOT available: $@ \n\n"; } ##$shandle1 = $db1->prepare("select ltime,sfn from Cns_file_replica where sfn like ?"); } ##exit 0; my $struct; my $voteam; if ( $ENV{VOTEAM} ) { $voteam = $ENV{VOTEAM}; } elsif ( $voname ) { $voteam = "$voname"; } else { $voteam = 'dteam'; } my $baseDteam = "/dpm/$site_domain/home/$voteam"; if ( $ENV{BASENAME} ) { $baseDteam = $ENV{BASENAME}; } my $baseDpm = $baseDteam; if ( $subTree ) { $baseDpm = "$baseDteam/$subTree"; } my $baseSrm = "srm://${target}:${portnum}/$baseDpm"; my $file = "${baseDpm}/$sfile"; ## The 'S'calar or 'S'hort stuff $short = "srmv22_Tfile.$sfile"; $file = "${baseSrm}/$short"; $struct->{$file}->{short} = "$short"; ## The Abort'F'iles stuff my $Fshort = "srmv22_Tfile.${sfile}F"; my $Ffile = "${baseSrm}/$Fshort"; $struct->{$Ffile}->{short} = "$Fshort"; $struct->{$Ffile}->{input} = "/etc/ldap.conf"; $struct->{$Ffile}->{fflag} = 1; $struct->{$Ffile}->{pin} = 11100000; ## The 'A'rray stuff # $valinc = $Counter->inc(); # $short = "srmv2_Tfile.fil$valinc"; $short = "srmv22_Tfile.${sfileH}A1"; my @Lfile = (); ##push @Lfile, "/dpm/dteam/grodid/fil$valinc"; #push @Lfile, "srm://$target.cern.ch:8444//dpm/dteam/grodid/srm_test_suite_file.fil$valinc"; push @Lfile, "${baseSrm}/$short"; $struct->{$Lfile[0]}->{short} = "$short"; my $tempDir; if ( $ENV{TEMPDIR} ) { $tempDir = $ENV{TEMPDIR}; } else { $tempDir = "/tmp"; } # $valinc = $Counter->inc(); # $short = "srmv2_Tfile.fil$valinc"; $short = "srmv22_Tfile.${sfileH}A2"; push @Lfile, "${baseSrm}/$short"; $struct->{$Lfile[1]}->{short} = "$short"; # $valinc = $Counter->inc(); # $short = "srmv2_Tfile.fil$valinc"; $short = "srmv22_Tfile.${sfileH}A3"; push @Lfile, "${baseSrm}/$short"; $struct->{$Lfile[2]}->{short} = "$short"; $struct->{$file}->{input} = "/etc/ldap.conf"; $struct->{$Lfile[0]}->{input} = "/etc/termcap"; ## Which kind of host are we running on ? if ( -e "/boot/vmlinux-2.4.20-30.7.legacysmp" ) { ## This is RH73 $struct->{$Lfile[1]}->{input} = "/boot/vmlinux-2.4.20-30.7.legacysmp"; $struct->{$Lfile[2]}->{input} = "/boot/initrd-2.4.20-30.7.legacysmp.img"; print STDOUT " The Current Host is a RH73 one: $fullname \n"; } elsif ( -e "/boot/vmlinux-2.4.21-20.EL.cernsmp" ) { ## This is SLC3 ##19if ( $ENV{HOST} eq "lxb1902" ) { ##21chomp(my $fullname = `hostname -f`); ##21if ( "$fullname" eq "$SLhost" ) { $struct->{$Lfile[1]}->{input} = "/boot/vmlinux-2.4.21-20.EL.cernsmp"; $struct->{$Lfile[2]}->{input} = "/boot/initrd-2.4.21-20.EL.cernsmp.img"; ##19 $endPoint = "https://lxb1902.cern.ch:8444"; ##21 $endPoint = "https://${target}:8444"; print STDOUT " The Current Host is a SLC3 one: $fullname \n"; } else { print STDOUT " Host type unidentified: $fullname \n"; ##exit 1; my @bList = `ls -dl /boot/* | sort -rn -k 5,5`; foreach ( @bList ) { my @m = split /\s+/; if ( ! $struct->{$Lfile[1]}->{input} ) { $struct->{$Lfile[1]}->{input} = $m[8]; } elsif ( $m[4]>100000 && $m[4]<900000 ) { $struct->{$Lfile[2]}->{input} = $m[8]; last; } } } foreach my $kfile ( sort keys %{$struct} ) { my $rls = `ls -l $struct->{$kfile}->{input}`; print STDOUT " File: $kfile Orig: $struct->{$kfile}->{input} \n$rls"; } ## Path setup ... one must start it from test/srmv2 for the time being ... $ENV{PATH} = "../../rfio:$ENV{PATH}"; $ENV{PATH} = "$ENV{PATH}:../../socket/dpmcli"; $ENV{PATH} = "$ENV{PATH}:../../ns"; $ENV{PATH} = "$ENV{PATH}:../../dpm"; $ENV{PATH} = "$ENV{PATH}:../../test/srmv1"; $ENV{PATH} = "$ENV{PATH}:../../test/srmv2"; $struct->{$file}->{fflag} = 1; $struct->{$Lfile[0]}->{fflag} = 2; $struct->{$Lfile[1]}->{fflag} = 2; $struct->{$Lfile[2]}->{fflag} = 2; $struct->{$file}->{pin} = 111000; $struct->{$Lfile[0]}->{pin} = 222000; $struct->{$Lfile[1]}->{pin} = 333000; $struct->{$Lfile[2]}->{pin} = 444000; ## Sizes in kbytes (1024) my $dss; ($struct->{$file}->{size}, $dss) = split /\s+/, `ls -s $struct->{$file}->{input} | awk '{print \$1}'`; ($struct->{$Ffile}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Ffile}->{input} | awk '{print \$1}'`; ($struct->{$Lfile[0]}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Lfile[0]}->{input} | awk '{print \$1}'`; ($struct->{$Lfile[1]}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Lfile[1]}->{input} | awk '{print \$1}'`; ($struct->{$Lfile[2]}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Lfile[2]}->{input} | awk '{print \$1}'`; #p print " VERIF0: $file $struct->{$file}->{input} $struct->{$file}->{size} \n"; my $fflag = 1; my $r_token; my $f_token; my $g_token; my $TURL; my $lTURL; my $status; my $tstatus; my $sTURL; my $findex; my $command; my @res; my $tStart; my $tEnd; my $tElapse; my $operation; XcuteComm("srm2_testPing", "$endPoint", "PNG", 0); $status = ( XtractVal("versionInfo:") eq 'v2.2' ) ? '[OK]' : '[FAILED]'; $status = ( XtractVal("versionInfo:") =~ '2.2' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetTransferProtocols", "$endPoint", "GTP", 0); $rfioSW = XtractVal('ExtraInfo: rfio'); $status = XtractVal('ExtraInfo: gsiftp') ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Temp GG 09/12/06 ##undef $rfioSW; chomp(my $lrfcp = `which rfcp`); if ( "$lrfcp" ne '/opt/lcg/bin/rfcp' && "$lrfcp" !~ 'LCG-DM/rfio/rfcp' ) { ## undef $rfioSW; print STDOUT "\n WARNING: rfio client with GSI authentication NOT available ? : >$lrfcp< \n\n"; } my $protoc = 'gsiftp'; if ( $rfioSW ) { $protoc = 'rfio'; print STDOUT "\n Protocol rfio with GSI authentication available \n\n"; } else { print STDOUT "\n WARNING: Protocol rfio with GSI authentication NOT available \n\n"; } ## Temporaire tests SSL3 if ( $ENV{TSRMV22} ) { exit 0; } if ( $subTree =~ /stress/ ) { my @m = split /\//, "${baseSrm}"; pop @m; my $baseSrs = join('/', @m); XcuteComm("srm2_testMkdir", "${baseSrs}", "MK00", 0); $status = ( XtractVal("request state") eq '0' || XtractVal("request state") eq '11') ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } } if ( $subTree ) { XcuteComm("srm2_testMkdir", "${baseSrm}", "MK0", 0); $status = ( XtractVal("request state") eq '0' || XtractVal("request state") eq '11') ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } } ## Put operation for the Sfile (Scalar) my $overWrite; my $fsize; if (0) { $operation = "srm2_testPut"; $overWrite = 0; $xCount++; $fsize = $struct->{$file}->{size}*1024; $command = "$operation $u_token 1 $overWrite $file 1000 2 $fsize"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; $tStart = time(); @res = `$command 2>&1`; $tEnd = time(); $tElapse = $tEnd - $tStart; foreach ( @res ) { print "L: $_"; my @m = split; if ( /r_token / ) { $r_token = $m[3]; } # if ( /TURL =/ ) { $lTURL = $_; $tstatus = $m[2]; $TURL = $m[5]; } if ( /state\[(\d+?)\]/ ) { $findex = $1; $lTURL = $_; chop($m[2]); $tstatus = $m[2]; ##NEW$tstatus = $RStatusCode{$m[2]}; ##WAS $TURL = $m[5]; $TURL = $m[6]; ##PREV$TURL =~ m[(.*?)://(.*)]; $TURL =~ m[(.*?)://.*?/(.*)]; $sTURL = $2; my $lfile; if ( $fflag == 1 ) { $lfile = $file; } else { $lfile = $Lfile[$findex]; } $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{sTURL} = $sTURL; ## $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{r_token} = $r_token; } ##PREVif ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } if ( /request state/ ) { $status = ( "$stat26" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" || $tstatus ne "24" ) { print " Put FAILED: $lTURL >$status< >$tstatus<\n"; ##20 exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } &printAndCExit(); } else { $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; if (0) { XcuteComm("srm2_testPut", "$u_token 1 $overWrite $file 1000 2 $fsize", "LS", "$stat26"); } else { XcuteComm("srm2_testPut", "$u_token 1 $overWrite 1000 - - - 2 - - $file $fsize", "LS", "$stat26", 1, 0); } $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } $struct->{$file}->{TURL} = XtractVal('TURL ='); $struct->{$file}->{r_token} = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } } ### TEST exit 0; ##$TURL =~ m[(.*?)://(.*)]; ##my $sTURL = $2; ## Put operation for the Lfile (Array) if (0) { undef $status; ##PREV@res = `dpmcli/dpm-put --dpmutoken=$u_token --dpmproto rfio --dpmreqsize 100 @Lfile`; ##@res = `srm2_testput @Lfile`; $xCount++; my $lifet = 1000; my $nbfiles = scalar(@Lfile); $command = "$operation $u_token $nbfiles $overWrite"; foreach my $kfile ( @Lfile ) { $lifet += 1000; my $fsize = $struct->{$kfile}->{size}*1024; if ( $lifet == 4000 ) { $command .= " $kfile $lifet 2 $fsize"; } else { $command .= " $kfile $lifet 0 $fsize"; } #p print " VERIF: $kfile $struct->{$kfile}->{size} \n"; } if ( $rfioSW ) { $command .= ' rfio'; } $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; $tStart = time(); @res = `$command 2>&1`; $tEnd = time(); $tElapse = $tEnd - $tStart; $fflag = 2; foreach ( @res ) { print "L: $_"; my @m = split; if ( /r_token / ) { $r_token = $m[3]; } # if ( /TURL =/ ) { $lTURL = $_; $tstatus = $m[2]; $TURL = $m[5]; } if ( /state\[(\d+?)\]/ ) { $findex = $1; $lTURL = $_; chop($m[2]); $tstatus = $m[2]; ##NEW$tstatus = $RStatusCode{$m[2]}; ##WAS $TURL = $m[5]; $TURL = $m[6]; ##PREV$TURL =~ m[(.*?)://(.*)]; $TURL =~ m[(.*?)://.*?/(.*)]; $sTURL = $2; my $lfile; if ( $fflag == 1 ) { $lfile = $file; } else { $lfile = $Lfile[$findex]; } $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{sTURL} = $sTURL; ## $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{r_token} = $r_token; } ##PREVif ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } if ( /request state/ ) { $status = ( "$stat26" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } ##PREVif ( $status ne "[OK]" || $tstatus ne "Ready," ) { if ( $status ne "[OK]" || $tstatus ne "24" ) { print " Put FAILED: $lTURL >$status< >$tstatus<\n"; ##20 exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } &printAndCExit(); } else { $overWrite = 0; my $lifet = 1000; my $nbfiles = scalar(@Lfile); my $opsargs = "$u_token $nbfiles $overWrite"; if (0) { foreach my $kfile ( @Lfile ) { $lifet += 1000; $fsize = $struct->{$kfile}->{size}*1024; if ( $lifet == 4000 ) { $opsargs .= " $kfile $lifet 2 $fsize"; } else { $opsargs .= " $kfile $lifet 0 $fsize"; } } if ( $rfioSW ) { $opsargs .= ' rfio'; } } else { $lifet += 1000; if ( $rfioSW ) { $opsargs .= " $lifet - rfio - 2 - -"; } else { $opsargs .= " $lifet - - - 2 - -"; } foreach my $kfile ( @Lfile ) { $fsize = $struct->{$kfile}->{size}*1024; $opsargs .= " $kfile $fsize"; } } XcuteComm("srm2_testPut", "$opsargs", "LA", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pr_token = XtractVal('r_token'); foreach my $findex ( 0 .. $nbfiles-1 ) { $struct->{$Lfile[$findex]}->{TURL} = XtractVal("state\\[$findex\\] = 24, SRM_SPACE_AVAILABLE, TURL ="); $struct->{$Lfile[$findex]}->{r_token} = $pr_token; } if ( $status ne '[OK]' ) { &printAndCExit(); } } ## Put operation for the $Ffile $fsize = $struct->{$Ffile}->{size}*1024; if (0) { XcuteComm("srm2_testPut", "$u_token 1 $overWrite $Ffile 1000 2 $fsize", "FFI", "$stat26"); } else { XcuteComm("srm2_testPut", "$u_token 1 $overWrite 1000 - - - 2 - - $Ffile $fsize", "FFI", "$stat26"); } $struct->{$Ffile}->{TURL} = XtractVal("TURL ="); $struct->{$Ffile}->{r_token} = XtractVal("soap_call_ns1__srmPrepareToPut returned r_token"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Put operation for the pinTime expiration test (see end of script for relevant putDone) $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $pt_file = "${file}pt"; my $pt_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - - - 0 - - $pt_file $fsize", "PTT1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pt_turl = XtractVal('TURL ='); my $pt_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($pt_turl, $pt_input, 'PTT1b'); ## Yet another put operation for the case where I will (inadvertantly) leave it pending with ## NEITHER a transfer NOR a putDone $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $pt2_file = "${file}pt2"; my $pt2_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 60 - - - 0 - - $pt2_file $fsize", "PTT2a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pt2_turl = XtractVal('TURL ='); my $pt2_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } ## Yet another put operation for the case where I will (inadvertantly) leave it pending with ## NEITHER a transfer NOR a putDone >> same as above but with f_type 'P' $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $pt3_file = "${file}pt3"; my $pt3_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 80 - $protoc - 2 - - $pt3_file $fsize", "PTT3a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pt3_turl = XtractVal('TURL ='); my $pt3_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } ##exit 0; ## TESTS V/P ## End of all put operations (the vector of files is in "keys %{$struct}") ##system("which rfcp"); ## Three (transfer + putdone + get) operations for all files altogether foreach my $kfile ( sort keys %{$struct} ) { ## Transfer step (uses rfcp when available) ... if (0) { undef $status; $xCount++; @res = (); my $lTURL = XtractGoodTurl($struct->{$kfile}->{TURL}); my $lLABL; ##if ( $rfioSW ) { if ( $lTURL !~ /gsiftp/ ) { $operation = 'rfcp'; $command = "$operation $struct->{$kfile}->{input} $lTURL"; $lLABL = 'RFCP'; } else { $operation = 'globus-url-copy'; $command = "$operation -dbg file:$struct->{$kfile}->{input} $lTURL"; $lLABL = 'GSIFTP'; } ##PREV$command = "$operation $struct->{$kfile}->{input} $struct->{$kfile}->{sTURL}"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; ##PREV@res = `rfcp $struct->{$kfile}->{input} $struct->{$kfile}->{sTURL} 2>&1`; $tStart = time(); @res = `$command 2>&1`; $tEnd = time(); $tElapse = $tEnd - $tStart; my $exitFlag = 0; foreach ( @res ) { print " ${lLABL}_TRACE $_"; if ( $ENV{RFIO_TRACE} ) { #p print " RFIO_TRACE $_"; } if ( /226 Transfer complete./ ) { $status = "[OK]"; } if ( /226 Transfer Complete./ ) { $status = "[OK]"; } if ( /bytes in/ ) { $status = "[OK]"; } if ( /Command exited/ || /Timed out/ ) { $status = "[FAILED]"; $exitFlag = 1; } } if ( $exitFlag && $ENV{RFIO_TRACE} ) { foreach ( @res ) { print " RFIO_FAIL $_"; } } &printAndCExit(); ###20 if ( $status ne "[OK]" ) { exit 1; } ###20 else { ###20 if ( $ENV{RFIO_TRACE} ) { ###20 ###20 } ###20 print " Operation: $operation = $status Duration: $tElapse \n"; ###20 } } else { my $lTURL = XtractGoodTurl($struct->{$kfile}->{TURL}); my $lLABL; my $opsargs; if ( $lTURL !~ /gsiftp/ ) { $operation = 'rfcp'; $opsargs = "$struct->{$kfile}->{input} $lTURL"; $lLABL = 'RFCP_TRACE'; } else { $operation = 'globus-url-copy'; $opsargs = "-dbg file:$struct->{$kfile}->{input} $lTURL"; $lLABL = 'GSIFTP_TRACE'; } XcuteComm("$operation", "$opsargs", "$lLABL", 0, 1); if ( $lTURL !~ /gsiftp/ ) { $status = ( XtractVal('seconds through') eq 'local' ) ? '[OK]' : '[FAILED]'; } else { $status = ( XtractVal('226 Transfer complete.') ) ? '[OK]' : '[FAILED]'; } ##$status = ( XtractVal('Command exited') ) ? '[FAILED]' : '[OK]'; ##$status = ( XtractVal('Timed out') ) ? '[FAILED]' : '[OK]'; if ( $status ne '[OK]' ) { &printAndCExit(); } } ## Putdone step ... if (0) { $operation = "srm2_testPutDone"; undef $status; my $SURL; @res = (); $xCount++; $command = "$operation $struct->{$kfile}->{r_token} $kfile"; ##PREVprint " CMD: dpmcli/dpm-putdone --dpmrtoken=$struct->{$kfile}->{r_token} $kfile \n"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; ##PREV@res = `dpmcli/dpm-putdone --dpmrtoken=$struct->{$kfile}->{r_token} $kfile`; @res = `$command 2>&1`; foreach ( @res ) { print "D: $_"; my @m = split; if ( /SURL =/ ) { $SURL = $m[5]; } if ( /request state/ ) { $status = ( "0" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } $SURL = XtractVal('SURL ='); ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } &printAndCExit(); if ( $SURL ne $kfile ) { print " Mismatch0: $SURL $kfile \n"; exit 1; } } else { my $SURL; XcuteComm("srm2_testPutDone", "$struct->{$kfile}->{r_token} $kfile", "D", 0, 1); $SURL = XtractVal('SURL ='); $status = ( "$SURL" eq "$kfile" ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { print " Mismatch0: $SURL $kfile \n"; &printAndCExit(); } } # Get operation (with rfio if available, gsiftp otherwise) my $fTURL; if (0) { $TURL = $struct->{$kfile}->{TURL}; undef $status; $operation = "srm2_testGet"; @res = (); $xCount++; my $tMode; if ( $rfioSW ) { $command = "$operation rfio $u_token $kfile"; $tMode = 'rfio'; } else { $command = "$operation gsiftp $u_token $kfile"; $tMode = 'gsiftp'; } ##PREVprint " CMD: dpmcli/dpm-get --dpmutoken=$u_token --dpmproto:rfio $kfile \n"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; ##PREV@res = `dpmcli/dpm-get --dpmutoken=$u_token --dpmproto:rfio $kfile`; $tStart = time(); @res = `$command 2>&1`; $tEnd = time(); $tElapse = $tEnd - $tStart; foreach ( @res ) { print "GF: $_"; my @m = split; if ( /r_token / ) { $f_token = $m[3]; } if ( /TURL =/ ) { $fTURL = $m[5]; } if ( /request state/ ) { $status = ( "$stat26" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } $fTURL = XtractVal('TURL ='); ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } &printAndCExit(); if (0) { if ( $TURL ne $fTURL ) { print " Mismatch1: $TURL $fTURL \n"; exit 1; } else { print " TURL[".lc($tMode)."]: $fTURL \n"; } } else { #p print " Mismatch1: $TURL $fTURL \n"; print " TURL[".lc($tMode)."]: $fTURL \n"; } } else { my $tMode; my $opsargs; if ( $rfioSW ) { $opsargs = "rfio $u_token - $kfile"; $tMode = 'rfio'; } else { $opsargs = "gsiftp $u_token - $kfile"; $tMode = 'gsiftp'; } XcuteComm("srm2_testGet", "$opsargs", "GF", "$stat26", 1); $fTURL = XtractVal('TURL ='); $f_token = XtractVal('r_token'); ##&printAndCExit(); print " TURL[".lc($tMode)."]: $fTURL \n"; } # Get operation (always with gsiftp) my $gTURL; if (0) { undef $status; @res = (); $xCount++; $command = "$operation gsiftp $u_token $kfile"; ##PREVprint " CMD: dpmcli/dpm-get --dpmutoken=$u_token --dpmproto:gsiftp $kfile \n"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; ##PREV@res = `dpmcli/dpm-get --dpmutoken=$u_token --dpmproto:gsiftp $kfile`; $tStart = time(); @res = `$command 2>&1`; $tEnd = time(); $tElapse = $tEnd - $tStart; foreach ( @res ) { print "GG: $_"; my @m = split; if ( /r_token / ) { $g_token = $m[3]; } if ( /TURL =/ ) { $gTURL = $m[5]; } if ( /request state/ ) { $status = ( "$stat26" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } $gTURL = XtractVal('TURL ='); ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } &printAndCExit(); print " TURL[gsiftp]: $gTURL \n"; } else { my $tMode; my $opsargs; $opsargs = "gsiftp $u_token - $kfile"; $tMode = 'gsiftp'; XcuteComm("srm2_testGet", "$opsargs", "GG", "$stat26", 1); $gTURL = XtractVal('TURL ='); $g_token = XtractVal('r_token'); ##&printAndCExit(); print " TURL[".lc($tMode)."]: $gTURL \n"; } $struct->{$kfile}->{f_token} = $f_token; $struct->{$kfile}->{g_token} = $g_token; $struct->{$kfile}->{fTURL} = $fTURL; $struct->{$kfile}->{gTURL} = $gTURL; $TURL = $struct->{$kfile}->{TURL}; if ( $TURL =~ /rfio/ ) { if ( $TURL ne $fTURL ) { print " Mismatch1: $TURL $fTURL \n"; exit 1; } } else { if ( $TURL ne $gTURL ) { print " Mismatch1: $TURL $gTURL \n"; exit 1; } } } print "<_________________________________________________________________________>\n\n"; ## End Of Overall (transfer + putdone + get) operations for all files altogether ##PREV$operation = "dpm-getreqsummary"; $operation = "srm2_testGetRequestSummary"; foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testGetRequestSummary", "$endPoint $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}", "SU", 0, 1); } if (1) { ## Does not exist here ... (srmV2) foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testGetRequestStatus", "$endPoint $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}", "ST", "0", 1); } } ##exit 0; ## TESTS pintime $operation = "srm2_testExtendFileLifeTime"; foreach my $kfile ( sort keys %{$struct} ) { my $lt = $struct->{$kfile}->{pin}; XcuteComm("srm2_testExtendFileLifeTime", "$struct->{$kfile}->{f_token} $lt - $kfile", "EF1", 0, 1); $lt = 2*$struct->{$kfile}->{pin}; XcuteComm("srm2_testExtendFileLifeTime", "$struct->{$kfile}->{g_token} $lt - $kfile", "EG2", 0, 1); } ##exit 0; ## TESTS queryDB if (1) { foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testGetRequestStatus", "$endPoint $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}", "ST2", "0", 1); } } $operation = "srm2_testExtendFileLifeTime"; foreach my $kfile ( sort keys %{$struct} ) { my $lt = 3*$struct->{$kfile}->{pin}; XcuteComm("srm2_testExtendFileLifeTime", "$struct->{$kfile}->{f_token} $lt - $kfile", "EF3", 0, 1); $lt = 5*$struct->{$kfile}->{pin}; XcuteComm("srm2_testExtendFileLifeTime", "$struct->{$kfile}->{g_token} $lt - $kfile", "EG5", 0, 1); } if (1) { foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testGetRequestStatus", "$endPoint $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}", "ST3", "0", 1); } } ##PREV$operation = "dpm-relfiles"; $operation = "srm2_testReleaseFiles"; foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testReleaseFiles", "$endPoint $struct->{$kfile}->{f_token} $kfile", "RL", 0, 1); } $operation = "srm2_testGetRequestStatus"; if (1) { foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testGetRequestStatus", "$endPoint $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}", "ST4", "0", 1); } } XcuteComm("srm2_testLs", "-l $file @Lfile", "LS", 0, 1); ## To get LsFullDetail XcuteComm("srm2_testLs", "-dl $file @Lfile", "LSFD", 0, 1); if (1) { ## To crosscheck srm2_testReleaseFiles action specifically on this file XcuteComm("srm2_testGetRequestStatus", "$endPoint $struct->{$Ffile}->{f_token}", "STFI", '0', 1); ##$status = ( XtractVal('pin = Thu Jan 1 01:00:00 1970') eq 'pin = Thu Jan 1 01:00:00 1970' ) ? '[OK]' : '[FAILED]'; $status = ( XtractVal('pinDate = 1970-01-01T00:00:00Z') eq 'pinDate = 1970-01-01T00:00:00Z' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } } ####exit 69; ## For special tests ## CopyCompare step ... ## for rfio and gsiftp 'get' operations ####foreach my $getType ( "fTURL", "gTURL" ) { ##foreach my $getType ( "gTURL" ) { my @lTurlList = ( "gTURL" ); if ( $rfioSW ) { @lTurlList = ( "fTURL", "gTURL" ); } foreach my $getType ( @lTurlList ) { ## for all 5 files at once ... foreach my $kfile ( sort keys %{$struct} ) { my $local; my $flocal; my $lTURL = XtractGoodTurl($struct->{$kfile}->{$getType}); if ( $getType eq "fTURL" ) { ## rfio case $operation = "rfcp"; $local = "$tempDir/$struct->{$kfile}->{short}"."F"; ## $struct->{$kfile}->{fLOCAL} = $local; $flocal = $local; } else { ## gsiftp case ## if (0) { ## TEMP GG 13/04/05 if (1) { ## TEMP GG 13/04/05 ## REVERTED on 10/05/05 for lxb1904 $operation = "globus-url-copy -vb"; $local = "$tempDir/$struct->{$kfile}->{short}"."G"; ## $struct->{$kfile}->{gLOCAL} = $local; $flocal = "file://".$local; } else { $operation = "rfcp"; $local = "$tempDir/$struct->{$kfile}->{short}"."F"; ## $struct->{$kfile}->{fLOCAL} = $local; $flocal = $local; } } XcuteComm("$operation", "$lTURL $flocal", "DWNL_$getType", 0); ## download substep XcuteComm("diff -s", "$struct->{$kfile}->{input} $local", "DIFF_$getType", 0); ## diff substep, non-fatal unlink $local; } } ## End of CopyCompare step ... ####exit 0; ## TEMPORARY ( to avoid killing any file ... ) foreach my $kfile ( sort keys %{$struct} ) { ## $struct->{$kfile}->{copyX} = "${kfile}X"; $struct->{$kfile}->{copyY} = "${baseSrm}/${mkdir_t}/$struct->{$kfile}->{short}"."Y"; $struct->{$kfile}->{copyX} = "${kfile}X"; $struct->{$kfile}->{copyZ} = "${kfile}Z"; } XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t", "MK", 0, 1); if ( $mach eq 'lxb1903' ) { ## 4 sequences about recursive Rmdir ## 1) empty dirs ## 2) non-empty dirs with V files ## 3) non-empty dirs with P files ###### 4) non-empty dirs with V+P files XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1", "MKD1", 0, 1); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1/D2a", "MKD2a", 0, 1); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1/D2b", "MKD2b", 0, 1); XcuteComm("srm2_testRmdir", "-R ${baseSrm}/$mkdir_t/D1", "RMD1", 0, 1); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1", "MKD1V", 0, 1); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1/D2a", "MKD2aV", 0, 1); my $rmd_file = "${baseSrm}/$mkdir_t/D1/D2a/f2aV"; XcuteComm("srm2_testPut", "$u_token 1 0 30 35 rfio - 0 0 0 $rmd_file $fsize", "PTPD2aV", 0, 1); my $rmd_token = XtractVal('r_token'); my $rmd_turl = XtractVal('TURL ='); &TransferTURL($rmd_turl, '/etc/ldap.conf', 'D2aV'); &putDone($rmd_token, "$rmd_file", 'D2aV'); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1/D2b", "MKD2bV", 0, 1); $rmd_file = "${baseSrm}/$mkdir_t/D1/D2b/f2bV"; XcuteComm("srm2_testPut", "$u_token 1 0 35 30 rfio - 0 0 0 $rmd_file $fsize", "PTPD2bV", 0, 1); $rmd_token = XtractVal('r_token'); $rmd_turl = XtractVal('TURL ='); &TransferTURL($rmd_turl, '/etc/ldap.conf', 'D2bV'); &putDone($rmd_token, "$rmd_file", 'D2bV'); sleep(35); XcuteComm("srm2_testRmdir", "-R ${baseSrm}/$mkdir_t/D1", "RMD1V", 0, 1); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1", "MKD1P", 0, 1); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1/D2a", "MKD2aP", 0, 1); $rmd_file = "${baseSrm}/$mkdir_t/D1/D2a/f2aP"; XcuteComm("srm2_testPut", "$u_token 1 0 50 - rfio - 2 0 0 $rmd_file $fsize", "PTPD2aP", 0, 1); $rmd_token = XtractVal('r_token'); $rmd_turl = XtractVal('TURL ='); &TransferTURL($rmd_turl, '/etc/ldap.conf', 'D2aP'); &putDone($rmd_token, "$rmd_file", 'D2aP'); XcuteComm("srm2_testMkdir", "${baseSrm}/$mkdir_t/D1/D2b", "MKD2bP", 0, 1); $rmd_file = "${baseSrm}/$mkdir_t/D1/D2b/f2bP"; XcuteComm("srm2_testPut", "$u_token 1 0 50 - rfio - 2 0 0 $rmd_file $fsize", "PTPD2bP", 0, 1); $rmd_token = XtractVal('r_token'); $rmd_turl = XtractVal('TURL ='); &TransferTURL($rmd_turl, '/etc/ldap.conf', 'D2bP'); &putDone($rmd_token, "$rmd_file", 'D2bP'); ##sleep(12); if (0) { $rmd_file = "${baseSrm}/$mkdir_t/D1/D2b/f2cP"; XcuteComm("srm2_testPut", "$u_token 1 0 50 - rfio - 2 0 0 $rmd_file $fsize", "PTPD2cP", 0, 1); $rmd_token = XtractVal('r_token'); $rmd_turl = XtractVal('TURL ='); &TransferTURL($rmd_turl, '/etc/ldap.conf', 'D2cP'); &putDone($rmd_token, "$rmd_file", 'D2cP'); } XcuteComm("srm2_testRmdir", "-R ${baseSrm}/$mkdir_t/D1", "RMD1P", '12', 1); XcuteComm("srm2_testLs", "-Rl ${baseSrm}/$mkdir_t/D1", "RMD1PL", '0', 1); XcuteComm("srm2_testRm", "${baseSrm}/$mkdir_t/D1/D2a/f2aP ${baseSrm}/$mkdir_t/D1/D2b/f2bP", "RMD1PF", 0, 1); XcuteComm("srm2_testRmdir", "-R ${baseSrm}/$mkdir_t/D1", "RMD1PE", '0', 1); } ## End of recursive Rmdir sequence ... $operation = "srm2_testMv"; foreach my $kfile ( sort keys %{$struct} ) { XcuteComm("srm2_testMv", "$kfile $struct->{$kfile}->{copyX}", "MV", 0, 1); } my $args = "$file @Lfile"; foreach my $kfile ( sort keys %{$struct} ) { $args .= " $struct->{$kfile}->{copyX}"; } XcuteComm("srm2_testLs", "-l $args", "LS2", 27, 1); ##my $pda2 = XtractVal('request pathDetailArray'); $status = ( XtractVal("request pathDetailArray") eq '9' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testLs", "-l ${baseSrm}/$mkdir_t", "LSD", 0, 1); ## was 1 XcuteComm("srm2_testLs", "-2 ${baseSrm}/$mkdir_t", "LSD2", 0, 1); ## was 1 XcuteComm("srm2_testGetPermission", "${baseSrm}/$mkdir_t $struct->{$Ffile}->{copyX}", "GPD2", 0, 1); ## was 1 ###BADexit 0; ## TEMP for checking gsiftp 24/05/05 $args = ""; foreach my $kfile ( @Lfile[0,1] ) { $args .= " $struct->{$kfile}->{copyX}"; } ## This one must partly fail ... with detailed explanation and filestatuses anyway XcuteComm("srm2_testRm", "${args}_ff", "RM", 27, 1); ## This particular one must partly fail as well ... with detailed explanation and filestatuses anyway XcuteComm("srm2_testRm", "${args}", "RMfp1", 27, 1); ## This particular one must fail in another way ... with detailed explanation and filestatuses anyway XcuteComm("srm2_testRm", "${args}_ff", "RMft2", 1, 1); $args = ""; foreach my $kfile ( sort keys %{$struct} ) { $args .= " $struct->{$kfile}->{copyX}"; } XcuteComm("srm2_testLs", "-l $args", "LS3", 27, 1); ## was 1 $status = ( XtractVal("request pathDetailArray") eq '5' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } $operation = "srm2_testMv"; foreach my $kfile ( $Lfile[2] ) { XcuteComm("srm2_testMv", "$struct->{$kfile}->{copyX} $struct->{$kfile}->{copyY}", "MVk", 0, 1); } ## To check that Mv towards a Dir target (instead of a file target) is fine ... foreach my $kfile ( $Lfile[2] ) { XcuteComm("srm2_testMv", "$struct->{$kfile}->{copyY} ${baseSrm}", "MVd1", 0, 1); } ## Reverse the above Mv ... foreach my $kfile ( $Lfile[2] ) { XcuteComm("srm2_testMv", "${baseSrm}/$struct->{$kfile}->{short}"."Y ${baseSrm}/$mkdir_t", "MVd2", 0, 1); } ## Extracting the user/group codes from the remote DPM node PWD/GRP files my %vogid = (); my %vogauid = (); my %vonid = (); my %voaid = (); my %votid = (); my %duser = (); ## Useless but ... my $sPWD; my $sGRP; ## To extract $pxGRP and $pxDN values from the proxy (to be used in ACL comparison later) ... &getPxAttributes(); ##exit 0; ##my $tempDir; ##if ( $ENV{TEMPDIR} ) { $tempDir = $ENV{TEMPDIR}; } ##else { $tempDir = "/tmp"; } if (0) { $sPWD = "$tempDir/${mach}_PWD_$sfileH"; $sGRP = "$tempDir/${mach}_GRP_$sfileH"; system("globus-url-copy gsiftp://${mach}.cern.ch/${mach}:/etc/passwd file://$sPWD"); system("globus-url-copy gsiftp://${mach}.cern.ch/${mach}:/etc/group file://$sGRP"); if ( ! ( -s "$sGRP" && -s "$sPWD" ) ) { system("rfcp ${mach}:/etc/passwd $sPWD"); system("rfcp ${mach}:/etc/group $sGRP"); } } ####if ( -s "$sGRP" && -s "$sPWD" ) { if (0) { foreach my $grp ( "atlas", "cms", "dteam" ) { my ($auid, $ux, $uid, $gid, $rest) = split /:/, `grep ${grp}006 $sPWD`; if ( ! $gid ) { next; } $vogid{$grp} = $gid; my ($ruid, $rpl, $rgid, $spus) = split /:/, `grep ${gid} $sGRP`; $vogauid{$grp} = $ruid; my ($mode, $ix, $irt, $aid, $nest) = split /\s+/, `dpns-ls -ld /dpm/${site_domain}/home/${grp}`; $voaid{$aid} = $gid; $vonid{$gid} = $aid; $votid{$grp} = $aid; $votid{$aid} = $grp; print " GRP: $grp, GID: $gid, AID: $aid RUID: $ruid\n"; } } if (0) { foreach my $grp ( "atlas", "cms", "dteam", "$pxGRP" ) { my @m = split /\s+/, `dpm-getgrpbynam $grp`; my $ruid = $m[-1]; $vogauid{$grp} = $ruid; $vogauid{$grp} = $grp; my ($mode, $ix, $irt, $aid, $nest) = split /\s+/, `dpns-ls -ld /dpm/${site_domain}/home/${grp}`; $votid{$grp} = $aid; $votid{$aid} = $grp; print " GRP: $grp, AID: $aid RUID: $ruid\n"; } } else { foreach my $grp ( "atlas", "cms", "dteam", "$pxGRP" ) { $vogauid{$grp} = $grp; } } if (0) { foreach my $nid ( 1, 4, 5, 6 ) { my ($auid, $ux, $uid, $gid, $rest) = split /:/, `grep dteam00$nid $sPWD`; $duser{$auid} = $uid; $duser{$uid} = $auid; print " DTEAM: AUID: $auid, UID: $uid\n"; } } if (0) { foreach my $nid ( 1, 2, 3 ) { ##my ($auid, $ux, $uid, $gid, $rest) = split /:/, `grep dteam00$nid $sPWD`; my $auid = "dteamtest0$nid"; ##my $aout = `dpm-getusrbynam $auid`; my @m = split /\s+/, `dpm-getusrbynam $auid`; my $uid = $m[-1]; $duser{$auid} = $uid; $duser{$uid} = $auid; print " DTEAM: AUID: $auid, UID: $uid\n"; } } ####} ##BELOWmy ($cmod, $ccix, $cuid, $cgid, $cest) = split /\s+/, `dpns-ls -l $baseDpm/$struct->{$rfile}->{short}X`; ##unlink "$sPWD"; ##unlink "$sGRP"; if (0) { my $atlas = $vogid{"atlas"}; my $cms = $vogid{"cms"}; my $dteam = $vogid{"dteam"}; } ##Temp: back to old situation (until virtual ID fixes it - 10/11/05) if (0) { my $atlas = "atlas"; my $cms = "cms"; my $dteam = "dteam"; } if (0) { my $atlas = "zp"; my $cms = "zh"; my $dteam = "cg"; } ## Seems to be the good one for now 10/11/05, at least for lxgate22 & lxb1727 ## Solves only the issue of making srm2_testSetPermission to work smoothly, not the comparison headache my $atlas = $vogauid{"atlas"}; my $cms = $vogauid{"cms"}; ##my $dteam = $vogauid{"dteam"}; my $dteam = $vogauid{"$pxGRP"}; my $cfile = $file; my $fileM = "$struct->{$Lfile[2]}->{copyY}"; ## Collision test ......................................................................... ## First setPermission to 444 $operation = "srm2_testSetPermission"; #OO$command = "$operation 2 4 4 $struct->{$cfile}->{copyX} 1 - dteam 4"; $command = "$operation 2 4 4 $struct->{$cfile}->{copyX} 1 - $dteam 4"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSP444: $_"; } ## Then issue a testMv, which MUST fail by now ... (14/07/05) with "Internal error" ## Seems to fail indeed, by now ... (12/09/05) with "File exists", which is far better ! TBC XcuteComm("srm2_testMv", "$fileM $struct->{$cfile}->{copyX}", "MWg", 11, 0); ## Then move back to setPermission to 664 $operation = "srm2_testSetPermission"; #OO$command = "$operation 2 6 4 $struct->{$cfile}->{copyX} 1 - dteam 6"; $command = "$operation 2 6 4 $struct->{$cfile}->{copyX} 1 - $dteam 6"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSP664: $_"; } $args = "$file"; foreach my $kfile ( $file, @Lfile ) { $args .= " $struct->{$kfile}->{copyX}"; $args .= " $struct->{$kfile}->{copyY}"; } XcuteComm("srm2_testLs", "-l $args", "LSk", 27, 1); ## was 1 $status = ( XtractVal("request pathDetailArray") eq '9' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testLs", "-l2 ${baseSrm}/$mkdir_t", "LSD3", 0, 1); ## was 1 XcuteComm("srm2_testGetPermission", "${baseSrm}/$mkdir_t $struct->{$Ffile}->{copyX}", "GPD3", 0, 1); ## was 1 XcuteComm("srm2_testRmdir", "${baseSrm}/$mkdir_t", "RMd", 12, 1); $args = "$file"; foreach my $kfile ( $file, @Lfile ) { $args .= " $struct->{$kfile}->{copyX}"; $args .= " $struct->{$kfile}->{copyY}"; } XcuteComm("srm2_testLs", "-l $args", "LSd", 27, 1); ## was 1 $status = ( XtractVal("request pathDetailArray") eq '9' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } $args = ""; foreach my $kfile ( $Lfile[2] ) { $args .= " $struct->{$kfile}->{copyY}"; } XcuteComm("srm2_testRm", "$args", "RMy", 0, 1); $args = "$file"; foreach my $kfile ( $file, @Lfile ) { $args .= " $struct->{$kfile}->{copyX}"; $args .= " $struct->{$kfile}->{copyY}"; } XcuteComm("srm2_testLs", "-l $args", "LSr", 27, 1); ## was 1 $status = ( XtractVal("request pathDetailArray") eq '9' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testRmdir", "${baseSrm}/$mkdir_t", "RMD", 0, 1); XcuteComm("srm2_testRmdir", "${baseSrm}/$mkdir_t", "RMA", 5, 1); ## Here begins the ACL testing section ... #my $rfile = $Lfile[1]; my $rfile = $file; my ($cmod, $ccix, $cuid, $cgid, $cest) = split /\s+/, `dpns-ls -l $baseDpm/$struct->{$rfile}->{short}X`; my @aclRes = (); my @naclRes = (); if (0) { $operation = "dpns-getacl"; undef $status; @res = (); $command = "$operation $baseDpm/$struct->{$rfile}->{short}X"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { if ( $_ =~ /^(\# owner: )(.*)/ ) { my $rest = $2; $rest =~ s/ /_/g; print "ACL0: # owner: $rest\n"; } else { print "ACL0: $_"; } #push @aclRes, "ACL1: $_"; #my @m = split; } } XcuteComm("srm2_testGetPermission", "$struct->{$rfile}->{copyX}", "NACL0", 0, 1); ## was 1 ## To get more info ... print "<_________________________________________________________________________>\n\n"; system("dpns-ls -l $baseDpm/$struct->{$rfile}->{short}X"); XcuteComm("srm2_testLs", "-l $struct->{$rfile}->{copyX}", "LSvACL0", 0, 1); ## was 1 # For owner and other permissions, first $operation = "srm2_testSetPermission"; undef $status; @res = (); $command = "$operation 2 7 4 $struct->{$rfile}->{copyX} - -"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPOP: $_"; } # For group permissions, now #ADD, REMOVE, CHANGE= 0, 1, 2 $command = "$operation 0 - - $struct->{$rfile}->{copyX} 2 - $atlas 3 $cms 6"; ##p print " CMD: $command\n"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPGP36: $_"; } $command = "$operation 2 - - $struct->{$rfile}->{copyX} 1 - $dteam 5"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPGP5: $_"; } if (0) { #my @aclRes = (); $operation = "dpns-getacl"; undef $status; @res = (); $command = "$operation $baseDpm/$struct->{$rfile}->{short}X"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { if ( $_ =~ /^(\# owner: )(.*)/ ) { my $rest = $2; $rest =~ s/ /_/g; $_ = "# owner: $rest\n"; } print "ACL1: $_"; push @aclRes, "ACL1: $_"; #my @m = split; } } XcuteComm("srm2_testGetPermission", "$struct->{$rfile}->{copyX}", "NACL1", 0, 1); ## was 1 foreach ( @res ) { if ( /request/ ) { next; } #chomp; push @naclRes, "NACL1: $_"; } XcuteComm("srm2_testLs", "-l $struct->{$rfile}->{copyX}", "LSvACL1", 0, 1); ## was 1 $operation = "srm2_testSetPermission"; #also test a REMOVE op, and a GROUP NONE $command = "$operation 1 - - $struct->{$rfile}->{copyX} 1 - $atlas 3"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPGPA: $_"; } $command = "$operation 2 - - $struct->{$rfile}->{copyX} 1 - $cms 0"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPGPC: $_"; } if (0) { $operation = "dpns-getacl"; undef $status; @res = (); $command = "$operation $baseDpm/$struct->{$rfile}->{short}X"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { if ( $_ =~ /^(\# owner: )(.*)/ ) { my $rest = $2; $rest =~ s/ /_/g; $_ = "# owner: $rest\n"; } print "ACL2: $_"; push @aclRes, "ACL2: $_"; #my @m = split; } } XcuteComm("srm2_testGetPermission", "$struct->{$rfile}->{copyX}", "NACL2", 0, 1); ## was 1 foreach ( @res ) { if ( /request/ ) { next; } #chomp; push @naclRes, "NACL2: $_"; } XcuteComm("srm2_testLs", "-l $struct->{$rfile}->{copyX}", "LSvACL2", 0, 1); ## was 1 #dteamsgm#'/C=CH/O=CERN/OU=GRID/CN=Maarten Litmaath 1689' #dteamsgm#'/C=CH/O=CERN/OU=GRID/CN=Jean-Philippe Baud 7183' #dteamsgm#'/C=CH/O=CERN/OU=GRID/CN=Sophie Lemaitre 5847' #.dteam#'/C=CH/O=CERN/OU=GRID/CN=Sophie Lemaitre 2268' #.dteam#'/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=grodid/CN=397549/CN=Gilbert Grosdidier' #.dteam#'/O=GRID-FR/C=FR/O=CNRS/OU=LAL/CN=Gilbert Grosdidier' #.dteam#'/DC=org/DC=doegrids/OU=People/CN=Gilbert Grosdidier 378567' #.lhcb#'/DC=org/DC=doegrids/OU=People/CN=Gilbert Grosdidier 378567' my $dteamtest03 = '\'/C=CH/O=CERN/OU=GRID/CN=Sophie Lemaitre 5847\''; $dteamtest03 = 'dteamtest03'; #For user permissions, later $operation = "srm2_testSetPermission"; $command = "$operation 0 - - $struct->{$rfile}->{copyX} - 1 dteam006 6"; $command = "$operation 0 - - $struct->{$rfile}->{copyX} - 1 dteamtest03 6"; $command = "$operation 0 - - $struct->{$rfile}->{copyX} - 1 $dteamtest03 6"; ##$command = "$operation 0 - - $struct->{$rfile}->{copyX} - 1 '/O=GRID-FR/C=FR/O=CNRS/OU=LAL/CN=Gilbert Grosdidier' 6"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPUP6: $_"; } $command = "$operation 0 - - $struct->{$rfile}->{copyX} - 2 dteam004 4 dteam005 5"; $command = "$operation 0 - - $struct->{$rfile}->{copyX} - 2 dteamtest01 4 dteamtest02 5"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPUP45: $_"; } if (0) { $operation = "dpns-getacl"; undef $status; @res = (); $command = "$operation $baseDpm/$struct->{$rfile}->{short}X"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { if ( $_ =~ /^(\# owner: )(.*)/ ) { my $rest = $2; $rest =~ s/ /_/g; $_ = "# owner: $rest\n"; } print "ACL3: $_"; push @aclRes, "ACL3: $_"; #my @m = split; } } XcuteComm("srm2_testGetPermission", "$struct->{$rfile}->{copyX}", "NACL3", 0, 1); ## was 1 foreach ( @res ) { if ( /request/ ) { next; } #chomp; push @naclRes, "NACL3: $_"; } XcuteComm("srm2_testLs", "-l $struct->{$rfile}->{copyX}", "LSvACL3", 0, 1); ## was 1 $operation = "srm2_testSetPermission"; $command = "$operation 1 - - $struct->{$rfile}->{copyX} - 1 dteam004 4"; $command = "$operation 1 - - $struct->{$rfile}->{copyX} - 1 dteamtest01 4"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPUP4: $_"; } $command = "$operation 2 - - $struct->{$rfile}->{copyX} - 1 dteam006 0"; $command = "$operation 2 - - $struct->{$rfile}->{copyX} - 1 $dteamtest03 0"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) {print "TSPUP0: $_"; } if (0) { $operation = "dpns-getacl"; undef $status; @res = (); $command = "$operation $baseDpm/$struct->{$rfile}->{short}X"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { if ( $_ =~ /^(\# owner: )(.*)/ ) { my $rest = $2; $rest =~ s/ /_/g; $_ = "# owner: $rest\n"; } print "ACL4: $_"; push @aclRes, "ACL4: $_"; #my @m = split; } } XcuteComm("srm2_testGetPermission", "$struct->{$rfile}->{copyX}", "NACL4", 0, 1); ## was 1 foreach ( @res ) { if ( /request/ ) { next; } #chomp; push @naclRes, "NACL4: $_"; } XcuteComm("srm2_testLs", "-l $struct->{$rfile}->{copyX}", "LSvACL4", 0, 1); ## was 1 ## ../../ns/dpns-getacl -a /dpm/dteam/grodid/srm_test_suite_file.fil606X if (0) { $operation = "compareACL"; $xCount++; print "<_________________________________________________________________________>\n\n"; $status = compareACL("$baseDpm/$struct->{$rfile}->{short}X"); ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status \n"; } &printAndCExit(); } $operation = "compareNACL"; $xCount++; print "<_________________________________________________________________________>\n\n"; $status = compareNACL("$struct->{$rfile}->{copyX}"); #############################291206&printAndCExit(); #############################060207&printAndCExit(); print "<_________________________________________________________________________>\n\n"; my $fileX = "$struct->{$rfile}->{copyX}"; if (0) { ## Obsoleted XcuteComm("srm2_testReassignToUser", "adummyname 1000 $fileX", "RTU", 16); } XcuteComm("srm2_testReserveSpace", "$endPoint $s_token StSysInfo1 4000 2000 20000 0", "RSP1", 0); my $sp_token = XtractVal("soap_call_ns1__srmReserveSpace returned s_token:"); ####exit 0; ## Test if (0) { ## Moved XcuteComm("srm2_testReleaseSpace", "$endPoint $sp_token StSysInfo1 1", "RLS", 16); } XcuteComm("srm2_testUpdateSpace", "$endPoint $sp_token StSysInfo1 2000 1000 10000", "USP", 0); if (0) { ## Obsoleted XcuteComm("srm2_testCompactSpace", "$endPoint $sp_token StSysInfo1", "CSP", 16); } ## "$endPoint $s_token StSysInfo1 3000 1500 15000 0", XcuteComm("srm2_testReserveSpace", "$endPoint $s_token StSysInfo1 30000000 15000000 15000 0", "RSP2", 0); my $sp_token1 = XtractVal("soap_call_ns1__srmReserveSpace returned s_token:"); XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token $sp_token1", "SMD", 0); ## Special JPB 18/10/06 if (1) { XcuteComm("srm2_testUpdateSpace", "$endPoint $sp_token1 StSysInfo1 2000 1000 15", "USPex", 0); sleep 16; XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token1", "SMDex", 0); ## Put operation for the $Ffile again with an expired space token $fsize = $struct->{$Ffile}->{size}*1024; if (0) { XcuteComm("srm2_testPut", "$u_token 1 $overWrite ${Ffile}ex 1000 2 $fsize - $sp_token1", "FFIex", "$stat26"); } else { XcuteComm("srm2_testPut", "$u_token 1 $overWrite 1000 - - $sp_token1 2 - - ${Ffile}ex $fsize", "FFIex", "$stat26"); } ## $struct->{$Ffile}->{TURL} = XtractVal("TURL ="); ## $struct->{$Ffile}->{r_token} = XtractVal("soap_call_ns1__srmPrepareToPut returned r_token"); $status = ( XtractVal('request state') eq "7" || XtractVal('request state') eq "1" ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } } if (0) { ## Obsoleted XcuteComm("srm2_testChangeFileStorageType", "0 $fileX", "FST", 16); } XcuteComm("srm2_testGetSpaceTokens", "$endPoint $s_token", "GST", 0, 1); XcuteComm("srm2_testReleaseSpace", "$endPoint $sp_token StSysInfo1 1", "RLS", 0, 1); if (0) { ## Obsoleted XcuteComm("srm2_testRemoveFiles", "$struct->{$rfile}->{r_token} $fileX", "RFL", 16); } XcuteComm("srm2_testAbortFiles", "$struct->{$Ffile}->{r_token} $Ffile", "AFL", 0, 1); ## Improve the AbortFiles test XcuteComm("srm2_testPut", "$u_token 2 $overWrite 1000 - - - 2 - - ${Ffile}af1 $fsize ${Ffile}af2 $fsize", "FAF1", "$stat26"); my $afr_token = XtractVal("soap_call_ns1__srmPrepareToPut returned r_token"); XcuteComm("srm2_testPut", "$u_token 1 0 1000 - - - 2 - - ${Ffile}af1 $fsize", "FAFo0", "$stat26"); XcuteComm("srm2_testPut", "$u_token 1 2 1000 - - - 2 - - ${Ffile}af1 $fsize", "FAFo2", "$stat26"); XcuteComm("srm2_testAbortFiles", "$afr_token ${Ffile}af1 ${Ffile}af2", "FAF2", 0, 1); XcuteComm("srm2_testAbortFiles", "$afr_token ${Ffile}af1", "FAF3", 0, 1); ## $status = ( XtractVal('request state') eq '4' ) ? '[OK]' : '[FAILED]'; ## if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testSuspendRequest", "$struct->{$rfile}->{r_token} $fileX", "SRQ", 16); XcuteComm("srm2_testResumeRequest", "$struct->{$rfile}->{r_token} $fileX", "RRQ", 16); XcuteComm("srm2_testCheckPermission", "$fileX", "CHP", 0, 1); XcuteComm("srm2_testGetRequestTokens", "$endPoint $u_token", "GID", 0, 1); XcuteComm("srm2_testStatusOfLsRequest", "$struct->{$rfile}->{r_token} $fileX", "SLR", 16); XcuteComm("srm2_testStatusOfReserveSpaceRequest", "$struct->{$rfile}->{r_token} $fileX", "RSR", 16); XcuteComm("srm2_testStatusOfUpdateSpaceRequest", "$struct->{$rfile}->{r_token} $fileX", "RSR", 16); XcuteComm("srm2_testChangeSpaceForFiles", "$struct->{$rfile}->{r_token} $fileX", "CSF", 16); XcuteComm("srm2_testStatusOfChangeSpaceForFilesRequest", "$struct->{$rfile}->{r_token} $fileX", "CSFR", 16); if (0) { XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$struct->{$rfile}->{r_token} $fileX", "EFS", 16); } XcuteComm("srm2_testPurgeFromSpace", "$struct->{$rfile}->{r_token} $fileX", "PFS", 16); if (0) { $operation = "dpm-getreqid"; undef $status; @res = (); $command = "$operation --format=dpmsurl:80,dpmrtyp,dpmpint,dpmfsiz,dpmmode,dpmstatus,dpmfstat $u_token"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { ## if ( /Stat problem/||/send2nsd: NS009/||/Array Control/ ) { next; } print "GID2: $_"; my @m = split; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status \n"; } &printAndCExit(); } if (0) { $operation = "dpm-getreqid"; undef $status; @res = (); $command = "$operation --format=dpmturl:90,dpmrtok,dpmcred $u_token"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { ## if ( /Stat problem/||/send2nsd: NS009/||/Array Control/ ) { next; } if ( /r_token/ ) { next; } print "GID3: $_"; my @m = split; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status \n"; } &printAndCExit(); } $operation = "srm2_testMv"; foreach my $kfile ( $file ) { XcuteComm("srm2_testMv", "$struct->{$kfile}->{copyX} $kfile", "MVB", 0, 1); } if (0) { $operation = "dpm-getreqid"; undef $status; @res = (); $command = "$operation --format=dpmsurl:80,dpmrtyp,dpmpint,dpmfsiz,dpmmode,dpmstatus,dpmfstat $u_token"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { print "GID4: $_"; my @m = split; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status \n"; } &printAndCExit(); } TestPutOW(0); ##TestPutOW($overWrite++); TestPutOW(1); ## The overwrite flag can take values (0|1|2) or (Never|Always|WhenFileIsDifferent) ## Last value is useless - implemented as being equal to Always TestPutOW(2); ## So that this last test (with 2) is discarded. if (0) { my $fileB = "file.Bigger"; system (" cat $struct->{$file}->{input} $struct->{$file}->{input} > $fileB"); $struct->{$file}->{input} = "$fileB"; ($struct->{$file}->{size}, $dss) = split /\s+/, `ls -s $struct->{$file}->{input} | awk '{print \$1}'`; TestPutOW(2); } ## Actually Transfer the file $lTURL = XtractGoodTurl($struct->{$file}->{TURL}); undef $status; $xCount++; $operation = "rfcp"; $operation = "globus-url-copy"; @res = (); $command = "$operation $struct->{$file}->{input} $lTURL"; $command = "$operation -dbg file:$struct->{$file}->{input} $lTURL"; @res = `$command 2>&1`; foreach ( @res ) { ## To fit new gridftp reply ... if ( $_ =~ /^226 Transfer Complete\./ ) { $_ = "226 Transfer complete.\n"; } print " GSIFTP_TROW $_"; } $status = ( XtractVal('226 Transfer complete.') eq '226 Transfer complete.' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } $operation = "srm2_testPutDone"; undef $status; my $SURL; @res = (); $xCount++; $command = "$operation $struct->{$file}->{r_token} $file"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { print "PDOW: $_"; my @m = split; if ( /SURL =/ ) { $SURL = $m[5]; } if ( /request state/ ) { $status = ( "0" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } $SURL = XtractVal('SURL ='); ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } &printAndCExit(); if ( $SURL ne $file ) { print " Mismatch2: $SURL $file \n"; exit 1; } ## Tail of test about expired pinTime for PrepareToPut (cf top of script) ##&TransferTURL($pt_turl, $pt_input, 'PTT1b'); if (0) { $operation = "srm2_testPutDone"; undef $status; my $pt_surl; @res = (); $xCount++; $command = "$operation $pt_token $pt_file"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { print "PTT1c: $_"; my @m = split; ## if ( /SURL =/ ) { $SURL = $m[5]; } if ( /request state/ ) { $status = ( "0" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } $pt_surl = XtractVal('SURL ='); &printAndCExit(); if ( $pt_surl ne $pt_file ) { print " Mismatch_pt: $pt_surl $pt_file \n"; exit 1; } } else { &putDone($pt_token, $pt_file, 'PTT1c', '1'); ## &putDone($pt_token, $pt_file, 'PTT1c'); } ## End of test about expired pinTime for PrepareToPut (cf top of script) ## This operation must fail, but the next one must succeed without spitting an SRM_DUPLICATION_ERROR ## To make it fail with SRM_INVALID_REQUEST, a wrong space_token is supplied to the srm2_testPut command ## ?? ee5fa4b0-b04c-405d-be9f-d5b43513228c $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $ilf_file = "${file}_ilf"; ##my $wg_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 1000 - $protoc WRONG 2 - - $ilf_file $fsize", "WRG1", "$stat26"); ##$status = ( XtractVal('request state') eq '4' ) ? '[OK]' : '[FAILED]'; $status = ( XtractVal('request state') eq '1' ) ? '[OK]' : '[FAILED]'; ##my $pt_turl = XtractVal('TURL ='); ##my $pt_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } ## Test to check that infinite filelifetime is supplied (after putDone) to a SURL where P f_type is provided, with NO space_token $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $ilf_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 1000 - $protoc - 2 - - $ilf_file $fsize", "ILF1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $ilf_turl = XtractVal('TURL ='); my $ilf_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($ilf_turl, $ilf_input, 'ILF1b'); &putDone($ilf_token, $ilf_file, 'ILF1c'); ## End of check for infinite filelifetime ## Test to check that day_length filelifetime is supplied (after putDone) to a SURL where V f_type is provided, with NO space_token $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $dlf_file = "${file}_dlf"; my $dlf_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - - - 0 - - $dlf_file $fsize", "DLF1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $dlf_turl = XtractVal('TURL ='); my $dlf_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($dlf_turl, $dlf_input, 'DLF1b'); &putDone($dlf_token, $dlf_file, 'DLF1c'); ## End of check for day_length filelifetime ## Test to check that correct non_default filelifetime is supplied (after putDone) to a SURL where V f_type is provided, with NO space_token $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $clf_file = "${file}_clf"; my $clf_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 200 56789 $protoc - 0 - - $clf_file $fsize", "CLF1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $clf_turl = XtractVal('TURL ='); my $clf_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($clf_turl, $clf_input, 'CLF1b'); &putDone($clf_token, $clf_file, 'CLF1c'); ## End of check for correct non_default filelifetime ## Test to check that space_token filelifetime is supplied (after putDone) to a SURL where V f_type is provided, with NO specified filelifetime XcuteComm("srm2_testReserveSpace", "$endPoint $s_token StSysInfo1 300000 150000 456789 0", "SLF0", 0); ## "$endPoint $s_token StSysInfo1 300000 150000 3456789 0", my $sp_token_slf = XtractVal("s_token:"); $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $slf_file = "${file}_slf"; my $slf_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 200 - $protoc $sp_token_slf 0 - - $slf_file $fsize", "SLF1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $slf_turl = XtractVal('TURL ='); my $slf_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($slf_turl, $slf_input, 'SLF1b'); &putDone($slf_token, $slf_file, 'SLF1c'); ## End of check for space_token filelifetime ## Test to check that space_token filelifetime is supplied (after putDone) to a SURL where V f_type is provided, with NORMAL specified filelifetime $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $sln_file = "${file}_sln"; my $sln_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 200 56789 $protoc $sp_token_slf 0 - - $sln_file $fsize", "SLN1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $sln_turl = XtractVal('TURL ='); my $sln_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($sln_turl, $sln_input, 'SLN1b'); &putDone($sln_token, $sln_file, 'SLN1c'); ## End of check for space_token filelifetime with NORMAL specified filelifetime ## Test to check that space_token filelifetime is supplied (after putDone) to a SURL where V f_type is provided, with TOO_BIG specified filelifetime $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $slt_file = "${file}_slt"; my $slt_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 200 567890 $protoc $sp_token_slf 0 - - $slt_file $fsize", "SLT1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $slt_turl = XtractVal('TURL ='); my $slt_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($slt_turl, $slt_input, 'SLT1b'); &putDone($slt_token, $slt_file, 'SLT1c'); ## End of check for space_token filelifetime with TOO_BIG specified filelifetime ## Test sequence about ExtendFileLifeTimeInSpace XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token_slf", "XIS1", 0); my $slf_rlft = XtractVal('r_lifetime:'); ## Too big XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$sp_token_slf 9999000 $slf_file", "XIS2", 0); #my $slf_lft = XtractVal('fileLifetime:'); $status = ( ($slf_rlft - XtractVal('fileLifetime:')) < 40 ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Smaller XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$sp_token_slf 99000 $slf_file", "XIS3", 0); $status = ( (99000 - XtractVal('fileLifetime:')) == 0 ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Default (should return spaceLifetime) XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$sp_token_slf - $slf_file", "XIS4", 0); ## 60 was 40 was 20 was 10 before (changed for stress test) $status = ( ($slf_rlft - XtractVal('fileLifetime:')) < 60 ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Bad SURL XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$sp_token_slf 88000 ${slf_file}_wng", "XIS5", 1); ## Bad SToken XcuteComm("srm2_testExtendFileLifeTimeInSpace", "${sp_token_slf}_wng 88000 $slf_file", "XIS6", 4); ## Multiple SURLs (partial failure) XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$sp_token_slf 77000 $slf_file ${slf_file}_wng $slt_file", "XIS7", 27); $status = ( (77000 - XtractVal('fileLifetime:')) == 0 ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Increase spaceLifetime beyond pool DEF_LIFETIME value (7.0d(ays)) XcuteComm("srm2_testUpdateSpace", "$endPoint $sp_token_slf StSysInfo1 300000 150000 3000000", "XIS8", 0); ## Default (should return 604800 = 7.0d) XcuteComm("srm2_testExtendFileLifeTimeInSpace", "$sp_token_slf - $slf_file", "XIS9", 0); $status = ( (604800 - XtractVal('fileLifetime:')) == 0 ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## End of sequence about ExtendFileLifeTimeInSpace ## Test about infinite pinTime XcuteComm("srm2_testGet", "gsiftp $u_token - $file", "INFa", "$stat26", 1); my $ir_token = XtractVal('r_token'); ## XcuteComm("srm2_testGetRequestStatus", ## "$endPoint $ir_token", ## "INFd", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$ir_token -1 - $file", "INFb", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $ir_token", "INFc", 0, 1); ########TEMP GG $status = ( XtractVal('pinDate =') eq 'INFINITE' ) ? '[OK]' : '[FAILED]'; $status = ( XtractVal('pinDate =') =~ /1970-01-01T11:59:1|1970-01-01T11:59:2|1970-01-01T11:59:3|1970-01-01T11:59:4|1970-01-01T11:59:5|1970-01-01T12:00:00Z/ ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } if (1) { ##################################### MUST BE ONE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ## Test POSIX length sequence for file name ## Must pass my $psl1_file = "${short}psl1"; my $flen = length("$psl1_file"); my $goodPad = "GoodPadding" x 25; my $finePad = "FinePadding" x 25; $psl1_file = substr("$goodPad", 0, 255 - $flen) . "$psl1_file"; ##my $psl1_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl1_file $fsize", "PSL1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##my $psl1_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $psl1_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $psl1_token", "PSL1b", 0, 1); ## Must pass my $goodDir = substr("$finePad", 0, 255); XcuteComm("srm2_testMkdir", "${baseSrm}/$goodDir", "PSL4m", 0); $status = ( XtractVal("request state") eq '0' || XtractVal("request state") eq '11') ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } my $psl4_file = "${short}psl4"; $flen = length("$psl4_file"); ##my $goodPad = "GoodPadding" x 25; $psl4_file = substr("$goodPad", 0, 255 - $flen) . "$psl4_file"; ##my $psl4_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/${goodDir}/$psl4_file $fsize", "PSL4a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##my $psl4_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $psl4_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $psl4_token", "PSL4b", 0, 1); ## Must fail my $psl2_file = "${short}psl2"; $flen = length("$psl2_file"); my $badPad = "BadPadding" x 27; $psl2_file = substr("$badPad", 0, 256 - $flen) . "$psl2_file"; ##my $psl2_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl2_file $fsize", "PSL2a", "$stat26"); $status = ( XtractVal('request state') eq '1' ) ? '[OK]' : '[FAILED]'; ##my $psl2_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); ##my $psl2_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $psl2_token", # "PSL2b", 0, 1); } ## Test strange strings in file name ## Must pass my $psl3_file = "${short}psl3"; ##my $flen = length("$psl3_file"); ##GOODmy $weirdPad = "Weird\\\'Padding\\\"Weird"; ## -_.!~*' my $weirdPad = "Weird\\\'Padding\\\"Weird-A_B\\\!C\\\~D\\\*E\\\#F"; $psl3_file = "$weirdPad" . "$psl3_file"; my $psl3_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl3_file $fsize", "PSL3a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $psl3_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $psl3_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $psl3_token", "PSL3b", 0, 1); ## Test for 2 successive PTP w/o PutDone in between. Must fail ... XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl3_file $fsize", "PSL3c", "$stat26"); $status = ( XtractVal('request state') eq '11' ) ? '[OK]' : '[FAILED]'; ## $psl3_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); ## $psl3_token = XtractVal('r_token'); ##if ( $status ne '[OK]' ) { &printAndCExit(); } # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $psl3_token", # "PSL3d", 0, 1); ##&TransferTURL("\"$psl3_turl\"", $psl3_input, 'PSL3e'); &TransferTURL(quotemeta($psl3_turl), $psl3_input, 'PSL3e'); ## To check that weird strings are actually correctly handled. Must fail ... XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl3_file $fsize", "PSL3f", "$stat26"); $status = ( XtractVal('request state') eq '11' ) ? '[OK]' : '[FAILED]'; ## To check how fails the sequence PTP, Mv, PDone. $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $ptm_file = "${file}_ptm"; my $ptm_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 0 - - $ptm_file $fsize", "PTM1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $ptm_turl = XtractVal('TURL ='); my $ptm_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($ptm_turl, $ptm_input, 'PTM1b'); XcuteComm("srm2_testMv", "$ptm_file ${ptm_file}bizz", "PTM1m", 0, 1); ## Must probably not fail any more ... &putDone($ptm_token, $ptm_file, 'PTM1c'); ##TEMP&putDone($ptm_token, $ptm_file, 'PTM1c', 1); ## Must probably fail ... &putDone($ptm_token, "${ptm_file}bizz", 'PTM1d', 1); # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $psl3_token", # "PSL3g", 0, 1); ## Test srmLs avec offset/count XcuteComm("srm2_testLs", "${baseSrm}", "LSFL", 0, 1); ## was 1 XcuteComm("srm2_testLs", "-lO 5 5 ${baseSrm}", "LSOC", 0, 1); ## was 1 ## Tests about reserveSpace lifetime, and relevant file removal my $sp_size1 = 15000000; ## in bytes my $sp_size0 = 2*$sp_size1; my $rq_size2 = 18000000; my $rq_size3 = 10000000; my $rq_size4 = 6000000; my $rq_size5 = 2000000; my $sp_ltime1 = 15000; ## in sec. my $rq_ltime2 = 20000; my $rq_ltime3 = 10000; my $rq_ltime4 = 10000; XcuteComm("srm2_testReserveSpace", "$endPoint $s_token StSysInfo1 $sp_size0 $sp_size1 $sp_ltime1 0", "RSP3", 0); my $sp_token3 = XtractVal("s_token:"); XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "SMD3", 0); ## Must be rejected ... $overWrite = 0; my $rp_file1 = "${file}_R3a"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 $rq_ltime3 - $sp_token3 0 - - $rp_file1 $rq_size2", "RSP3a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##my $rp_turl2 = XtractVal('TURL ='); ##my $rp_token2 = XtractVal('r_token'); ####if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "SMD3a", 0); ## Must be accepted ... but the effective filelifetime will be shrinked to that of the space_token after putDone my $rp_file2 = "${file}_R3b"; my $rp_input2 = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 $rq_ltime2 - $sp_token3 0 - - $rp_file2 $rq_size3", "RSP3b", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $rp_turl2 = XtractVal('TURL ='); my $rp_token2 = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "SMD3b", 0); &TransferTURL($rp_turl2, $rp_input2, 'TRT3b'); &putDone($rp_token2, $rp_file2, 'PTD3b'); ## This one must fail ... to check that filestatuses are correctly filled ##&TransferTURL($rp_turl2, "$rp_input2 ${rp_input2}_bb", 'TRT3bb'); &putDone($rp_token2, "$rp_file2 ${rp_file2}_bb", 'PTD3bb', '1'); ## Must be accepted ... ##$fsize = $struct->{$file}->{size}*1024; my $rp_file3 = "${file}_R3c"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 $rq_ltime3 - $sp_token3 0 - - $rp_file3 $rq_size3", "RSP3c", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $rp_turl3 = XtractVal('TURL ='); my $rp_token3 = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "SMD3c", 0); ## Must be rejected ... total space size exceeds space_token one ?? ##$fsize = $struct->{$file}->{size}*1024; my $rp_file4 = "${file}_R3d"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 $rq_ltime3 - $sp_token3 0 - - $rp_file4 $rq_size4", "RSP3d", "$stat26"); $status = ( XtractVal('request state') eq '8' ) ? '[OK]' : '[FAILED]'; ##my $rp_turl4 = XtractVal('TURL ='); ##my $rp_token4 = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "SMD3d", 0); ## Must be partly rejected ... total space size exceeds space_token one ?? ##$fsize = $struct->{$file}->{size}*1024; my $rp_file5 = "${file}_R3e"; my $rp_input5 = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 3 $overWrite 100 $rq_ltime3 $protoc $sp_token3 0 - - ${rp_file5}_0 $rq_size5 ${rp_file5}_1 $rq_size5 ${rp_file5}_2 $rq_size5", "RSP3e", "$stat26"); $status = ( XtractVal('request state') eq '8' ) ? '[OK]' : '[FAILED]'; my $rp_turl5_0 = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $rp_turl5_1 = XtractVal('state\[1\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $rp_token5 = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($rp_turl5_0, $rp_input5, 'TRT3e_0'); &TransferTURL($rp_turl5_1, $rp_input5, 'TRT3e_1'); ## Must be partly rejected ... 2 files out of 4 are not correct ... &putDone($rp_token5, "${rp_file5}_0 ${rp_file5}_1 ${rp_file5}_2 ${rp_file5}_ff", 'PTD3e', '27'); XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "SMD3e", 0); ## Partial success ... XcuteComm("srm2_testGetRequestStatus", "$endPoint $rp_token5 ${rp_token5}_ff", "GRT3e1", 27, 1); ## $status = ( XtractVal('PutR: state\[0\] =') eq '0,' ) ? '[OK]' : '[FAILED]'; $status = ( XtractVal('PutR: state\[1\] =') eq '0,' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Partial success ... as well ?? XcuteComm("srm2_testGet", "rfio $u_token - ${rp_file5}_0 ${rp_file5}_1 ${rp_file5}_2 ${rp_file5}_ff", "GET3e", '27', 0); ## "GET3e", "$stat26", 0); my $grp_token5 = XtractVal('r_token'); ## Partial success ... again ! XcuteComm("srm2_testGetRequestStatus", "$endPoint $rp_token5 ${rp_token5}_ff $grp_token5", "GRT3e2", 27, 1); $status = ( XtractVal('GetR: state\[1\] =') eq '22,' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Check rp_file2 is still existing ... XcuteComm("srm2_testGet", "rfio $u_token - $rp_file2", "GET3b", "$stat26", 1); my $grp_token2 = XtractVal('r_token'); XcuteComm("srm2_testGetRequestSummary", "$endPoint $grp_token2", "GRS3b", 0, 1); $status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Put operation for the reservespace oversize test # 1st file : simple overflow of the preparetoput reserved size # 2nd file : same as before + overflow of the space reserved size $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $po1_file = "${file}po1"; my $po2_file = "${file}po2"; my $po1_input = "$struct->{$Lfile[1]}->{input}"; ## actual size about 3.7MB my $po2_input = "$struct->{$Lfile[1]}->{input}"; ## actual size about 3.7MB XcuteComm("srm2_testPut", "$u_token 2 $overWrite 200 - $protoc $sp_token3 0 - - $po1_file $fsize $po2_file $fsize", "POT1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $po1_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $po2_turl = XtractVal('state\[1\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $po_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } &TransferTURL($po1_turl, $po1_input, 'POT1b1'); &TransferTURL($po2_turl, $po2_input, 'POT1b2'); &putDone($po_token, "${po1_file} ${po2_file}", 'POT1c'); XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "POT1d", 0); ## and finally release the space to check if the file disappears with it ... XcuteComm("srm2_testReleaseSpace", "$endPoint $sp_token3 StSysInfo1 1", "RLS3b", 0); XcuteComm("srm2_testGetRequestStatus", "$endPoint $rp_token2 $grp_token2", "GRT3b", 0, 1); $status = ( XtractVal('PutR: state\[0\] =') eq '0,' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## Put operation for the ExtendFileLifeTime test XcuteComm("srm2_testUpdateSpace", "$endPoint $sp_token3 StSysInfo1 $sp_size0 $sp_size0 $sp_ltime1", "PET1u", 0); XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $sp_token3", "PET1m", 0); $overWrite = 0; $fsize = $struct->{$file}->{size}*1024; my $pe1_file = "${file}pe1"; my $pe1_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 140 - $protoc $sp_token3 0 - - $pe1_file $fsize", "PET1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pe1_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $pe1_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_token", "PET1r0", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pe1_token -1 - $pe1_file", "PET1b", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_token", "PET1ri", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pe1_token 999 - $pe1_file", "PET1c", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_token", "PET1r", 0, 1); my $pe1_gr_token; my $pet1get = 1; if ( $pet1get ) { &TransferTURL($pe1_turl, $pe1_input, 'PET1tr'); &putDone($pe1_token, "${pe1_file}", 'PET1pt'); XcuteComm("srm2_testGet", "gsiftp $u_token - $pe1_file", "PET1gr0", "$stat26", 1); $pe1_gr_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_gr_token", "PET1gr1", 0, 1); } XcuteComm("srm2_testExtendFileLifeTime", "- - 999999 $pe1_file", "PET1d", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_token", "PET1sd", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "- - -1 $pe1_file", "PET1e", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_token", "PET1se", 0, 1); if ( $pet1get ) { # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $pe1_gr_token", # "PET1gr2", 0, 1); } XcuteComm("srm2_testExtendFileLifeTime", "- - 9999 $pe1_file", "PET1f", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe1_token", "PET1sf", 0, 1); if ( $pet1get ) { # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $pe1_gr_token", # "PET1gr3", 0, 1); } ## Same ExtendFileLifeTime test as above, but without spaceToken ... 'V'olatile file my $pe2_file = "${file}pe2"; my $pe2_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 120 - $protoc - 0 - - $pe2_file $fsize", "PET2a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pe2_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $pe2_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_token", "PET2r0", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pe2_token -1 - $pe2_file", "PET2b", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_token", "PET2ri", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pe2_token 999 - $pe2_file", "PET2c", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_token", "PET2r", 0, 1); my $pe2_gr_token; my $pet2get = 1; if ( $pet2get ) { &TransferTURL($pe2_turl, $pe2_input, 'PET2tr'); &putDone($pe2_token, "${pe2_file}", 'PET2pt'); XcuteComm("srm2_testGet", "gsiftp $u_token 1200 $pe2_file", "PET2gr0", "$stat26", 1); $pe2_gr_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_gr_token", "PET2gr1", 0, 1); } XcuteComm("srm2_testExtendFileLifeTime", "- - 999999 $pe2_file", "PET2d", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_token", "PET2sd", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "- - -1 $pe2_file", "PET2e", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_token", "PET2se", 0, 1); if ( $pet2get ) { # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $pe2_gr_token", # "PET2gr2", 0, 1); } XcuteComm("srm2_testExtendFileLifeTime", "- - 9999 $pe2_file", "PET2f", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe2_token", "PET2sf", 0, 1); if ( $pet2get ) { # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $pe2_gr_token", # "PET2gr3", 0, 1); } ## Same ExtendFileLifeTime test as above, but with a 'P'ermanent file my $pe3_file = "${file}pe3"; my $pe3_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - $pe3_file $fsize", "PET3a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; my $pe3_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $pe3_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_token", "PET3r0", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pe3_token -1 - $pe3_file", "PET3b", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_token", "PET3ri", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pe3_token 999 - $pe3_file", "PET3c", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_token", "PET3r", 0, 1); my $pe3_gr_token; my $pet3get = 1; if ( $pet3get ) { &TransferTURL($pe3_turl, $pe3_input, 'PET3tr'); &putDone($pe3_token, "${pe3_file}", 'PET3pt'); XcuteComm("srm2_testGet", "gsiftp $u_token - $pe3_file", "PET3gr0", "$stat26", 1); $pe3_gr_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_gr_token", "PET3gr1", 0, 1); } XcuteComm("srm2_testExtendFileLifeTime", "- - 999999 $pe3_file", "PET3d", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_token", "PET3sd", 0, 1); XcuteComm("srm2_testExtendFileLifeTime", "- - -1 $pe3_file", "PET3e", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_token", "PET3se", 0, 1); if ( $pet3get ) { # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $pe3_gr_token", # "PET3gr2", 0, 1); } XcuteComm("srm2_testExtendFileLifeTime", "- - 9999 $pe3_file", "PET3f", 0, 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $pe3_token", "PET3sf", 0, 1); if ( $pet3get ) { # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $pe3_gr_token", # "PET3gr3", 0, 1); } ## Test putDone on an already putDone file : must fail &putDone($pe1_token, "${pe1_file}", 'AGN1pt', 1); # XcuteComm("srm2_testPutDone", # "$pe1_token $pe1_file", # "AGN1pt", 1, 1); ####&putDone($pe1_token, "${pe1_file}", 'AGN1pt_bis', 1); ## Test ExtendFileLifeTime on an already putDone file : must fail XcuteComm("srm2_testExtendFileLifeTime", "$pe1_token 9999 - $pe1_file", "AGN2pt", 1, 1); ## Test partial Get failure + partial then global ReleaseFiles XcuteComm("srm2_testGet", "rfio $u_token - ${pe3_file}_bid $pe3_file $pe2_file $pe1_file", "GRETa", '27', 1); my $gret_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gret_token", "GRETb", 0, 1); if (1) { XcuteComm("srm2_testReleaseFiles", "$endPoint $gret_token $pe2_file $pe3_file", "GRETc", 0, 1); } else { ## XcuteComm("srm2_testReleaseFiles", ## "$endPoint $gret_token $pe2_file $pe1_file", ## "GRETc", 0, 1); XcuteComm("srm2_testReleaseFiles", "$endPoint $gret_token $pe2_file", "GRETc", 0, 1); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $gret_token", "GRETd", 0, 1); XcuteComm("srm2_testReleaseFiles", "$endPoint $gret_token", "GRETe", '27', 1); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gret_token", "GRETf", 0, 1); ## Test ReleaseFiles on Put request : must fail XcuteComm("srm2_testReleaseFiles", "$endPoint $pe3_token", "GRETp", 4, 1); ## AbortRequest sequence ... XcuteComm("srm2_testGet", "gsiftp $u_token - $file", "GRQa", "$stat26", 1); my $gr_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestSummary", "$endPoint $gr_token", "GRQb", 0, 1); $status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testAbortRequest", "$endPoint $gr_token", "GRQc", 0, 1); XcuteComm("srm2_testGetRequestSummary", "$endPoint $gr_token", "GRQd", 0, 1); $status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } ## testBring sequence ... if (0) { XcuteComm("srm2_testGet", "gsiftp $u_token $file", "BRGa", 26, 1); } XcuteComm("srm2_testBring", "$u_token $file", "BRGa", "$stat26", 1); my $brg_token = XtractVal('r_token'); ##$status = ( XtractVal("request state0") eq '18' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestSummary", "$endPoint $brg_token", "BRGsm", 0, 1); $status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $brg_token", "BRGst", '0', 1); $status = ( XtractVal('SURL =') eq "${file}," ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testReleaseFiles", "$endPoint $brg_token $file", "BRGrf", '0', 1); ## testCopy sequence ... XcuteComm("srm2_testCopy", "$u_token $file srm://dummy.cern.ch:${portnum}//dpm/cern.ch/home/dteam/srmv22_Tfile.fil103926c28A0cp01", "CPYa", '16', 0); ##TEMPREM "CPYa", '00', 1); my $cpy_token = XtractVal('r_token'); ##TEMPREM $status = ( XtractVal("request state0") eq '18' ) ? '[OK]' : '[FAILED]'; ####$status = ( XtractVal("request state") eq '16' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } if (0) { ##TEMPREM XcuteComm("srm2_testGetRequestSummary", "$endPoint $cpy_token", "CPYs", 0, 1); $status = ( XtractVal('state\[0\]:') eq '18' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $cpy_token", "CPYr", '0', 1); $status = ( XtractVal('sSURL =') eq "${file}," ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } } if (0) { ## test POSIX length sequence ## Must pass my $psl1_file = "${short}psl1"; my $flen = length("$psl1_file"); my $goodPad = "GoodPadding" x 25; $psl1_file = substr("$goodPad", 0, 255 - $flen) . "$psl1_file"; ##my $psl1_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl1_file $fsize", "PSL1a", "$stat26"); $status = ( XtractVal('request state') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##my $psl1_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); my $psl1_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $psl1_token", "PSL1b", 0, 1); ## Must fail my $psl2_file = "${short}psl2"; $flen = length("$psl2_file"); my $badPad = "BadPadding" x 27; $psl2_file = substr("$badPad", 0, 256 - $flen) . "$psl2_file"; ##my $psl2_input = "$struct->{$file}->{input}"; XcuteComm("srm2_testPut", "$u_token 1 $overWrite 100 - $protoc - 2 - - ${baseSrm}/$psl2_file $fsize", "PSL2a", "$stat26"); $status = ( XtractVal('request state') eq '1' ) ? '[OK]' : '[FAILED]'; ##my $psl2_turl = XtractVal('state\[0\] = 24, SRM_SPACE_AVAILABLE, TURL ='); ##my $psl2_token = XtractVal('r_token'); if ( $status ne '[OK]' ) { &printAndCExit(); } # XcuteComm("srm2_testGetRequestStatus", # "$endPoint $psl2_token", # "PSL2b", 0, 1); ## Test srmLs avec offset/count XcuteComm("srm2_testLs", "${baseSrm}", "LSFL", 0, 1); ## was 1 XcuteComm("srm2_testLs", "-lO 5 5 ${baseSrm}", "LSOC", 0, 1); ## was 1 } ## ExtendFileLifetime on EXPIRED (GET then PUT) TURL sequence ... XcuteComm("srm2_testGet", "gsiftp $u_token 10 $file", "GEXTa", "$stat26", 1); my $gxr_token = XtractVal('r_token'); XcuteComm("srm2_testPut", "$u_token 1 $overWrite 10 - $protoc - 2 - - ${file}pxr $fsize", "PEXTa", "$stat26", 1); my $pxr_token = XtractVal('r_token'); sleep(12); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gxr_token", "GEXTst", '0', 1); $status = ( XtractVal('state\[0\] =') eq '6,' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $pxr_token", "PEXTst", '0', 1); $status = ( XtractVal('state\[0\] =') eq '24,' ) ? '[OK]' : '[FAILED]'; if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testExtendFileLifeTime", "$gxr_token 100 - $file", "GEXTb", 1, 1); XcuteComm("srm2_testExtendFileLifeTime", "$pxr_token 100 - ${file}pxr", "PEXTb", 1, 1); XcuteComm("srm2_testGetSpaceTokens", "$endPoint $s_token", "GST2", 0, 1); my @s_tokens = (); foreach ( @res ) { if ( ! /s_token/ ) { next; } my @ms = split /\s+/, $_; push @s_tokens, $ms[-1]; } foreach my $s_token ( @s_tokens ) { XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $s_token", "SMD1a", 0); #my $t_space = XtractVal('t_space:'); my $g_space = XtractVal('g_space:'); my $u_space = XtractVal('u_space:'); #my $r_lifetime = XtractVal('r_lifetime:'); ##if ( $g_space == 30000000 ) { ##$u_space = int((($g_space-$u_space+1000000)/1000000))*1000000; if ( $g_space >= 14000000 ) { $u_space = int((($g_space-$u_space+1000)/1000))*1000; XcuteComm("srm2_testUpdateSpace", "$endPoint $s_token - - $u_space -", "SMD1b", 0); XcuteComm("srm2_testGetSpaceMetaData", "$endPoint $s_token", "SMD1c", 0); } } ## End of event loop ----------------------------------------------------------------------- print "<_________________________________________________________________________>\n\n"; my $tAlmost = time() - $otStart; $operation = "OVERALL SUITE"; print " Operation: $operation = $status Duration: $tAlmost sec.\n"; print "<_________________________________________________________________________>\n\n"; exit 0; #################################################################################################### sub printAndCExit { ##20 if ( $status ne "[OK]" ) { exit 1; } ##20 else { print " Operation: $operation = $status Duration: $tElapse \n"; } if ( $status ne "[OK]" ) { foreach ( @res ) { print " FAILURE: $_"; } print " Operation: $operation = $status Duration: $tElapse \n"; #p print "<_________________________________________________________________________>\n\n"; exit 1; } else { print " Operation: $operation = $status Duration: $tElapse \n"; #p print "<_________________________________________________________________________>\n\n"; return; } } #################################################################################################### sub XtractVal { my $string = shift; ## $flat =~ m/$string\s+(.+?)\s+/; my $val = ""; foreach (@res) { if ( /$string\s+(\S+?)\s+/ ) { $val = $1; } elsif ( /($string\S*?)\s+/ ) { $val = $1; } } print " XtractVal: >$string< >$val< \n"; return $val; } #################################################################################################### sub getPxAttributes { ## extract the 'role' or 'VO' (DPM view) chomp(my $fqan0 = `voms-proxy-info -fqan | head -1`); ## if ( $fqan0 =~ 'WARNING' ) { ## chomp($fqan0 = `voms-proxy-info -vo | head -1`); if ( $fqan0 eq '' ) { $pxGRP = $voteam; print " Got pxGRP: $pxGRP\n"; } else { my @m = split /\//, $fqan0; $pxGRP = $m[1]; foreach my $in ( 2 .. scalar(@m) ) { if ( $m[$in] =~ 'NULL' ) { last; } $pxGRP .= "/" . "$m[$in]"; } print " Got pxGRP: $pxGRP\n"; } ## extract the 'DN' chomp(my $ident = `voms-proxy-info -identity | tail -1`); $pxDN = "$ident"; ##NotAnyMore $pxDN =~ s/ /_/g; print " Got pxDN: $pxDN\n"; return 0; } #################################################################################################### sub XcuteComm { $operation = shift; my $cargs = shift; my $label = shift; my $xpectStat = shift; my $fatalXit = shift; my $runGdb = shift; $xCount++; ##old undef $status; $status = "[UNDEF]"; @res = (); $usage = `$operation 2>&1`; $command = "$operation $cargs"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; ##O my $tStart = time(); $tStart = time(); if (0) { if ( $operation ne 'srm2_testPut' ) { @res = `$command 2>&1`; } else { system("$command"); } #OLD my $exitFlag = $?; #OLD print " STEP: $xCount OPERATION: $operation RET: $exitFlag\n"; } else { ##print " fatalXit runGdb: >$fatalXit< >$runGdb< \n"; if ( $runGdb ) { $command = "gdb $operation <&1 |"; while ( ) { push @res, $_; } close RES; } else { open RES, "$command 2>&1 |"; ## open RES, "$command |"; while ( ) { ## To fit new gridftp reply ... if ( $_ =~ /^226 Transfer Complete\./ ) { $_ = "226 Transfer complete.\n"; } # if ( ! /^\s+$|^\.\.\.$/ ) { # print "$label: $_"; # } push @res, $_; } close RES; } } my $exitFlag = $?; # print " STEP: $xCount OPERATION: $operation RET: $exitFlag\n"; # # foreach ( @res ) { # # print " RES: $_"; # # } ##O my $tEnd = time(); ##O my $tElapse = $tEnd - $tStart; $tEnd = time(); $tElapse = $tEnd - $tStart; ## my $exitFlag = 0; foreach ( @res ) { $_ =~ s/req.*TURL/TURL/; if ( ! /^\s+$|^\.\.\.$/ ) { print "$label: $_"; } my @m = split; if ( /request state/ ) { $status = ( "$xpectStat" eq "$m[2]" ) ? "[OK]" : "[FAILED]" ; } elsif ( /Command exited/ || /Timed out/ ) { $status = "[FAILED]" ; } } if ( $status eq "[UNDEF]" ) { ##if ( $exitFlag ) { $status = "[FAILED]" ; } $status = ( $exitFlag ) ? "[FAILED]" : "[OK]" ; ## $status = ( $exitFlag && $fatalXit ) ? "[FAILED]" : "[OK]" ; } if ( $status ne "[OK]" && $fatalXit) { # if ( $status ne "[OK]" && ( $fatalXit || $exitFlag ) ) { foreach ( @res ) { print " FAILURE: $_"; } print " Operation: $operation = $status Duration: $tElapse \n"; print "<_________________________________________________________________________>\n\n"; exit 1; } else { if ( $exitFlag ) { print " RET: $exitFlag\n"; foreach ( @res ) { print " WARNING: $_"; } } print " Operation: $operation = $status Duration: $tElapse \n"; print "<_________________________________________________________________________>\n\n"; } ## if ( $db1 && $operation eq 'srm2_testExtendFileLifeTime' ) { if ( $db1 && $operation =~ 'srm2_testExtendFileLifeTime' ) { ##my @m = split /\s+/, $cargs; &queryDB($label, $operation, $cargs); } ##system('ls -l core*'); return 0; } #################################################################################################### sub compareNACL { my $file = shift; my @comp; ## Should use here local definition for grp names ## That is to say %votid my $atlas = "atlas"; my $cms = "cms"; my $dteam = "$pxGRP"; my %duserl = (); $duserl{dteamtest01} = "dteamtest01"; $duserl{dteamtest02} = "dteamtest02"; $duserl{dteamtest03} = "$dteamtest03"; my $tstNAME = "$pxDN"; my $tstGRP = "$pxGRP"; @comp = <<"EOACL"; NACL1: Stat: 0, SRM_SUCCESS NACL1: Path: $file NACL1: OwnR: $tstNAME NACL1: OwnP: RWX NACL1: OthP: R NACL1: GrpP: 3 $dteam:RX $atlas:WX $cms:RW NACL1: ================= NACL2: Stat: 0, SRM_SUCCESS NACL2: Path: $file NACL2: OwnR: $tstNAME NACL2: OwnP: RWX NACL2: OthP: R NACL2: GrpP: 2 $dteam:RX $cms:NONE NACL2: ================= NACL3: Stat: 0, SRM_SUCCESS NACL3: Path: $file NACL3: OwnR: $tstNAME NACL3: OwnP: RWX NACL3: OthP: R NACL3: UsrP: 3 $duserl{dteamtest01}:R $duserl{dteamtest02}:RX $duserl{dteamtest03}:RW NACL3: GrpP: 2 $dteam:RX $cms:NONE NACL3: ================= NACL4: Stat: 0, SRM_SUCCESS NACL4: Path: $file NACL4: OwnR: $tstNAME NACL4: OwnP: RWX NACL4: OthP: R NACL4: UsrP: 2 $duserl{dteamtest02}:RX $duserl{dteamtest03}:NONE NACL4: GrpP: 2 $dteam:RX $cms:NONE NACL4: ================= EOACL my $naclRes = join "", @naclRes; foreach ( @naclRes ) { ##print; } foreach ( @comp ) { ##print; } if ( "$naclRes" ne "@comp" ) { print "\n NACLRES:> \n@naclRes \n"; print " COMP:> \n@comp \n"; print " compareNACL [FAILED]\n"; return "[FAILED]"; } return "[OK]"; } #################################################################################################### sub compareACL { my $file = shift; my @comp; if ( 0 ) { @comp = <<"EOACL"; ACL1: # file: $file ACL1: # owner: $tstNAME ACL1: # group: cg ACL1: user::rwx ACL1: group::r-x #effective:r-x ACL1: group:zp:-wx #effective:-wx ACL1: group:zh:rw- #effective:rw- ACL1: mask::rwx ACL1: other::r-- ACL2: # file: $file ACL2: # owner: $tstNAME ACL2: # group: cg ACL2: user::rwx ACL2: group::r-x #effective:r-x ACL2: group:zh:--- #effective:--- ACL2: mask::rwx ACL2: other::r-- ACL3: # file: $file ACL3: # owner: $tstNAME ACL3: # group: cg ACL3: user::rwx ACL3: user:dteam004:r-- #effective:r-- ACL3: user:dteam005:r-x #effective:r-x ACL3: user:dteam006:rw- #effective:rw- ACL3: group::r-x #effective:r-x ACL3: group:zh:--- #effective:--- ACL3: mask::rwx ACL3: other::r-- ACL4: # file: $file ACL4: # owner: $tstNAME ACL4: # group: cg ACL4: user::rwx ACL4: user:dteam005:r-x #effective:r-x ACL4: user:dteam006:--- #effective:--- ACL4: group::r-x #effective:r-x ACL4: group:zh:--- #effective:--- ACL4: mask::rwx ACL4: other::r-- EOACL } else { ## Should use here local definition for grp names ## That is to say %votid #my $atlas = $votid{"atlas"}; #my $cms = $votid{"cms"}; #my $dteam = $votid{"dteam"}; my $atlas = "atlas"; my $cms = "cms"; #my $dteam = "dteam"; my $dteam = "$pxGRP"; my %duserl = (); $duserl{dteamtest01} = "dteamtest01"; $duserl{dteamtest02} = "dteamtest02"; $duserl{dteamtest03} = "dteamtest03"; ## my $tstNAME = "$cuid"; ## my $tstGRP = "$cgid"; my $tstNAME = "$pxDN"; my $tstGRP = "$pxGRP"; @comp = <<"EOACL"; ACL1: # file: $file ACL1: # owner: $tstNAME ACL1: # group: $tstGRP ACL1: user::rwx ACL1: group::r-x #effective:r-x ACL1: group:$atlas:-wx #effective:-wx ACL1: group:$cms:rw- #effective:rw- ACL1: mask::rwx ACL1: other::r-- ACL2: # file: $file ACL2: # owner: $tstNAME ACL2: # group: $tstGRP ACL2: user::rwx ACL2: group::r-x #effective:r-x ACL2: group:$cms:--- #effective:--- ACL2: mask::rwx ACL2: other::r-- ACL3: # file: $file ACL3: # owner: $tstNAME ACL3: # group: $tstGRP ACL3: user::rwx ACL3: user:$duserl{dteamtest01}:r-- #effective:r-- ACL3: user:$duserl{dteamtest02}:r-x #effective:r-x ACL3: user:$duserl{dteamtest03}:rw- #effective:rw- ACL3: group::r-x #effective:r-x ACL3: group:$cms:--- #effective:--- ACL3: mask::rwx ACL3: other::r-- ACL4: # file: $file ACL4: # owner: $tstNAME ACL4: # group: $tstGRP ACL4: user::rwx ACL4: user:$duserl{dteamtest02}:r-x #effective:r-x ACL4: user:$duserl{dteamtest03}:--- #effective:--- ACL4: group::r-x #effective:r-x ACL4: group:$cms:--- #effective:--- ACL4: mask::rwx ACL4: other::r-- EOACL } # # ACL1: # file: $file # # ACL1: # owner: $tstNAME # # ACL1: # group: $tstGRP # # ACL1: user::rwx # # ACL1: group::r-- #effective:r-- # # ACL1: group:atlas:-wx #effective:-wx # # ACL1: group:cms:rw- #effective:rw- # # ACL1: mask::rwx # # ACL1: other::r-- # # ACL2: # file: $file # # ACL2: # owner: $tstNAME # # ACL2: # group: $tstGRP # # ACL2: user::rwx # # ACL2: group::r-- #effective:r-- # # ACL2: group:cms:--- #effective:--- # # ACL2: mask::rwx # # ACL2: other::r-- # # ACL3: # file: $file # # ACL3: # owner: $tstNAME # # ACL3: # group: $tstGRP # # ACL3: user::rwx # # ACL3: user:dteam004:r-- #effective:r-- # # ACL3: user:dteam005:r-x #effective:r-x # # ACL3: user:dteam006:rw- #effective:rw- # # ACL3: group::r-- #effective:r-- # # ACL3: group:cms:--- #effective:--- # # ACL3: mask::rwx # # ACL3: other::r-- # # ACL4: # file: $file # # ACL4: # owner: $tstNAME # # ACL4: # group: $tstGRP # # ACL4: user::rwx # # ACL4: user:dteam005:r-x #effective:r-x # # ACL4: user:dteam006:--- #effective:--- # # ACL4: group::r-- #effective:r-- # # ACL4: group:cms:--- #effective:--- # # ACL4: mask::rwx # # ACL4: other::r-- my @aclOrig = (join "",@aclRes); my ($a, $b); if ( 0 ) { foreach my $c ( 1..10 ) { $a = shift @aclOrig; $b = shift @comp; print "A: >$a<\n"; print "B: >$b<\n"; } } $aclOrig[0] =~ s;\s+; ;g; $comp[0] =~ s;\s+; ;g; # print " lengths: ", scalar(@aclRes), " ", scalar(@comp), " \n"; if ( "@aclOrig" ne "@comp" ) { my @aL = split / /, $aclOrig[0]; my @cL = split / /, $comp[0]; my $n = 0; foreach my $a ( @aL ) { my $c = shift @cL; $n++; if ( $a ne $c ) { print " DIFF: $a $c $n\n"; } } } if ( "@aclOrig" ne "@comp" ) { print " ACLRES: @aclOrig \n"; print " COMP: @comp \n"; print " compareACL [FAILED]\n"; ############################## return "[FAILED]"; } return "[OK]"; } #################################################################################################### sub XtractGoodTurl { my $TURL = shift; if (0) { my $sTURL; if ( $TURL =~ /rfio/ ) { $TURL =~ m[(.*?)://.*?/(.*)]; $TURL =~ m[(.*?)://(.*)]; $sTURL = $2; $sTURL =~ s;//;:/; ; if ( $ENV{NEW_RFIO_SYNTAX} ) { $sTURL = $TURL; ### For the NEW RFIOD 30/11/05 } } else { $TURL =~ m[(.*?://.*?)(/.*?:)(/.*)]; $sTURL = $1 . $3; $sTURL = $TURL; ### For the NEW FTPD 23/05/05 } print "\n XtractGoodTurl\n INPUT: $TURL\n OUTPUT: $sTURL\n"; return $sTURL; } else { ## GG 06/02/07 return $TURL; } } #################################################################################################### sub TestPutOW { my $overWrite = shift; my $status; my $lTURL; $operation = "srm2_testPut"; $xCount++; my $lifet = 123456; my $nbfiles = 1; $command = "$operation $u_token $nbfiles $overWrite"; #foreach my $kfile ( $Lfile[0] ) { foreach my $kfile ( $file ) { my $fsize = $struct->{$kfile}->{size}*1024; if ( $overWrite == 2 ) { $fsize *= 100; } ## $command .= " $kfile $lifet 0 $fsize"; $command .= " $lifet - - - 0 - - $kfile $fsize"; } $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; $tStart = time(); @res = `$command 2>&1`; $tEnd = time(); $tElapse = $tEnd - $tStart; foreach ( @res ) { print "LOW$overWrite: $_"; my @m = split; if ( /r_token / ) { $r_token = $m[3]; } if ( /state\[(\d+?)\]/ ) { $lTURL = $_; chop($m[2]); $tstatus = $m[2]; ##WAS $TURL = $m[5]; $TURL = $m[6]; $struct->{$file}->{TURL} = $TURL; $struct->{$file}->{r_token} = $r_token; } if ( $overWrite ) { if ( /request state/ ) { $status = ( "$stat26" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } else { ## This operation must fail when overWrite = 0 ... if ( /request state/ ) { $tstatus = "24"; ## Cheating ... $status = ( "11" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } } if ( $status ne "[OK]" || $tstatus ne "24" ) { print " Put FAILED: $lTURL >$status< >$tstatus<\n"; ##exit 1; } else { print " Operation: $operation = $status Duration: $tElapse \n"; } return; } #################################################################################################### sub TransferTURL { my $fileTURL = shift; my $fileInput = shift; my $lLABL = shift; my $lTURL = XtractGoodTurl($fileTURL); my $opsargs; if ( $lTURL !~ /gsiftp/ ) { $operation = 'rfcp'; $opsargs = "$fileInput $lTURL"; $lLABL = 'RFCP_TRACE_' . "$lLABL"; } else { $operation = 'globus-url-copy'; $opsargs = "-dbg file:$fileInput $lTURL"; $lLABL = 'GSIFTP_TRACE_' . "$lLABL"; } XcuteComm("$operation", "$opsargs", "$lLABL", 0, 1); if ( $lTURL !~ /gsiftp/ ) { $status = ( XtractVal('seconds through') eq 'local' ) ? '[OK]' : '[FAILED]'; } else { $status = ( XtractVal('226 Transfer complete.') ) ? '[OK]' : '[FAILED]'; } if ( $status ne '[OK]' ) { &printAndCExit(); } return; } #################################################################################################### sub putDone { my $pt_token = shift; my $pt_file = shift; my $lLABL = shift; my $xpectStat = shift || '0'; $operation = "srm2_testPutDone"; undef $status; my $pt_surl; @res = (); $xCount++; $command = "$operation $pt_token $pt_file"; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); $dateSTZ = `date --utc '+%FT%TZ'`; print "++++ $$ $dateST $dateSTZ\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { print "PD_${lLABL}: $_"; my @m = split; ## if ( /SURL =/ ) { $SURL = $m[5]; } if ( /request state/ ) { $status = ( "$xpectStat" eq "$m[2]" ) ? "[OK]" : "[FAILED]" ; } } &printAndCExit(); if ( "$xpectStat" ne '0' ) { return; } $pt_surl = XtractVal('SURL ='); my @m = split /\s+/, $pt_file; my $pt_filel = $m[-1]; if ( $pt_surl ne $pt_filel ) { print " Mismatch3: $pt_surl $pt_filel \n"; exit 1; } XcuteComm("srm2_testGetRequestStatus", "$endPoint $pt_token", "GRS_${lLABL}", "0", 1); return; } #################################################################################################### sub queryDB { my $label = shift; my $opera = shift; my $cargs = shift; my ($tok, $pT, $lT, $fn); if ( $opera =~ 'Space' ) { ($tok, $pT, $fn) = split /\s+/, $cargs; $lT = 'NA'; } else { ($tok, $pT, $lT, $fn) = split /\s+/, $cargs; } my ($ltime, $sfn); my @m = split '/', $fn; $fn = $m[-1]; my $shandle1 = $db1->prepare("select ltime,sfn from Cns_file_replica where sfn like ?"); $shandle1->execute("%${fn}%"); ($ltime, $sfn) = $shandle1->fetchrow_array; $shandle1->finish; #my $Atime = scalar localtime $ltime; my $Dtime = $ltime - time(); my $Atime = strftime '%FT%TZ', localtime($ltime); @m = split /-/, $Atime; if ( $m[0] eq '2038' ) { $Dtime = 'INFINITE'; } if ( $Atime eq '1970-01-01T01:00:00Z' ) { $Dtime = '0'; } ##GOODprint " Values: $fn: datestz: $Atime deltime: $Dtime sfn: $sfn \n"; print " String: $fn: datestz: $Atime deltime: $Dtime \n"; my $rpT = XtractVal('pinLifetime:'); $rpT = ( $rpT eq "" ) ? '-' : $rpT; my $rlT = XtractVal('fileLifetime:'); $rlT = ( $rlT eq "" ) ? '-' : $rlT; # print " LIFET: $label fn: $fn requested: $pT $lT returned: $rpT $rlT filelifetimeDB: $Dtime \n"; # printf (" LIFET: %6s fn: %32s requested: %6s %6s returned: %6s %7s filelifetimeDB: %8s \n", $label, $fn, $pT, $lT, $rpT, $rlT, $Dtime); printf (" LIFET: %5s reqd: %6s %6s retd: %6s %7s lfTDB: %8s \n", $label, $pT, $lT, $rpT, $rlT, $Dtime); return; } #################################################################################################### lcgdm-1.8.7/test/srmv2.2/srm.v2.2.wsdl0000644000175000017500000030631710542043011016527 0ustar ellertellert srm.v2.2.wsdl Wed Sep 27 08:22:41 PDT 2006 Mon Jul 3 09:49:53 PDT 2006 Tue Jun 20 07:21:54 PDT 2006 - FINALIZED Mon Jun 19 09:45:38 PDT 2006 Created by Junmin Gu, Alex Sim Lawrence Berkeley National Laboratory on basis of the Storage Resource Manager Interface Specification v2.2 published at http://sdm.lbl.gov/srm-wg the following location of the service is specific to the particular deployment and is not part of the specification lcgdm-1.8.7/test/srmv2.2/srm2_testCheckPermission.c0000644000175000017500000001060710542043011021434 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testCheckPermission.c,v 1.1 2006/12/19 20:05:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmCheckPermissionResponse_ rep; struct ns1__ArrayOfTSURLPermissionReturn *repfs; struct ns1__srmCheckPermissionRequest req; struct ns1__TSURLInfo *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; enum ns1__TPermissionMode {None=0, X=1, W=2, WX=3, R=4, RX=5, RW=6, RWX=7}; static enum ns1__TPermissionMode f_modes[] = {None, X, W, WX, R, RX, RW, RWX}; char* sf_modes[] = {"None", "X", "W", "WX", "R", "RX", "RW", "RWX"}; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL ) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->surlInfoArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->surlInfoArray[i]; /* if ((reqfilep->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ //reqfilep->SURL = argv[i+1]; req.arrayOfSURLs->urlArray[i] = argv[i+1]; } if (soap_call_ns1__srmCheckPermission (&soap, srm_endpoint, "CheckPermission", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmCheckPermissionResponse->returnStatus; repfs = rep.srmCheckPermissionResponse->arrayOfPermissions; /* wait for file "ready" */ printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS ) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } if (! repfs) { printf ("arrayOfPermissions is NULL\n"); soap_end (&soap); exit (0); } printf ("request surlPermissionArray %d\n", repfs->__sizesurlPermissionArray); for (i = 0; i < repfs->__sizesurlPermissionArray; i++) { if ((repfs->surlPermissionArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->surlPermissionArray[i])->status->statusCode, (repfs->surlPermissionArray[i])->status->explanation); else #if 0 printf ("state[%d] = %d, %s, Perm = %s, SURL = %s\n", i, (repfs->surlPermissionArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->surlPermissionArray[i])->status->statusCode), //(repfs->surlPermissionArray[i])->userPermission, sf_modes[*((repfs->surlPermissionArray[i])->permission)], (repfs->surlPermissionArray[i])->surl); #else printf ("state[%d] = %d, %s", i, (repfs->surlPermissionArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->surlPermissionArray[i])->status->statusCode)); if ( (repfs->surlPermissionArray[i])->permission ) printf (", Perm = %s", sf_modes[*((repfs->surlPermissionArray[i])->permission)]); printf (", SURL = %s\n", (repfs->surlPermissionArray[i])->surl); #endif } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testStatusOfReserveSpaceRequest.c0000644000175000017500000000435710542043011024004 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testStatusOfReserveSpaceRequest.c,v 1.1 2006/12/19 20:05:29 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmStatusOfReserveSpaceRequestResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmStatusOfReserveSpaceRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.requestToken->value = argv[1]; */ req.requestToken = argv[1]; if (soap_call_ns1__srmStatusOfReserveSpaceRequest (&soap, srm_endpoint, "StatusOfReserveSpaceRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmStatusOfReserveSpaceRequestResponse->returnStatus; printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testBring.c0000644000175000017500000001471110542043011017407 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testBring.c,v 1.1 2006/12/19 20:05:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; char** lprotos; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio ", #endif #if GFAL_ENABLE_DCAP "gsidcap ", #endif "" }; int r = 0; char *r_token; struct ns1__srmBringOnlineResponse_ rep; struct ns1__ArrayOfTBringOnlineRequestFileStatus *repfs; struct ns1__srmBringOnlineRequest req; struct ns1__TGetFileRequest *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfBringOnlineRequestResponse_ srep; struct ns1__srmStatusOfBringOnlineRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s u_token SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //nbproto = 1; /* lprotos = calloc (nbproto, sizeof(char*)); lprotos[0] = strdup(argv[1]); */ soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfFileRequests = soap_malloc (&soap, sizeof(struct ns1__ArrayOfTGetFileRequest))) == NULL || (req.arrayOfFileRequests->requestArray = soap_malloc (&soap, nbfiles * sizeof(struct ns1__TGetFileRequest *))) == NULL /* || (req.arrayOfTransferProtocols = soap_malloc (&soap, sizeof(struct ns1__ArrayOf_USCORExsd_USCOREstring))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } for (i = 0; i < nbfiles; i++) { if ((req.arrayOfFileRequests->requestArray[i] = soap_malloc (&soap, sizeof(struct ns1__TGetFileRequest))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } req.arrayOfFileRequests->__sizerequestArray = nbfiles; /* req.arrayOfTransferProtocols->stringArray = &argv[1]; req.arrayOfTransferProtocols->__sizestringArray = nbproto; */ if ( strcmp(argv[1], "-") ) req.userRequestDescription = argv[1]; for (i = 0; i < nbfiles; i++) { reqfilep = req.arrayOfFileRequests->requestArray[i]; memset (reqfilep, 0, sizeof(*reqfilep)); /* if ((reqfilep->sourceSURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } reqfilep->sourceSURL->value = argv[i+2]; */ reqfilep->sourceSURL = argv[i+2]; /* FIXME: still existing ? */ //??reqfilep->sourceSURL->storageSystemInfo = NULL; /* FIXME: new input parameter to fill in */ reqfilep->dirOption = NULL; /* FIXME: many new file parameters to fill in */ /* GG special tests */ /* if ( i == 0 ) //CRASHreqfilep->fromSURLInfo = NULL; //CRASHreqfilep->fromSURLInfo->SURLOrStFN = NULL; //CRASHreqfilep->fromSURLInfo->SURLOrStFN->value = NULL; */ } #if 0 if (soap_call_ns1__srmBringOnline (&soap, srm_endpoint, "BringOnline", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(BringOnline, re); #endif /* FIXME: arrayOfFileStatuses when wsdl agreed NONEED ? */ reqstatp = rep.srmBringOnlineResponse->returnStatus; //repfs = rep.srmBringOnlineResponse->arrayOfFileStatuses; if (rep.srmBringOnlineResponse->requestToken) { r_token = rep.srmBringOnlineResponse->requestToken; printf ("soap_call_ns1__srmBringOnline returned r_token %s\n", r_token); } memset (&sreq, 0, sizeof(sreq)); /* GG special tests */ //GOODsreq.requestToken = NULL; /* Good token = 049672c4-0f64-471b-a393-c8fbeac9101c */ //BADstrcpy(sreq.requestToken, special_token); //BADsreq.requestToken = strdup(special_token); //GOODstrcat(rep.srmBringOnlineResponse->requestToken->value, "uu"); //CRASHrep.srmBringOnlineResponse->requestToken->value = NULL; //GOODstrcpy(rep.srmBringOnlineResponse->requestToken->value, r_token); //GOODstrcpy(rep.srmBringOnlineResponse->requestToken->value, strfry(r_token)); sreq.requestToken = rep.srmBringOnlineResponse->requestToken; /* wait for file "ready" */ while (reqstatp->statusCode == SRM_USCOREREQUEST_USCOREQUEUED || reqstatp->statusCode == SRM_USCOREREQUEST_USCOREINPROGRESS || reqstatp->statusCode == SRM_USCOREREQUEST_USCORESUSPENDED) { printf ("request status0 %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf("request state0 %d\n", reqstatp->statusCode); sleep ((r++ == 0) ? 1 : DEFPOLLINT); #if 0 if (soap_call_ns1__srmStatusOfBringOnlineRequest (&soap, srm_endpoint, "StatusOfBringOnlineRequest", &sreq, &srep)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(StatusOfBringOnlineRequest, sre); #endif reqstatp = srep.srmStatusOfBringOnlineRequestResponse->returnStatus; repfs = srep.srmStatusOfBringOnlineRequestResponse->arrayOfFileStatuses; /* TEMPORARY, because not fully implemented ... */ if ( r>3 ) { printf ("request state 00\n"); soap_end (&soap); exit (1); } } printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->sourceSURL) printf ("state[%d] = %d, %s, TURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->sourceSURL); else if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("state[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/Imakefile0000644000175000017500000000505111000742233016147 0ustar ellertellertCOMM COMM Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL COMM All rights reserved COMM COMM @(#)$RCSfile: Imakefile,v $ $Revision: 1.8 $ $Date: 2008/04/14 20:54:51 $ CERN Jean-Philippe Baud COMM $Id: Imakefile,v 1.8 2008/04/14 20:54:51 szamsu Exp $ COMM Make srmv2.2 tests GLOBUS_LOCATION=GlobusLocation #if defined(__STDC__) GLOBUS_FLAVOUR=GlobusFlavour##pthr #else GLOBUS_FLAVOUR=GlobusFlavour/**/pthr #endif GLOBUS_LIBS=-L$(GLOBUS_LOCATION)/lib -lglobus_gssapi_gsi_$(GLOBUS_FLAVOUR) -lglobus_gss_assist_$(GLOBUS_FLAVOUR) GSOAP_LOCATION=GsoapLocation GSOAP_VERSION=GsoapVersion WSDL2H_FLAGS=GsoapWsdl2hFlags CGSI_GSOAP_LOCATION=CgsiGsoapLocation SECFLG = -DGFAL_SECURE SECLIB = -L$(CGSI_GSOAP_LOCATION)/$(_lib) -lcgsi_plugin_gsoap_$(GSOAP_VERSION) $(GLOBUS_LIBS) SOAPFLG = -DWITH_IPV6 RFIOFLG = -DGFAL_ENABLE_RFIO prefixsrmv2.2 = $(prefix)/test/sbin/ INCLUDES = ./ COMM######################### FLAGS ############################## CFLAGS = $(SECFLG) $(RFIOFLG) $(SOAPFLG) -I$(INCLUDES) -I$(GSOAP_LOCATION)/include -I$(CGSI_GSOAP_LOCATION)/include COMM######################### RULES ############################## PROGS = $(patsubst %.c,%,$(wildcard srm2_test*.c)) PROGOS = $(patsubst %.c,%.Osuf,$(wildcard srm2_test*.c)) SCRIPTS = srmv2Suite \ srmv2Stress SOAP_OBJS = srmv2C.Osuf \ srmv2Client.Osuf \ stdsoap2.Osuf PROGSBIN = $(addprefix $(prefixsrmv2.2),$(PROGS) $(SCRIPTS)) all: $(PROGS) srmv2H.h srmv2Stub.h srmv2C.c srmv2Client.c srmSoapBinding.nsmap: srm.v2.2.h $(GSOAP_LOCATION)/bin/soapcpp2 -c -p srmv2 srm.v2.2.h srm.v2.2.h: srm.v2.2.wsdl $(GSOAP_LOCATION)/bin/wsdl2h $(WSDL2H_FLAGS) -c -e -y -t typemap.dat srm.v2.2.wsdl stdsoap2.Osuf: $(GSOAP_LOCATION)/src/stdsoap2.c $(CC) -c -I$(GSOAP_LOCATION)/include $(SOAPFLG) $(GSOAP_LOCATION)/src/stdsoap2.c install: $(PROGSBIN) install.man: $(prefixsrmv2.2)%: % cp $? $@ $(PROGS): %: %.Osuf $(SOAP_OBJS) $(DEPLIBS) ### @echo "========================g" $@ $(LD) -o $@ $(LDFLAGS) $< $(SOAP_OBJS) $(LIBS) $(SECLIB) COMM###################### CLEANING RULES ######################## clean: -@RemoveFiles(*.Osuf *H.h *Object.h *Proxy.h *Stub.h *C.c *Client.c *Lib.c *Server.c *.nsmap *.xml srm.v2.2.h) clobber: clean -@RemoveFiles($(PROGS)) #if _WIN32 depend: @echo Not supported on this platform #else depend: makedepend -Y$(INCLUDES) *.c 2> /dev/null #endif Makefiles: FORCE: COMM###################### DEPENDENCIES ########################## $(PROGOS): srmv2H.h srmSoapBinding.nsmap parsesurl.ic soapcallns1.ic COMM DO NOT DELETE THIS LINE -- make depend depends on it. lcgdm-1.8.7/test/srmv2.2/srm2_testStatusOfUpdateSpaceRequest.c0000644000175000017500000000435110542043011023605 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testStatusOfUpdateSpaceRequest.c,v 1.1 2006/12/19 20:05:29 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmStatusOfUpdateSpaceRequestResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmStatusOfUpdateSpaceRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.requestToken->value = argv[1]; */ req.requestToken = argv[1]; if (soap_call_ns1__srmStatusOfUpdateSpaceRequest (&soap, srm_endpoint, "StatusOfUpdateSpaceRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmStatusOfUpdateSpaceRequestResponse->returnStatus; printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testUpdateSpace.c0000644000175000017500000001030010553430076020547 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testUpdateSpace.c,v 1.2 2007/01/17 14:18:38 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmUpdateSpaceResponse_ rep; //struct ArrayOfTSURLPermissionReturn *repfs; struct ns1__srmUpdateSpaceRequest req; //struct ns1__TSURLInfo *reqfilep; struct ns1__TReturnStatus *reqstatp; struct ns1__srmUpdateSpaceResponse *repp; char *sfn; struct soap soap; char *srm_endpoint; if (argc < 7) { fprintf (stderr, "usage: %s endPoint s_token [storage_system_info|-] [newSizeOfTotalSpaceDesired|-] [newSizeOfGuaranteedSpaceDesired|-] [newLifeTimeFromCallingTime|-|-1]\n", argv[0]); exit (1); } #if 0 if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.spaceToken = soap_malloc (&soap, sizeof(struct ns1__TSpaceToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.spaceToken = argv[2]; if ((req.storageSystemInfo = soap_malloc (&soap, sizeof(struct ns1__TExtraInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.storageSystemInfo->value = argv[3]; /* req.storageSystemInfo->__sizeextraInfoArray = 1; req.storageSystemInfo->extraInfoArray[0]->key = "0"; req.storageSystemInfo->extraInfoArray[0]->value = argv[3]; */ req.storageSystemInfo->__sizeextraInfoArray = 0; req.storageSystemInfo->extraInfoArray = NULL; //printf("Step 1\n"); if ( strcmp(argv[4], "-") ) { if ((req.newSizeOfTotalSpaceDesired = soap_malloc (&soap, sizeof(ULONG64))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } *(req.newSizeOfTotalSpaceDesired) = atoll(argv[4]); //printf("Step 2\n"); } if ( strcmp(argv[5], "-") ) { if ((req.newSizeOfGuaranteedSpaceDesired = soap_malloc (&soap, sizeof(ULONG64))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } *(req.newSizeOfGuaranteedSpaceDesired) = atoll(argv[5]); //printf("Step 3\n"); } if ( strcmp(argv[6], "-") ) { if ((req.newLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } *(req.newLifeTime) = atoi(argv[6]); //printf("Step 4\n"); } /* To send the request ... */ #if 0 if (soap_call_ns1__srmUpdateSpace (&soap, argv[1], "UpdateSpace", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else srm_endpoint = argv[1]; SOAP_CALL_NS1(UpdateSpace, re); #endif reqstatp = rep.srmUpdateSpaceResponse->returnStatus; //repfs = rep.srmCheckPermissionResponse->arrayOfPermissions; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } repp = rep.srmUpdateSpaceResponse; /* printf ("srmUpdateSpace provided actual_s_type: %d actual_t_space: %llu actual_g_space: %llu actual_lifetime: %d\n", (*repp->typeOfReservedSpace), repp->sizeOfTotalReservedSpace->value, repp->sizeOfGuaranteedReservedSpace->value, repp->lifetimeOfReservedSpace->value ); */ printf ("srmUpdateSpace provided actual_t_space: %llu actual_g_space: %llu actual_lifetime: %d\n", *(repp->sizeOfTotalSpace), *(repp->sizeOfGuaranteedSpace), *(repp->lifetimeGranted) ); soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testGetSpaceMetaData.c0000644000175000017500000001211710542043011021440 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetSpaceMetaData.c,v 1.1 2006/12/19 20:05:25 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmGetSpaceMetaDataResponse_ rep; struct ns1__ArrayOfTMetaDataSpace *repfs; struct ns1__TMetaDataSpace *repmdp; struct ns1__srmGetSpaceMetaDataRequest req; struct ns1__TSpaceToken *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; char *s_type; enum ns1__TSpaceType {Volatile = 0, Durable = 1, Permanent = 2}; char* s_retpol[] = { "REPLICA", "OUTPUT", "CUSTODIAL", }; if (argc < 3) { fprintf (stderr, "usage: %s endPoint SpaceTokenS\n", argv[0]); exit (1); } nbfiles = argc - 2; #if 0 if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfSpaceTokens = soap_malloc (&soap, sizeof(struct ns1__ArrayOfString))) == NULL|| (req.arrayOfSpaceTokens->stringArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSpaceTokens->tokenArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSpaceToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.arrayOfSpaceTokens->__sizestringArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSpaceTokens->tokenArray[i]; //reqfilep->value = argv[i+2]; req.arrayOfSpaceTokens->stringArray[i] = argv[i+2]; } /* To send the request ... */ #if 0 if (soap_call_ns1__srmGetSpaceMetaData (&soap, argv[1], "SrmGetSpaceMetaData", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else srm_endpoint = argv[1]; SOAP_CALL_NS1(GetSpaceMetaData, re); #endif reqstatp = rep.srmGetSpaceMetaDataResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } repfs = rep.srmGetSpaceMetaDataResponse->arrayOfSpaceDetails; if (! repfs) { printf ("arrayOfSpaceDetails is NULL\n"); soap_end (&soap); exit (0); } printf ("request spaceDataArray %d\n", repfs->__sizespaceDataArray); for (i = 0; i < repfs->__sizespaceDataArray; i++) { repmdp = repfs->spaceDataArray[i]; /* if ( (*repmdp->type) == Volatile ) */ /* s_type = "Volatile"; */ /* printf ("state[%d] => s_token: %s s_type: d client_dn: %s\n", i, repmdp->spaceToken, //(*repmdp->type), repmdp->owner ); */ /* printf ("state[%d] => t_space: %llu g_space: %llu u_space: %llu a_lifetime: %llu r_lifetime: %llu client_dn: %s\n", i, repmdp->totalSize->value, repmdp->guaranteedSize->value, repmdp->unusedSize->value, repmdp->lifetimeAssigned->value, repmdp->lifetimeLeft->value, repmdp->owner->value ); */ //printf ("state[%d] => s_token: %s s_type: %s t_space: %llu g_space: %llu u_space: %llu a_lifetime: %llu r_lifetime: %llu client_dn: %s\n", if ( repmdp->owner ) printf ("state[%d] = %d, %s, s_token: %s t_space: %llu g_space: %llu u_space: %llu a_lifetime: %d r_lifetime: %d client_dn: %s\n", i, repmdp->status->statusCode, soap_ns1__TStatusCode2s (&soap, repmdp->status->statusCode), repmdp->spaceToken, //VX(*repmdp->type), //BADs_retpol[*(repmdp->retentionPolicyInfo)->retentionPolicy], *(repmdp->totalSize), *(repmdp->guaranteedSize), *(repmdp->unusedSize), *(repmdp->lifetimeAssigned), *(repmdp->lifetimeLeft), repmdp->owner ); else printf ("state[%d] = %d, %s, s_token: %s\n", i, repmdp->status->statusCode, soap_ns1__TStatusCode2s (&soap, repmdp->status->statusCode), repmdp->spaceToken ); /* printf ("state[%d] => a_lifetime: %llu r_lifetime: %llu\n", i, repmdp->lifetimeAssigned->value, repmdp->lifetimeLeft->value ); */ /* printf ("state[%d] => a_lifetime: %llu\n", i, repmdp->lifetimeAssigned->value //repmdp->lifetimeLeft->value ); */ } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testChangeSpaceForFiles.c0000644000175000017500000000424710542043011022144 0ustar ellertellert/* * Copyright (C) 2004-2005 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testChangeSpaceForFiles.c,v 1.1 2006/12/19 20:05:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmChangeSpaceForFilesResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmChangeSpaceForFilesRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 0 if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.requestToken->value = argv[1]; #endif if (soap_call_ns1__srmChangeSpaceForFiles (&soap, srm_endpoint, "ChangeSpaceForFiles", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmChangeSpaceForFilesResponse->returnStatus; printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testStatusOfChangeSpaceForFilesRequest.c0000644000175000017500000000451510542043011025204 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testStatusOfChangeSpaceForFilesRequest.c,v 1.1 2006/12/19 20:05:29 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmStatusOfChangeSpaceForFilesRequestResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmStatusOfChangeSpaceForFilesRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.requestToken = argv[1]; if (soap_call_ns1__srmStatusOfChangeSpaceForFilesRequest (&soap, srm_endpoint, "StatusOfChangeSpaceForFilesRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmStatusOfChangeSpaceForFilesRequestResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testAbortRequest.c0000644000175000017500000000444510542043011020771 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testAbortRequest.c,v 1.1 2006/12/19 20:05:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmAbortRequestResponse_ rep; struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__srmAbortRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s endPoint reqid\n", argv[0]); exit (1); } //nbfiles = argc - 2; #if 0 if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.requestToken = argv[2]; //if (soap_call_ns1__srmAbortRequest (&soap, srm_endpoint, "AbortRequest", if (soap_call_ns1__srmAbortRequest (&soap, argv[1], "AbortRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmAbortRequestResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testRm.c0000644000175000017500000000754410542043011016732 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testRm.c,v 1.1 2006/12/19 20:05:28 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmRmResponse_ rep; struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__srmRmRequest req; //struct ns1__TSURLInfo *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL ) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->urlArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->urlArray[i]; //if ((reqfilep->SURLOrStFN = /* if ((reqfilep->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ //reqfilep->SURLOrStFN->value = argv[i+1]; //reqfilep->SURL = argv[i+1]; req.arrayOfSURLs->urlArray[i] = argv[i+1]; //reqfilep->storageSystemInfo = NULL; } //req.arrayOfFilePaths = 0; // TEST0 CRASH //req.arrayOfFilePaths->surlInfoArray = 0; // TEST1 CRASH //req.arrayOfFilePaths->surlInfoArray[0] = 0; // TEST2 CRASH //req.arrayOfFilePaths->surlInfoArray[0]->SURLOrStFN = 0; // TEST4 CRASH if (soap_call_ns1__srmRm (&soap, srm_endpoint, "SrmRm", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmRmResponse->returnStatus; repfs = rep.srmRmResponse->arrayOfFileStatuses; /* wait for file "ready" */ printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %s, explanation = %s\n", i, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->status->explanation); else printf ("state[%d] = %d, %s, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->surl); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testGetRequestTokens.c0000644000175000017500000000571710542043011021630 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetRequestTokens.c,v 1.1 2006/12/19 20:05:25 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmGetRequestTokensResponse_ rep; struct ns1__srmGetRequestTokensRequest req; struct ns1__TReturnStatus *reqstatp; //struct ns1__ArrayOfTRequestTokens *repfs; struct ns1__ArrayOfTRequestTokenReturn *repfs; char *sfn; struct soap soap; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s endPoint [user_request_description|-]\n", argv[0]); exit (1); } #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ( strncmp(argv[2], "-", 1) ) req.userRequestDescription = argv[2]; else req.userRequestDescription = NULL; /* GG special tests */ //GOODreq.userRequestDescription = NULL; // OUTPUTS EVERYTHING from the DB ! #if 0 if (soap_call_ns1__srmGetRequestTokens (&soap, srm_endpoint, "GetRequestTokens", #else if (soap_call_ns1__srmGetRequestTokens (&soap, argv[1], "GetRequestTokens", #endif &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmGetRequestTokensResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } repfs = rep.srmGetRequestTokensResponse->arrayOfRequestTokens; if (! repfs) { printf ("arrayOfRequestTokens is NULL\n"); soap_end (&soap); exit (0); } printf ("request tokenArray %d\n", repfs->__sizetokenArray); printf("=== RETURNED REQUEST TOKENS ===\n"); for (i = 0; i < repfs->__sizetokenArray; i++) printf("%s createdAt: %s\n", repfs->tokenArray[i]->requestToken, repfs->tokenArray[i]->createdAtTime /* soap_dateTime2s (&soap, (time_t*) (repfs->tokenArray[i]->createdAtTime->value) ) */ ); soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testPurgeFromSpace.c0000644000175000017500000001056010565000203021227 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testPurgeFromSpace.c,v 1.2 2007/02/15 06:41:07 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmPurgeFromSpaceResponse_ rep; struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__srmPurgeFromSpaceRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; //struct ns1__srmStatusOfGetRequestResponse_ srep; //struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 4) { fprintf (stderr, "usage: %s spaceToken [storage_system_info|-] SURLs\n", argv[0]); exit (1); } nbfiles = argc - 3; if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); req.spaceToken = argv[1]; if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("mallocA"); soap_end (&soap); exit (1); } req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) req.arrayOfSURLs->urlArray[i] = argv[i+3]; if ((req.storageSystemInfo = soap_malloc (&soap, sizeof(struct ns1__TExtraInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.storageSystemInfo->value = argv[2]; /* req.storageSystemInfo->__sizeextraInfoArray = 1; req.storageSystemInfo->extraInfoArray[0]->key = "0"; req.storageSystemInfo->extraInfoArray[0]->value = argv[3]; */ req.storageSystemInfo->__sizeextraInfoArray = 0; req.storageSystemInfo->extraInfoArray = NULL; if (soap_call_ns1__srmPurgeFromSpace (&soap, srm_endpoint, "PurgeFromSpace", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmPurgeFromSpaceResponse->returnStatus; repfs = rep.srmPurgeFromSpaceResponse->arrayOfFileStatuses; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } #if 1 if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else { #if 1 printf ("state[%d] = %d, %s, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->surl); #else printf ("state[%d] = %d, %s", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode)); if ( (repfs->statusArray[i])->pinLifetime ) /* FIXME */ //printf (", pinLifetime: %s", soap_dateTime2s (&soap, (time_t) *(repfs->statusArray[i])->pinLifetime)); printf (", pinLifetime: %d", *(repfs->statusArray[i])->pinLifetime); if ( (repfs->statusArray[i])->fileLifetime ) printf (", fileLifetime: %d", *(repfs->statusArray[i])->fileLifetime); printf (" SURL = %s\n", (repfs->statusArray[i])->surl); #endif } } #endif soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testLs.c0000644000175000017500000002743410647615600016751 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testLs.c,v 1.7 2007/07/19 08:06:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" struct soap soap; //static enum ns1__TPermissionMode permod[] = { NONE, X, W, WX, R, RX, RW, RWX, }; char* s_permod[] = { "NONE", "X", "W", "WX", "R", "RX", "RW", "RWX", }; main(argc, argv) int argc; char **argv; { int flags; int i, j; int isurl = 1; // pointer to the 1st actual SURL in the arg list int nbfiles; int nbproto = 0; static enum xsd__boolean trueoption = true_; // JPB static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; char *r_token; struct ns1__srmLsResponse_ rep; #define PRET 1 #ifdef PRET struct ns1__ArrayOfTMetaDataPathDetail *repfs; #endif struct ns1__srmLsRequest req; #define INIT 1 #ifdef INIT //struct ns1__TSURLInfo;;;xsd__anyURI *reqfilep; struct ns1__TReturnStatus *reqstatp; #endif char *sfn; //struct soap soap; //struct ns1__srmStatusOfGetRequestResponse_ srep; //struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; int booll = 0; int boolR = 0; int nolv = -1; int boolV = 0; int boolP = 0; //int booll = 0; //int boolR = 0; int boolO = 0; // to provide pair offset/count //static enum ns1__TPermissionMode permod[] = { NONE, X, W, WX, R, RX, RW, RWX, }; enum ns1__TStorageType {Volatile=0, Durable=1, Permanent=2}; static enum ns1__TStorageType ftypes[] = {Volatile, Durable, Permanent}; if (argc < 2) { fprintf (stderr, "usage: %s [-R|-l|-d|-2|-V|-P|-O] [offset count] SURLs\n", argv[0]); exit (1); } if ( strchr(argv[1], '-' ) == argv[1] ) { isurl = 2; if ( strchr(argv[1], 'l' ) ) booll = 1 ; if ( strchr(argv[1], 'R' ) ) boolR = 1 ; if ( strchr(argv[1], '2' ) ) nolv = 1 ; if ( strchr(argv[1], 'd' ) ) nolv = 0 ; if ( strchr(argv[1], 'V' ) ) boolV = 1 ; if ( strchr(argv[1], 'P' ) ) boolP = 1 ; if ( strchr(argv[1], 'O' ) ) { boolO = 1 ; isurl = 4; } } nbfiles = argc - isurl; if (parsesurl (argv[isurl], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; // Special BestMan - LBL //1807flags |= CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif #ifdef INIT memset (&req, 0, sizeof(req)); if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL ) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->surlInfoArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.arrayOfSURLs->__sizeurlArray = nbfiles; if ( booll ) req.fullDetailedList = &trueoption; // GG if ( boolR ) req.allLevelRecursive = &trueoption; // GG new if ( boolV ) req.fileStorageType = &ftypes[0]; // GG new2 if ( boolP ) req.fileStorageType = &ftypes[2]; // GG new2 if ( nolv > -1 ) req.numOfLevels = &nolv; if ( boolO ) { if ((req.offset = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } if ((req.count = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } *(req.offset) = atoi(argv[2]); *(req.count) = atoi(argv[3]); } else { req.offset = NULL; req.count = NULL; } for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->urlArray[i]; /* if ((reqfilep->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.arrayOfSURLs->urlArray[i] = argv[i+isurl]; //req.arrayOfSURLs->urlArray[i]->storageSystemInfo = NULL; } #if 0 if ((req.storageSystemInfo = soap_malloc (&soap, sizeof(struct ns1__TExtraInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.storageSystemInfo->value = argv[3]; /* req.storageSystemInfo->__sizeextraInfoArray = 1; req.storageSystemInfo->extraInfoArray[0]->key = "0"; req.storageSystemInfo->extraInfoArray[0]->value = argv[3]; */ req.storageSystemInfo->__sizeextraInfoArray = 0; req.storageSystemInfo->extraInfoArray = NULL; //printf("Step 1\n"); #else req.storageSystemInfo = NULL; #endif #else soap_default_ns1__srmLsRequest (&soap, &req); req.storageSystemInfo = NULL; req.arrayOfSURLs->__sizesurlInfoArray = nbfiles; if ( booll ) req.fullDetailedList = &trueoption; // GG if ( boolR ) req.allLevelRecursive = &trueoption; // GG new req.numOfLevels = &nolv; #endif //printf("Step 8-0\n"); #if 0 if (soap_call_ns1__srmLs (&soap, srm_endpoint, "Ls", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(Ls, re); #endif #ifdef PRET reqstatp = rep.srmLsResponse->returnStatus; if (rep.srmLsResponse->requestToken) { r_token = rep.srmLsResponse->requestToken; printf ("soap_call_ns1__srmLs returned l_token %s\n", r_token); } repfs = rep.srmLsResponse->details; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfTMetaDataPathDetail is NULL\n"); soap_end (&soap); exit (0); } printf ("request pathDetailArray %d\n", repfs->__sizepathDetailArray); // GG for (i = 0; i < repfs->__sizepathDetailArray; i++) { printABranch(repfs, i); } soap_end (&soap); exit (0); #endif } printABranch (struct ns1__ArrayOfTMetaDataPathDetail *repfs, int i) { struct ns1__ArrayOfTMetaDataPathDetail *repfsl; struct ns1__ArrayOfString *repfst; int j, il, it, nsub; //printf("Stat: %d\n", repfs->pathDetailArray[i]->status->statusCode); // GG printf("Stat: %d, %s\n", repfs->pathDetailArray[i]->status->statusCode, soap_ns1__TStatusCode2s (&soap, repfs->pathDetailArray[i]->status->statusCode) ); // GG if ( repfs->pathDetailArray[i]->arrayOfSubPaths ) //OLD2printf("Path: %s Subpath: %d\n", repfs->pathDetailArray[i]->surl, repfs->pathDetailArray[i]->arrayOfSubPaths->__sizepathDetailArray); printf("Path: %s Subpath: %d\n", repfs->pathDetailArray[i]->path, repfs->pathDetailArray[i]->arrayOfSubPaths->__sizepathDetailArray); else //OLD2printf("Path: %s\n", repfs->pathDetailArray[i]->surl); printf("Path: %s\n", repfs->pathDetailArray[i]->path); if ( repfs->pathDetailArray[i]->status->statusCode ) { printf("----=============\n"); return; // continue; } printf("Size: %d\n", *(repfs->pathDetailArray[i]->size)); if ( repfs->pathDetailArray[i]->type ) printf("Type: %d, %s\n", (*repfs->pathDetailArray[i]->type), soap_ns1__TFileType2s(&soap, (*repfs->pathDetailArray[i]->type)) ); if ( repfs->pathDetailArray[i]->fileStorageType ) printf("FStT: %d, %s\n", (*repfs->pathDetailArray[i]->fileStorageType), soap_ns1__TFileStorageType2s(&soap, (*repfs->pathDetailArray[i]->fileStorageType)) ); if ( repfs->pathDetailArray[i]->fileLocality ) printf("FLoc: %d, %s\n", (*repfs->pathDetailArray[i]->fileLocality), soap_ns1__TFileLocality2s(&soap, (*repfs->pathDetailArray[i]->fileLocality)) ); if ( repfst = repfs->pathDetailArray[i]->arrayOfSpaceTokens ) { printf ("request tokenArray %d\n", repfst->__sizestringArray); printf("=== Space Tokens ===\n"); for (it = 0; it < repfst->__sizestringArray; it++) printf("s_token[%d]: %s\n", it, repfst->stringArray[it]); } #if 0 if ( repfs->pathDetailArray[i]->ownerPermission ) printf("OwnR: %s\n", repfs->pathDetailArray[i]->ownerPermission); if ( repfs->pathDetailArray[i]->groupPermission ) printf("GrpP: %s\n", repfs->pathDetailArray[i]->groupPermission); #else if ( repfs->pathDetailArray[i]->ownerPermission ) printf("OwnP: %s %s\n", repfs->pathDetailArray[i]->ownerPermission->userID, s_permod[(repfs->pathDetailArray[i]->ownerPermission->mode)]); if ( repfs->pathDetailArray[i]->groupPermission ) printf("GrpP: %s %s\n", repfs->pathDetailArray[i]->groupPermission->groupID, s_permod[(repfs->pathDetailArray[i]->groupPermission->mode)]); #endif if ( repfs->pathDetailArray[i]->otherPermission ) printf("OthP: %s\n", s_permod[*(repfs->pathDetailArray[i]->otherPermission)]); if ( repfs->pathDetailArray[i]->checkSumType ) printf("ChST: %s\n", repfs->pathDetailArray[i]->checkSumType); if ( repfs->pathDetailArray[i]->createdAtTime ) printf("Crea: %s\n", repfs->pathDetailArray[i]->createdAtTime); //printf("Crea: %s\n", soap_dateTime2s (&soap, (time_t) (repfs->pathDetailArray[i]->createdAtTime->value))); if ( repfs->pathDetailArray[i]->lastModificationTime ) printf("Last: %s\n", repfs->pathDetailArray[i]->lastModificationTime); //3if ( repfs->pathDetailArray[i]->ownerPermission ) //3 printf("OwnP: %s\n", s_permod[*(repfs->pathDetailArray[i]->ownerPermission->mode)]); //7if ( repfs->pathDetailArray[i]->clientPermission ) //7 printf("CliP: %s\n", s_permod[*(repfs->pathDetailArray[i]->clientPermission)]); //printf("OwnP: %d\n", repfs->pathDetailArray[i]->ownerPermission->mode); //3if ( repfs->pathDetailArray[i]->otherPermission ) //3 printf("OthP: %s\n", s_permod[*(repfs->pathDetailArray[i]->otherPermission->mode)]); // Warning: there should be a loop here if __size>1 /* if ( repfs->pathDetailArray[i]->arrayOfUserPermissions ) { printf("UsrP: %d", repfs->pathDetailArray[i]->arrayOfUserPermissions->__sizeuserPermissionArray); for (j = 0; j < repfs->pathDetailArray[i]->arrayOfUserPermissions->__sizeuserPermissionArray; j++ ) { printf(" %s:%s", repfs->pathDetailArray[i]->arrayOfUserPermissions->userPermissionArray[j]->userID->value, s_permod[*(repfs->pathDetailArray[i]->arrayOfUserPermissions->userPermissionArray[j]->mode)]); } printf("\n"); } if ( repfs->pathDetailArray[i]->arrayOfGroupPermissions ) { printf("GrpP: %d", repfs->pathDetailArray[i]->arrayOfGroupPermissions->__sizegroupPermissionArray); for (j = 0; j < repfs->pathDetailArray[i]->arrayOfGroupPermissions->__sizegroupPermissionArray; j++ ) { printf(" %s:%s", repfs->pathDetailArray[i]->arrayOfGroupPermissions->groupPermissionArray[j]->groupID->value, s_permod[*(repfs->pathDetailArray[i]->arrayOfGroupPermissions->groupPermissionArray[j]->mode)]); } printf("\n"); } */ if ( repfs->pathDetailArray[i]->lifetimeAssigned ) printf("LifA: %d\n", *(repfs->pathDetailArray[i]->lifetimeAssigned)); if ( repfs->pathDetailArray[i]->lifetimeLeft ) printf("LifL: %d\n", *(repfs->pathDetailArray[i]->lifetimeLeft)); /* FIXME: check if there are new fields to be printed with 2.2 */ printf("=================\n"); //Loop on subpaths ... if ( ! repfs->pathDetailArray[i]->arrayOfSubPaths ) return; repfsl = repfs->pathDetailArray[i]->arrayOfSubPaths; nsub = repfsl->__sizepathDetailArray; if ( ! nsub ) return; for (il = 0; il < nsub; il++) { printf("================= Branch: %d\n", il); printABranch(repfsl, il); } return; } lcgdm-1.8.7/test/srmv2.2/srm2_testGet.c0000644000175000017500000002311010751773676017113 0ustar ellertellert/* * Copyright (C) 2004-2008 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGet.c,v 1.3 2008/02/05 05:44:30 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; char** lprotos; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio ", #endif #if GFAL_ENABLE_DCAP "gsidcap ", #endif "" }; int r = 0; char *r_token; struct ns1__srmPrepareToGetResponse_ rep; struct ns1__ArrayOfTGetRequestFileStatus *repfs; struct ns1__srmPrepareToGetRequest req; struct ns1__TGetFileRequest *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; int pptonly = 0; (void) setbuf(stdout, NULL); (void) setbuf(stderr, NULL); /* GG : '+' in place of 'u_token' arg means 'PrepareToGet step only' 09/01/08 */ if (argc < 5) { fprintf (stderr, "usage: %s [-|protocol] [+|-|u_token] [-|pinTime] SURLs\n", argv[0]); exit (1); } nbfiles = argc - 4; if (parsesurl (argv[4], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } nbproto = 1; lprotos = calloc (nbproto, sizeof(char*)); if ( strcmp(argv[1], "-") ) lprotos[0] = strdup(argv[1]); else nbproto = 0; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfFileRequests = soap_malloc (&soap, sizeof(struct ns1__ArrayOfTGetFileRequest))) == NULL || (req.arrayOfFileRequests->requestArray = soap_malloc (&soap, nbfiles * sizeof(struct ns1__TGetFileRequest *))) == NULL /* || (req.arrayOfTransferProtocols = soap_malloc (&soap, sizeof(struct ns1__ArrayOf_USCORExsd_USCOREstring))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } for (i = 0; i < nbfiles; i++) { if ((req.arrayOfFileRequests->requestArray[i] = soap_malloc (&soap, sizeof(struct ns1__TGetFileRequest))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } req.arrayOfFileRequests->__sizerequestArray = nbfiles; /* req.arrayOfTransferProtocols->stringArray = &argv[1]; req.arrayOfTransferProtocols->__sizestringArray = nbproto; */ if ( ! strcmp(argv[2], "+") ) pptonly = 1; else if ( strcmp(argv[2], "-") ) req.userRequestDescription = argv[2]; if ((req.desiredPinLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } if ( strcmp(argv[3], "-") ) *(req.desiredPinLifeTime) = atol(argv[3]); for (i = 0; i < nbfiles; i++) { reqfilep = req.arrayOfFileRequests->requestArray[i]; memset (reqfilep, 0, sizeof(*reqfilep)); /* if ((reqfilep->sourceSURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } reqfilep->sourceSURL->value = argv[i+3]; */ reqfilep->sourceSURL = argv[i+4]; /* FIXME: still existing ? */ //??reqfilep->sourceSURL->storageSystemInfo = NULL; /* FIXME: new input parameter to fill in */ reqfilep->dirOption = NULL; /* FIXME: many new file parameters to fill in */ /* GG special tests */ /* if ( i == 0 ) //CRASHreqfilep->fromSURLInfo = NULL; //CRASHreqfilep->fromSURLInfo->SURLOrStFN = NULL; //CRASHreqfilep->fromSURLInfo->SURLOrStFN->value = NULL; */ } //printf("Step 7\n"); if ((req.transferParameters = soap_malloc (&soap, sizeof(struct ns1__TTransferParameters))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.transferParametersHint->__sizesizeArray = 0; //req.transferParametersHint->sizeArray = NULL; req.transferParameters->accessPattern = NULL; req.transferParameters->connectionType = NULL; req.transferParameters->arrayOfClientNetworks = NULL; req.transferParameters->arrayOfTransferProtocols = NULL; //printf("Step 8-0\n"); if ((req.transferParameters->arrayOfTransferProtocols = soap_malloc (&soap, nbproto*sizeof(struct ns1__ArrayOfString))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //printf("Step 8-1 nbproto: %d\n", nbproto); req.transferParameters->arrayOfTransferProtocols->__sizestringArray = 1; //printf("Step 8-2\n"); req.transferParameters->arrayOfTransferProtocols->stringArray = lprotos; //printf("Step 8\n"); #if 0 if (soap_call_ns1__srmPrepareToGet (&soap, srm_endpoint, "PrepareToGet", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(PrepareToGet, re); #endif /* FIXME: arrayOfFileStatuses when wsdl agreed */ reqstatp = rep.srmPrepareToGetResponse->returnStatus; repfs = rep.srmPrepareToGetResponse->arrayOfFileStatuses; if (rep.srmPrepareToGetResponse->requestToken) { r_token = rep.srmPrepareToGetResponse->requestToken; printf ("soap_call_ns1__srmPrepareToGet returned r_token %s\n", r_token); } // New if (! repfs) printf ("PTG: arrayOfFileStatuses is NULL\n"); printFileStatus(&soap, repfs); if (pptonly) { soap_end (&soap); exit (0); } memset (&sreq, 0, sizeof(sreq)); /* GG special tests */ //GOODsreq.requestToken = NULL; /* Good token = 049672c4-0f64-471b-a393-c8fbeac9101c */ //BADstrcpy(sreq.requestToken, special_token); //BADsreq.requestToken = strdup(special_token); //GOODstrcat(rep.srmPrepareToGetResponse->requestToken->value, "uu"); //CRASHrep.srmPrepareToGetResponse->requestToken->value = NULL; //GOODstrcpy(rep.srmPrepareToGetResponse->requestToken->value, r_token); //GOODstrcpy(rep.srmPrepareToGetResponse->requestToken->value, strfry(r_token)); sreq.requestToken = rep.srmPrepareToGetResponse->requestToken; /* wait for file "ready" */ while (reqstatp->statusCode == SRM_USCOREREQUEST_USCOREQUEUED || reqstatp->statusCode == SRM_USCOREREQUEST_USCOREINPROGRESS || reqstatp->statusCode == SRM_USCOREREQUEST_USCORESUSPENDED) { printf ("request status0 %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf("request state0 %d\n", reqstatp->statusCode); sleep ((r++ == 0) ? 1 : DEFPOLLINT); #if 0 if (soap_call_ns1__srmStatusOfGetRequest (&soap, srm_endpoint, "StatusOfGetRequest", &sreq, &srep)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(StatusOfGetRequest, sre); #endif reqstatp = srep.srmStatusOfGetRequestResponse->returnStatus; //FSrepfs = srep.srmStatusOfGetRequestResponse->arrayOfFileStatuses; repfs = srep.srmStatusOfGetRequestResponse->arrayOfFileStatuses; printFileStatus(&soap, repfs); } printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) { printf ("explanation: %s\n", reqstatp->explanation); } if ( ! r ) { soap_end (&soap); exit (1); } /* soap_end (&soap); exit (1); */ } #define FS 1 #ifdef FS repfs = srep.srmStatusOfGetRequestResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->transferURL) printf ("state[%d] = %d, %s, TURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->transferURL); else if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else #if 0 printf ("state[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); #else printf ("state[%d] = %d, %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode)); #endif } #endif soap_end (&soap); exit (0); } int printFileStatus (struct soap* soap, struct ns1__ArrayOfTGetRequestFileStatus *repfs) { int i; if (! repfs) { printf ("SUB: arrayOfFileStatuses is NULL\n"); /* soap_end (soap); exit (0); */ return; } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->transferURL) printf ("pstate[%d] = %d, %s, TURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->transferURL); else if ((repfs->statusArray[i])->status->explanation) printf ("pstate[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else #if 0 printf ("pstate[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); #else printf ("pstate[%d] = %d, %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode)); #endif } return; } lcgdm-1.8.7/test/srmv2.2/srm2_testAbortFiles.c0000644000175000017500000000675210553430076020423 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testAbortFiles.c,v 1.2 2007/01/17 14:18:38 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmAbortFilesResponse_ rep; struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__srmAbortFilesRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ( /* (req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL || */ (req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->urlArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.requestToken = argv[1]; req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->surlArray[i]; //reqfilep->value = argv[i+2]; req.arrayOfSURLs->urlArray[i] = argv[i+2]; } if (soap_call_ns1__srmAbortFiles (&soap, srm_endpoint, "AbortFiles", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmAbortFilesResponse->returnStatus; repfs = rep.srmAbortFilesResponse->arrayOfFileStatuses; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("state[%d] = %d, %s, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->surl); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/soapcallns1.ic0000644000175000017500000000514010542043011017070 0ustar ellertellert/* * Copyright (C) 2004-2005 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: soapcallns1.ic,v 1.1 2006/12/19 20:05:29 grodid Exp $ char **faultcode; char **faultstring; char **faultdetail; int nscount; #define SOAP_CALL_NS1O(func) \ while (1) { \ if (soap_call_ns1__srm ## func (&soap, srm_endpoint, "srm" #func, \ &req, &rep)) { \ faultcode = (char**) soap_faultcode(&soap); \ faultstring = (char**) soap_faultstring(&soap); \ faultdetail = (char**) soap_faultdetail(&soap); \ printf (" SOAP fault processing:\ncode: %s\nstring: %s\ndetail: %s\n", faultcode[0], faultstring[0], faultdetail[0]); \ if ( ! strcmp(faultcode[0], "SOAP-ENV:Client") || ! strcmp(faultcode[0], "SOAP-ENV:Server") ) { \ printf (" SOAP fault: restarting soap_call_ns1__srm" #func "\n"); \ usleep(1000); \ continue; \ } else { \ soap_print_fault (&soap, stderr); \ soap_print_fault_location (&soap, stderr); \ soap_end (&soap); \ exit (1); \ } \ } \ break; \ } #define SOAP_CALL_NS1(func, ptrs) \ nscount = 0; \ while (1) { \ if (soap_call_ns1__srm ## func (&soap, srm_endpoint, "srm" #func, \ & ptrs ## q, & ptrs ## p)) { \ faultcode = (char**) soap_faultcode(&soap); \ faultstring = (char**) soap_faultstring(&soap); \ faultdetail = (char**) soap_faultdetail(&soap); \ printf (" SOAP fault processing:\ncode: %s\nstring: %s\ndetail: %s\n", faultcode[0], faultstring[0], faultdetail[0]); \ if ( (! strcmp(faultcode[0], "SOAP-ENV:Client") || ! strcmp(faultcode[0], "SOAP-ENV:Server")) && nscount++ < 5 ) { \ printf (" SOAP fault: restarting soap_call_ns1__srm" #func "\n"); \ usleep(10000 * nscount); \ continue; \ } else { \ soap_print_fault (&soap, stderr); \ soap_print_fault_location (&soap, stderr); \ soap_end (&soap); \ exit (1); \ } \ } \ break; \ } #define SOAP_CALL_NS1RO(func) \ while (1) { \ if (soap_call_ns1__srm ## func (&soap, srm_endpoint, "srm" #func, \ &sreq, &srep)) { \ faultcode = (char**) soap_faultcode(&soap); \ faultstring = (char**) soap_faultstring(&soap); \ faultdetail = (char**) soap_faultdetail(&soap); \ printf (" SOAP fault processing:\ncode: %s\nstring: %s\ndetail: %s\n", faultcode[0], faultstring[0], faultdetail[0]); \ if ( ! strcmp(faultcode[0], "SOAP-ENV:Client") || ! strcmp(faultcode[0], "SOAP-ENV:Server") ) { \ printf (" SOAP fault: restarting soap_call_ns1__srm" #func "\n"); \ usleep(1000); \ continue; \ } else { \ soap_print_fault (&soap, stderr); \ soap_print_fault_location (&soap, stderr); \ soap_end (&soap); \ exit (1); \ } \ } \ break; \ } lcgdm-1.8.7/test/srmv2.2/srm2_testReleaseSpace.c0000644000175000017500000000601010553430076020710 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testReleaseSpace.c,v 1.2 2007/01/17 14:18:38 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmReleaseSpaceResponse_ rep; //struct ArrayOfTSURLPermissionReturn *repfs; struct ns1__srmReleaseSpaceRequest req; struct ns1__TSURLInfo *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; static enum xsd__boolean trueoption = true_; // JPB if (argc < 5) { fprintf (stderr, "usage: %s endPoint s_token storage_system_info force_flag\n", argv[0]); exit (1); } #if 0 if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.spaceToken = soap_malloc (&soap, sizeof(struct ns1__TSpaceToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.spaceToken = argv[2]; if ((req.storageSystemInfo = //soap_malloc (&soap, sizeof(struct ns1__TStorageSystemInfo))) == NULL) { soap_malloc (&soap, sizeof(struct ns1__TExtraInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.storageSystemInfo->value = argv[3]; /* req.storageSystemInfo->__sizeextraInfoArray = 1; req.storageSystemInfo->extraInfoArray[0]->key = "0"; req.storageSystemInfo->extraInfoArray[0]->value = argv[3]; */ req.storageSystemInfo->__sizeextraInfoArray = 0; req.storageSystemInfo->extraInfoArray = NULL; //printf("Step 1\n"); /* req.forceFileRelease = atoi(argv[4]); */ if ( atoi(argv[4]) == 1 ) req.forceFileRelease = &trueoption; /* To send the request ... */ #if 0 if (soap_call_ns1__srmReleaseSpace (&soap, argv[1], "SrmReleaseSpace", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else srm_endpoint = argv[1]; SOAP_CALL_NS1(ReleaseSpace, re); #endif reqstatp = rep.srmReleaseSpaceResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testReleaseFiles.c0000644000175000017500000001033010542043011020702 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testReleaseFiles.c,v 1.1 2006/12/19 20:05:28 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmReleaseFilesResponse_ rep; struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__srmReleaseFilesRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; int keepFlag = 2; // Special Test static enum xsd__boolean trueoption = true_; static enum xsd__boolean falseoption = false_; if (argc < 3) { fprintf (stderr, "usage: %s endPoint reqid [SURLs]\n", argv[0]); exit (1); } nbfiles = argc - 3; #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #else srm_endpoint = argv[1]; #endif //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ( nbfiles ) { if (/* (req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL || */ (req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.arrayOfSURLs->__sizeurlArray = nbfiles; } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->surlArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.requestToken = argv[2]; switch (keepFlag) { case 0: break; case 1: req.doRemove = &falseoption; break; case 2: req.doRemove = &trueoption; break; default: break; } for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->surlArray[i]; //reqfilep->value = argv[i+2]; req.arrayOfSURLs->urlArray[i] = argv[i+3]; /* GG special tests */ /* if ( i == 0 ) //GOODreq.siteURLs->surlArray[i] = NULL; //CRASHreqfilep->value = NULL; */ } /* GG special tests */ //GOODreq.siteURLs = NULL; #if 0 if (soap_call_ns1__srmReleaseFiles (&soap, srm_endpoint, "ReleaseFiles", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(ReleaseFiles, re); #endif reqstatp = rep.srmReleaseFilesResponse->returnStatus; repfs = rep.srmReleaseFilesResponse->arrayOfFileStatuses; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) { printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } } if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("state[%d] = %d, %s, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->surl); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testPutDone.c0000644000175000017500000000743410647615600017747 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testPutDone.c,v 1.4 2007/07/19 08:06:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmPutDoneResponse_ rep; struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__srmPutDoneRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; // Special BestMan - LBL //1807flags |= CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ( /* (req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL || */ (req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->surlArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.requestToken = argv[1]; req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->surlArray[i]; //reqfilep->value = argv[i+2]; req.arrayOfSURLs->urlArray[i] = argv[i+2]; /* GG special tests */ /* if ( i == 0 ) //GOODreq.arrayOfSiteURLs->surlArray[i] = NULL; //CRASHreqfilep->value = NULL; */ } /* GG special tests */ //GOODreq.arrayOfSiteURLs = NULL; if (soap_call_ns1__srmPutDone (&soap, srm_endpoint, "PutDone", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmPutDoneResponse->returnStatus; repfs = rep.srmPutDoneResponse->arrayOfFileStatuses; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("state[%d] = %d, %s, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->surl); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testRmdir.c0000644000175000017500000000543510613621015017433 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testRmdir.c,v 1.2 2007/04/25 09:40:29 grodid Exp $ /* TODO: let the user choose if recursive flag should be set or not */ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; static enum xsd__boolean trueoption = true_; // JPB #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; int isurl = 1; // pointer to the 1st actual SURL in the arg list char *r_token; struct ns1__srmRmdirResponse_ rep; struct ns1__srmRmdirRequest req; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; int boolR = 0; if (argc < 2) { fprintf (stderr, "usage: %s [-R] SURL\n", argv[0]); exit (1); } if ( strchr(argv[1], '-' ) == argv[1] ) { isurl = 2; if ( strchr(argv[1], 'R' ) ) boolR = 1 ; } if (parsesurl (argv[isurl], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 0 if ((req.directoryPath = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL /* || //(req.directoryPath->SURLOrStFN = (req.directoryPath->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } #endif //req.directoryPath->SURLOrStFN->value = argv[1]; //OLD2req.directoryPath = argv[1]; req.SURL = argv[isurl]; //req.directoryPath->storageSystemInfo = NULL; req.storageSystemInfo = NULL; if ( boolR ) req.recursive = &trueoption; // GG new printf("Step 1: %s\n", req.SURL); #if 0 if (soap_call_ns1__srmRmdir (&soap, srm_endpoint, "Rmdir", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(Rmdir, re); #endif //printf("Step 2\n"); reqstatp = rep.srmRmdirResponse->returnStatus; //printf("Step 3\n"); printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testExtendFileLifeTime.c0000644000175000017500000001661510600015140022016 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testExtendFileLifeTime.c,v 1.3 2007/03/20 17:31:12 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmExtendFileLifeTimeResponse_ rep; //struct ns1__ArrayOfTSURLReturnStatus *repfs; struct ns1__ArrayOfTSURLLifetimeReturnStatus *repfs; struct ns1__srmExtendFileLifeTimeRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 5) { fprintf (stderr, "usage: %s [-|reqid] [-|pinlifetime|-1] [newlifetime|-|-1] SURLs\n", argv[0]); exit (1); } /* Case where [ r p n ] -> must be [ r p - ] */ if ( strncmp(argv[1], "-", 1) ) if ( strcmp(argv[2], "-") ) if ( strcmp(argv[3], "-") ) { fprintf (stderr, "usage: %s reqid pinlifetime - SURLs\n", argv[0]); exit (1); } /* Case where [ - - - ] -> must be [ - - n ] */ if ( ! strncmp(argv[1], "-", 1) ) if ( ! strcmp(argv[2], "-") ) if ( ! strcmp(argv[3], "-") && strncmp(argv[3], "-1", 2) ) { fprintf (stderr, "usage: %s - - newlifetime SURLs\n", argv[0]); exit (1); } /* Case where [ r - ? ] -> must be [ r p - ] */ if ( strncmp(argv[1], "-", 1) ) if ( ! strcmp(argv[2], "-") ) { fprintf (stderr, "usage: %s reqid pinlifetime - SURLs\n", argv[0]); exit (1); } /* Case where [ - p ? ] -> must be [ - - n ] */ if ( ! strncmp(argv[1], "-", 1) ) if ( strcmp(argv[2], "-") ) { fprintf (stderr, "usage: %s - - newlifetime SURLs\n", argv[0]); exit (1); } nbfiles = argc - 4; if (parsesurl (argv[4], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 0 if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.requestToken->value = argv[1]; if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* FIXME: it's now an array to fill in ! DONE */ req.arrayOfSURLs->value = argv[3]; #else if ( /* (req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL || */ (req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->surlArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ if ( strncmp(argv[1], "-", 1) ) { req.requestToken = argv[1]; //printf("Step 0\n"); } else req.requestToken = NULL; req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->urlArray[i]; //reqfilep->value = argv[i+4]; req.arrayOfSURLs->urlArray[i] = argv[i+4]; //NOreqfilep->storageSystemInfo = NULL; } #endif if ((req.newFileLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } if ( strcmp(argv[3], "-") || ! strncmp(argv[3], "-1", 2) ) { //req.newFileLifeTime = atoi(argv[2]); *(req.newFileLifeTime) = atoi(argv[3]); printf("Step 1\n"); } else req.newFileLifeTime = NULL; /* FIXME: add a new argument newPinLifeTime DONE */ if ((req.newPinLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //if ( strchr(argv[3], '-' ) == argv[3] ) if ( strcmp(argv[2], "-") || ! strncmp(argv[2], "-1", 2) ) { *(req.newPinLifeTime) = atoi(argv[2]); printf("Step 2\n"); } else req.newPinLifeTime = NULL; /* else req.newPinLifeTime = NULL; */ /* GG special tests */ //CRASHreq.requestToken->value = NULL; //GOODreq.requestToken = NULL; //CRASHreq.siteURL->value = NULL; //GOODreq.siteURL = NULL; //GOODreq.newLifeTime->value = 0; //GOODreq.newLifeTime = NULL; #if 0 if (soap_call_ns1__srmExtendFileLifeTime (&soap, srm_endpoint, "ExtendFileLifeTime", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(ExtendFileLifeTime, re); #endif reqstatp = rep.srmExtendFileLifeTimeResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } #if 0 //if (rep.srmExtendFileLifeTimeResponse->fileLifetime) if (rep->fileLifetime) printf("time extended to: %d\n", rep.srmExtendFileLifeTimeResponse->fileLifetime); /* FIXME: add a new print newPinLifeTime DONE */ if (rep.srmExtendFileLifeTimeResponse->pinLifetime) printf("pintime extended to: %d\n", rep.srmExtendFileLifeTimeResponse->pinLifetime); #endif /* FIXME: add a new print for filestatuses DONE */ repfs = rep.srmExtendFileLifeTimeResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, %s, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->status->explanation); else { #if 0 printf ("state[%d] = %d, %s, pinLifetime: %d, fileLifetime: %d, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), *(repfs->statusArray[i])->pinLifetime, *(repfs->statusArray[i])->fileLifetime, (repfs->statusArray[i])->surl ); #else printf ("state[%d] = %d, %s", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode)); if ( (repfs->statusArray[i])->pinLifetime ) /* FIXME */ //printf (", pinLifetime: %s", soap_dateTime2s (&soap, (time_t) *(repfs->statusArray[i])->pinLifetime)); printf (", pinLifetime: %d", *(repfs->statusArray[i])->pinLifetime); if ( (repfs->statusArray[i])->fileLifetime ) printf (", fileLifetime: %d", *(repfs->statusArray[i])->fileLifetime); printf (", SURL = %s\n", (repfs->statusArray[i])->surl); #endif } } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/parsesurl.ic0000644000175000017500000000200110553430076016676 0ustar ellertellert/* * Copyright (C) 2004-2005 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: parsesurl.ic,v 1.2 2007/01/17 14:18:38 grodid Exp $ parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[256]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; return (-1); } #ifdef GFAL_SECURE //strcpy (srm_ep, "https://"); strcpy (srm_ep, "httpg://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testSuspendRequest.c0000644000175000017500000000432510542043011021340 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testSuspendRequest.c,v 1.1 2006/12/19 20:05:29 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmSuspendRequestResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmSuspendRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.requestToken = argv[1]; if (soap_call_ns1__srmSuspendRequest (&soap, srm_endpoint, "SuspendRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmSuspendRequestResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testGetSpaceTokens.c0000644000175000017500000000503710542043011021226 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetSpaceTokens.c,v 1.1 2006/12/19 20:05:25 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmGetSpaceTokensResponse_ rep; struct ns1__srmGetSpaceTokensRequest req; struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfString *repfs; char *sfn; struct soap soap; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s endPoint [user_space_token_description|-]\n", argv[0]); exit (1); } #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ( strncmp(argv[2], "-", 1) ) req.userSpaceTokenDescription = argv[2]; else req.userSpaceTokenDescription = NULL; #if 0 if (soap_call_ns1__srmGetSpaceTokens (&soap, srm_endpoint, "GetSpaceTokens", #else if (soap_call_ns1__srmGetSpaceTokens (&soap, argv[1], "GetSpaceTokens", #endif &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmGetSpaceTokensResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } repfs = rep.srmGetSpaceTokensResponse->arrayOfSpaceTokens; if (! repfs) { printf ("arrayOfSpaceTokens is NULL\n"); soap_end (&soap); exit (0); } printf ("request tokenArray %d\n", repfs->__sizestringArray); printf("=== RETURNED SPACE TOKENS ===\n"); for (i = 0; i < repfs->__sizestringArray; i++) printf("s_token[%d]: %s\n", i, repfs->stringArray[i]); soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testGetRequestSummary.c0000644000175000017500000001474210542043011022020 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetRequestSummary.c,v 1.1 2006/12/19 20:05:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmGetRequestSummaryResponse_ rep; struct ns1__ArrayOfTRequestSummary *repfs; struct ns1__srmGetRequestSummaryRequest req; struct ns1__TRequestToken *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfPutRequestResponse_ srep; struct ns1__srmStatusOfPutRequestRequest sreq; char *srm_endpoint; char *rtype; int j, nbstat, numfiles; if (argc < 3) { fprintf (stderr, "usage: %s endPoint reqids\n", argv[0]); exit (1); } nbfiles = argc - 2; #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #else srm_endpoint = argv[1]; #endif //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfRequestTokens = soap_malloc (&soap, sizeof(struct ns1__ArrayOfString))) == NULL || (req.arrayOfRequestTokens->stringArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfRequestTokens->tokenArray[i] = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.arrayOfRequestTokens->__sizestringArray = nbfiles; for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfRequestTokens->tokenArray[i]; //reqfilep->value = argv[i+2]; req.arrayOfRequestTokens->stringArray[i] = argv[i+2]; /* GG special tests */ /* CRASH if ( i == 0 ) reqfilep->value = NULL; */ /* GOOD if ( i == 0 ) req.arrayOfRequestTokens->requestTokenArray[i] = NULL; */ } /* GG special tests */ //GOODreq.arrayOfRequestTokens = NULL; #if 0 #if 0 if (soap_call_ns1__srmGetRequestSummary (&soap, srm_endpoint, "GetRequestSummary", #else if (soap_call_ns1__srmGetRequestSummary (&soap, argv[1], "GetRequestSummary", #endif &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(GetRequestSummary, re); #endif reqstatp = rep.srmGetRequestSummaryResponse->returnStatus; repfs = rep.srmGetRequestSummaryResponse->arrayOfRequestSummaries; /* wait for file "ready" */ printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); /* Useless now printf ("request state %d %d\n", reqstatp->statusCode, repfs->__sizesummaryArray); // GG */ if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfRequestSummaries is NULL\n"); soap_end (&soap); exit (0); } printf ("request summaryArray %d\n", repfs->__sizesummaryArray); for (i = 0; i < repfs->__sizesummaryArray; i++) { printf("======= BEGIN SUMMARY ========\n"); //printf("Finished files: %d\n", repfs->summaryArray[i]->numOfFinishedRequests); //printf("Processing files: %d\n", repfs->summaryArray[i]->numOfProgressingRequests); //BADprintf("Number of files: %d\n", repfs->summaryArray[i]->totalNumFilesInRequest); //printf("Number of files: %d\n", (*repfs->summaryArray[i]->totalNumFilesInRequest)); /* if ((*repfs->summaryArray[i]->requestType) == PREPARE_USCORETO_USCOREGET) rtype = "PrepareToGet"; else if ((*repfs->summaryArray[i]->requestType) == PREPARE_USCORETO_USCOREPUT) rtype = "PrepareToPut"; else rtype = "Copy"; */ //printf("Type of req: %s\n", rtype); //printf("Type of req: %d\n", (*repfs->summaryArray[i]->requestType)); if ( repfs->summaryArray[i]->requestType ) printf("Type of req: %s\n", soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType))); printf("Request token: %s\n", repfs->summaryArray[i]->requestToken); /* printf ("request statArray %d\n", repfs->summaryArray[i]->arrayOfRequestStats->__sizestatArray); nbstat = repfs->summaryArray[i]->arrayOfRequestStats->__sizestatArray; for (j = 0; j < nbstat; j++) { numfiles = repfs->summaryArray[i]->arrayOfRequestStats->statArray[j]->numOfFiles; printf("Status[%s]: %d files\n", soap_ns1__TStatusCode2s (&soap, repfs->summaryArray[i]->arrayOfRequestStats->statArray[j]->statusCode), numfiles); }*/ /* FIXME: add all new fields to be printed DONE */ #if 0 printf ("Status[%s]: totalNumFilesInRequest: %d, numOfCompletedFiles: %d, numOfWaitingFiles: %d, numOfFailedFiles: %d\n", i, *(repfs->summaryArray[i]->totalNumFilesInRequest), *(repfs->summaryArray[i]->numOfCompletedFiles), *(repfs->summaryArray[i]->numOfWaitingFiles), *(repfs->summaryArray[i]->numOfFailedFiles) ); #else printf ("state[%d]: %d %s", i, repfs->summaryArray[i]->status->statusCode, soap_ns1__TStatusCode2s (&soap,repfs->summaryArray[i]->status->statusCode)); if ( (repfs->summaryArray[i]->totalNumFilesInRequest) ) printf (", totalNumFilesInRequest: %d", *(repfs->summaryArray[i]->totalNumFilesInRequest)); //printf ("Status[%i]: totalNumFilesInRequest: %d\n", i, *(repfs->summaryArray[i]->totalNumFilesInRequest)); if ( (repfs->summaryArray[i]->numOfCompletedFiles) ) printf (", numOfCompletedFiles: %d", *(repfs->summaryArray[i]->numOfCompletedFiles)); if ( (repfs->summaryArray[i]->numOfWaitingFiles) ) printf (", numOfWaitingFiles: %d", *(repfs->summaryArray[i]->numOfWaitingFiles)); if ( (repfs->summaryArray[i]->numOfFailedFiles) ) printf (", numOfFailedFiles: %d", *(repfs->summaryArray[i]->numOfFailedFiles)); printf("\n"); #endif } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testStatusOfLsRequest.c0000644000175000017500000000434710542043011021772 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testStatusOfLsRequest.c,v 1.1 2006/12/19 20:05:29 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmStatusOfLsRequestResponse_ rep; //struct ArrayOfTSURLReturnStatus *repfs; struct ns1__srmStatusOfLsRequestRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 3) { fprintf (stderr, "usage: %s reqid SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); /* if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.requestToken = argv[1]; if (soap_call_ns1__srmStatusOfLsRequest (&soap, srm_endpoint, "StatusOfLsRequest", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmStatusOfLsRequestResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testGetRequestStatus.c0000644000175000017500000005021310542456711021656 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetRequestStatus.c,v 1.2 2006/12/21 10:11:21 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" char pdate[21]; char *pdati = "INFINITE"; time_t current_time; main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; //Sint sbrk0; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmGetRequestSummaryResponse_ rep; struct ns1__ArrayOfTRequestSummary *repfs; struct ns1__srmGetRequestSummaryRequest req; struct ns1__TRequestToken *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; /* struct ns1__srmStatusOfPutRequestResponse_ srep; struct ns1__srmStatusOfPutRequestRequest sreq; */ char *srm_endpoint; char *rtype; int j, nbstat, numfiles; struct ns1__ArrayOfTRequestSummary *lrepfs; size_t srepfs, nzf; int nrs; (void) setbuf(stdout, NULL); (void) setbuf(stderr, NULL); if (argc < 3) { fprintf (stderr, "usage: %s endPoint reqids\n", argv[0]); exit (1); } nbfiles = argc - 2; #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #else srm_endpoint = argv[1]; #endif //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfRequestTokens = soap_malloc (&soap, sizeof(struct ns1__ArrayOfString))) == NULL || (req.arrayOfRequestTokens->stringArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.arrayOfRequestTokens->__sizestringArray = nbfiles; for (i = 0; i < nbfiles; i++) { req.arrayOfRequestTokens->stringArray[i] = argv[i+2]; } /* GG special tests */ //GOODreq.arrayOfRequestTokens = NULL; #if 0 #if 0 if (soap_call_ns1__srmGetRequestSummary (&soap, srm_endpoint, "GetRequestSummary", #else if (soap_call_ns1__srmGetRequestSummary (&soap, argv[1], "GetRequestSummary", #endif &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(GetRequestSummary, re); #endif reqstatp = rep.srmGetRequestSummaryResponse->returnStatus; repfs = rep.srmGetRequestSummaryResponse->arrayOfRequestSummaries; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfRequestSummaries is NULL\n"); soap_end (&soap); exit (0); } //Ssbrk0 = sbrk(0); printf ("request summaryArray %d\n", repfs->__sizesummaryArray); #if 0 nrs = repfs->__sizesummaryArray; lrepfs = malloc(sizeof(struct ns1__ArrayOfTRequestSummary)); lrepfs->__sizesummaryArray = nrs; lrepfs->summaryArray = calloc(nrs, sizeof(struct ns1__TRequestSummary *)); nzf = sizeof(struct ns1__TRequestSummary); srepfs = calloc(nrs, nzf); printf (" nrs nzf lrepfs srepfs: %d %d %d %d \n", nrs, nzf, lrepfs, srepfs); for (i = 0; i < repfs->__sizesummaryArray; i++) { memmove(srepfs+nzf*i, repfs->summaryArray[i], nzf); lrepfs->summaryArray[i] = srepfs+nzf*i; printf("Type of req: %s\n", soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType))); printf("Request token: %s\n", repfs->summaryArray[i]->requestToken); printf("Address token: %d\n", repfs->summaryArray[i]->requestToken); printf("Type of lreq: %s\n", soap_ns1__TRequestType2s (&soap, (*lrepfs->summaryArray[i]->requestType))); printf("Request ltoken: %s\n", lrepfs->summaryArray[i]->requestToken); printf("Address ltoken: %d\n", lrepfs->summaryArray[i]->requestToken); } #endif #if 1 for (i = 0; i < repfs->__sizesummaryArray; i++) { printf("======= Begin Request ========\n"); //printf("Finished files: %d\n", repfs->summaryArray[i]->numOfFinishedRequests); //printf("Processing files: %d\n", repfs->summaryArray[i]->numOfProgressingRequests); //BADprintf("Number of files: %d\n", repfs->summaryArray[i]->totalNumFilesInRequest); //printf("Number of files: %d\n", (*repfs->summaryArray[i]->totalNumFilesInRequest)); if ( repfs->summaryArray[i]->requestType ) printf("Type of req: %s\n", soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType))); printf("Request token: %s\n", repfs->summaryArray[i]->requestToken); printf ("state[%d]: %d %s", i, repfs->summaryArray[i]->status->statusCode, soap_ns1__TStatusCode2s (&soap,repfs->summaryArray[i]->status->statusCode)); if ( (repfs->summaryArray[i]->totalNumFilesInRequest) ) printf (", totalNumFilesInRequest: %d", *(repfs->summaryArray[i]->totalNumFilesInRequest)); if ( (repfs->summaryArray[i]->numOfCompletedFiles) ) printf (", numOfCompletedFiles: %d", *(repfs->summaryArray[i]->numOfCompletedFiles)); if ( (repfs->summaryArray[i]->numOfWaitingFiles) ) printf (", numOfWaitingFiles: %d", *(repfs->summaryArray[i]->numOfWaitingFiles)); if ( (repfs->summaryArray[i]->numOfFailedFiles) ) printf (", numOfFailedFiles: %d", *(repfs->summaryArray[i]->numOfFailedFiles)); printf("\n"); if ( repfs->summaryArray[i]->requestType ) { if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType)), "PREPARE_TO_PUT") ) { printPutRequest(&soap, srm_endpoint, repfs->summaryArray[i]->requestToken); } else if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType)), "PREPARE_TO_GET") ) { printGetRequest(&soap, srm_endpoint, repfs->summaryArray[i]->requestToken); } else if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType)), "BRING_ONLINE") ) { printBrgRequest(&soap, srm_endpoint, repfs->summaryArray[i]->requestToken); } else if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*repfs->summaryArray[i]->requestType)), "COPY") ) { printCpyRequest(&soap, srm_endpoint, repfs->summaryArray[i]->requestToken); } else { // Unknown or Unimplemented type ... } } //Sprintf("MemLeak: %d\n", sbrk(0)-sbrk0); } #else for (i = 0; i < lrepfs->__sizesummaryArray; i++) { printf("======= Begin Request ========\n"); //printf("Finished files: %d\n", repfs->summaryArray[i]->numOfFinishedRequests); //printf("Processing files: %d\n", repfs->summaryArray[i]->numOfProgressingRequests); //BADprintf("Number of files: %d\n", repfs->summaryArray[i]->totalNumFilesInRequest); //printf("Number of files: %d\n", (*repfs->summaryArray[i]->totalNumFilesInRequest)); if ( lrepfs->summaryArray[i]->requestType ) printf("Type of req: %s\n", soap_ns1__TRequestType2s (&soap, (*lrepfs->summaryArray[i]->requestType))); printf("Request token: %s\n", lrepfs->summaryArray[i]->requestToken); printf ("state[%d]: %d %s", i, lrepfs->summaryArray[i]->status->statusCode, soap_ns1__TStatusCode2s (&soap,lrepfs->summaryArray[i]->status->statusCode)); if ( (lrepfs->summaryArray[i]->totalNumFilesInRequest) ) printf (", totalNumFilesInRequest: %d", *(lrepfs->summaryArray[i]->totalNumFilesInRequest)); if ( (lrepfs->summaryArray[i]->numOfCompletedFiles) ) printf (", numOfCompletedFiles: %d", *(lrepfs->summaryArray[i]->numOfCompletedFiles)); if ( (lrepfs->summaryArray[i]->numOfWaitingFiles) ) printf (", numOfWaitingFiles: %d", *(lrepfs->summaryArray[i]->numOfWaitingFiles)); if ( (lrepfs->summaryArray[i]->numOfFailedFiles) ) printf (", numOfFailedFiles: %d", *(lrepfs->summaryArray[i]->numOfFailedFiles)); printf("\n"); if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*lrepfs->summaryArray[i]->requestType)), "PREPARE_TO_PUT") ) { printPutRequest(&soap, srm_endpoint, lrepfs->summaryArray[i]->requestToken); } else if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*lrepfs->summaryArray[i]->requestType)), "PREPARE_TO_GET") ) { printGetRequest(&soap, srm_endpoint, lrepfs->summaryArray[i]->requestToken); } else if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*lrepfs->summaryArray[i]->requestType)), "BRING_ONLINE") ) { printBrgRequest(&soap, srm_endpoint, lrepfs->summaryArray[i]->requestToken); } else if ( ! strcmp(soap_ns1__TRequestType2s (&soap, (*lrepfs->summaryArray[i]->requestType)), "COPY") ) { printCpyRequest(&soap, srm_endpoint, lrepfs->summaryArray[i]->requestToken); } else { // Unknown or Unimplemented type ... } printf("MemLeak: %d\n", sbrk(0)-sbrk0); } #endif //Pprintf("MemLeak: %d\n", sbrk(0)-sbrk0); soap_end (&soap); exit (0); } int printPutRequest (struct soap* soap, char* srm_endpoint, char* r_token) { struct ns1__srmStatusOfPutRequestResponse_ srep; struct ns1__srmStatusOfPutRequestRequest sreq; struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfTPutRequestFileStatus *repfs; int i; memset (&sreq, 0, sizeof(sreq)); sreq.requestToken = r_token; //Pprintf("Step 8 %s %s\n", r_token, srm_endpoint); if (soap_call_ns1__srmStatusOfPutRequest (soap, srm_endpoint, "StatusOfPutRequest", &sreq, &srep)) { soap_print_fault (soap, stderr); soap_end (soap); exit (1); } //(void) time (¤t_time); current_time = time (0); //Pprintf("Step 9 %s\n", r_token); reqstatp = srep.srmStatusOfPutRequestResponse->returnStatus; repfs = srep.srmStatusOfPutRequestResponse->arrayOfFileStatuses; printf ("request putstatus %s\n", soap_ns1__TStatusCode2s (soap, reqstatp->statusCode)); printf ("request putstate %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREREQUEST_USCOREINPROGRESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (soap); exit (1); */ //return; } repfs = srep.srmStatusOfPutRequestResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); /* soap_end (soap); exit (1); */ return; } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->transferURL) { strcpy(pdate, soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingPinLifetime))); if ( ! strcmp(pdate, "1969-12-31T23:59:59Z") ) strcpy(pdate, pdati); else strcpy(pdate, soap_dateTime2s (soap, current_time + (time_t) (*repfs->statusArray[i]->remainingPinLifetime))); printf ("PutR: state[%d] = %d, %s, SURL = %s, TURL = %s, fsz = %llu, pinDate = %s", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->SURL, (repfs->statusArray[i])->transferURL, (*repfs->statusArray[i]->fileSize), pdate //soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingPinLifetime)) ); if ( repfs->statusArray[i]->remainingFileLifetime ) { strcpy(pdate, soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingFileLifetime))); if ( ! strcmp(pdate, "1969-12-31T23:59:59Z") ) strcpy(pdate, pdati); else strcpy(pdate, soap_dateTime2s (soap, current_time + (time_t) (*repfs->statusArray[i]->remainingFileLifetime))); printf (" lifeDate = %s\n", pdate); } else printf ("\n"); } else if ((repfs->statusArray[i])->status->explanation) printf ("PutR: state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("PutR: state[%d] = %d, %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode)); } //BADsoap_dealloc(soap, NULL); //soap_free(soap); //??free (repfs); //??free (srep.srmStatusOfPutRequestResponse->arrayOfFileStatuses); return; } int printGetRequest (struct soap* soap, char* srm_endpoint, char* r_token) { struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfTGetRequestFileStatus *repfs; int i; memset (&sreq, 0, sizeof(sreq)); sreq.requestToken = r_token; //Pprintf("Step 8 %s %s\n", r_token, srm_endpoint); if (soap_call_ns1__srmStatusOfGetRequest (soap, srm_endpoint, "StatusOfGetRequest", &sreq, &srep)) { soap_print_fault (soap, stderr); soap_end (soap); exit (1); } //Pprintf("Step 9 %s\n", r_token); reqstatp = srep.srmStatusOfGetRequestResponse->returnStatus; //printf("request state 2 %d\n", reqstatp->statusCode); repfs = srep.srmStatusOfGetRequestResponse->arrayOfFileStatuses; printf ("request getstatus %s\n", soap_ns1__TStatusCode2s (soap, reqstatp->statusCode)); printf ("request getstate %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREREQUEST_USCOREINPROGRESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (soap); exit (1); */ //return; } repfs = srep.srmStatusOfGetRequestResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); /* soap_end (soap); exit (1); */ return; } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->transferURL) { strcpy(pdate, soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingPinTime))); if ( ! strcmp(pdate, "1969-12-31T23:59:59Z") ) strcpy(pdate, pdati); printf ("GetR: state[%d] = %d, %s, SURL = %s, TURL = %s, fsz = %llu, pinDate = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->sourceSURL, (repfs->statusArray[i])->transferURL, (*repfs->statusArray[i]->fileSize), pdate //soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingPinTime)) ); } else if ((repfs->statusArray[i])->status->explanation) printf ("GetR: state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("GetR: state[%d] = %d, %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode)); } //soap_free(soap); return; } int printBrgRequest (struct soap* soap, char* srm_endpoint, char* r_token) { struct ns1__srmStatusOfBringOnlineRequestResponse_ srep; struct ns1__srmStatusOfBringOnlineRequestRequest sreq; struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfTBringOnlineRequestFileStatus *repfs; int i; memset (&sreq, 0, sizeof(sreq)); sreq.requestToken = r_token; //Pprintf("Step 8 %s %s\n", r_token, srm_endpoint); if (soap_call_ns1__srmStatusOfBringOnlineRequest (soap, srm_endpoint, "StatusOfBringOnlineRequest", &sreq, &srep)) { soap_print_fault (soap, stderr); soap_end (soap); exit (1); } //Pprintf("Step 9 %s\n", r_token); reqstatp = srep.srmStatusOfBringOnlineRequestResponse->returnStatus; //printf("request state 2 %d\n", reqstatp->statusCode); repfs = srep.srmStatusOfBringOnlineRequestResponse->arrayOfFileStatuses; printf ("request brgstatus %s\n", soap_ns1__TStatusCode2s (soap, reqstatp->statusCode)); printf ("request brgstate %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREREQUEST_USCOREINPROGRESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (soap); exit (1); */ //return; } repfs = srep.srmStatusOfBringOnlineRequestResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); /* soap_end (soap); exit (1); */ return; } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->sourceSURL) { strcpy(pdate, soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingPinTime))); if ( ! strcmp(pdate, "1969-12-31T23:59:59Z") ) strcpy(pdate, pdati); printf ("BrgR: state[%d] = %d, %s, SURL = %s, fsz = %llu, pinDate = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->sourceSURL, //(repfs->statusArray[i])->transferURL, (*repfs->statusArray[i]->fileSize), pdate //soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingPinTime)) ); } else if ((repfs->statusArray[i])->status->explanation) printf ("BrgR: state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("BrgR: state[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); } //soap_free(soap); return; } int printCpyRequest (struct soap* soap, char* srm_endpoint, char* r_token) { struct ns1__srmStatusOfCopyRequestResponse_ srep; struct ns1__srmStatusOfCopyRequestRequest sreq; struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfTCopyRequestFileStatus *repfs; int i; memset (&sreq, 0, sizeof(sreq)); sreq.requestToken = r_token; //Pprintf("Step 8 %s %s\n", r_token, srm_endpoint); if (soap_call_ns1__srmStatusOfCopyRequest (soap, srm_endpoint, "StatusOfCopyRequest", &sreq, &srep)) { soap_print_fault (soap, stderr); soap_end (soap); exit (1); } //Pprintf("Step 9 %s\n", r_token); reqstatp = srep.srmStatusOfCopyRequestResponse->returnStatus; //printf("request state 2 %d\n", reqstatp->statusCode); repfs = srep.srmStatusOfCopyRequestResponse->arrayOfFileStatuses; printf ("request cpystatus %s\n", soap_ns1__TStatusCode2s (soap, reqstatp->statusCode)); printf ("request cpystate %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREREQUEST_USCOREINPROGRESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (soap); exit (1); */ //return; } repfs = srep.srmStatusOfCopyRequestResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); /* soap_end (soap); exit (1); */ return; } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->targetSURL) { strcpy(pdate, soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingFileLifetime))); if ( ! strcmp(pdate, "1969-12-31T23:59:59Z") ) strcpy(pdate, pdati); printf ("CpyR: state[%d] = %d, %s, sSURL = %s, tSURL = %s, fsz = %llu, pinDate = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->sourceSURL, (repfs->statusArray[i])->targetSURL, (*repfs->statusArray[i]->fileSize), pdate //soap_dateTime2s (soap, (time_t) (*repfs->statusArray[i]->remainingFileLifetime)) ); } else if ((repfs->statusArray[i])->status->explanation) printf ("CpyR: state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("CpyR: state[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); } //soap_free(soap); return; } lcgdm-1.8.7/test/srmv2.2/srm2_testGetPermission.c0000644000175000017500000002227310553430076021155 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetPermission.c,v 1.2 2007/01/17 14:18:38 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" struct soap soap; //static enum ns1__TPermissionMode permod[] = { NONE, X, W, WX, R, RX, RW, RWX, }; char* s_permod[] = { "NONE", "X", "W", "WX", "R", "RX", "RW", "RWX", }; main(argc, argv) int argc; char **argv; { int flags; int i, j; int isurl = 1; // pointer to the 1st actual SURL in the arg list int nbfiles; int nbproto = 0; static enum xsd__boolean trueoption = true_; // JPB static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; char *r_token; struct ns1__srmGetPermissionResponse_ rep; //////#define PRET 1 //////#ifdef PRET struct ns1__ArrayOfTPermissionReturn *repfs; //////#endif struct ns1__srmGetPermissionRequest req; //////#define INIT 1 //////#ifdef INIT //struct ns1__TSURLInfo;;;xsd__anyURI *reqfilep; struct ns1__TReturnStatus *reqstatp; //////#endif char *sfn; //struct soap soap; //struct ns1__srmStatusOfGetRequestResponse_ srep; //struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; int booll = 0; int boolR = 0; int nolv = 0; //static enum ns1__TPermissionMode permod[] = { NONE, X, W, WX, R, RX, RW, RWX, }; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } /* if ( strchr(argv[1], '-' ) == argv[1] ) { isurl = 2; if ( strchr(argv[1], 'l' ) ) booll = 1 ; if ( strchr(argv[1], 'R' ) ) boolR = 1 ; if ( strchr(argv[1], '2' ) ) nolv = 1 ; } */ nbfiles = argc - isurl; if (parsesurl (argv[isurl], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif //////#ifdef INIT memset (&req, 0, sizeof(req)); if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL ) { perror ("malloc"); soap_end (&soap); exit (1); } /* for (i = 0; i < nbfiles; i++) { if ((req.arrayOfSURLs->surlInfoArray[i] = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } */ req.arrayOfSURLs->__sizeurlArray = nbfiles; /* if ( booll ) req.fullDetailedList = &trueoption; // GG if ( boolR ) req.allLevelRecursive = &trueoption; // GG new req.numOfLevels = &nolv; */ for (i = 0; i < nbfiles; i++) { //reqfilep = req.arrayOfSURLs->surlInfoArray[i]; /* if ((req.arrayOfSURLs->surlInfoArray[i]->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.arrayOfSURLs->urlArray[i] = argv[i+isurl]; //req.arrayOfSURLs->surlInfoArray[i]->storageSystemInfo = NULL; } #if 0 if ((req.storageSystemInfo = soap_malloc (&soap, sizeof(struct ns1__TExtraInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.storageSystemInfo->value = argv[3]; /* req.storageSystemInfo->__sizeextraInfoArray = 1; req.storageSystemInfo->extraInfoArray[0]->key = "0"; req.storageSystemInfo->extraInfoArray[0]->value = argv[3]; */ req.storageSystemInfo->__sizeextraInfoArray = 0; req.storageSystemInfo->extraInfoArray = NULL; //printf("Step 1\n"); #else //req.storageSystemInfo = NULL; #endif //////#else /* soap_default_ns1__srmGetPermissionRequest (&soap, &req); req.storageSystemInfo = NULL; req.arrayOfSURLs->__sizesurlInfoArray = nbfiles; if ( booll ) req.fullDetailedList = &trueoption; // GG if ( boolR ) req.allLevelRecursive = &trueoption; // GG new req.numOfLevels = &nolv; */ //////#endif //printf("Step 8-0\n"); if (soap_call_ns1__srmGetPermission (&soap, srm_endpoint, "GetPermission", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } //////#ifdef PRET reqstatp = rep.srmGetPermissionResponse->returnStatus; /* if (rep.srmGetPermissionResponse->requestToken) { r_token = rep.srmGetPermissionResponse->requestToken; printf ("soap_call_ns1__srmGetPermission returned l_token %s\n", r_token); } */ repfs = rep.srmGetPermissionResponse->arrayOfPermissionReturns; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfPermissionReturns is NULL\n"); soap_end (&soap); exit (0); } printf ("request permissionArray %d\n", repfs->__sizepermissionArray); // GG for (i = 0; i < repfs->__sizepermissionArray; i++) { printABranch(repfs, i); } soap_end (&soap); exit (0); //////#endif } //////#if 0 printABranch (struct ns1__ArrayOfTPermissionReturn *repfs, int i) { //struct ns1__arrayOfPermissionReturns *repfsl; int j, il, nsub; printf("Stat: %d, %s\n", repfs->permissionArray[i]->status->statusCode, soap_ns1__TStatusCode2s (&soap, repfs->permissionArray[i]->status->statusCode) ); // GG /* if ( repfs->pathDetailArray[i]->arrayOfSubPaths ) printf("Path: %s Subpath: %d\n", repfs->pathDetailArray[i]->surl, repfs->pathDetailArray[i]->arrayOfSubPaths->__sizepathDetailArray); else */ printf("Path: %s\n", repfs->permissionArray[i]->surl); if ( repfs->permissionArray[i]->status->statusCode ) { printf("----=============\n"); return; // continue; } //4printf("Size: %d\n", repfs->permissionArray[i]->size); //4printf("Type: %d\n", (*repfs->permissionArray[i]->type)); //4if ( repfs->permissionArray[i]->fileStorageType ) //4 printf("FStT: %d\n", (*repfs->permissionArray[i]->fileStorageType)); if ( repfs->permissionArray[i]->owner ) printf("OwnR: %s\n", repfs->permissionArray[i]->owner); //4if ( repfs->permissionArray[i]->checkSumType ) //4 printf("ChST: %s\n", repfs->permissionArray[i]->checkSumType); //4if ( repfs->permissionArray[i]->createdAtTime ) //4 printf("Crea: %s\n", repfs->permissionArray[i]->createdAtTime); //printf("Crea: %s\n", soap_dateTime2s (&soap, (time_t) (repfs->pathDetailArray[i]->createdAtTime->value))); //4if ( repfs->permissionArray[i]->lastModificationTime ) //4 printf("Last: %s\n", repfs->permissionArray[i]->lastModificationTime); if ( repfs->permissionArray[i]->ownerPermission ) printf("OwnP: %s\n", s_permod[*(repfs->permissionArray[i]->ownerPermission)]); //4if ( repfs->permissionArray[i]->clientPermission ) //4 printf("CliP: %s\n", s_permod[*(repfs->permissionArray[i]->clientPermission)]); //printf("OwnP: %d\n", repfs->pathDetailArray[i]->ownerPermission->mode); if ( repfs->permissionArray[i]->otherPermission ) printf("OthP: %s\n", s_permod[*(repfs->permissionArray[i]->otherPermission)]); // Warning: there should be a loop here if __size>1 if ( repfs->permissionArray[i]->arrayOfUserPermissions ) { printf("UsrP: %d", repfs->permissionArray[i]->arrayOfUserPermissions->__sizeuserPermissionArray); for (j = 0; j < repfs->permissionArray[i]->arrayOfUserPermissions->__sizeuserPermissionArray; j++ ) { printf(" %s:%s", repfs->permissionArray[i]->arrayOfUserPermissions->userPermissionArray[j]->userID, s_permod[repfs->permissionArray[i]->arrayOfUserPermissions->userPermissionArray[j]->mode]); } printf("\n"); } if ( repfs->permissionArray[i]->arrayOfGroupPermissions ) { printf("GrpP: %d", repfs->permissionArray[i]->arrayOfGroupPermissions->__sizegroupPermissionArray); for (j = 0; j < repfs->permissionArray[i]->arrayOfGroupPermissions->__sizegroupPermissionArray; j++ ) { printf(" %s:%s", repfs->permissionArray[i]->arrayOfGroupPermissions->groupPermissionArray[j]->groupID, s_permod[repfs->permissionArray[i]->arrayOfGroupPermissions->groupPermissionArray[j]->mode]); } printf("\n"); } /* if ( repfs->permissionArray[i]->lifetimeAssigned ) printf("LifA: %d\n", repfs->permissionArray[i]->lifetimeAssigned); if ( repfs->permissionArray[i]->lifetimeLeft ) printf("LifL: %d\n", repfs->permissionArray[i]->lifetimeLeft); */ /* FIXME: check if there are new fileds to be printed with 2.2 */ printf("=================\n"); /* //Loop on subpaths ... if ( ! repfs->pathDetailArray[i]->arrayOfSubPaths ) return; repfsl = repfs->pathDetailArray[i]->arrayOfSubPaths; nsub = repfsl->__sizepathDetailArray; if ( ! nsub ) return; for (il = 0; il < nsub; il++) { printf("================= Branch: %d\n", il); printABranch(repfsl, il); } */ return; } //////#endif lcgdm-1.8.7/test/srmv2.2/typemap.dat0000644000175000017500000000004210542043011016500 0ustar ellertellertxsd__dateTime = | char * | char * lcgdm-1.8.7/test/srmv2.2/srm2_testMkdir.c0000644000175000017500000000465610647615600017442 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testMkdir.c,v 1.3 2007/07/19 08:06:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; char *r_token; struct ns1__srmMkdirResponse_ rep; struct ns1__srmMkdirRequest req; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; if (argc < 2) { fprintf (stderr, "usage: %s SURL\n", argv[0]); exit (1); } if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; // Special BestMan - LBL //1807flags |= CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 0 if ((req.directoryPath = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL /* || //(req.directoryPath->SURLOrStFN = (req.directoryPath->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } #endif //req.directoryPath->SURLOrStFN->value = argv[1]; //OLD2req.directoryPath = argv[1]; req.SURL = argv[1]; req.storageSystemInfo = NULL; //req.directoryPath = 0; // TEST30 CRASH //req.directoryPath->SURLOrStFN = 0; // TEST32 CRASH #if 0 if (soap_call_ns1__srmMkdir (&soap, srm_endpoint, "Mkdir", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(Mkdir, re); #endif reqstatp = rep.srmMkdirResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testCopy.c0000644000175000017500000001431610647615600017300 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testCopy.c,v 1.2 2007/07/19 08:06:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmCopyResponse_ rep; struct ns1__ArrayOfTCopyRequestFileStatus *repfs; struct ns1__srmCopyRequest req; struct ns1__TCopyFileRequest *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfCopyRequestResponse_ srep; struct ns1__srmStatusOfCopyRequestRequest sreq; char *srm_endpoint; //userRequestDescription //char *u_token; (void) setbuf(stdout, NULL); (void) setbuf(stderr, NULL); if (argc < 3) { fprintf (stderr, "usage: %s u_token string-of-fromSURLs string-of-toSURLs\n", argv[0]); exit (1); } nbfiles = (argc - 2)/2; if ( (nbfiles*2 + 2) < argc ) { fprintf (stderr, "usage: %s u_token string-of-fromSURLs string-of-toSURLs\n", argv[0]); exit (1); } if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; //1807flags |= CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); if ((req.arrayOfFileRequests = soap_malloc (&soap, sizeof(struct ns1__ArrayOfTCopyFileRequest))) == NULL || (req.arrayOfFileRequests->requestArray = soap_malloc (&soap, nbfiles * sizeof(struct ns1__TCopyFileRequest *))) == NULL /*|| (req.arrayOfTransferProtocols = soap_malloc (&soap, sizeof(struct ArrayOf_USCORExsd_USCOREstring))) == NULL*/) { perror ("malloc"); soap_end (&soap); exit (1); } for (i = 0; i < nbfiles; i++) { if ((req.arrayOfFileRequests->requestArray[i] = soap_malloc (&soap, sizeof(struct ns1__TCopyFileRequest))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } req.arrayOfFileRequests->__sizerequestArray = nbfiles; //req.arrayOfTransferProtocols->__ptr = protocols; //req.arrayOfTransferProtocols->__size = nbproto; if ( ! strcmp(argv[1], "-") ) req.userRequestDescription = argv[1]; for (i = 0; i < nbfiles; i++) { reqfilep = req.arrayOfFileRequests->requestArray[i]; /* good */ //memset (reqfilep, 0, sizeof(*reqfilep)); /* good as well */ memset (reqfilep, 0, sizeof(struct ns1__TCopyFileRequest)); if ((reqfilep->targetSURL = soap_malloc (&soap, sizeof(char *))) == NULL /* || (reqfilep->targetSURLInfo->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } if ((reqfilep->sourceSURL = soap_malloc (&soap, sizeof(char *))) == NULL /* || (reqfilep->sourceSURLInfo->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } reqfilep->sourceSURL = argv[i+2]; reqfilep->targetSURL = argv[i+2+nbfiles]; /* good reqfilep->lifetime = NULL; reqfilep->fileStorageType = NULL; reqfilep->spaceToken = NULL; reqfilep->overwriteMode = NULL; reqfilep->dirOption = NULL; */ } if (soap_call_ns1__srmCopy (&soap, srm_endpoint, "Copy", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmCopyResponse->returnStatus; //FSrepfs = rep.srmCopyResponse->arrayOfFileStatuses; if (rep.srmCopyResponse->requestToken) { r_token = rep.srmCopyResponse->requestToken; printf ("soap_call_ns1__srmCopy returned r_token %s\n", r_token); } memset (&sreq, 0, sizeof(sreq)); sreq.requestToken = rep.srmCopyResponse->requestToken; /* wait for file "ready" */ while (reqstatp->statusCode == SRM_USCOREREQUEST_USCOREQUEUED || reqstatp->statusCode == SRM_USCOREREQUEST_USCOREINPROGRESS || reqstatp->statusCode == SRM_USCOREREQUEST_USCORESUSPENDED) { printf ("request status0 %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf("request state0 %d\n", reqstatp->statusCode); sleep ((r++ == 0) ? 1 : DEFPOLLINT); if (soap_call_ns1__srmStatusOfCopyRequest (&soap, srm_endpoint, "StatusOfCopyRequest", &sreq, &srep)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = srep.srmStatusOfCopyRequestResponse->returnStatus; //FSrepfs = srep.srmStatusOfCopyRequestResponse->arrayOfFileStatuses; /* TEMPORARY, because not fully implemented ... */ if ( r>3 ) { printf ("request state 00\n"); soap_end (&soap); exit (1); } } printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) { printf ("explanation: %s\n", reqstatp->explanation); } if ( ! r ) { soap_end (&soap); exit (1); } } #define FS 1 #ifdef FS if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->targetSURL) printf ("state[%d] = %d, %s, target SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->targetSURL); else if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else printf ("state[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); } #endif soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testMv.c0000644000175000017500000000657210647615600016755 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testMv.c,v 1.4 2007/07/19 08:06:24 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; char *r_token; struct ns1__srmMvResponse_ rep; //struct ArrayOfTGetRequestFileStatus *repfs; struct ns1__srmMvRequest req; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; if (argc != 3) { fprintf (stderr, "usage: %s src_FILE_SURL [dst_FILE_SURL|dst_DIR_SURL]\n", argv[0]); exit (1); } if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; // Special BestMan - LBL //1807flags |= CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 0 if ((req.fromSURL = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL /* || (req.fromSURL->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL || (req.toPath = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL || (req.toPath->SURLOrStFN = soap_malloc (&soap, sizeof(struct ns1__TSURL)))*/) { perror ("malloc1"); soap_end (&soap); exit (1); } if (/*(req.fromPath = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL || (req.fromPath->SURLOrStFN = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL ||*/ (req.toSURL = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL /*|| (req.toPath->SURLOrStFN = soap_malloc (&soap, sizeof(struct ns1__TSURL)))*/) { perror ("malloc2"); soap_end (&soap); exit (1); } #endif //printf("Step 1\n"); #if 0 if (/*(req.fromPath = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL || (req.fromPath->SURLOrStFN = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL || (req.toPath = soap_malloc (&soap, sizeof(struct ns1__TSURLInfo))) == NULL ||*/ (req.toSURL->SURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc3"); soap_end (&soap); exit (1); } #endif //printf("Step 2\n"); /* soap_end (&soap); exit(0); */ req.fromSURL = argv[1]; //req.fromSURL->storageSystemInfo = NULL; req.toSURL = argv[2]; req.storageSystemInfo = NULL; //printf("Step 3\n"); if (soap_call_ns1__srmMv (&soap, srm_endpoint, "Mv", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmMvResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testPut.c0000644000175000017500000004744110647615600017143 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testPut.c,v 1.4 2007/07/19 08:06:24 grodid Exp $ // Last mod by GG (16/11/2006) //Humm...#include "u64subr.h" #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; static char *protocols[] = { "gsiftp", "rfio", #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; //OLD enum ns1__TRequestType f_type; // = 0; enum ns1__TStorageType {Volatile=0, Durable=1, Permanent=2}; static enum ns1__TStorageType ftypes[] = {Volatile, Durable, Permanent}; enum ns1__TRetentionPolicy {Replica = 0, Output = 1, Custodial = 2}; enum ns1__TAccessLatency {Online = 0, Nearline = 1}; static enum ns1__TRetentionPolicy rtypes[] = {Replica, Output, Custodial}; static enum ns1__TAccessLatency atypes[] = {Online, Nearline}; //struct ns1__TSizeInBytes f_size; //struct ns1__TLifeTimeInSeconds f_lifet; char *r_token; struct ns1__srmPrepareToPutResponse_ rep; struct ns1__ArrayOfTPutRequestFileStatus *repfs; struct ns1__srmPrepareToPutRequest req; struct ns1__TPutFileRequest *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfPutRequestResponse_ srep; struct ns1__srmStatusOfPutRequestRequest sreq; char *srm_endpoint; //struct ns1__TSURL *sreqfilep; ////char *sreqfilep; char *special_token = "049672c4-0f64-471b-a393-c8fbeac9101c"; //userRequestDescription //char *u_token; enum ns1__TOverwriteMode iovw = 2; char *ct; // Below, overW is overWrite flag (-|0|1|2) for (Never|Always|WhenFilesAreDifferent) (defaults to 2 when '-') // protocol can be either '-' or 'rfio' (defaults to gsiftp when '-') // storType is storageType flag (-|0|1|2) for (Volatile|Durable|Permanent) (defaults to 0 when '-') // retPol is retentionPolicy flag (-|0|1|2) for (Replica|Output|Custodial) (defaults to 0 when '-') // acLat is accessLatency flag (-|0|1) for (Online|Nearline) (defaults to 0 when '-') //(void) fflush(NULL); (void) setbuf(stdout, NULL); (void) setbuf(stderr, NULL); if (argc < 13) { fprintf (stderr, "usage: %s [-|u_token] nbSURLs [-|overW] [-|pinTime] [-|lifeTime] [-|protocol] [-|spaceToken] [-|storType] [-|retPol] [-|acLat] SURL1 size1 [[SURL2 size2] [ ... ]]\n", argv[0]); exit (1); } //nbfiles = argc - 3; nbfiles = atoi(argv[2]); if (argc < (11+nbfiles*2)) { //fprintf (stderr, "usage: %s u_token nbSURLs overW SURL1 pintime1 type1 size1 [SURL2 pintime2 type2 size2] [ ... ] [protocol] [spaceToken]\n", argv[0]); fprintf (stderr, "usage: %s [-|u_token] nbSURLs [-|overW] [-|pinTime] [-|lifeTime] [-|protocol] [-|spaceToken] [-|storType] [-|retPol] [-|acLat] SURL1 size1 [[SURL2 size2] [ ... ]]\n", argv[0]); exit (1); } if (parsesurl (argv[11], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK ; //printf ( " CGSI_TEST value: %d \n", flags); // Special BestMan - LBL ////flags |= CGSI_OPT_DELEG_FLAG; //1807flags |= CGSI_OPT_DELEG_FLAG; //printf ( " CGSI_TEST value: %d \n", flags); soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif if ( (ct = getenv ("CRASH_TEST")) ) //ct = getenv ("CRASH_TEST"); printf ( " CRASH_TEST value: %s \n", ct); else { ct = NULL; printf ( " srm_endpoint value: %s \n", srm_endpoint); } //ct = strdup(" "); memset (&req, 0, sizeof(req)); if ((req.arrayOfFileRequests = soap_malloc (&soap, sizeof(struct ns1__ArrayOfTPutFileRequest))) == NULL || (req.arrayOfFileRequests->requestArray = soap_malloc (&soap, nbfiles * sizeof(struct ns1__TPutFileRequest *))) == NULL /* || (req.arrayOfTransferProtocols = soap_malloc (&soap, sizeof(struct ns1__ArrayOf_USCORExsd_USCOREstring))) == NULL */ ) { perror ("malloc"); soap_end (&soap); exit (1); } req.authorizationID = NULL; for (i = 0; i < nbfiles; i++) { if ((req.arrayOfFileRequests->requestArray[i] = soap_malloc (&soap, sizeof(struct ns1__TPutFileRequest))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } } req.arrayOfFileRequests->__sizerequestArray = nbfiles; /* req.arrayOfTransferProtocols->stringArray = protocols; req.arrayOfTransferProtocols->__sizestringArray = nbproto; */ if ( strcmp(argv[1], "-") ) req.userRequestDescription = argv[1]; if ( strcmp(argv[3], "-") ) iovw = (enum ns1__TOverwriteMode) atoi(argv[3]); req.overwriteOption = &iovw; for (i = 0; i < nbfiles; i++) { reqfilep = req.arrayOfFileRequests->requestArray[i]; memset (reqfilep, 0, sizeof(*reqfilep)); /* if ((reqfilep->targetSURL = soap_malloc (&soap, sizeof(struct ns1__TSURL))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } reqfilep->targetSURL->value = argv[i*4+4]; */ reqfilep->targetSURL = argv[i*2+11]; /* FIXME: replaced by something else ? */ //reqfilep->targetSURL->storageSystemInfo = NULL; #if 0 // FIXME to move outside of the nbfiles loop if ((reqfilep->desiredFileLifeTime = soap_malloc (&soap, sizeof(struct ns1__TLifeTimeInSeconds))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //f_lifet = (ns1__TLifeTimeInSeconds) atoi(argv[i*4+4]); //f_lifet = atoul(argv[i*4+4]); /* FIXME: to be added in the input parameters */ //reqfilep->desiredFileLifeTime->value = atol(argv[i*4+5]); reqfilep->desiredPinLifeTime->value = atol(argv[i*4+5]); /* OLD f_type = (enum ns1__TRequestType) atoi(argv[i*4+5]); reqfilep->fileStorageType = &f_type; */ reqfilep->fileStorageType = &ftypes[atoi(argv[i*4+6])]; if ((reqfilep->knownSizeOfThisFile = soap_malloc (&soap, sizeof(struct ns1__TSizeInBytes))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //f_size = (ns1__TSizeInBytes) atoul(argv[i*4+6]); //2Gb reqfilep->knownSizeOfThisFile->value = atol(argv[i*4+7]); //Humm... reqfilep->knownSizeOfThisFile->value = strtou64(argv[i*4+7]); reqfilep->knownSizeOfThisFile->value = atoll(argv[i*4+7]); #endif if ((reqfilep->expectedFileSize = soap_malloc (&soap, sizeof(ULONG64))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } *reqfilep->expectedFileSize = atoll(argv[i*2+12]); } //--------------------------- End of loop // reqfilep->fileStorageType = &ftypes[atoi(argv[8])]; if ((req.desiredPinLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* FIXME: to be added in the input parameters */ if ( strcmp(argv[4], "-") ) *(req.desiredPinLifeTime) = atol(argv[4]); if ((req.desiredFileLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } /* FIXME: to be added in the input parameters */ if ( strcmp(argv[5], "-") ) *(req.desiredFileLifeTime) = atol(argv[5]); if ((req.transferParameters = soap_malloc (&soap, sizeof(struct ns1__TTransferParameters))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.transferParametersHint->__sizesizeArray = 0; //req.transferParametersHint->sizeArray = NULL; req.transferParameters->accessPattern = NULL; req.transferParameters->connectionType = NULL; req.transferParameters->arrayOfClientNetworks = NULL; req.transferParameters->arrayOfTransferProtocols = NULL; //printf("Step 8-0\n"); if ((req.transferParameters->arrayOfTransferProtocols = soap_malloc (&soap, nbproto*sizeof(struct ns1__ArrayOfString))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //printf("Step 8-1 nbproto: %d\n", nbproto); // In any case, only one protocol is specified ... req.transferParameters->arrayOfTransferProtocols->__sizestringArray = 1; //printf("Step 8-2\n"); //strcpy(req.transferParametersHint->arrayOfTransferProtocols->stringArray[0], protocols[0]); //req.transferParametersHint->arrayOfTransferProtocols->stringArray[0] = strdup(protocols[0]); //req.transferParametersHint->arrayOfTransferProtocols->stringArray[0] = protocols[0]; //req.transferParametersHint->arrayOfTransferProtocols->stringArray[0] = soap_strdup(&soap, protocols[0]); // Default case is to use "gsiftp" req.transferParameters->arrayOfTransferProtocols->stringArray = protocols; // Unless "rfio" is specified as the 'protocol' option //if ( argc > nbfiles*4+4 && argv[nbfiles*4+4] && ! strcmp(argv[nbfiles*4+4], "rfio") ) if ( ! strcmp(argv[6], "rfio") ) req.transferParameters->arrayOfTransferProtocols->stringArray = &protocols[1]; //printf("Step 8\n"); /* Deprecated ... if ( argc > nbfiles*4+4 && argv[nbfiles*4+4] ) printf (" Protocol arg found: %s %d \n", argv[nbfiles*4+4], argc); if ( argc > nbfiles*4+5 && argv[nbfiles*4+5] ) printf (" spaceTok arg found: %s %d \n", argv[nbfiles*4+5], argc); */ /* Space Token if provided */ //if ( strcmp(argv[7], "--") ) if ( strncmp(argv[7], "-", 1) ) req.targetSpaceToken = argv[7]; /* Storage Type if provided */ if ( strcmp(argv[8], "-") ) req.desiredFileStorageType = &ftypes[atoi(argv[8])]; else req.desiredFileStorageType = &ftypes[0]; #if 1 if ((req.targetFileRetentionPolicyInfo = soap_malloc (&soap, sizeof(struct ns1__TRetentionPolicyInfo))) == NULL) { perror ("mallocR"); soap_end (&soap); exit (1); } //req.retentionPolicyInfo->retentionPolicy = atoi(argv[7]); /* Retention Policy when provided */ if ( strcmp(argv[9], "-") ) req.targetFileRetentionPolicyInfo->retentionPolicy = atoi(argv[9]); else req.targetFileRetentionPolicyInfo->retentionPolicy = 0; /* Access Latency when provided */ if ( strcmp(argv[10], "-") ) req.targetFileRetentionPolicyInfo->accessLatency = &atypes[atoi(argv[10])]; else req.targetFileRetentionPolicyInfo->accessLatency = &atypes[0]; //*req.targetFileRetentionPolicyInfo->accessLatency = 0; #else // Test 29/12/06 req.targetFileRetentionPolicyInfo = NULL; #endif // Special for tests ... ////memset (&req, 0, sizeof(req)); // CRASHes as well // Special for tests ... //req.arrayOfFileRequests->requestArray = 0; // Diag: Too many errors, NO CRASH0 //req.arrayOfFileRequests->requestArray[0] = 0; // CRASH1 //req.arrayOfFileRequests = 0; // CRASH2 //req.arrayOfTransferProtocols->stringArray = 0; // CRASH3 //req.arrayOfTransferProtocols->stringArray[0] = 0; // CRASH4 // If '&req' replaced with 0 below ==> CRASH5 //req.arrayOfTransferProtocols = 0; // CRASH6 if ( ct ) { switch (ct[0]) { case 'a': printf (" Case a \n"); req.arrayOfFileRequests->requestArray[0] = NULL; //req.arrayOfFileRequests->requestArray = NULL; break; case 'b': printf (" Case b \n"); req.arrayOfFileRequests = NULL; break; /* case 'c': printf (" Case c \n"); req.arrayOfTransferProtocols->stringArray = NULL; break; case 'd': printf (" Case d \n"); req.arrayOfTransferProtocols->stringArray[0] = NULL; break; case 'f': printf (" Case f \n"); req.arrayOfTransferProtocols = NULL; break; */ case 'g': /* Weird, this one does not crash ... */ printf (" Case g \n"); memset (&req, 0, sizeof(req)); break; default: printf (" NO Action1 Case >%c< \n", ct[0]); break; } } #if 0 //if ( ct[0] == 'e' ) if ( ct && ! strncmp(ct, "e", 1) ) { printf (" Case e \n"); /* normal test */ if (soap_call_ns1__srmPrepareToPut (&soap, srm_endpoint, "PrepareToPut", 0, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } /* special JPB value */ /* if (soap_call_ns1__srmPrepareToPut (&soap, srm_endpoint, "PrepareToPut", &req, 0)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } */ } else if (soap_call_ns1__srmPrepareToPut (&soap, srm_endpoint, "PrepareToPut", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(PrepareToPut, re); #endif /* FIXME: arrayOfFileStatuses when wsdl agreed */ reqstatp = rep.srmPrepareToPutResponse->returnStatus; repfs = rep.srmPrepareToPutResponse->arrayOfFileStatuses; if (rep.srmPrepareToPutResponse->requestToken) { r_token = rep.srmPrepareToPutResponse->requestToken; printf ("soap_call_ns1__srmPrepareToPut returned r_token %s\n", r_token); //printf("request state 00 %d\n", reqstatp->statusCode); } // New if (! repfs) printf ("PTP: arrayOfFileStatuses is NULL\n"); printFileStatus(&soap, repfs); memset (&sreq, 0, sizeof(sreq)); if ((sreq.arrayOfTargetSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (sreq.arrayOfTargetSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } sreq.arrayOfTargetSURLs->__sizeurlArray = nbfiles; #if 1 for (i = 0; i < nbfiles; i++) { ////sreqfilep = sreq.arrayOfTargetSURLs->urlArray[i]; reqfilep = req.arrayOfFileRequests->requestArray[i]; ////sreqfilep = reqfilep->targetSURL; sreq.arrayOfTargetSURLs->urlArray[i] = reqfilep->targetSURL; /* GG special tests */ /* if ( i == 0 ) //GOODsreq.arrayOfTargetSURLs = NULL; //GOODsreq.arrayOfTargetSURLs->surlArray[i] = NULL; //CRASHsreqfilep->value = NULL; */ } #else sreq.arrayOfTargetSURLs->urlArray = req.arrayOfFileRequests->requestArray; #endif sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; #if 0 if (ct) { switch (ct[0]) { case 'h': printf (" Case h \n"); sreq.requestToken = NULL; break; case 'i': printf (" Case i \n"); strcat(rep.srmPrepareToPutResponse->requestToken, "uu"); sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; break; case 'j': printf (" Case j \n"); rep.srmPrepareToPutResponse->requestToken = NULL; sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; break; case 'k': printf (" Case k \n"); /* in fact the standard case ... for double-checking ... */ strcpy(rep.srmPrepareToPutResponse->requestToken, r_token); sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; break; case 'l': printf (" Case l \n"); strcpy(rep.srmPrepareToPutResponse->requestToken, strfry(r_token)); sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; break; default: printf (" NO Action2 Case >%c< \n", ct[0]); sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; break; } } else sreq.requestToken = rep.srmPrepareToPutResponse->requestToken; #endif /* wait for file "ready" */ while (reqstatp->statusCode == SRM_USCOREREQUEST_USCOREQUEUED || reqstatp->statusCode == SRM_USCOREREQUEST_USCOREINPROGRESS || reqstatp->statusCode == SRM_USCOREREQUEST_USCORESUSPENDED) { printf ("request status0 %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf("request state0 %d\n", reqstatp->statusCode); if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); sleep ((r++ == 0) ? 1 : DEFPOLLINT); #if 0 if (soap_call_ns1__srmStatusOfPutRequest (&soap, srm_endpoint, "StatusOfPutRequest", &sreq, &srep)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(StatusOfPutRequest, sre); #endif reqstatp = srep.srmStatusOfPutRequestResponse->returnStatus; //printf("request state 2 %d\n", reqstatp->statusCode); //FSrepfs = srep.srmStatusOfPutRequestResponse->arrayOfFileStatuses; } //printf ( " After the srmStatusOfPutRequest Call ... \n"); printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREPARTIAL_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) { printf ("explanation: %s\n", reqstatp->explanation); // if ( ! r ) { // soap_end (&soap); // exit (1); // } } if ( ! r ) { soap_end (&soap); exit (1); } /* soap_end (&soap); exit (1); */ } //(void) fflush(NULL); #define FS 1 #ifdef FS repfs = srep.srmStatusOfPutRequestResponse->arrayOfFileStatuses; if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->transferURL) #if 0 printf ("state[%d] = %d, %s, TURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->transferURL); #else if ( (repfs->statusArray[i])->remainingPinLifetime && (repfs->statusArray[i])->remainingFileLifetime ) printf ("state[%d] = %d, %s, TURL = %s pinT = %d, lifeT = %d\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->transferURL, *(repfs->statusArray[i])->remainingPinLifetime, *(repfs->statusArray[i])->remainingFileLifetime); else printf ("state[%d] = %d, %s, TURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->transferURL); /* soap_dateTime2s (&soap, (time_t) ((repfs->statusArray[i])->remainingPinLifetime)), soap_dateTime2s (&soap, (time_t) ((repfs->statusArray[i])->remainingFileLifetime))); */ #endif else if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else #if 0 printf ("state[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); #else printf ("state[%d] = %d, %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode)); #endif } #endif soap_end (&soap); exit (0); } int printFileStatus (struct soap* soap, struct ns1__ArrayOfTPutRequestFileStatus *repfs) { int i; if (! repfs) { printf ("SUB: arrayOfFileStatuses is NULL\n"); /* soap_end (soap); exit (0); */ return; } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if (repfs->statusArray[i]->transferURL) printf ("pstate[%d] = %d, %s, TURL = %s pinT = %d, lifeT = %d\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->transferURL, *(repfs->statusArray[i])->remainingPinLifetime, *(repfs->statusArray[i])->remainingFileLifetime); /* soap_dateTime2s (&soap, (time_t) ((repfs->statusArray[i])->remainingPinLifetime)), soap_dateTime2s (&soap, (time_t) ((repfs->statusArray[i])->remainingFileLifetime))); */ else if ((repfs->statusArray[i])->status->explanation) printf ("pstate[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else #if 0 printf ("pstate[%d] = %d\n", i, (repfs->statusArray[i])->status->statusCode); #else printf ("pstate[%d] = %d, %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (soap, (repfs->statusArray[i])->status->statusCode)); #endif } return; } lcgdm-1.8.7/test/srmv2.2/srm2_testExtendFileLifeTimeInSpace.c0000644000175000017500000001065610565000203023264 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testExtendFileLifeTimeInSpace.c,v 1.3 2007/02/15 06:41:07 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmExtendFileLifeTimeInSpaceResponse_ rep; struct ns1__ArrayOfTSURLLifetimeReturnStatus *repfs; struct ns1__srmExtendFileLifeTimeInSpaceRequest req; struct ns1__TSURL *reqfilep; struct ns1__TReturnStatus *reqstatp; char *sfn; struct soap soap; struct ns1__srmStatusOfGetRequestResponse_ srep; struct ns1__srmStatusOfGetRequestRequest sreq; char *srm_endpoint; if (argc < 4) { fprintf (stderr, "usage: %s spaceToken [newLifetime|-] SURLs\n", argv[0]); exit (1); } nbfiles = argc - 3; if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } //while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 0 if ((req.requestToken = soap_malloc (&soap, sizeof(struct ns1__TRequestToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } req.requestToken->value = argv[1]; #else if ((req.arrayOfSURLs = soap_malloc (&soap, sizeof(struct ns1__ArrayOfAnyURI))) == NULL || (req.arrayOfSURLs->urlArray = soap_malloc (&soap, nbfiles * sizeof(char *))) == NULL) { perror ("mallocA"); soap_end (&soap); exit (1); } #if 1 if ( strncmp(argv[1], "-", 1) ) { req.spaceToken = argv[1]; //printf("Step 0\n"); } else req.spaceToken = NULL; if ((req.newLifeTime = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("mallocL"); soap_end (&soap); exit (1); } if ( strcmp(argv[2], "-") ) { *(req.newLifeTime) = atoi(argv[2]); //printf("Step 1 %d\n", nbfiles); } else req.newLifeTime = NULL; #endif #endif req.arrayOfSURLs->__sizeurlArray = nbfiles; for (i = 0; i < nbfiles; i++) req.arrayOfSURLs->urlArray[i] = argv[i+3]; if (soap_call_ns1__srmExtendFileLifeTimeInSpace (&soap, srm_endpoint, "ExtendFileLifeTimeInSpace", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = rep.srmExtendFileLifeTimeInSpaceResponse->returnStatus; repfs = rep.srmExtendFileLifeTimeInSpaceResponse->arrayOfFileStatuses; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); /* soap_end (&soap); exit (1); */ } if (! repfs) { printf ("arrayOfFileStatuses is NULL\n"); soap_end (&soap); exit (0); } printf ("request statusArray %d\n", repfs->__sizestatusArray); for (i = 0; i < repfs->__sizestatusArray; i++) { if ((repfs->statusArray[i])->status->explanation) printf ("state[%d] = %d, explanation = %s\n", i, (repfs->statusArray[i])->status->statusCode, (repfs->statusArray[i])->status->explanation); else { #if 0 printf ("state[%d] = %d, %s, SURL = %s\n", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode), (repfs->statusArray[i])->surl); #else printf ("state[%d] = %d, %s", i, (repfs->statusArray[i])->status->statusCode, soap_ns1__TStatusCode2s (&soap, (repfs->statusArray[i])->status->statusCode)); if ( (repfs->statusArray[i])->pinLifetime ) /* FIXME */ //printf (", pinLifetime: %s", soap_dateTime2s (&soap, (time_t) *(repfs->statusArray[i])->pinLifetime)); printf (", pinLifetime: %d", *(repfs->statusArray[i])->pinLifetime); if ( (repfs->statusArray[i])->fileLifetime ) printf (", fileLifetime: %d", *(repfs->statusArray[i])->fileLifetime); printf (" SURL = %s\n", (repfs->statusArray[i])->surl); #endif } } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srm2_testGetTransferProtocols.c0000644000175000017500000000657410542043011022507 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testGetTransferProtocols.c,v 1.1 2006/12/19 20:05:25 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmGetTransferProtocolsResponse_ rep; struct ns1__srmGetTransferProtocolsRequest req; #define SUP1 1 #ifdef SUP1 struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfTSupportedTransferProtocol *repfs; #endif char *sfn; struct soap soap; char *srm_endpoint; int j; int nbprots; if (argc < 2) { fprintf (stderr, "usage: %s endPoint\n", argv[0]); exit (1); } #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); //req.userTransferProtocolsDescription = argv[2]; #if 0 if (soap_call_ns1__srmGetTransferProtocols (&soap, srm_endpoint, "GetTransferProtocols", #else if (soap_call_ns1__srmGetTransferProtocols (&soap, argv[1], "GetTransferProtocols", #endif &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #ifdef SUP1 reqstatp = rep.srmGetTransferProtocolsResponse->returnStatus; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } repfs = rep.srmGetTransferProtocolsResponse->protocolInfo; if (! repfs) { printf ("protocolInfo is NULL\n"); soap_end (&soap); exit (1); } nbprots = repfs->__sizeprotocolArray; printf ("request protocols %d\n", nbprots); for (i = 0; i < repfs->__sizeprotocolArray; i++) { printf ("protocol[%d]: ExtraInfo: %s\n", i, repfs->protocolArray[i]->transferProtocol); //printf ("protocol[%s]: ExtraInfo: %d\n", repfs->protocolArray[i]->transferProtocol, i); //repfs->protocolArray[i]->attributes->__sizeextraInfoArray); /* if ( repfs->protocolArray[i]->attributes->__sizeextraInfoArray ) { for (j = 0; j < repfs->protocolArray[i]->attributes->__sizeextraInfoArray; j++) { printf (" Extra Info[%s]= %s\n", repfs->protocolArray[i]->attributes->extraInfoArray[j]->key, repfs->protocolArray[i]->attributes->extraInfoArray[j]->value); } } */ } #if 0 printf("=== RETURNED SPACE TOKENS ===\n"); for (i = 0; i < repfs->__sizetokenArray; i++) printf("s_token[%d]: %s\n", i, repfs->tokenArray[i]->value); #endif #endif #define SUP2 1 #ifdef SUP2 soap_end (&soap); exit (0); #endif } lcgdm-1.8.7/test/srmv2.2/srm2_testReserveSpace.c0000644000175000017500000001601610542043011020735 0ustar ellertellert/* * Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testReserveSpace.c,v 1.1 2006/12/19 20:05:28 grodid Exp $ /* #include "u64subr.h" */ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 1 int nbproto = 0; static char *protocols[] = { "gsiftp", #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; static enum ns1__TRetentionPolicy retpol[] = { REPLICA, OUTPUT, CUSTODIAL, }; char* s_retpol[] = { "REPLICA", "OUTPUT", "CUSTODIAL", }; char *s_token; struct ns1__srmReserveSpaceResponse_ rep; //struct ArrayOfTSURLPermissionReturn *repfs; struct ns1__srmReserveSpaceRequest req; //struct ns1__TSURLInfo *reqfilep; struct ns1__TReturnStatus *reqstatp; struct ns1__srmReserveSpaceResponse *repp; char *sfn; struct soap soap; char *srm_endpoint; char tmpbut[25]; char tmpbug[25]; if (argc < 8) { fprintf (stderr, "usage: %s endPoint user_space_token_description storage_system_info sizeOfTotalSpaceDesired sizeOfGuaranteedSpaceDesired lifetimeOfSpaceToReserve typeOfSpace\n", argv[0]); exit (1); } //nbfiles = argc - 3; #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } else printf ("request endpoint %s\n", srm_endpoint); #endif while (*protocols[nbproto]) nbproto++; soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); //printf("Step 0\n"); #if 0 /* if ((req.spaceToken = soap_malloc (&soap, sizeof(struct ns1__TSpaceToken))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.spaceToken = argv[2]; #endif #if 0 if ((req.storageSystemInfo = soap_malloc (&soap, sizeof(struct ns1__TExtraInfo))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } //req.storageSystemInfo->value = argv[3]; /* req.storageSystemInfo->__sizeextraInfoArray = 1; req.storageSystemInfo->extraInfoArray[0]->key = "0"; req.storageSystemInfo->extraInfoArray[0]->value = argv[3]; */ req.storageSystemInfo->__sizeextraInfoArray = 0; req.storageSystemInfo->extraInfoArray = NULL; #else req.storageSystemInfo = NULL; #endif //printf("Step 1\n"); if ((req.desiredSizeOfTotalSpace= //soap_malloc (&soap, sizeof(struct ns1__TSizeInBytes))) == NULL) { soap_malloc (&soap, sizeof(ULONG64 *))) == NULL) { perror ("malloc0"); soap_end (&soap); exit (1); } *(req.desiredSizeOfTotalSpace) = atoll(argv[4]); //printf("Step 2\n"); /* if ((req.desiredSizeOfGuaranteedSpace = soap_malloc (&soap, sizeof(struct ns1__TSizeInBytes))) == NULL) { perror ("malloc"); soap_end (&soap); exit (1); } */ req.desiredSizeOfGuaranteedSpace = atoll(argv[5]); //printf("Step 3\n"); if ((req.desiredLifetimeOfReservedSpace = soap_malloc (&soap, sizeof(int))) == NULL) { perror ("malloc1"); soap_end (&soap); exit (1); } *(req.desiredLifetimeOfReservedSpace) = atoi(argv[6]); //printf("Step 4\n"); if ((req.arrayOfExpectedFileSizes = soap_malloc (&soap, sizeof(struct ns1__ArrayOfUnsignedLong))) == NULL) { perror ("malloc2"); soap_end (&soap); exit (1); } req.arrayOfExpectedFileSizes->__sizeunsignedLongArray = 0; req.arrayOfExpectedFileSizes->unsignedLongArray = NULL; //req.arrayOfExpectedFileSizes->extraInfoArray[0]->key = "0"; //req.arrayOfExpectedFileSizes->extraInfoArray[0]->value = argv[3]; //printf("Step 5\n"); req.userSpaceTokenDescription = argv[2]; //printf("Step 6\n"); if ((req.retentionPolicyInfo = soap_malloc (&soap, sizeof(struct ns1__TRetentionPolicyInfo))) == NULL) { perror ("malloc3"); soap_end (&soap); exit (1); } ////TOFIXreq.typeOfSpace = atoi(argv[7]); req.retentionPolicyInfo->retentionPolicy = atoi(argv[7]); //req.retentionPolicyInfo->retentionPolicy = &retpol[atoi(argv[7])]; //printf("Step 7\n"); if ((req.transferParameters = soap_malloc (&soap, sizeof(struct ns1__TTransferParameters))) == NULL) { perror ("malloc4"); soap_end (&soap); exit (1); } //req.transferParameters->__sizesizeArray = 0; //req.transferParameters->sizeArray = NULL; req.transferParameters->accessPattern = NULL; req.transferParameters->connectionType = NULL; req.transferParameters->arrayOfClientNetworks = NULL; req.transferParameters->arrayOfTransferProtocols = NULL; //printf("Step 8-0\n"); //printf("Step 8-00 nbproto: %d\n", nbproto); if ((req.transferParameters->arrayOfTransferProtocols = soap_malloc (&soap, nbproto*sizeof(struct ns1__ArrayOfString))) == NULL) { perror ("malloc5"); soap_end (&soap); exit (1); } //printf("Step 8-1 nbproto: %d\n", nbproto); req.transferParameters->arrayOfTransferProtocols->__sizestringArray = 1; //printf("Step 8-2\n"); req.transferParameters->arrayOfTransferProtocols->stringArray = protocols; //printf("Step 8\n"); /* To send the request ... */ #if 0 if (soap_call_ns1__srmReserveSpace (&soap, argv[1], "SrmReserveSpace", &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else srm_endpoint = argv[1]; SOAP_CALL_NS1(ReserveSpace, re); #endif reqstatp = rep.srmReserveSpaceResponse->returnStatus; //repfs = rep.srmCheckPermissionResponse->arrayOfPermissions; printf ("request status %s\n", soap_ns1__TStatusCode2s (&soap, reqstatp->statusCode)); printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } repp = rep.srmReserveSpaceResponse; if (repp->spaceToken) { s_token = repp->spaceToken; printf ("soap_call_ns1__srmReserveSpace returned s_token: %s\n", s_token); } /* if ( repp->retentionPolicy && repp->retentionPolicy->retentionPolicy ) printf ("srmReserveSpace provided actual_s_type: %s\n", s_retpol[*(repp->retentionPolicy->retentionPolicy)]); */ //printf ("srmReserveSpace provided actual_s_type: %s actual_t_space: %llu actual_g_space: %llu actual_lifetime: %d\n", s_retpol[*(repp->retentionPolicy->retentionPolicy)] /* (*repp->typeOfReservedSpace) */, repp->sizeOfTotalReservedSpace->value, repp->sizeOfGuaranteedReservedSpace->value, repp->lifetimeOfReservedSpace->value ); printf ("srmReserveSpace provided actual_t_space: %llu actual_g_space: %llu actual_lifetime: %d\n", //s_retpol[*(repp->retentionPolicy->retentionPolicy)] , *(repp->sizeOfTotalReservedSpace), *(repp->sizeOfGuaranteedReservedSpace), *(repp->lifetimeOfReservedSpace) ); soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv2.2/srmv2Stress0000755000175000017500000000261710625223675016566 0ustar ellertellert#!/usr/bin/perl -w ########################################################################################## # # stressSuite # # A Perl script to test the srmV2 # # Author: Gilbert Grosdidier, LAL (Universite Paris-Sud, Orsay) # Creation Date : 3/11/2004 # Migration : 27/12/2004 # Last rev: 23/05/2007 (GG) # ########################################################################################## ### ### Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL ### All rights reserved ### # $Id: srmv2Stress,v 1.4 2007/05/24 05:50:53 grodid Exp $ # Usage: srmv2Stress lxgate22 50 2100 [domain] use strict; my $mach = shift; my $many = shift; my $label = shift; my $domain = shift || "cern.ch"; $label--; ##my $command = "time srmv2Suite ${mach}.${domain} 8446 grodid filestress$lab dteam subdirst$lab > /tmp/suite-SLC3-${mach}-sec.lis"; foreach my $cn ( 1 .. $many ) { my $lab = $label + $cn; my $laber = $label + 1; ##$ENV{CGSI_TRACE} = "1"; ##$ENV{CGSI_TRACEFILE} = "/tmp/grodid/cgsi_trace/cgsi_trace-${mach}.lis$lab"; $ENV{TEMPDIR} = "/var/tmp/grodid/stress/subdirst$lab"; system("mkdir -p $ENV{TEMPDIR}"); my $command = "time srmv2Suite ${mach}.${domain} 8446 grodid filest$lab dteam grodid/stress/rn$laber/sd$lab > /var/tmp/grodid/stress/suite-SLC4-${mach}.lis"; my $cm = "nohup $command$lab 2>&1 &"; print "CM: >> $cm << \n"; system ("$cm"); } exit 0; lcgdm-1.8.7/test/srmv2.2/srm2_testPing.c0000644000175000017500000000522710622610227017255 0ustar ellertellert/* * Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL * All rights reserved */ // $Id: srm2_testPing.c,v 1.3 2007/05/16 14:09:27 grodid Exp $ #include "srmv2H.h" #include "srmSoapBinding.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/v2_1_1/srm" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #include "parsesurl.ic" #include "soapcallns1.ic" main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; #if 0 int nbproto = 0; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; #endif int r = 0; char *r_token; struct ns1__srmPingResponse_ rep; struct ns1__srmPingRequest req; //struct ns1__TReturnStatus *reqstatp; struct ns1__ArrayOfTExtraInfo *repfs; char *sfn; struct soap soap; char *srm_endpoint; char *vers; if (argc < 2) { fprintf (stderr, "usage: %s endPoint\n", argv[0]); exit (1); } #if 0 if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } #endif soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif memset (&req, 0, sizeof(req)); #if 1 //req.userSpaceTokenDescription = argv[2]; #if 0 if (soap_call_ns1__srmPing (&soap, srm_endpoint, "Ping", #else if (soap_call_ns1__srmPing (&soap, argv[1], "Ping", #endif &req, &rep)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } #else SOAP_CALL_NS1(Ping, re); #endif #if 0 reqstatp = rep.srmPingResponse->returnStatus; printf ("request state %d\n", reqstatp->statusCode); if (reqstatp->statusCode != SRM_USCORESUCCESS && reqstatp->statusCode != SRM_USCOREDONE) { if (reqstatp->explanation) printf ("explanation: %s\n", reqstatp->explanation); soap_end (&soap); exit (1); } #endif vers = rep.srmPingResponse->versionInfo; if ( !vers ) { printf ("versionInfo is NULL\n"); soap_end (&soap); exit (1); } else { printf ("versionInfo: %s\n", vers); } repfs = rep.srmPingResponse->otherInfo; #if 1 if (! repfs) { printf ("otherInfo is NULL\n"); soap_end (&soap); exit (0); } #endif // Don't know how to do ... but is always 0 for DPM ;-) #if 1 if ( repfs ) { printf("=== RETURNED OTHER INFOS ===\n"); for (i = 0; i < repfs->__sizeextraInfoArray; i++) printf("other_info[%s]: %s\n", repfs->extraInfoArray[i]->key, repfs->extraInfoArray[i]->value); } #endif soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv1/0000755000175000017500000000000012202120643014174 5ustar ellertellertlcgdm-1.8.7/test/srmv1/srm_testgetProtocols.c0000644000175000017500000000140110132421153020601 0ustar ellertellert#include #include "srmv1H.h" #include "ISRM.nsmap" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif main(argc, argv) int argc; char **argv; { int flags; int i; struct ns5__getProtocolsResponse out; struct soap soap; if (argc != 2) { fprintf (stderr, "usage: %s srm_endpoint\n", argv[0]); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif if (soap_call_ns5__getProtocols (&soap, argv[1], "getProtocols", &out)) { soap_print_fault (&soap, stderr); exit (1); } printf ("Supported protocols are:"); if (out._Result) for (i = 0; i < out._Result->__size; i++) printf (" %s", out._Result->__ptr[i]); printf ("\n"); exit (0); } lcgdm-1.8.7/test/srmv1/Imakefile0000644000175000017500000000502111000742233016003 0ustar ellertellertCOMM COMM Copyright (C) 2004-2007 by CERN/IT/GD/CT & CNRS/IN2P3/LAL COMM All rights reserved COMM COMM @(#)$RCSfile: Imakefile,v $ $Revision: 1.15 $ $Date: 2008/04/14 20:54:51 $ CERN Jean-Philippe Baud COMM $Id: Imakefile,v 1.15 2008/04/14 20:54:51 szamsu Exp $ COMM Make srmv1 tests GLOBUS_LOCATION=GlobusLocation #if defined(__STDC__) GLOBUS_FLAVOUR=GlobusFlavour##pthr #else GLOBUS_FLAVOUR=GlobusFlavour/**/pthr #endif GLOBUS_LIBS=-L$(GLOBUS_LOCATION)/lib -lglobus_gssapi_gsi_$(GLOBUS_FLAVOUR) -lglobus_gss_assist_$(GLOBUS_FLAVOUR) GSOAP_LOCATION=GsoapLocation GSOAP_VERSION=GsoapVersion WSDL2H_FLAGS=GsoapWsdl2hFlags CGSI_GSOAP_LOCATION=CgsiGsoapLocation SECFLG = -DGFAL_SECURE SECLIB = -L$(CGSI_GSOAP_LOCATION)/$(_lib) -L$(CGSI_GSOAP_LOCATION)/lib -lcgsi_plugin_gsoap_$(GSOAP_VERSION) $(GLOBUS_LIBS) SOAPFLG = -DWITH_IPV6 RFIOFLG = -DGFAL_ENABLE_RFIO prefixsrmv1 = $(prefix)/test/sbin/ INCLUDES = ./ COMM######################### FLAGS ############################## CFLAGS = $(SECFLG) $(RFIOFLG) $(SOAPFLG) -I$(INCLUDES) -I$(GSOAP_LOCATION)/include -I$(CGSI_GSOAP_LOCATION)/include COMM######################### RULES ############################## PROGS = $(patsubst %.c,%,$(wildcard srm_test*.c)) PROGOS = $(patsubst %.c,%.Osuf,$(wildcard srm_test*.c)) SCRIPTS = srmv1Suite \ srmv1Stress SOAP_OBJS = srmv1C.Osuf \ srmv1Client.Osuf \ stdsoap2.Osuf PROGSBIN = $(addprefix $(prefixsrmv1),$(PROGS) $(SCRIPTS)) all: $(PROGS) srmv1H.h srmv1Stub.h srmv1C.c srmv1Client.c ISRM.nsmap: srm.v1.1.h $(GSOAP_LOCATION)/bin/soapcpp2 -c -p srmv1 srm.v1.1.h srm.v1.1.h: srm.v1.1.wsdl $(GSOAP_LOCATION)/bin/wsdl2h $(WSDL2H_FLAGS) -c -e -w -y -t typemap.dat srm.v1.1.wsdl stdsoap2.Osuf: $(GSOAP_LOCATION)/src/stdsoap2.c $(CC) -c -I$(GSOAP_LOCATION)/include $(SOAPFLG) $(GSOAP_LOCATION)/src/stdsoap2.c install: $(PROGSBIN) install.man: $(prefixsrmv1)%: % cp $? $@ $(PROGS): %: %.Osuf $(SOAP_OBJS) $(DEPLIBS) ### @echo "========================g" $@ $(LD) -o $@ $(LDFLAGS) $< $(SOAP_OBJS) $(LIBS) $(SECLIB) COMM###################### CLEANING RULES ######################## clean: -@RemoveFiles(*.Osuf *H.h *Object.h *Proxy.h *Stub.h *C.c *Client.c *Lib.c *Server.c *.nsmap *.xml srm.v1.1.h) clobber: clean -@RemoveFiles($(PROGS)) #if _WIN32 depend: @echo Not supported on this platform #else depend: makedepend -Y$(INCLUDES) *.c 2> /dev/null #endif Makefiles: FORCE: COMM###################### DEPENDENCIES ########################## $(PROGOS): srmv1H.h ISRM.nsmap COMM DO NOT DELETE THIS LINE -- make depend depends on it. lcgdm-1.8.7/test/srmv1/my_gsiftp_in.sh0000755000175000017500000000060710343032663017235 0ustar ellertellert#!/bin/bash # # This script is a part of SRM test suite. This is a wrapper script around # rfcp, used to copy files from the remote machine (from TURL got from SRM # server) and store it locally. # # $Id: my_gsiftp_in.sh,v 1.5 2005/11/29 11:04:19 jamesc Exp $ echo 'TURL:' $1 TURL_RFCP=$1 ## 24/05/05 echo 'TURL_gsiftp: ' $TURL_RFCP globus-url-copy $TURL_RFCP file://`pwd`/$2 exit $? lcgdm-1.8.7/test/srmv1/srm_testgetFileMetaData.c0000644000175000017500000000416310132425301021104 0ustar ellertellert#include #include "srmv1H.h" #include "ISRM.nsmap" #define SRM_EP_PATH "/srm/managerv1" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[256]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; return (-1); } #ifdef GFAL_SECURE strcpy (srm_ep, "https://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } main (int argc, char **argv) { int flags; struct ns5__getFileMetaDataResponse out; char *sfn; struct soap soap; char *srm_endpoint; struct ArrayOfstring surlarray; if (argc != 2) { fprintf (stderr, "usage: %s SURL\n", argv[0]); exit (1); } if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif /* issue "getFileMetaData" request */ surlarray.__ptr = &argv[1]; surlarray.__size = 1; if (soap_call_ns5__getFileMetaData (&soap, srm_endpoint, "getFileMetaData", &surlarray, &out)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } if (out._Result->__size == 0 || out._Result->__ptr[0]->SURL == NULL) { fprintf (stderr, "error\n"); soap_end (&soap); exit (1); } if (out._Result->__ptr[0]->owner) printf ("owner = %s\n", out._Result->__ptr[0]->owner); if (out._Result->__ptr[0]->group) printf ("group = %s\n", out._Result->__ptr[0]->group); printf ("size = %lld\n", out._Result->__ptr[0]->size); soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv1/my_rfcp_out.sh0000755000175000017500000000101310345401020017051 0ustar ellertellert#!/bin/bash # # This script is a part of SRM (V1) test suite. This is a wrapper script around # rfcp, used to copy files to the remote machine (to TURL got from SRM # server). # # $Id: my_rfcp_out.sh,v 1.8 2005/12/06 21:26:40 grodid Exp $ echo 'TURL:' $2 TURL_RFCP=`echo $2 | perl -pe 's;(.*?)://(.*)$;$2;g'` TURL_RFCP=`echo $TURL_RFCP | perl -pe 's;//;:/;'` if [ "$NEW_RFIO_SYNTAX" ]; then TURL_RFCP=$2; ### For the NEW RFIOD 30/11/05 fi echo 'TURL_rfcp: ' $TURL_RFCP which rfcp rfcp $1 $TURL_RFCP exit $? lcgdm-1.8.7/test/srmv1/srm_testping.c0000644000175000017500000000125410131424223017060 0ustar ellertellert#include #include "srmv1H.h" #include "ISRM.nsmap" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif main(argc, argv) int argc; char **argv; { int flags; struct ns5__pingResponse out; struct soap soap; if (argc != 2) { fprintf (stderr, "usage: %s srm_endpoint\n", argv[0]); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif if (soap_call_ns5__ping (&soap, argv[1], "ping", &out)) { soap_print_fault (&soap, stderr); exit (1); } if (out._Result) printf ("SRM server is alive\n"); else printf ("SRM server is not responding\n"); exit (0); } lcgdm-1.8.7/test/srmv1/my_rfcp_in.sh0000755000175000017500000000103010345401020016647 0ustar ellertellert#!/bin/bash # # This script is a part of SRM (V1) test suite. This is a wrapper script around # rfcp, used to copy files from the remote machine (from TURL got from SRM # server) and store it locally. # # $Id: my_rfcp_in.sh,v 1.7 2005/12/06 21:26:40 grodid Exp $ echo 'TURL:' $1 TURL_RFCP=`echo $1 | perl -pe 's;(.*?)://(.*)$;$2;g'` TURL_RFCP=`echo $TURL_RFCP | perl -pe 's;//;:/;'` if [ "$NEW_RFIO_SYNTAX" ]; then TURL_RFCP=$1; ### For the NEW RFIOD 30/11/05 fi echo 'TURL_rfcp: ' $TURL_RFCP rfcp $TURL_RFCP $2 exit $? lcgdm-1.8.7/test/srmv1/my_dccp_out.sh0000755000175000017500000000053010343032663017046 0ustar ellertellert#!/bin/bash # This script is a part of SRM test suite. This is a wrapper script around # rfcp, used to copy files to the remote machine (to TURL got from SRM # server). # $Id: my_dccp_out.sh,v 1.5 2005/11/29 11:04:19 jamesc Exp $ echo 'TURL:' $2 TURL_RFCP=$2 echo 'TURL_DCCP: ' $TURL_RFCP /opt/d-cache/dcap/bin/dccp $1 $TURL_RFCP exit $? lcgdm-1.8.7/test/srmv1/srmv1Stress0000755000175000017500000000200210253556677016420 0ustar ellertellert#!/usr/bin/perl -w ########################################################################################## # # stressSuite # # A Perl script to stress the srmV1 # # Author: Gilbert Grosdidier, LAL (Universite Paris-Sud, Orsay) # Creation Date : 3/11/2004 # Migration : 27/12/2004 # Last rev: 14/06/2005 (GG) # ########################################################################################## ### ### Copyright (C) 2004-2005 by CERN/IT/GD/CT & CNRS/IN2P3/LAL ### All rights reserved ### # $Id: srmv1Stress,v 1.3 2005/06/14 13:38:07 grodid Exp $ # Usage: srmv1Stress lxgate22 50 2100 gftp [domain] use strict; my $mach = shift; my $many = shift; my $label = shift; my $proto = shift; my $domain = shift || "cern.ch"; $label--; my $command = "time srmv1Suite ${mach}.${domain} grodid $proto > /tmp/suite-SLC3-${proto}-${mach}-sec.lis"; foreach my $cn ( 1 .. $many ) { my $lab = $label + $cn; my $cm = "nohup $command$lab 2>&1 &"; print "CM: >> $cm << \n"; system ("$cm"); } exit 0; lcgdm-1.8.7/test/srmv1/srm_testput.c0000644000175000017500000001046710334422516016751 0ustar ellertellert#include "srmv1H.h" #include "ISRM.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/srm/managerv1" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[256]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; return (-1); } #ifdef GFAL_SECURE strcpy (srm_ep, "https://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; struct ns5__putResponse out; struct ns5__getRequestStatusResponse outq; struct ArrayOfboolean permarray; struct ArrayOfstring protoarray; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", // was "gsidcap" for a TEMP test #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; int reqid; struct ns1__RequestStatus *reqstatp; char *sfn; struct ArrayOflong sizearray; struct soap soap; struct ArrayOfstring srcarray; char *srm_endpoint; struct ArrayOfstring surlarray; LONG64 zero = 0; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } while (*protocols[nbproto]) nbproto++; soap_init(&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif if ((surlarray.__ptr = malloc (nbfiles * sizeof(char *))) == NULL || (srcarray.__ptr = malloc (nbfiles * sizeof(char *))) == NULL || (sizearray.__ptr = malloc (nbfiles * sizeof(LONG64))) == NULL || (permarray.__ptr = malloc (nbfiles * sizeof(enum xsd__boolean))) == NULL) { perror ("malloc"); exit (1); } for (i = 0; i < nbfiles; i++) { surlarray.__ptr[i] = argv[i+1]; srcarray.__ptr[i] = argv[i+1]; sizearray.__ptr[i] = zero; permarray.__ptr[i] = true_; } surlarray.__size = nbfiles; srcarray.__size = nbfiles; sizearray.__size = nbfiles; permarray.__size = nbfiles; //protoarray.__ptr = 0; // TEMP protocols; protoarray.__ptr = protocols; protoarray.__size = nbproto; if (soap_call_ns5__put (&soap, srm_endpoint, "put", &srcarray, &surlarray, &sizearray, &permarray, &protoarray, &out)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = out._Result; if (reqstatp->fileStatuses == NULL) { errno = EPROTONOSUPPORT; perror ("put"); soap_end (&soap); exit (1); } reqid = reqstatp->requestId; printf ("soap_call_ns5__put returned reqid: %d\n", reqid); /* wait for file "ready" */ while (strcmp (reqstatp->state, "pending") == 0 || strcmp (reqstatp->state, "Pending") == 0) { printf("request state %s\n", reqstatp->state); sleep ((r++ == 0) ? 1 : (reqstatp->retryDeltaTime > 0) ? reqstatp->retryDeltaTime : DEFPOLLINT); if (soap_call_ns5__getRequestStatus (&soap, srm_endpoint, "getRequestStatus", reqid, &outq)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = outq._Result; } printf ("request state %s\n", reqstatp->state); if (strcmp (reqstatp->state, "failed") == 0 || strcmp (reqstatp->state, "Failed") == 0) { if (reqstatp->errorMessage) printf ("errorMessage: %s\n", reqstatp->errorMessage); soap_end (&soap); exit (1); } for (i = 0; i < reqstatp->fileStatuses->__size; i++) { if (strcmp ((reqstatp->fileStatuses->__ptr[i])->state, "ready") && strcmp ((reqstatp->fileStatuses->__ptr[i])->state, "Ready")) printf ("state[%d] = %s\n", i, (reqstatp->fileStatuses->__ptr[i])->state); else printf ("state[%d] = %s, TURL = %s\n", i, (reqstatp->fileStatuses->__ptr[i])->state, (reqstatp->fileStatuses->__ptr[i])->TURL); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv1/srm_testadvisoryDelete.c0000644000175000017500000000336510132425301021112 0ustar ellertellert#include #include "srmv1H.h" #include "ISRM.nsmap" #define SRM_EP_PATH "/srm/managerv1" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[256]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; return (-1); } #ifdef GFAL_SECURE strcpy (srm_ep, "https://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } main (int argc, char **argv) { int flags; struct ns5__advisoryDeleteResponse out; char *sfn; struct soap soap; char *srm_endpoint; struct ArrayOfstring surlarray; if (argc != 2) { fprintf (stderr, "usage: %s SURL\n", argv[0]); exit (1); } if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif /* issue "advisoryDelete" request */ surlarray.__ptr = &argv[1]; surlarray.__size = 1; if (soap_call_ns5__advisoryDelete (&soap, srm_endpoint, "advisoryDelete", &surlarray, &out)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv1/srm_testget.c0000644000175000017500000000727310152576001016716 0ustar ellertellert#include "srmv1H.h" #include "ISRM.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/srm/managerv1" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[256]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; return (-1); } #ifdef GFAL_SECURE strcpy (srm_ep, "https://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; struct ns5__getResponse out; struct ns5__getRequestStatusResponse outq; struct ArrayOfstring protoarray; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; int reqid; struct ns1__RequestStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; struct ArrayOfstring surlarray; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } while (*protocols[nbproto]) nbproto++; soap_init(&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif if ((surlarray.__ptr = malloc (nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); exit (1); } for (i = 0; i < nbfiles; i++) surlarray.__ptr[i] = argv[i+1]; surlarray.__size = nbfiles; protoarray.__ptr = protocols; protoarray.__size = nbproto; if (soap_call_ns5__get (&soap, srm_endpoint, "get", &surlarray, &protoarray, &out)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = out._Result; if (reqstatp->fileStatuses == NULL) { errno = EPROTONOSUPPORT; perror ("get"); soap_end (&soap); exit (1); } reqid = reqstatp->requestId; printf ("soap_call_ns5__get returned reqid: %d\n", reqid); /* wait for file "ready" */ while (strcmp (reqstatp->state, "pending") == 0 || strcmp (reqstatp->state, "Pending") == 0) { printf("request state %s\n", reqstatp->state); sleep ((r++ == 0) ? 1 : (reqstatp->retryDeltaTime > 0) ? reqstatp->retryDeltaTime : DEFPOLLINT); if (soap_call_ns5__getRequestStatus (&soap, srm_endpoint, "getRequestStatus", reqid, &outq)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = outq._Result; } printf ("request state %s\n", reqstatp->state); if (strcmp (reqstatp->state, "failed") == 0 || strcmp (reqstatp->state, "Failed") == 0) { if (reqstatp->errorMessage) printf ("errorMessage: %s\n", reqstatp->errorMessage); soap_end (&soap); exit (1); } for (i = 0; i < reqstatp->fileStatuses->__size; i++) { if (strcmp ((reqstatp->fileStatuses->__ptr[i])->state, "ready") && strcmp ((reqstatp->fileStatuses->__ptr[i])->state, "Ready")) printf ("state[%d] = %s\n", i, (reqstatp->fileStatuses->__ptr[i])->state); else printf ("state[%d] = %s, TURL = %s\n", i, (reqstatp->fileStatuses->__ptr[i])->state, (reqstatp->fileStatuses->__ptr[i])->TURL); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv1/my_dccp_in.sh0000755000175000017500000000074410343032663016654 0ustar ellertellert#!/bin/bash # # This script is a part of SRM test suite. This is a wrapper script around # rfcp, used to copy files from the remote machine (from TURL got from SRM # server) and store it locally. # # $Id: my_dccp_in.sh,v 1.5 2005/11/29 11:04:19 jamesc Exp $ echo 'TURL:' $1 TURL_RFCP=`echo $1 | sed 's;rfio://;;g'` TURL_RFCP=`echo $1 | perl -pe 's;rfio://([^/]*?):?//?(.*)$;$1:/$2;g'` TURL_RFCP=$1 echo 'TURL_DCCP: ' $TURL_RFCP /opt/d-cache/dcap/bin/dccp $TURL_RFCP $2 exit $? lcgdm-1.8.7/test/srmv1/srm.v1.1.wsdl0000644000175000017500000004016407756664175016420 0ustar ellertellert diskCacheV111.srm.server.SRMServerV1 web service lcgdm-1.8.7/test/srmv1/my_gsiftp_out.sh0000755000175000017500000000055710343032663017442 0ustar ellertellert#!/bin/bash # # This script is a part of SRM test suite. This is a wrapper script around # rfcp, used to copy files to the remote machine (to TURL got from SRM # server). # # $Id: my_gsiftp_out.sh,v 1.5 2005/11/29 11:04:19 jamesc Exp $ echo 'TURL:' $2 TURL_RFCP=$2 ## 24/05/05 echo 'TURL_gsiftp: ' $TURL_RFCP globus-url-copy file://`pwd`/$1 $TURL_RFCP exit $? lcgdm-1.8.7/test/srmv1/srm_testgetEstGetTime.c0000644000175000017500000000735510155576460020666 0ustar ellertellert#include "srmv1H.h" #include "ISRM.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/srm/managerv1" #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[256]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; return (-1); } #ifdef GFAL_SECURE strcpy (srm_ep, "https://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } main(argc, argv) int argc; char **argv; { int flags; int i; int nbfiles; int nbproto = 0; struct ns5__getEstGetTimeResponse out; struct ns5__getRequestStatusResponse outq; struct ArrayOfstring protoarray; static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "gsidcap", #endif "" }; int r = 0; int reqid; struct ns1__RequestStatus *reqstatp; char *sfn; struct soap soap; char *srm_endpoint; struct ArrayOfstring surlarray; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if (parsesurl (argv[1], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } while (*protocols[nbproto]) nbproto++; soap_init(&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif if ((surlarray.__ptr = malloc (nbfiles * sizeof(char *))) == NULL) { perror ("malloc"); exit (1); } for (i = 0; i < nbfiles; i++) surlarray.__ptr[i] = argv[i+1]; surlarray.__size = nbfiles; protoarray.__ptr = protocols; protoarray.__size = nbproto; if (soap_call_ns5__getEstGetTime (&soap, srm_endpoint, "getEstGetTime", &surlarray, &protoarray, &out)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = out._Result; if (reqstatp->fileStatuses == NULL) { errno = EPROTONOSUPPORT; perror ("getEstGetTime"); soap_end (&soap); exit (1); } reqid = reqstatp->requestId; printf ("soap_call_ns5__getEstGetTime returned reqid: %d\n", reqid); /* wait for file "ready" */ while (strcmp (reqstatp->state, "pending") == 0 || strcmp (reqstatp->state, "Pending") == 0) { printf("request state %s\n", reqstatp->state); sleep ((r++ == 0) ? 1 : (reqstatp->retryDeltaTime > 0) ? reqstatp->retryDeltaTime : DEFPOLLINT); if (soap_call_ns5__getRequestStatus (&soap, srm_endpoint, "getRequestStatus", reqid, &outq)) { soap_print_fault (&soap, stderr); soap_end (&soap); exit (1); } reqstatp = outq._Result; } printf ("request state %s\n", reqstatp->state); if (strcmp (reqstatp->state, "failed") == 0 || strcmp (reqstatp->state, "Failed") == 0) { if (reqstatp->errorMessage) printf ("errorMessage: %s\n", reqstatp->errorMessage); soap_end (&soap); exit (1); } for (i = 0; i < reqstatp->fileStatuses->__size; i++) { if (strcmp ((reqstatp->fileStatuses->__ptr[i])->state, "ready") && strcmp ((reqstatp->fileStatuses->__ptr[i])->state, "Ready")) printf ("state[%d] = %s\n", i, (reqstatp->fileStatuses->__ptr[i])->state); else printf ("state[%d] = %s, TURL = %s\n", i, (reqstatp->fileStatuses->__ptr[i])->state, (reqstatp->fileStatuses->__ptr[i])->TURL); } soap_end (&soap); exit (0); } lcgdm-1.8.7/test/srmv1/srm_testJiri.c0000644000175000017500000011732710336072515017043 0ustar ellertellert/* * SRM test suite, written by Jiri Kosina , based on work done * by Jean-Phillipe Baud * Migrated to gsoap_2.6 by GG * * TODO (among others): * - let user choose between rfio, gsiftp & dcap * */ // $Id: srm_testJiri.c,v 1.8 2005/11/14 11:30:21 grodid Exp $ #define VERSION "0.3.4_multiple_gsoap_2.6" #include #include #include #include #include #include #include #include #include #include "srmv1H.h" #include "ISRM.nsmap" #define DEFPOLLINT 10 #define SRM_EP_PATH "/srm/managerv1" #define PINNED 0 #define UNPINNED 1 #define METHOD_RFIO 1 #define METHOD_GSIFTP 2 #define METHOD_DCAP 3 #ifdef GFAL_SECURE #include "cgsi_plugin.h" #endif #ifdef DMALLOC #include "dmalloc.h" #endif /* debugging output */ #define DEBUG #ifdef DEBUG #define PRINTF(format, args...) printf (format, ## args); fflush(stdout) #else #define PRINTF(format, args...) #endif /* taken from gfal_api.h */ struct srm_filestatus { char *surl; char *turl; int fileid; int status; }; /* forward declaration */ struct ns1__FileMetaData **request_get_file_metadata(char **argv, int i); char testfilename1[1024], testfilename2[1024]; /* ugly */ char current_command[1024]; /* ugly, should be replaced by union */ struct soap soap; volatile int segfault = 0; sigjmp_buf env; int saved_sigs; int flags; int reqid; int nbproto; int somebug = 0; /* this is global variable which indicates if there was any problem during the whoel run of test suite - in other words, if everything passed or not */ int transfer_method = 0; int SURL_was_not_set = 0; /* SIGSEGV handler used to detect SRM server returning junk */ void segv(int dummy) { segfault = 1; siglongjmp(env, 1); } /* check if returned metadata about file corresponds to local file */ int check_metadata_consistency (struct ns1__FileMetaData **p, char *fname, int pin) { struct stat buf; int ret; printf("stating %s\n", fname); ret = stat(fname, &buf); if (ret == -1){ PRINTF("[!] \tstrange, local stat() failed\n"); perror("stat"); somebug = 1; return 1; } if (buf.st_size != (*p)->size){ PRINTF("[!]\tsize of localfile (%d) differs from what SRM reports (%d), FAILED\n", buf.st_size, (*p)->size); somebug = 1; } else PRINTF("[+]\tsizes of local file and SRM reported size match\n"); if (buf.st_mode != (*p)->permMode){ PRINTF("[?]\tmode of localfile (%o) differs from what SRM reports (%o)\n", buf.st_mode, (*p)->permMode); } else PRINTF("[+]\tmode of local file and SRM reported size match (%o)\n", buf.st_mode); if (pin == PINNED && (*p)->isPinned == true_){ PRINTF("[+]\tfile is correctly pinned\n"); } else if (pin == PINNED && (*p)->isPinned == false_){ PRINTF("[?]\tfile is not pinned, but should be\n"); /* somebug = 1;*/ } if (pin == UNPINNED && (*p)->isPinned == false_) { PRINTF("[+]\tfile is correctly unpinned\n"); } else if (pin == UNPINNED && (*p)->isPinned == true_) { PRINTF("[?]\tfile is pinned, but should be unpinned\n"); /* somebug = 1;*/ } return 0; } /* this routine checks if all fields of requestFileStatus are set * with compilance of "standard" * * More checks could be added (StartTime > SubmitTime, etc) * * Maybe dumping the whole structure at error would be nice */ int check_request_file_status_consistency(struct ns1__RequestStatus *p, char *invoking_method, char **argv) { /* FIXME */ #define CHKPRINTF PRINTF //OLDBADstruct ns1__RequestFileStatus *status; struct ns1__RequestFileStatus **status; int i; /* FIXME FIXME FIXME DEBUG */ if (!p) { CHKPRINTF("[!]\t\trequest status is NULL, FAILED\n"); somebug = 1; } else CHKPRINTF("[+]\t\trequest status check not-NULL, passed\n"); if (strcasecmp(p->type, invoking_method) != 0){ CHKPRINTF("[!]\t\trequest %s and returned type %s do not match, FAILED\n", invoking_method, p->type); somebug = 1; } else CHKPRINTF("[+]\t\trequest and returned type match, passed\n"); if (!p->fileStatuses){ CHKPRINTF("[!]\t\tGot no filestatuses, FAILED\n"); errno = EPROTONOSUPPORT; perror ("put"); soap_end (&soap); somebug = 1; return -1; } if (p->fileStatuses->__size != 2){ CHKPRINTF("[!]\t\trequest status contains %d file(s), WRONG", p->fileStatuses->__size); somebug = 1; } else { CHKPRINTF("[+]\t\trequest status contains %d file(s), passed\n", p->fileStatuses->__size); } status = p->fileStatuses->__ptr; for (i=0; i < p->fileStatuses->__size; i++){ signal(SIGSEGV, segv); if (sigsetjmp(env, saved_sigs) != 0){ CHKPRINTF("\t\tFATAL: SRM server returned junk SURL in second fileStatus.\n"); somebug = 1; exit (1); } //OLDBADif (!status[i].SURL) { if (!status[i]->SURL) { CHKPRINTF("[!]\t\t%d: surl not set\n", i); somebug = 1; } else if (!strcasecmp(status[i]->SURL, argv[i+2])){ CHKPRINTF("[+]\t\t%d: surl (%s) check passed\n", i, status[i]->SURL); } else { CHKPRINTF("[!]\t\t%d: surl (%s, %s) check mismatch! FAILED\n", i, status[i]->SURL, argv[i+2]); somebug = 1; } signal(SIGSEGV, SIG_DFL); if (status[i]->size < 0) { CHKPRINTF("[!]\t\t%dsize < 0, this shouldn't happen, FAILED\n", i); somebug = 1; } else CHKPRINTF("[+]\t\t%d: size (%d) check passed\n", i, status[i]->size); if (!status[i]->state || (strcasecmp(status[i]->state, "Pending") && strcasecmp(status[i]->state, "Running") && strcasecmp(status[i]->state, "Ready") && strcasecmp(status[i]->state, "Failed") && strcasecmp(status[i]->state, "Done"))){ CHKPRINTF("[!]\t\t%d: state (%s) check FAILED\n", i, status[i]->state); somebug = 1; } else CHKPRINTF("[+]\t\t%d: state (%s) check passed\n", i, status[i]->state); /* if (status[i]->fileId < 0){ CHKPRINTF("[!]\t\t%d: fileId < 0, this shouldn't happen, check FAILED\n", i); somebug = 1; } else CHKPRINTF("[+]\t\t%d: fileId (%d) check passed\n", i, status[i]->fileId); */ CHKPRINTF("[+]\t\t%d: fileId (%d) check disabled\n", i, status[i]->fileId); if ((!strcasecmp(status[i]->state, "Ready") || !strcasecmp(status[i]->state, "Done")) && !status[i]->TURL){ CHKPRINTF("[!]\t\t%d: TURL shouldn't be NULL at this moment, FAILED\n", i); somebug = 1; } } return 0; } /* just ping the SRM server */ int request_ping(char **argv) { struct ns5__pingResponse out; struct ArrayOfstring surlarray; char *srm_endpoint, *sfn; struct ns1__FileMetaData *p; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 0; } surlarray.__ptr = &argv[2]; surlarray.__size = 1; //surlarray.__offset = 0; if (soap_call_ns5__ping (&soap, srm_endpoint, "Ping", &out)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); somebug = 1; } if (out._Result){ PRINTF ("[+]\tSRM server is alive\n"); } else { PRINTF ("[!]\tSRM server is not responding\n"); somebug = 1; return 1; } return 0; } /* make the file pinned (in use) on SRM server */ int request_pin(char **argv) { struct ns5__pinResponse out; struct ArrayOfstring surlarray; char *srm_endpoint, *sfn; struct ns1__FileMetaData *p; // Missing same cross-check for argv[3] ? if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 1; } surlarray.__ptr = (char **)argv+2; surlarray.__size = 2; //surlarray.__offset = 0; if (soap_call_ns5__pin (&soap, srm_endpoint, "Pin", &surlarray, &out)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); somebug = 1; } /* here the out._Result->fileStatuses == NULL :/ */ /* if (out._Result->fileStatuses == NULL){ printf("[!]\tfileStatuses pointer is bogus after Pin command. reporting as a bug (is this OK?)\n"); somebug = 1; } */ return 0; } /* advisoryDelete both files on the SRM server */ int request_advisoryDelete (char **argv, int i) { int flags; struct ns5__advisoryDeleteResponse out; char *sfn; struct soap soap; char *srm_endpoint; struct ArrayOfstring surlarray; if (parsesurl (argv[2+i], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); exit (1); } soap_init (&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif /* issue "advisoryDelete" request */ surlarray.__ptr = &argv[2+i]; surlarray.__size = 2; surlarray.__size = 1; // 1st try ... if (soap_call_ns5__advisoryDelete (&soap, srm_endpoint, "advisoryDelete", &surlarray, &out)) { soap_print_fault (&soap, stderr); soap_end (&soap); return (1); } soap_end (&soap); return (0); } /* make the file unpin (not in use) on SRM server */ int request_unpin(char **argv, int reqid) { struct ns5__unPinResponse out; struct ArrayOfstring surlarray; char *srm_endpoint, *sfn; struct ns1__FileMetaData *p; // Missing same cross-check for argv[3] ? if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 0; } //Jiri's Bug ? surlarray.__ptr = (char **)argv; surlarray.__ptr = (char **)argv+2; surlarray.__size = 2; //surlarray.__offset = 0; if (soap_call_ns5__unPin (&soap, srm_endpoint, "UnPin", &surlarray, reqid, &out)) { soap_print_fault (&soap, stderr); soap_print_fault_location (&soap, stderr); somebug = 1; } /* here ... se above */ } /* I made the following macros and not functions because of * argument madness :) */ /* initialize structures for getFileMetaData and send to SRM server */ #define init_get_file_metadata_request() \ surlarray.__ptr = (char **)argv+2; \ surlarray.__size = 2; \ \ if (soap_call_ns5__getFileMetaData (&soap, srm_endpoint, \ "getFileMetaData", &surlarray, &out)) { \ soap_print_fault (&soap, stderr); \ somebug = 1; \ } /* initialize structures for GET request and send to SRM server */ #define init_get_request() \ while (*protocols[nbproto]) nbproto++; \ \ surlarray = (struct ArrayOfstring *) malloc(sizeof(struct ArrayOfstring));\ surlarray->__ptr = (char **)argv+2; \ \ surlarray->__size = 2; \ \ protoarray.__ptr = protocols; \ protoarray.__size = nbproto; \ \ if (soap_call_ns5__get (&soap, srm_endpoint, "Get", surlarray, \ &protoarray, &out)) { \ soap_print_fault (&soap, stderr); \ soap_print_fault_location (&soap, stderr); \ somebug = 1; \ return -1; \ } \ \ reqstatp = out._Result; \ /* FIXME will be duplicit after writing checks */\ if (reqstatp->fileStatuses == NULL) { \ errno = EPROTONOSUPPORT; \ perror ("get"); \ somebug = 1; \ return -1; \ } \ reqid = reqstatp->requestId; /* initialize structures for PUT request and send to SRM server */ #define init_put_request() \ while (*protocols[nbproto]) nbproto++; \ \ surlarray = (struct ArrayOfstring *) malloc(sizeof(struct ArrayOfstring));\ \ srcarray = (struct ArrayOfstring *) malloc(sizeof(struct ArrayOfstring));\ \ sizearray = (struct ArrayOflong *) malloc(sizeof(struct ArrayOflong));\ \ permarray = (struct ArrayOfboolean *) malloc(sizeof(struct ArrayOfboolean));\ \ srcarray->__ptr = (char **)argv+2; \ srcarray->__size = 2; \ \ surlarray->__size = 2; \ surlarray->__ptr = (char **)argv+2; \ \ /* dummy */ \ size_tmp_arr[0] = 1; \ size_tmp_arr[1] = 1; \ sizearray->__size = 2; \ sizearray->__ptr = &size_tmp_arr[0]; \ \ /* dummy */ \ perm_tmp_arr[0] = 1; \ perm_tmp_arr[1] = 1; \ permarray->__size = 2; \ permarray->__ptr = &perm_tmp_arr[0]; \ \ protoarray.__ptr = protocols; \ protoarray.__size = nbproto; \ \ \ /* send PUT command to SRM */ \ PRINTF("[+]\tSending Put to SRM server\n"); \ if (soap_call_ns5__put (&soap, srm_endpoint, "Put", srcarray, \ surlarray, sizearray, permarray, &protoarray, &out)) { \ soap_print_fault (&soap, stderr); \ soap_print_fault_location (&soap, stderr); \ somebug = 1; \ return 1; \ } \ \ reqstatp = out._Result; \ if (reqstatp->errorMessage) \ printf ("errorMessage: %s\n", reqstatp->errorMessage); \ \ fflush (stdout);\ fflush (stderr);\ /* FIXME will be duplicit after writing checks */\ if (reqstatp->fileStatuses == NULL) { \ errno = EPROTONOSUPPORT; \ perror ("put"); \ somebug = 1; \ return 1; \ } \ reqid = reqstatp->requestId; /* this macro loops, polling SRM server, while the status of the * request is "pending". * TODO add some timeouting, this could loop forever */ // !strcasecmp(reqstatp->state, "active") || #if OLD #define loop_while_pending() \ PRINTF ("[GG0]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); \ PRINTF ("[GG0]\tsoap_call_ns5__put returned reqstatp->fileStatuses->__ptr->state: %s\n", \ reqstatp->fileStatuses->__ptr->state); \ while ((strcmp(reqstatp->state, "pending") == 0 || \ strcmp(reqstatp->state, "Pending") == 0) || \ (strcmp(reqstatp->fileStatuses->__ptr->state, "pending") == 0 \ || strcmp(reqstatp->fileStatuses->__ptr->state, \ "Pending") == 0)) { \ sleep((r++ == 0) ? 1 : (reqstatp->retryDeltaTime > 0) ? \ reqstatp->retryDeltaTime : DEFPOLLINT); \ if (soap_call_ns5__getRequestStatus(&soap, srm_endpoint, \ "getRequestStatus", \ reqid, &outq)) { \ soap_print_fault(&soap, stderr); \ soap_end(&soap); \ exit(1); \ } \ reqstatp = outq._Result; \ PRINTF ("[GGw]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); \ PRINTF ("[GGw]\tsoap_call_ns5__put returned reqstatp->fileStatuses->__ptr->state: %s\n", \ reqstatp->fileStatuses->__ptr->state); \ } \ if (reqstatp->errorMessage) \ printf("errorMessage: %s\n", reqstatp->errorMessage); \ if (strcmp(reqstatp->fileStatuses->__ptr->state, "ready") && \ strcmp(reqstatp->fileStatuses->__ptr->state, "Ready")) { \ printf("state = %s\n", \ reqstatp->fileStatuses->__ptr->state); \ somebug = 1; \ return 1; \ } \ \ #endif // while ( ! strcasecmp(reqstatp->state, "pending") ) { #if GG ( strcasecmp(reqstatp->state, "Done") && \ strcasecmp(reqstatp->state, "Failed") ) ) { \ #endif #define loop_while_pending() \ PRINTF ("[GG0]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); \ while ( ! reqstatp->state || \ \ ( strcasecmp(reqstatp->state, "pending" ) == 0 ) && \ (strcasecmp(reqstatp->fileStatuses->__ptr[0]->state, "pending") == 0 \ || strcasecmp(reqstatp->fileStatuses->__ptr[1]->state, "pending") == 0 ) ) { \ \ sleep((r++ == 0) ? 1 : (reqstatp->retryDeltaTime > 0) ? \ reqstatp->retryDeltaTime : DEFPOLLINT); \ if (soap_call_ns5__getRequestStatus(&soap, srm_endpoint, \ "getRequestStatus", \ reqid, &outq)) { \ soap_print_fault(&soap, stderr); \ soap_end(&soap); \ exit(1); \ } \ reqstatp = outq._Result; \ PRINTF ("[GGw]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); \ } \ if (reqstatp->errorMessage) \ printf("errorMessage: %s\n", reqstatp->errorMessage); \ if ( ( strcasecmp(reqstatp->fileStatuses->__ptr[0]->state, "ready") || \ strcasecmp(reqstatp->fileStatuses->__ptr[1]->state, "ready") ) ) { \ printf("[?]\tstates = %s %s\n", \ reqstatp->fileStatuses->__ptr[0]->state, \ reqstatp->fileStatuses->__ptr[1]->state); \ somebug = 1; \ return 1; \ } \ \ /* now the request status is ready, let's proceed */ \ n = reqstatp->fileStatuses->__size; \ filestatuses = malloc (n * sizeof(struct srm_filestatus)); \ //f = reqstatp->fileStatuses->__ptr; \ f = (*reqstatp->fileStatuses->__ptr); \ fs = filestatuses; \ for (i = 0; i < n; i++) { \ if ((f+i)->SURL && (fs->surl = strdup ((f+i)->SURL)) == NULL) \ somebug = 1; \ if ((f+i)->state) { \ if (strcmp ((f+i)->state, "Pending") == 0 || \ strcmp ((f+i)->state, "pending") == 0) \ fs->status = 0; \ else if (strcmp ((f+i)->state, "Failed") == 0 || \ strcmp ((f+i)->state, "failed") == 0) \ fs->status = -1; \ else \ fs->status = 1; \ } \ fs->fileid = (f+i)->fileId; \ if ((f+i)->TURL && (fs->turl = strdup ((f+i)->TURL)) == NULL) \ somebug = 1; \ fs++; \ } \ \ PRINTF("[+]\tCalling check_request_file_status_consistency()\n"); \ check_request_file_status_consistency(reqstatp, current_command, argv); /* macros used to set file status */ /* GG on SRM server ? */ #define set_file_status(status) \ PRINTF("[+]\t\tCalled set_file_status() with %s (fileId %d)\n", status, p->__ptr[i]->fileId); \ if (soap_call_ns5__setFileStatus (&soap, srm_endpoint, "setFileStatus", \ reqid, p->__ptr[i]->fileId, \ status, &outs)){ \ soap_print_fault (&soap, stderr); \ somebug = 1; \ return 1; \ \ }\ \ memset (&outq, 0, sizeof(struct ns5__getRequestStatusResponse));\ if (soap_call_ns5__getRequestStatus (&soap, srm_endpoint, \ "getRequestStatus", reqid, &outq)) { \ soap_print_fault (&soap, stderr); \ somebug = 1; \ return 1; \ } \ reqstatp = outq._Result; \ PRINTF("[+]\tCalling check_request_file_status_consistency()\n");\ check_request_file_status_consistency(reqstatp, current_command, argv);\ if (strcasecmp(reqstatp->fileStatuses->__ptr[i]->state, status)){\ PRINTF("[!]\t\tReturned state %s differs from %s (which was set)\n", \ reqstatp->fileStatuses->__ptr[i]->state, status);\ somebug = 1;\ } int parsesurl (const char *surl, char **endpoint, char **sfn) { int len; int lenp; char *p; static char srm_ep[1024]; if (strncmp (surl, "srm://", 6)) { errno = EINVAL; return (-1); } if (p = strstr (surl + 6, "?SFN=")) { *sfn = p + 5; } else if (p = strchr (surl + 6, '/')) { *sfn = p; } else { errno = EINVAL; somebug = 1; return (-1); } #ifdef GFAL_SECURE strcpy (srm_ep, "https://"); lenp = 8; #else strcpy (srm_ep, "http://"); lenp = 7; #endif len = p - surl - 6; if (lenp + len >= sizeof(srm_ep)) { errno = EINVAL; return (-1); } strncpy (srm_ep + lenp, surl + 6, len); *(srm_ep + lenp + len) = '\0'; if (strchr (srm_ep + lenp, '/') == NULL) { if (strlen (SRM_EP_PATH) + lenp + len >= sizeof(srm_ep)) { errno = EINVAL; somebug = 1; return (-1); } strcat (srm_ep, SRM_EP_PATH); } *endpoint = srm_ep; return (0); } int gsiftp_copy_out(char *src, char *dest) { char command[1024]; int ret; //sprintf(command, "./my_gsiftp_out.sh %s %s\n", src, sprintf(command, "my_gsiftp_out.sh %s %s\n", src, dest); PRINTF("%s\n", command); ret = system(command); ret = WEXITSTATUS(ret); if (ret != 0){ PRINTF("[!]\tgsiftp copy failed!!"); somebug = 1; return 1; } return 0; } int gsiftp_copy_in(char *src, char *dest) { char command[1024]; int ret; //sprintf(command, "./my_gsiftp_in.sh %s %s\n", src, sprintf(command, "my_gsiftp_in.sh %s %s\n", src, dest); PRINTF("%s\n", command); ret = system(command); ret = WEXITSTATUS(ret); if (ret != 0){ PRINTF("[!]\tgsiftp copy failed!!"); somebug = 1; return 1; } return 0; } int rfio_copy_out(char *src, char *dest) { char command[512]; int ret; //sprintf(command, "./my_rfcp_out.sh %s %s\n", src, sprintf(command, "my_rfcp_out.sh %s %s\n", src, dest); PRINTF("%s\n", command); ret = system(command); ret = WEXITSTATUS(ret); if (ret != 0){ PRINTF("[!]\trfio copy failed!!"); somebug = 1; return 1; } return 0; } int rfio_copy_in(char *src, char *dest) { char command[512]; int ret; //sprintf(command, "./my_rfcp_in.sh %s %s\n", src, sprintf(command, "my_rfcp_in.sh %s %s\n", src, dest); PRINTF("%s\n", command); ret = system(command); ret = WEXITSTATUS(ret); if (ret != 0){ PRINTF("[!]\trfio copy failed!!"); somebug = 1; return 1; } return 0; } int dcap_copy_out(char *src, char *dest) { char command[512]; int ret; //sprintf(command, "./my_dccp_out.sh %s %s\n", src, sprintf(command, "my_dccp_out.sh %s %s\n", src, dest); PRINTF("%s\n", command); ret = system(command); ret = WEXITSTATUS(ret); if (ret != 0){ PRINTF("[!]\tdcap copy failed!!"); somebug = 1; return 1; } return 0; } int dcap_copy_in(char *src, char *dest) { char command[512]; int ret; //sprintf(command, "./my_dccp_in.sh %s %s\n", src, sprintf(command, "my_dccp_in.sh %s %s\n", src, dest); PRINTF("%s\n", command); ret = system(command); ret = WEXITSTATUS(ret); if (ret != 0){ PRINTF("[!]\tdcap copy failed!!"); somebug = 1; return 1; } return 0; } /* this handles communication with SRM server in case of * getFileMetaData request * * the second parameter indicates which file (in case of multiple files * per request) is caller interested into */ /* returns pointer to received structure, caller should check * the values against uploaded file */ struct ns1__FileMetaData **request_get_file_metadata(char **argv, int i) { /* we need the structure static, because caller wants to access it */ static struct ns5__getFileMetaDataResponse out; struct ArrayOfstring surlarray; char *srm_endpoint, *sfn; struct ns1__FileMetaData **p; // Missing same cross-check for argv[3] ? if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return NULL; } init_get_file_metadata_request(); p = out._Result->__ptr; /* FIXME specification doesn't say which fields are mandatory and * which are not :/ */ PRINTF("\t======== metadata dump begin =========\n"); // for (i=0; i < out._Result->__size; i++){ if (p[i]->SURL){ PRINTF("\tSURL: %s\n", p[i]->SURL); if (strcasecmp(p[i]->SURL, argv[i+2])){ PRINTF("\t[!] returned SURL and requested SURL don't match!\n"); somebug = 1; } } else { PRINTF("\t[?] SURL was not set\n"); SURL_was_not_set++; } if (p[i]->permMode >= 0){ PRINTF("\t[+] permMode: %o\n", p[i]->permMode); } else PRINTF("\t[?] permMode was not set\n"); if (p[i]->checksumType){ PRINTF("\t[+] checksumType: %s\n", p[i]->checksumType); } else PRINTF("\t[?] checksumType was not set\n"); if (p[i]->owner){ PRINTF ("\t[+] owner = %s\n", p[i]->owner); } else PRINTF ("\t[?] owner was not set\n"); if (p[i]->group) { printf ("\t[+] group = %s\n", p[i]->group); } else PRINTF ("\t[?] group was not set\n"); if (p[i]->size >= 0) { PRINTF ("\t[+] size = %lld\n", p[i]->size); } else PRINTF ("\t[?] size was negative\n"); if (p[i]->isPinned == true_) { PRINTF("\t[+] the file is pinned\n"); } else PRINTF("\t[+] the file is not pinned\n"); if (p[i]->isPermanent == true_) { PRINTF("\t[+] the file is permanent\n"); } else PRINTF("\t[+] the file is not permanent\n"); if (p[i]->isCached == true_) { PRINTF("\t[+] the file is cached\n"); } else PRINTF("\t[+] the file is not cached\n"); // } PRINTF("\t======== metadata dump end =========\n"); return p+i; } /* this handles communication with SRM server in case of PUT request * and also copies file to TURL received from server * */ int request_push(char **argv) { int flags; int nbproto = 0; int ret; struct ns5__setFileStatusResponse outs; struct ns5__putResponse out; struct ns5__getRequestStatusResponse outq; char command[1024]; /* ugly */ char rfcp_file[1024]; /* ugly */ char *rfcp_file_p; /* static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "dcap", #endif #if GFAL_ENABLE_GSIFTP "gsiftp" #endif "" }; */ char *protocols[2]; int r = 0, i; struct ns1__RequestStatus *reqstatp; struct ArrayOfRequestFileStatus *p; char *sfn; struct ArrayOflong *sizearray; struct ArrayOfstring *srcarray; struct ArrayOfstring *surlarray; struct ArrayOfboolean *permarray; struct ArrayOfstring protoarray; char ** ptr; char *srm_endpoint; //struct ns1__RequestFileStatus **f; struct ns1__RequestFileStatus *f; struct srm_filestatus *filestatuses; struct srm_filestatus *fs; int n; enum xsd__boolean perm_tmp_arr[2]; LONG64 size_tmp_arr[2]; //enum xsd__boolean size_tmp_arr[2]; strcpy(current_command, "put"); if (transfer_method == METHOD_RFIO) protocols[0] = "rfio"; if (transfer_method == METHOD_GSIFTP) protocols[0] = "gsiftp"; if (transfer_method == METHOD_DCAP) protocols[0] = "gsidcap"; protocols[1] = ""; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 1; } if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 1; } //PRINTF ("[GG0]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); init_put_request(); PRINTF ("[+]\tsoap_call_ns5__put returned reqid: %d %x\n", reqid, reqid); PRINTF ("[GG1]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); /* loop while the file is pending */ loop_while_pending(); PRINTF ("[GG2]\tsoap_call_ns5__put returned reqstatp->state: %s\n", reqstatp->state); /* let's roll */ p = reqstatp->fileStatuses; for (i = 0; i< p->__size; i++){ PRINTF ("[+]\tfileid %d, request state %s\n[+]\tTURL = %s\n", p->__ptr[i]->fileId, p->__ptr[i]->state, p->__ptr[i]->TURL); /* update the status to running */ PRINTF ("[+]\tUpdating status to Running\n"); set_file_status("Running"); if (i == 0){ if (transfer_method == METHOD_GSIFTP) { PRINTF("[+]\tPerforming gsiftp copy from %s to %s\n", testfilename1, p->__ptr[i]->TURL); ret = gsiftp_copy_out(testfilename1, p->__ptr[i]->TURL); } if (transfer_method == METHOD_RFIO) { PRINTF("[+]\tPerforming rfio copy from %s to %s\n", testfilename1, p->__ptr[i]->TURL); ret = rfio_copy_out(testfilename1, p->__ptr[i]->TURL); } if (transfer_method == METHOD_DCAP) { PRINTF("[+]\tPerforming dcap copy from %s to %s\n", testfilename1, p->__ptr[i]->TURL); ret = dcap_copy_out(testfilename1, p->__ptr[i]->TURL); } } else { if (transfer_method == METHOD_GSIFTP) { PRINTF("[+]\tPerforming gsiftp copy from %s to %s\n", testfilename2, p->__ptr[i]->TURL); ret = gsiftp_copy_out(testfilename2, p->__ptr[i]->TURL); } if (transfer_method == METHOD_RFIO) { PRINTF("[+]\tPerforming rfio copy from %s to %s\n", testfilename2, p->__ptr[i]->TURL); ret = rfio_copy_out(testfilename2, p->__ptr[i]->TURL); } if (transfer_method == METHOD_DCAP) { PRINTF("[+]\tPerforming dcap copy from %s to %s\n", testfilename2, p->__ptr[i]->TURL); ret = dcap_copy_out(testfilename2, p->__ptr[i]->TURL); } } if (ret != 0){ PRINTF("[+]\tUpdating status to Failed\n"); set_file_status("Failed"); somebug = 1; ret = 1; } else { PRINTF("[+]\tFile copied successfully to %s\n", p->__ptr[i]->TURL); PRINTF("[+]\tUpdating status to Done ...\n"); set_file_status("Done"); } } fflush(stdout); return 0; } int request_pull(char **argv) { char command[512]; /* ugly */ int ret, i; struct ns5__getResponse out; struct ns5__getRequestStatusResponse outq; struct ns5__setFileStatusResponse outs; struct ArrayOfRequestFileStatus *p; //struct ns1__RequestFileStatus **f; struct ns1__RequestFileStatus *f; struct srm_filestatus *filestatuses; struct srm_filestatus *fs; /* static char *protocols[] = { #if GFAL_ENABLE_RFIO "rfio", #endif #if GFAL_ENABLE_DCAP "dcap", #endif #if GFAL_ENABLE_GSIFTP "gsiftp", #endif "" }; */ char *protocols[2]; int r = 0; int n; struct ns1__RequestStatus *reqstatp; char *sfn; char *srm_endpoint; struct ArrayOfstring *surlarray; struct ArrayOfstring protoarray; strcpy(current_command, "get"); if (transfer_method == METHOD_RFIO) protocols[0] = "rfio"; if (transfer_method == METHOD_GSIFTP) protocols[0] = "gsiftp"; if (transfer_method == METHOD_DCAP) protocols[0] = "gsidcap"; protocols[1] = ""; if (parsesurl (argv[2], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 1; } if (parsesurl (argv[3], &srm_endpoint, &sfn) < 0) { perror ("parsesurl"); somebug = 1; return 1; } init_get_request(); PRINTF ("[+]\tsoap_call_ns5__get returned reqid: %x\n", reqid); PRINTF ("[GG1]\tsoap_call_ns5__get returned reqstatp->state: %s\n", reqstatp->state); /* now wait for change from pending state */ loop_while_pending(); PRINTF ("[GG2]\tsoap_call_ns5__get returned reqstatp->state: %s\n", reqstatp->state); /* let's roll */ p = reqstatp->fileStatuses; for (i = 0; i< p->__size; i++){ PRINTF ("[+]\tfileid %d, request state %s\n[+]\tTURL = %s\n", p->__ptr[i]->fileId, p->__ptr[i]->state, p->__ptr[i]->TURL); /* update the status to running */ PRINTF ("[+]\tUpdating status to Running\n"); set_file_status("Running"); if (i == 0){ if (transfer_method == METHOD_GSIFTP) { PRINTF("[+]\tPerforming gsiftp copy from %s to %s\n", p->__ptr[i]->TURL, testfilename1); ret = gsiftp_copy_in(p->__ptr[i]->TURL, testfilename1); } if (transfer_method == METHOD_RFIO) { PRINTF("[+]\tPerforming rfio copy from %s to %s\n", p->__ptr[i]->TURL, testfilename1); ret = rfio_copy_in(p->__ptr[i]->TURL, testfilename1); } if (transfer_method == METHOD_DCAP) { PRINTF("[+]\tPerforming dcap copy from %s to %s\n", p->__ptr[i]->TURL, testfilename1); ret = dcap_copy_in(p->__ptr[i]->TURL, testfilename1); } } else { if (transfer_method == METHOD_GSIFTP) { PRINTF("[+]\tPerforming gsiftp copy from %s to %s\n", p->__ptr[i]->TURL, testfilename2); ret = gsiftp_copy_in(p->__ptr[i]->TURL, testfilename2); } if (transfer_method == METHOD_RFIO) { PRINTF("[+]\tPerforming rfio copy from %s to %s\n", p->__ptr[i]->TURL, testfilename2); ret = rfio_copy_in(p->__ptr[i]->TURL, testfilename2); } if (transfer_method == METHOD_DCAP) { PRINTF("[+]\tPerforming dcap copy from %s to %s\n", p->__ptr[i]->TURL, testfilename2); ret = dcap_copy_in(p->__ptr[i]->TURL, testfilename2); } } if (ret != 0){ PRINTF("[+]\tUpdating status to Failed\n"); set_file_status("Failed"); somebug = 1; ret = 1; } else { PRINTF("[+]\tFile copied successfully\n"); PRINTF("[+]\tUpdating status to Done ...\n"); set_file_status("Done"); } } fflush(stdout); return 0; } int main(int argc, char **argv) { char command[1024]; struct ns1__FileMetaData **metadata; int ret = 0; #ifdef DEBUG printf("[+] srm_testsuite %s starting, compiled in verbose mode\n", VERSION); #else printf("[+] srm_testsuite %s starting, compiled in quiet mode\n", VERSION); #endif fflush(stdout); if (argc != 4) { fprintf (stderr, "[!] usage: %s [rfio|gsiftp|dcap] SURL SURL\n", argv[0]); return 1; } if ((strcmp(argv[1],"rfio") != 0) && (strcmp(argv[1], "gsiftp") != 0) && (strcmp(argv[1], "dcap") != 0)) { fprintf (stderr, "[!] usage: %s [rfio|gsiftp|dcap] SURL SURL\n", argv[0]); return 1; } if (!strcmp(argv[1], "rfio")) transfer_method = METHOD_RFIO; if (!strcmp(argv[1], "gsiftp")) transfer_method = METHOD_GSIFTP; if (!strcmp(argv[1], "dcap")) transfer_method = METHOD_DCAP; soap_init(&soap); #ifdef GFAL_SECURE flags = CGSI_OPT_DISABLE_NAME_CHECK; soap_register_plugin_arg (&soap, client_cgsi_plugin, &flags); #endif /* first, ping the server * FIXME this is not in specification (?) */ PRINTF("[+] Calling request_ping()\n"); ret = request_ping(argv); if (ret == 1){ PRINTF("[+] request_ping() failed, no use to try more\n"); somebug = 1; goto out; } /* ugly */ strcpy(testfilename1,"TESTFILE"); strcpy(testfilename2,"TESTFILE2"); /* * 1) create file (done by wrapper) * 2) upload * 3) get it back to file.x * 4) modify it and cp to file.x.y * 5) overwrite through SRM on server * 6) get it back as file.x.y.y */ /* the file management GET/PUT tests */ /* pin and upload the file */ /* Jiri's version, does not work PRINTF("[+] Calling request_pin()\n"); ret = request_pin(argv); if (ret == 1){ PRINTF("[!] request_pin() failed, but this is not too critical, going on\n"); } */ PRINTF("[+] Calling request_push()\n"); ret = request_push(argv); if (ret == 1) { PRINTF("[!] request_push() failed, no use to try more\n"); somebug = 1; goto out; } /* moved by GG, but not successfully */ #ifdef RPIN PRINTF("[+] Calling request_pin()\n"); ret = request_pin(argv); if (ret == 1){ PRINTF("[!] request_pin() failed, but this is not too critical, going on\n"); } #endif /* now check through getFileMetaData if it is OK */ PRINTF("[+] Calling request_getFileMetaData(0)\n"); metadata = request_get_file_metadata(argv, 0); if (metadata) { check_metadata_consistency(metadata, testfilename1, PINNED); } else { PRINTF("[!] request_getFileMetaData(0) failed\n"); somebug = 1; } PRINTF("[+] Calling request_getFileMetaData(1)\n"); metadata = request_get_file_metadata(argv, 1); if (metadata) { check_metadata_consistency(metadata, testfilename2, PINNED); } else { PRINTF("[!] request_getFileMetaData(1) failed\n"); somebug = 1; } /* get it back to .x */ strcat(testfilename1, ".x"); strcat(testfilename2, ".x"); PRINTF("[+] Calling request_pull()\n"); ret = request_pull(argv); if (ret == 1){ PRINTF("[!] request_pull() failed, no use to try more\n"); somebug = 1; goto out; } /* 2nd try by GG */ #ifdef RPIN PRINTF("[+] Calling GG request_pin() for both files.x, after request_pull\n"); ret = request_pin(argv); if (ret == 1){ PRINTF("[!] request_pin() failed, but this is not too critical, going on\n"); } #endif /* now check through getFileMetaData if it is OK */ PRINTF("[+] Calling request_getFileMetaData()\n"); metadata = request_get_file_metadata(argv, 0); if (metadata) { check_metadata_consistency(metadata, testfilename1, PINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } PRINTF("[+] Calling request_getFileMetaData()\n"); metadata = request_get_file_metadata(argv, 1); if (metadata) { check_metadata_consistency(metadata, testfilename2, PINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } sprintf(command, "cp -p %s %s.y", testfilename1, testfilename1); system(command); sprintf(command, "cp -p %s %s.y", testfilename2, testfilename2); system(command); strcat(testfilename1, ".y"); strcat(testfilename2, ".y"); sprintf(command, "echo 'ADDED' >> %s", testfilename1); /* FIXME this can also fail */ system(command); sprintf(command, "echo 'ADDED' >> %s", testfilename2); /* FIXME this can also fail */ system(command); /* now the file will be uploaded back. We'll modify the SURL in * last byte, since SRM implementation doesn't allow overwriting * (while castor SRM handles it, dCache SRM does not) * This is nasty, but works, as far as we have control over the * SURL format. */ argv[2][strlen(argv[2])-1] = 'X'; argv[3][strlen(argv[3])-1] = 'X'; PRINTF("[+] Calling request_push()\n"); ret = request_push(argv); if (ret == 1){ PRINTF("[!] request_push() failed, no use to try more\n"); somebug = 1; goto out; } /* again check through getFileMetaData if it is OK */ PRINTF("[+] Calling request_getFileMetaData()\n"); metadata = request_get_file_metadata(argv, 0); if (metadata) { check_metadata_consistency(metadata, testfilename1, PINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } metadata = request_get_file_metadata(argv, 1); if (metadata) { check_metadata_consistency(metadata, testfilename2, PINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } /* get it back to .x.y.y and unpin it */ strcat(testfilename1, ".y"); strcat(testfilename2, ".y"); PRINTF("[+] Calling request_pull()\n"); ret = request_pull(argv); if (ret == 1){ PRINTF("[!] request_pull() failed, no use to try more\n"); somebug = 1; goto out; } #ifdef RPIN PRINTF("[+] Calling request_unpin()\n"); ret = request_unpin(argv, reqid); if (ret == 1){ PRINTF("[!] request_unpin() failed, but this is not too critical, going on\n"); } #endif /* now check through getFileMetaData if it is OK * especially if the file is unpinned */ PRINTF("[+] Calling request_getFileMetaData()\n"); metadata = request_get_file_metadata(argv, 0); if (metadata) { check_metadata_consistency(metadata, testfilename1, UNPINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } metadata = request_get_file_metadata(argv, 1); if (metadata) { check_metadata_consistency(metadata, testfilename2, UNPINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } /* request_advisoryDelete Test */ ret = request_advisoryDelete(argv, 0); if (ret == 1){ PRINTF("[!] request_advisoryDelete(0) failed, but this is not too critical, going on\n"); } /* ret = request_advisoryDelete(argv, 1); if (ret == 1){ PRINTF("[!] request_advisoryDelete(1) failed, but this is not too critical, going on\n"); } */ SURL_was_not_set = 0; PRINTF("[+] Calling request_getFileMetaData() after request_advisoryDelete for %s \n", argv[2]); metadata = request_get_file_metadata(argv, 0); /* if (metadata) { check_metadata_consistency(metadata, testfilename1, UNPINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } */ PRINTF("[+] Calling request_getFileMetaData() after request_advisoryDelete for %s \n", argv[3]); metadata = request_get_file_metadata(argv, 1); /* if (metadata) { check_metadata_consistency(metadata, testfilename2, UNPINNED); } else { PRINTF("[!] request_getFileMetaData() failed\n"); somebug = 1; } */ if ( SURL_was_not_set != 1 ) { PRINTF("[!] request_advisoryDelete() failed: %d\n", SURL_was_not_set); somebug = 1; } /* now it is up to the wrapping script above us to test * if original and .x are the same, and .x and .x.y.y differ */ /* the remaining methods are advisoryDelete and mkPermanent. As * both of these methods are not required to be supported by SRM, * it's not worth testing them, because noone can know if it failed * because 'not supported' or because 'bug'. */ soap_end(&soap); /* this is the only exit point. we return the global flag * to wrapping scipt, to indicate him if everything went flawlessly * or not */ printf("[%s] srm_testsuite finished, bug(s) %sencountered\n", somebug == 1 ? "!" : "+", somebug == 1 ? "" : "not "); out: return somebug; } lcgdm-1.8.7/test/srmv1/typemap.dat0000644000175000017500000000014410647435054016364 0ustar ellertellertxsd__dateTime = | char * | char * ns1 = "http://www.themindelectric.com/package/diskCacheV111.srm/" lcgdm-1.8.7/test/srmv1/srmv1Suite0000755000175000017500000002104710717450012016215 0ustar ellertellert#!/bin/bash # # This script is a part of SRM test suite. It is a wrapper around the main # srm_test binary, calling it with apropriate args, checking output, # diffing the resulting files and notifying user about result. # # Written by Jiri Kosina # Modified/Improved/Updated by GG (Gilbert.Grosdidier@cern.ch) # Last rev: 27/12/2006 (GG) + 16/11/2007 # # $Id: srmv1Suite,v 1.14 2007/11/17 02:20:58 grodid Exp $ ## Comments by GG ## Required: ## - Grid proxy ## - srmv1 server running on target machine UNDER ROOT ## > setenv GRIDMAPDIR /etc/grid-security/gridmapdir/ ## > setenv GRIDMAP /etc/grid-security/grid-mapfile ## > limit coredumpsize unlimited ## > /afs/cern.ch/project/gd/grodid/DPM-MYSQL-RH73/srmv1/srmv1 -c /afs/cern.ch/user/g/grodid/private/PROC/procps-3.2.3/dpns_lxb1901.config -l /var/tmp/grodid/logs/srmv1.log ## - NO $DPNS/DPM_HOST vars ## - settings: machine, protocol ## Usage: $0 targetNode userName protocol target=$1 tstNAME=$2 proto=$3 sfile=$4 subTree=$5 ##BADsite_domain=`echo $target | perl -pe 's/(\w*?)\.(.*)/$2/'` site_domain=`echo $target | perl -pe 's/([-\w]*?)\.(.*)/$2/'` # uhm ... let's clean this sometime :) ##export PATH=/opt/lcg/bin:/opt/globus/bin:/opt/globus/sbin:/opt/edg/bin:/usr/local/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/cern/pro/bin:/opt/gpt/sbin:/usr/java/j2sdk1.4.1_01/bin:/software/j2re1.3.1/bin:/opt/edg/bin:/opt/edg/sbin:/opt/edg/bin:/opt/edg/sbin:$PATH export PATH=$PATH:/opt/lcg/bin:/opt/globus/bin:/opt/globus/sbin:/opt/edg/bin:/usr/local/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/cern/pro/bin:/opt/gpt/sbin:/usr/java/j2sdk1.4.1_01/bin:/software/j2re1.3.1/bin:/opt/edg/bin:/opt/edg/sbin:/opt/edg/bin:/opt/edg/sbin ## Implies that in standalone mode, we run it from test/srmv1 directory ## Not really required: PATH redefined for rfcp in my_rfcp_in.sh & my_rfcp_out.sh ## Not valid any more export PATH=../../rfio:$PATH # which protocol [gsiftp/gftp/rfio/(gsi)dcap] PROTO=gsiftp PROTO=gftp #PROTO=rfio #PROTO=dcap PROTO=$proto if [ "$PROTO" = "gftp" ] then PROTO=gsiftp fi if [ "$VOTEAM"X = "X" ] then voteam="dteam" else voteam=$VOTEAM fi # this for castortest SURL=srm://castorgridtest.cern.ch:8443//castor/cern.ch/grid/dteam/srm_test_suite_file.$$.$RANDOM # this for castorgrid SURL=srm://castorgrid.cern.ch:8443//castor/cern.ch/grid/dteam/srm_test_suite_file.$$.$RANDOM # this for lxb1909 (Castor - 1760 SURL=srm://lxb1909.cern.ch:8443//castor/cern.ch/home/dteam/srm_test_suite_file.$$.$RANDOM SURL=srm://lxb1760.cern.ch:8443//castor/cern.ch/home/dteam/srm_test_suite_file.$$.$RANDOM # this for dcache at lxb1753 (dCache #SURL=srm://lxb1753.cern.ch:8443//pnfs/cern.ch/data/dteam/srm_test_suite_file.$$.$RANDOM #BADSURL=srm://lxb1753.cern.ch:8443//pnfs/cern.ch/data/srm_test_suite_file.$$.$RANDOM # this for dcache at lxn1180 (dCache #SURL=srm://lxn1180.cern.ch:8443//pnfs/cern.ch/data/dteam/srm_test_suite_file.$$.$RANDOM # this for dcache at lxb0740 (dCache #SURL=srm://lxb0740.cern.ch:8443//pnfs/cern.ch/data/dteam/srm_test_suite_file.$$.$RANDOM # this for dpm at lxb1901 (GG machine ... - not GSIFTP enabled yet SURL=srm://lxb1901.cern.ch:8443//dpm/dteam/grodid/srm_test_suite_file.$$.$RANDOM SURL=srm://${target}:8443//dpm/dteam/grodid/srm_test_suite_file.$$.$RANDOM ##SURL=srm://${target}:8443//dpm/dteam/grodid/otherdir/srm_test_suite_file.$$.$RANDOM # this for dpm at lxb1727, lxb1904, lxgate22 (GG machines ... if [ "$subTree"X = "X" ] then SURL=srm://${target}:8443//dpm/${site_domain}/home/${voteam}/srmv1_Tfile.$$.$RANDOM SURL=srm://${target}:8443//dpm/${site_domain}/home/${voteam}/srmv1_Tfile.${sfile}.$RANDOM else SURL=srm://${target}:8443//dpm/${site_domain}/home/${voteam}/${subTree}/srmv1_Tfile.$$.$RANDOM SURL=srm://${target}:8443//dpm/${site_domain}/home/${voteam}/${subTree}/srmv1_Tfile.${sfile}.$RANDOM fi # this for dpm at lxb0732 (JPB machine ... srmv1 ? RH73 - not GSIFTP enabled yet ? #SURL=srm://lxb0732.cern.ch:8443//dpm/dteam/grodid/srm_test_suite_file.$$.$RANDOM # this for dpm at lxb0739 (Classic - 1767 - CANNOT work - not SRM enabled ! #SURL=srm://lxb0739.cern.ch:8443//dpm/dteam/grodid/srm_test_suite_file.$$.$RANDOM case "$target" in # this for castorgrid castor) SURL=srm://castorgrid.cern.ch:8443//castor/cern.ch/grid/dteam/srm_test_suite_file.$$.$RANDOM;; # this for lxb1909 (Castor - 1760 lxb1909) SURL=srm://lxb1909.cern.ch:8443//castor/cern.ch/home/dteam/srm_test_suite_file.$$.$RANDOM;; lxb1760) SURL=srm://lxb1760.cern.ch:8443//castor/cern.ch/home/dteam/srm_test_suite_file.$$.$RANDOM;; # this for dcache at lxb1753 (dCache - 0740 lxb1753) SURL=srm://lxb1753.cern.ch:8443//pnfs/cern.ch/data/dteam/srm_test_suite_file.$$.$RANDOM;; lxb0740) SURL=srm://lxb0740.cern.ch:8443//pnfs/cern.ch/data/dteam/srm_test_suite_file.$$.$RANDOM;; esac ##### this for castorgrid ####if [ "$target" = "castor" ] #### SURL=srm://castorgrid.cern.ch:8443//castor/cern.ch/grid/dteam/srm_test_suite_file.$$.$RANDOM #### ##### this for lxb1909 (Castor - 1760 ####if [ "$target" = "lxb1909" ] #### SURL=srm://lxb1909.cern.ch:8443//castor/cern.ch/home/dteam/srm_test_suite_file.$$.$RANDOM #### ##echo "[++]" ./$SRM_TEST $PROTO $SURL $SURL2 ##exit 0 SURL2=$SURL.SECOND_FILE BUG=0 SRM_TEST=srm_test SRM_TEST=srm_testjiri_26 SRM_TEST=srm_testJiri /bin/rm -f TESTFILE* /bin/rm -f OUTPUT # create file that would be used echo "This is my test file." > TESTFILE echo "This is my test file2." > TESTFILE2 #cp -p /boot/vmlinux-2.4.21-20.0.1.EL.cernsmp TESTFILE2 ##GOODcp -p /boot/vmlinux-2.4.21-20.EL.cernsmp TESTFILE2 ##??ln -sb /tmp/grodid/csec_trace.log TESTFILE2 ##GG chmod +x ./my_gsiftp_in.sh ##GG chmod +x ./my_gsiftp_out.sh ##GG chmod +x ./my_rfcp_in.sh ##GG chmod +x ./my_rfcp_out.sh ##GG chmod +x ./my_dccp_in.sh ##GG chmod +x ./my_dccp_out.sh ## echo "[+] ./srm_test" $PROTO $SURL $SURL2 ## chmod +x ./srm_test ## echo "***" ## ./srm_test $PROTO $SURL $SURL2 echo "[+]" ./$SRM_TEST $PROTO $SURL $SURL2 ##GG chmod +x ./$SRM_TEST echo "***" ##GG ./$SRM_TEST $PROTO $SURL $SURL2 $SRM_TEST $PROTO $SURL $SURL2 RETVAL=$? echo "Return value from test suite is $RETVAL" echo "***" if [ $RETVAL -eq 1 ]; then BUG=1 echo "There was some bug(s) during run of test suite." echo "See the output and look for lines beginning with [!]" echo "If error messages follow, this is probably due to previous SRM errors" echo "" echo "However if everything later passes, this doesn't mean that the SRM" echo "implementation is OK - it just means that the files were correctly transmitted" fi # First file BUGF=0 if ( ! [ -f TESTFILE ]; ) then echo "[!] TESTFILE not found!" BUGF=1 fi if ( ! [ -f TESTFILE.x ]; ) then echo "[!] TESTFILE.x not found!" BUGF=1 fi if ( ! [ -f TESTFILE.x.y.y ]; ) then echo "[!] TESTFILE.x.y.y not found!" BUGF=1 fi if ( ! [ $BUGF -eq 1 ]; ) then diff TESTFILE TESTFILE.x > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "[!] #1: Strange differ (diff of TESTFILE and TESTFILE.x)" BUG=1 else echo "[+] #1: PASSED (diff of TESTFILE and TESTFILE.x)" fi # this should differ diff TESTFILE.x TESTFILE.x.y.y > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "[+] #2: PASSED (diff of TESTFILE.x and TESTFILE.x.y.y)" else echo "[!] #2: Strange equality (diff of TESTFILE.x and TESTFILE.x.y.y)" BUG=1 fi diff TESTFILE.x.y TESTFILE.x.y.y > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "[!] #3: Strange differ (diff of TESTFILE.x.y and TESTFILE.x.y.y)" BUG=1 else echo "[+] #3: PASSED (diff of TESTFILE.x.y and TESTFILE.x.y.y)" fi else BUG=1 fi # Second file BUGF=0 if ( ! [ -f TESTFILE2 ]; ) then echo "[!] TESTFILE2 not found!" BUGF=1 fi if ( ! [ -f TESTFILE2.x ]; ) then echo "[!] TESTFILE2.x not found!" BUGF=1 fi if ( ! [ -f TESTFILE2.x.y.y ]; ) then echo "[!] TESTFILE2.x.y.y not found!" BUGF=1 fi if ( ! [ $BUGF -eq 1 ]; ) then diff TESTFILE2 TESTFILE2.x > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "[!] #1: Strange differ (diff of TESTFILE2 and TESTFILE2.x)" BUG=1 else echo "[+] #1: PASSED (diff of TESTFILE2 and TESTFILE2.x)" fi # this should differ diff TESTFILE2.x TESTFILE2.x.y.y > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "[+] #2: PASSED (diff of TESTFILE2.x and TESTFILE2.x.y.y)" else echo "[!] #2: Strange equality (diff of TESTFILE2.x and TESTFILE2.x.y.y)" BUG=1 fi diff TESTFILE2.x.y TESTFILE2.x.y.y > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "[!] #3: Strange differ (diff of TESTFILE2.x.y and TESTFILE2.x.y.y)" BUG=1 else echo "[+] #3: PASSED (diff of TESTFILE2.x.y and TESTFILE2.x.y.y)" fi else BUG=1 fi # final word if [ $BUG -eq 1 ]; then echo "Final result: NOT passed all tests" else echo "Final result: PASSED all tests" fi exit $BUG lcgdm-1.8.7/test/dpm/0000755000175000017500000000000012202120643013704 5ustar ellertellertlcgdm-1.8.7/test/dpm/globalSuite0000755000175000017500000027026210751774035016136 0ustar ellertellert#!/usr/bin/perl -w ########################################################################################## # # globalSuite[.pl] # # A Perl script to test the DPM (all interfaces + more) # # Author: Gilbert Grosdidier, LAL (Universite Paris-Sud, Orsay) # Creation Date: 06/07/2005 # Last rev: 04/02/2008 (GG) # ########################################################################################## ### ### Copyright (C) 2005-2008 by CNRS/IN2P3/LAL ### All rights reserved ### # $Id: globalSuite,v 1.42 2008/02/05 05:46:05 grodid Exp $ use strict; no strict 'refs'; use File::Basename; use Getopt::Long; ## Arg fetching ... my $mach = shift; ##my $many = shift; ##my $label = shift; chomp(my $site_domain = `dnsdomainname`); my $proxyT = shift || "globus"; ## Allowed: globus, voms, vomsR, expired, extern ## Remark: vomsR -> ppdg only; my $certA = shift || "NADA"; ## Allowed: NADA, ppdg, cnrs, cern, lhcb, ops ## Remark: lhcb VO -> ppdg; ops VO -> cern; my $domain = shift || "$site_domain"; my $fmach = "$mach.$domain"; ## Inits ... my $Counter; my $user = $ENV{USER}; my $valinc; my $short = $mach; my $sfile; my $xCount = 0; my $globOK = 0; my $globFD = 0; my $operation; my $dateST; my $command; my $proxyI; my $userI; my @res = (); my @m = (); my @dServer = (); my $dServer0; my $status; my $statusLocal; my $result; my $flat; chomp(my $dday = `date '+%j'`); chomp(my $Dday = `date '+%F'`); chomp(my $Hday = `date '+%H%M%S'`); my $otStart = time(); if ( ! $sfile ) { ##F $Counter = File::CounterFile->new("./CounterFile", 1000+$dday); ##F $valinc = $Counter->inc(); $valinc = "$Hday"; $sfile = "fil$valinc"; print " Counter Start Value: $sfile \n"; } my $statDone = 'Done'; #my $statDone = 'Ready'; my $choiceVO = 'dteam'; my $userD; if ( $certA eq 'NADA' ) { $userD = "$ENV{USER}"; $userI = 'N'; } elsif ( $certA eq 'ppdg' ) { $userD = "$ENV{USER}p"; $userI = 'P'; } elsif ( $certA eq 'cnrs' ) { $userD = "$ENV{USER}c"; $userI = 'C'; } elsif ( $certA eq 'cern' ) { $userD = "$ENV{USER}g"; $userI = 'G'; } elsif ( $certA eq 'lhcb' ) { $userD = "$ENV{USER}l"; $userI = 'L'; $choiceVO = 'lhcb'; } elsif ( $certA eq 'ops' ) { $userD = "$ENV{USER}s"; $userI = 'S'; $choiceVO = 'ops'; } ##Fmy $tempDir = "/tmp/grodid/global/$mach/$sfile"; my $tempDir = "/var/tmp/${userD}/global/$mach/$Dday/$sfile"; my $logFile = "$tempDir/logFile"; system("mkdir -p $tempDir"); print " Printing to: $logFile\n"; my $fhlRef = switchStdouterr($logFile); print " Counter Start Value: $sfile \n"; my $dpmRoot = "/dpm/${domain}/home/$choiceVO"; ##Fmy $pfxPath = "grodid/tglob/S$valinc"; my $pfxPath = "${userD}/tglob/M$mach/D$Dday/H$valinc"; my $endPointV1 = "srm://${fmach}:8443/srm/managerv1?SFN="; my $endPointV2 = "srm://${fmach}:8446/srm/managerv2?SFN="; ## Local proxy creation ... moved down ... ##&CreateProxy(); ## Env Vars ## Alternate (SLC3TB BDII in fact) $ENV{LCG_GFAL_INFOSYS} = "lxb2017.cern.ch:2170"; ##GOODD$ENV{LCG_GFAL_INFOSYS} = "lxb2033.cern.ch:2170"; ## Alternate (RH73TB BDII in fact) ##$ENV{LCG_GFAL_INFOSYS} = "lxb1916.cern.ch:2170"; ## Local GRIS $ENV{LCG_GFAL_INFOSYS} = "$fmach:2135"; chomp(my $lmach = `hostname -s`); if ( $lmach eq 'lxb0728' ) { $ENV{LCG_GFAL_INFOSYS} = "lxb0728.cern.ch:2170"; } if (0) { ##if ( $mach =~ 'lxb1903' || $mach =~ 'lxb5407' ) { if ( $mach eq 'lxb1903' || $mach eq 'lxb5407' ) { $ENV{LCG_GFAL_INFOSYS} = 'lxb0728.cern.ch:2170'; ## For testing Remi's version ... $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/rmollon/usr'; ##$ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal'; $ENV{LD_LIBRARY_PATH} = "$ENV{LCG_LOCATION}/lib:/opt/lcg/lib:/opt/globus/lib:/opt/edg/lib:/usr/local/lib:/usr/local/lib:/usr/local/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib"; } } ## To control use of standard lcg_util version my $stdSwitch = 1; if ($stdSwitch) { # Temporary (?) removal to use default version (20/11/07) ##if ( $mach eq 'lxb1727' || $mach eq 'lxb1921' ) { if ( $mach eq 'lxb1921' || $mach eq 'lxb1917' || $mach eq 'lxb5407' || $mach eq 'lxb1903' || $mach eq 'lxb1727' || $mach eq 'lxb1902' || $mach eq 'lxdpm102' || $mach eq 'lxb2036' || $mach eq 'lxb6132v2' || $mach eq 'lxb0988v2' || $mach eq 'ctb-conf-se' || $mach eq 'ctb-conf-bdii' || $mach eq 'vm02-lxb6121' || $mach eq 'pcitdhs02' ) { ## For testing Remi's version ... $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/rmollon/usr'; ##GOODOLD $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal'; ## $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal-150607'; ##USELESS $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal-260607'; ## $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal-221107'; ## $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal-231107'; ##GOODSLC3 $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/grodid/gfal-dev2/usr'; ###$ENV{LD_LIBRARY_PATH} = "$ENV{LCG_LOCATION}/lib:/opt/lcg/lib:/opt/globus/lib:/opt/edg/lib:/usr/local/lib:/usr/local/lib:/usr/local/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib"; $ENV{LD_LIBRARY_PATH} = "$ENV{LCG_LOCATION}/lib:$ENV{LD_LIBRARY_PATH}"; $ENV{PATH} = "$ENV{LCG_LOCATION}/bin:$ENV{PATH}"; } } if ( $mach eq 'lxb1727' ) { $ENV{LCG_GFAL_INFOSYS} = "$fmach:2135"; } ##if ( $mach eq 'lxb1921' ) { ## 07/05/07 ## 15/11/07 if ( $mach eq 'lxb1921' || $mach eq 'lxb5407' || $mach eq 'lxb1903' || $mach eq 'lxb1727' || $mach eq 'lxb1902' || $mach eq 'lxdpm102' || $mach eq 'lxb6132v2' || $mach eq 'lxb0988v2' || $mach eq 'ctb-conf-se' || $mach eq 'ctb-conf-bdii' || $mach eq 'vm02-lxb6121' || $mach eq 'lxb1917' || $mach eq 'pcitdhs02' ) { $ENV{LCG_GFAL_INFOSYS} = "lxb1903.cern.ch:2135"; } ##if ( $mach eq 'lxb1921' || $mach eq 'lxb1917' || $mach eq 'lxb2036' ) { #if ( $mach eq 'lxb1917' || $mach eq 'lxb2036' ) { if ( $mach eq 'lxb2036' ) { $ENV{LCG_GFAL_INFOSYS} = "lxb2033.cern.ch:2170"; ## $ENV{LCG_GFAL_INFOSYS} = "lxb1917.cern.ch:2170"; } $ENV{DPNS_HOST} = "$fmach"; $ENV{DPM_HOST} = "$fmach"; $ENV{LCG_RFIO_TYPE} = "dpm"; $ENV{LCG_CATALOG_TYPE} = "lfc"; $ENV{LFC_HOME} = "/grid/$choiceVO/nightly/$userD"; $ENV{LFC_HOME} = "/grid/$choiceVO/nightly/$pfxPath"; ## To define LFC_HOST as well ! $ENV{LFC_HOST} = "lfc-dteam-test.cern.ch"; ## NEW:29/08/05 ####$ENV{LFC_HOST} = "lxb0716.cern.ch"; ## SPECIAL:17/11/05 tests Sophie $ENV{LFC_HOST} = "lxb1941.cern.ch"; ## NEW: 10/02/06 MySQL, SLC3TB ##$ENV{LFC_HOST} = "lxb1782.cern.ch"; ## NEW: 03/10/06 Oracle, SLC3TB $ENV{LFC_HOST} = "lxb6129.cern.ch"; ## NEW: 18/01/08 Louis print " Testing DPM server: $fmach ($mach) with LCG_GFAL_INFOSYS: $ENV{LCG_GFAL_INFOSYS} and LFC_HOST: $ENV{LFC_HOST}\n"; ##print " Testing DPM server: $mach with LCG_GFAL_INFOSYS: $ENV{LCG_GFAL_INFOSYS}\n"; ## Path setup ... one must start it from test/dpm for the time being ... ##my $relPath = "/afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-133-n/LCG-DM"; my $relPath = dirname (dirname "$ENV{PWD}"); ##my $relPathLBNL = dirname (dirname "$relPath"); ##$relPathLBNL = "$relPathLBNL/SLC3-CVS-dpm-140-lbnl/LCG-DM/test/srmv2"; my $relPathLBNL = "$relPath/test/srmv2-lbnl"; my $pathStore = $ENV{PATH}; # $ENV{PATH} = "../../rfio:$ENV{PATH}"; ## $ENV{PATH} = "$relPath/rfio:$ENV{PATH}"; $ENV{PATH} = "$relPath/rfio"; $ENV{PATH} = "$ENV{PATH}:$relPath/socket/dpmcli"; $ENV{PATH} = "$ENV{PATH}:$relPath/ns"; $ENV{PATH} = "$ENV{PATH}:$relPath/dpm"; $ENV{PATH} = "$ENV{PATH}:$relPath/test/srmv1"; $ENV{PATH} = "$ENV{PATH}:$relPath/test/srmv2"; $ENV{PATH} = "$ENV{PATH}:$relPath/test/dpm"; $ENV{PATH} = "$ENV{PATH}:$pathStore"; print " Testing DPM server: $fmach ($mach) with LD_LIBRARY_PATH: $ENV{LD_LIBRARY_PATH}\n"; print " Testing DPM server: $fmach ($mach) with PATH: $ENV{PATH}\n"; system("which lcg-gt"); ##Cchdir "/afs/cern.ch/user/g/grodid/public/grid/tar/CVS-tar-0.1.15/localGfalTest"; chdir $tempDir; $ENV{TEMPDIR} = $tempDir; $ENV{VOTEAM} = $choiceVO; if ( $mach eq 'lxb1917' ) { system("mysql_process.sh"); } ## Local proxy creation &CreateProxy(); $sfile = "$sfile" . "$userI" . "$proxyI"; print " Counter Start Value: $sfile \n"; system("env|grep -v 'GSI_'|sort"); system("which rfcp"); system("voms-proxy-info -all"); system("which srm2_testPut"); if (0) { my %vogid = (); my %vonid = (); my %voaid = (); ## Extracting the user/group codes from the remote DPM node PWD/GRP files system("globus-url-copy gsiftp://${mach}.cern.ch/${mach}:/etc/passwd file://$tempDir/${mach}_PWD"); system("globus-url-copy gsiftp://${mach}.cern.ch/${mach}:/etc/group file://$tempDir/${mach}_GRP"); foreach my $grp ( "atlas", "cms", "dteam" ) { my ($auid, $ux, $uid, $gid, $rest) = split /:/, `grep ${grp}006 $tempDir/${mach}_PWD`; $vogid{$grp} = $gid; my ($mode, $ix, $irt, $aid, $nest) = split /\s+/, `dpns-ls -ld /dpm/${site_domain}/home/${grp}`; $voaid{$aid} = $gid; $vonid{$gid} = $aid; print " GRP: $grp, GID: $gid, AID: $aid\n"; } my %duser = (); foreach my $nid ( 1, 4, 5, 6 ) { my ($auid, $ux, $uid, $gid, $rest) = split /:/, `grep dteam00$nid $tempDir/${mach}_PWD`; $duser{$auid} = $uid; $duser{$uid} = $auid; print " DTEAM: AUID: $auid, UID: $uid\n"; } } ##exit 0; XcuteComm("dpm-qryconf", "", "QRY", 1, "S_TYPE", "", "POOL"); foreach ( @res ) { if ( /CAPACITY/ ) { my @m = split /\s+/; if ( $m[3] eq "CAPACITY" && $m[-1] !~ m/RDONLY|DISABLED/ ) { push @dServer, $m[1]; if ( $m[1] ne $fmach ) { $dServer0 = $m[1]; } } } } print(" dServer: $#dServer $dServer0 \n"); ##exit 0; ## Tests vomses ## Management of different message classes for different GridFTP Server versions ... my %gsiftpV = (); my %gsiLsMs= (); $gsiLsMs{'1.12'} = "taken.: No such file or"; $gsiLsMs{'2.3'} = "stat error: No such file or"; $gsiLsMs{'2.7'} = "stat error: No such file or"; my %gsiRmdMs= (); $gsiRmdMs{'1.12'} = "subgDirS1: Directory not"; $gsiRmdMs{'2.3'} = "500 500 Command failed : rmdir error:"; $gsiRmdMs{'2.7'} = "500 500 Command failed : rmdir error:"; my %gsiTrfMs= (); $gsiTrfMs{'1.12'} = "226 Transfer complete"; $gsiTrfMs{'2.3'} = "226 Transfer Complete"; $gsiTrfMs{'2.7'} = "226 Transfer Complete"; ## Detection of the different GridFTP Server versions for the target DPM ... foreach my $serv ( @dServer ) { if ( defined $gsiftpV{$serv} ) { next; } XcuteComm("globus-url-copy", "-dbg file:/etc/group gsiftp://${serv}/${serv}:/dumDUM", "DUM_$serv", 0, "BLOCK", "", "GridFTP Server"); my $vval = $result; #?? my $sval = XtractVal("DUM_$serv: 220 $serv GridFTP Server"); my $sval = XtractVal('^220'); if ( $sval ne $serv ) { exit 1; } $gsiftpV{$sval} = "$vval"; } if ( $ENV{TSRMV22} ) { $ENV{PATH} = "$relPath/test/srmv2.2:$ENV{PATH}"; ## srmv2.2Suite XcuteComm("srmv2Suite", "$fmach 8446 $user $sfile $choiceVO $pfxPath", "SRV22", 0, "OVERALL SUITE =", "[OK]", "SURL ="); # @m = grep /GID4:.*?Done OK/, @res; # @m = split /\s+/, $m[0]; print " srm10: $result\n"; (my $srm10 = $result) =~ s/8446/8443/;; @m = split /\//, $srm10; my $lfn10 = $m[-1]; ## Temporaire tests SSL3 exit 0; } if (1) { XcuteComm("lfc-ping", " ", "LFCPNG", 0, "1.6", "", "BLOB"); XcuteComm("dpns-ping", " ", "DPNSPNG", 0, "1.6", "", "BLOB"); XcuteComm("dpm-ping", " ", "DPMPNG", 0, "1.6", "", "BLOB"); } XcuteComm("dpns-mkdir -p", "$dpmRoot/$pfxPath", "DMKD", 0, "BLOCK", "", "BLOB"); XcuteComm("lfc-mkdir -p", "$ENV{LFC_HOME}", "LMKD", 0, "BLOCK", "", "BLOB"); XcuteComm("dpns-ls -ild", "$dpmRoot/$pfxPath", "LSD", 1, "$dpmRoot/$pfxPath", "", "$dpmRoot/$pfxPath"); if ( "$result" ne "$dpmRoot/$pfxPath" ) { exit 1; } XcuteComm("lfc-ls -ild", "$ENV{LFC_HOME}", "LLSD", 1, "$ENV{LFC_HOME}", "", "BLOB"); ## Investigations : look if the SRMV2 server is an LBNL version (assume default: it is NOT) my $dpmb = "$dpmRoot/$pfxPath/bidon"; my $srmb = "srm://$fmach:8444/$dpmb"; ######my $rstate; my $rstate = 1; if (0) { #XcuteComm("srm2_testPut", # "gutokenbidon 1 0 $srmb 1000 2 8", # "LBNL0", 0, # "HTTP/1.1 500 Internal Server", "Error", # "BLOB"); #if ( $status eq "[OK]" ) { # $ENV{PATH} = "$relPathLBNL:$ENV{PATH}"; # XcuteComm("srm2_testPut", # "gutokenbidon 1 0 $srmb 1000 2 8", # "LBNL1", 1, # "request state", "26", # "BLOB"); #} #} else { if ( $mach eq 'lxb1903notanymore' ) { $rstate = 1; ## kludge for SLC4 testing ... } elsif (1) { XcuteComm("srm2_testPut", "gutokenbidon 1 0 $srmb 1000 2 8", "LBNL0", 0, "BLOCK", "", "HTTP/1.1 500 Internal Server"); if ( $result eq "Error" ) { $ENV{PATH} = "$relPathLBNL:$ENV{PATH}"; XcuteComm("srm2_testPut", "gutokenbidon 1 0 $srmb 1000 2 8", "LBNL1", 0, "BLOCK", "", "request state"); if ( "$result" ne "0" ) { exit 1; } } $rstate = XtractVal('request state'); ##system("dpm-rm $dpmb"); XcuteComm("dpm-rm", "$dpmb", "LBNL2", 1, "request state", "Done", "BLOB"); } } if ( $rstate == 26 ) { $ENV{STAT26} = '26'; $statDone = 'Done'; print STDOUT "\n The (Old) Selected Return Status System is: stat26: $ENV{STAT26} statDone: $statDone \n"; } else { $statDone = 'Ready'; print STDOUT "\n The (New) Selected Return Status System is: stat26: 0 statDone: $statDone \n"; } ##exit 0; ######} my $gfalC = "gfal_test.c"; &createGfalTestC("$gfalC"); if (0) { system("ldapsearch -LLL -H ldap://lxb2033.cern.ch:2170 -x -b 'mds-vo-name=local,o=grid' | grep -E 'GlueSEUniqueID|GlueSEName' | grep -B1 'GlueSEName: CERNDpmTest:' 2>&1 &"); print " System1: $?\n"; system("ldapsearch -LLL -H ldap://$ENV{LCG_GFAL_INFOSYS} -x -b 'mds-vo-name=local,o=grid' | grep -E 'GlueSEUniqueID|GlueSEName' | grep -B1 'GlueSEName: CERNDpmTest:' 2>&1 &"); print " System2: $?\n"; } my $finit1 = "gilb-OLD"; &createGilbOld($finit1, $gfalC); $finit1 = "$tempDir/$finit1"; my $lfn1 = "ggtgloblcgcr$sfile"; system("which lcg-cr"); if (1) { ##Added '-t 20' below for timeouting ... XcuteComm("lcg-cr", "-v -t 20 --vo $choiceVO -d $fmach -l lfn:$lfn1 -P $pfxPath/$lfn1 file:$finit1", "LCR", 0, "Alias registered in Catalog:", "lfn:$ENV{LFC_HOME}/$lfn1", "Destination URL registered in Catalog:"); } else { XcuteComm("lcg-cr", "-v --vo $choiceVO -d $fmach -P $pfxPath/$lfn1 file:$finit1", "LCR", 0, "Alias registered in Catalog:", "", "Destination URL registered in Catalog:"); } my $sfn1 = $result; (my $srm1 = $result) =~ s/sfn/srm/; ## Testing srmv2 interface ... if (1) { ###if ( ! $stdSwitch ) { my $lfnv1 = "ggtglobsrmv1$sfile"; XcuteComm("lcg-cr", "-v -t 20 -D srmv1 --nobdii --vo $choiceVO -d $endPointV1/$dpmRoot/$pfxPath/$lfnv1 -l lfn:$lfnv1 file:$finit1", "LCR", 0, "Alias registered in Catalog:", "lfn:$ENV{LFC_HOME}/$lfnv1", "Destination URL registered in Catalog:"); ###### "-v -t 20 -D srmv2 --vo $choiceVO -d $fmach -l lfn:$lfnv2 -P $pfxPath/$lfnv2 file:$finit1", my $lfnv2 = "ggtglobsrmv2$sfile"; XcuteComm("lcg-cr", "-v -t 20 -D srmv2 --nobdii --vo $choiceVO -d $endPointV2/$dpmRoot/$pfxPath/$lfnv2 -l lfn:$lfnv2 file:$finit1", "LCR", 0, "Alias registered in Catalog:", "lfn:$ENV{LFC_HOME}/$lfnv2", "Destination URL registered in Catalog:"); ###} } if ( "$mach" eq "lxb5407" && ! $ENV{CRON_JOB}) { &dicomTests(); goto EXITE; } ###goto EXITE; ####exit 0; ## SPECIAL tests Invalid XcuteComm("lcg-gt", "$srm1 rfio", "GTR", 0, "rfio", "", "rfio"); my $rTURL = XtractGoodTurl($result); XcuteComm("rfcp", "$rTURL $tempDir/fcrap1r", "TURLr", 0, "seconds through eth", "", "BLOB"); XcuteComm("lcg-gt", "$srm1 gsiftp", "GTF", 0, "gsiftp", "", "gsiftp"); my $fTURL = XtractGoodTurl($result); my @m1 = split '/', $fTURL; XcuteComm("globus-url-copy", "-dbg $fTURL file:$tempDir/fcrap1f", "TURLf", 0, "$gsiTrfMs{$gsiftpV{$m1[2]}}", "", "BLOB"); ## "226 Transfer complete.", "", ##my $gsiftpV = XtractVal('GridFTP Server'); ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSD", 0, "$lfn1", "", "BLOB"); ###goto EXITE; ####exit 0; ## Tests LFC_HOST ... my $rinit2 = "DPMsource.lxb1706"; createDpmSource($rinit2); ##my $finit2 = "file:$ENV{PWD}/$rinit2"; my $finit2 = "file:$tempDir/$rinit2"; my $lfn2 = "ggtglobr$sfile"; ## Direct rfcp ... XcuteComm("rfcp", "$rinit2 $dpmRoot/$pfxPath/$lfn2", "RFCP", 0, "seconds through local", "", "BLOB"); XcuteComm("rfcp", "$dpmRoot/$pfxPath/$lfn2 $tempDir/fcrap2", "FCPR", 0, "seconds through eth", "", "BLOB"); ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSDR", 0, "$lfn2", "", "BLOB"); $xCount++; ####$dServer0 = 'lxb1903.cern.ch'; my $tmach = "$fmach"; #if ( $tmach eq 'lxb1903.cern.ch' ) { ## Special since there is only 1 remote disk server on this DPM node # $tmach = "$dServer0"; # undef $dServer0; #} &rfioSuite("DPM", $tmach); &rfioSuite("NODPM", $tmach); &gsiftpSuite("DPM", $tmach); &gsiftpSuite("NODPM", $tmach); if ( $dServer0 ) { undef $dServer0; &rfioSuite("NODPM", $tmach); &gsiftpSuite("DPM", $tmach); &gsiftpSuite("NODPM", $tmach); } else { $xCount += 3; } ####exit 0; $xCount--; my $lfn3 = "ggtglobf$sfile"; ## Direct globus-url-copy ... XcuteComm("globus-url-copy", "-dbg $finit2 gsiftp://$tmach/$dpmRoot/$pfxPath/$lfn3", "GFTP", 0, "$gsiTrfMs{$gsiftpV{$tmach}}", "", "BLOB"); ## "226 Transfer complete.", "", XcuteComm("globus-url-copy", "-dbg gsiftp://$tmach/$dpmRoot/$pfxPath/$lfn3 file:$tempDir/fcrap3", "FTPG", 0, "$gsiTrfMs{$gsiftpV{$tmach}}", "", "BLOB"); ## "226 Transfer complete.", "", ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSDF", 0, "$lfn3", "", "BLOB"); my $lfn4 = "gfal_Tfile.$sfile"; #PRODGOODPREVmy $srm4 = "srm://$fmach:8443/$dpmRoot/$pfxPath/$lfn4"; ##GOOD1my $srm4 = "srm://$fmach:8446/$dpmRoot/$pfxPath/$lfn4"; my $srm46 = "srm://$fmach:8446/$dpmRoot/$pfxPath/${lfn4}c"; my $srm4v2 = "srm://$fmach/srm/managerv2?SFN=$dpmRoot/$pfxPath/${lfn4}d"; ##GOOD2my $srm4 = "srm://${fmach}/$dpmRoot/$pfxPath/$lfn4"; ##GOOD3my $srm4 = "srm://${fmach}:8443/$dpmRoot/$pfxPath/$lfn4"; my $srm43 = "srm://$fmach:8443/$dpmRoot/$pfxPath/${lfn4}a"; my $srm4v1 = "srm://$fmach/srm/managerv1?SFN=$dpmRoot/$pfxPath/${lfn4}b"; #BAD?my $srm4 = "srm://${fmach}$dpmRoot/$pfxPath/$lfn4"; my $srmv4 = $srm46; ##my $finit4 = "../gftest.gg"; my $finit4 = "gftest.gg"; &createGftest($finit4); ## gfal ... if (0) { my $gfalC = "gfal_test.c"; &createGfalTestC("$gfalC"); } ## For testing Remi's version ... Moved upstream ... ### $ENV{LCG_LOCATION} = '/afs/cern.ch/project/gd/rmollon/usr'; ### $ENV{LD_LIBRARY_PATH} = "$ENV{LCG_LOCATION}/lib:/opt/lcg/lib:/opt/globus/lib:/opt/edg/lib:/usr/local/lib:/usr/local/lib:/usr/local/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib:/opt/glite/lib:/opt/glite/externals/lib:/opt/d-cache/dcap/lib"; ## Testing SRMV1 syntax ... system("gcc -Wall -g -DSRM=1 -I $ENV{LCG_LOCATION}/include -L$ENV{LCG_LOCATION}/lib -lgfal -o gfal_test $gfalC"); ##system("gcc -I /opt/lcg/include -L/opt/lcg/lib -lgfal_pthr -o gilb $gfalC"); XcuteComm("./gfal_test", "-g 4 -D $tempDir -R -W $finit4 $srm43", "GFALa", 0, "srm_get: 3", "", "surl: 3"); ##my $srm4Y = $result; ## "-g 7 -D $tempDir -R -W $finit4 $srm4", ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSDYa", 0, "${lfn4}aYY", "", "BLOB"); XcuteComm("./gfal_test", "-g 4 -D $tempDir -R -W $finit4 $srm4v1", "GFALb", 0, "srm_get: 3", "", "surl: 3"); XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSDYb", 0, "${lfn4}bYY", "", "BLOB"); ###goto EXITE; ## Testing SRMV2 syntax ... ##system("gcc -Wall -g -DSRM=2 -I $ENV{LCG_LOCATION}/include -L$ENV{LCG_LOCATION}/lib -lgfal -o gfal_test $gfalC"); system("gcc -Wall -g -DSRM=2 -D_LARGEFILE64_SOURCE -I $ENV{LCG_LOCATION}/include -L$ENV{LCG_LOCATION}/lib -lgfal -o gfal_test $gfalC"); ##system("gcc -I /opt/lcg/include -L/opt/lcg/lib -lgfal_pthr -o gilb $gfalC"); XcuteComm("./gfal_test", "-g 7 -D $tempDir -R -W $finit4 $srm46", "GFALc", 0, "srm_get: 6", "", "surl: 6"); my $srm4Y = $result; ## "-g 7 -D $tempDir -R -W $finit4 $srm4", ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSDYc", 0, "${lfn4}cYYYY", "", "BLOB"); XcuteComm("./gfal_test", "-g 4 -D $tempDir -R -W $finit4 $srm4v2", "GFALd", 0, "srm_get: 3", "", "surl: 3"); XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath", "LSDYd", 0, "${lfn4}dYY", "", "BLOB"); ## Temporarily (29/03/07) ... Removed 30/03/07. if ( $mach eq 'lxb1903' ) { #### exit 0; } ###goto EXITE; ####exit 0; ## srmv1 tests ... ##Cchdir "/afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-133-n/LCG-DM/test/srmv1"; ## rfio XcuteComm("srmv1Suite", "$fmach $user rfio $sfile $pfxPath", "SV1R", 0, "Final result:", "PASSED", "SURL:"); (my $srm5 = $result) =~ s/_FILX/_FILE/; @m = split /\//, $srm5; my $lfn5 = $m[-1]; ## gsiftp XcuteComm("srmv1Suite", "$fmach $user gsiftp $sfile $pfxPath", "SV1F", 0, "Final result:", "PASSED", "SURL:"); (my $srm6 = $result) =~ s/_FILX/_FILE/; @m = split /\//, $srm6; my $lfn6 = $m[-1]; ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath | grep \"`date '+%b %d'`\" ", "LSD6", 0, "${lfn6}", "", "BLOB"); $srm4Y =~ s/8446/8443/;; ## srm_testget on one of the files created by the Gfal test ($srm4Y) XcuteComm("srm_testget", "$srm4Y", "STGTa", 0, "request state", "$statDone", "TURL ="); my $turl7 = $result; ### This one postponed ... ### $srm4Y =~ s;:8443/;/srm/managerv1?SFN=; ;; ### XcuteComm("srm_testget", ### "$srm4Y", ### "STGTb", 0, ### "request state", "$statDone", ### "TURL ="); ## srmv2 tests ... ##Cchdir "/afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-133-n/LCG-DM/test/srmv2"; ##??chdir "$relPath/test/srmv2"; ## srmv2Suite XcuteComm("srmv2Suite", "$fmach $user $sfile $pfxPath", "SRV2", 0, "OVERALL SUITE =", "[OK]", "BLOB"); @m = grep /GID4:.*?Done OK/, @res; @m = split /\s+/, $m[0]; print " srm8: $m[1]\n"; (my $srm8 = $m[1]) =~ s/8444/8443/;; ##"RSP: soap_call_ns1__srmReserveSpace returned s_token:" my $s_token = XtractVal("RSP2: soap_call_ns1__srmReserveSpace returned s_token:"); print " DPMSTOKEN: $s_token\n"; ## socket tests ... ##Cchdir "/afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-133-n/LCG-DM/test/dpm"; ##??chdir "$relPath/test/dpm"; ## socket XcuteComm("socketSuite", "$fmach $user $sfile $pfxPath $s_token", "SOCK", 0, "OVERALL SUITE =", "[OK]", "BLOB"); @m = grep /GID3:.*?Done OK/, @res; @m = split /\s+/, $m[0]; print " srm9: $m[1]\n"; my $srm9 = $m[1]; $srm9 = "srm://$fmach:8443/$srm9"; @m = split /\//, $srm9; my $lfn9 = $m[-1]; ## srm tests ... ##Cchdir "/afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-133-n/LCG-DM/test/srmv1"; chdir "$tempDir"; ## srm_testget on one of the files created by the srmv2 test ($srm8) XcuteComm("srm_testget", "$srm8", "TGT8", 0, "request state", "$statDone", "TURL ="); my $turl8 = $result; ## srm_testget on one of the files created by the socket test ($srm9) XcuteComm("srm_testget", "$srm9", "TGT9", 0, "request state", "$statDone", "TURL ="); my $turl9 = $result; $ENV{PATH} = "$relPath/test/srmv2.2:$ENV{PATH}"; ## srmv2.2Suite XcuteComm("srmv2Suite", "$fmach 8446 $user $sfile $choiceVO $pfxPath", "SRV22", 0, "OVERALL SUITE =", "[OK]", 'BRGrf: state\[0\] = 0, SRM_SUCCESS, SURL ='); ##OLD "SURL ="); # @m = grep /GID4:.*?Done OK/, @res; # @m = split /\s+/, $m[0]; print " srm10: $result\n"; (my $srm10 = $result) =~ s/8446/8443/;; @m = split /\//, $srm10; my $lfn10 = $m[-1]; ## srm_testget on one of the files created by the srv2.2 test ($srm10) XcuteComm("srm_testget", "$srm10", "TGT10", 0, "request state", "$statDone", "TURL ="); my $turl10 = $result; ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath | grep \"`date '+%b %d'`\" ", "LSD10", 0, "${lfn10}_R3b", "", "BLOB"); if (0) { XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath | grep \"`date '+%b %d'`\" ", "LSD10_b", 0, "${lfn10}".'\$', "", "BLOB"); XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath | grep \"`date '+%b %d'`\" ", "LSD10_c", 0, "${lfn10}\n", "", "BLOB"); } print "\n"; print " turl7: $turl7 \n"; print " turl8: $turl8 \n"; print " turl9: $turl9 \n"; print " turl10: $turl10 \n"; system("ls -l $tempDir"); system("which srm_testget"); # print " OVERALL Score: OK=$globOK FAILED=$globFD\n"; ##my $flat = "@res"; # my @m = split /\s+/, $flat; # my $pool = XtractVal("POOL"); # print " M: ", scalar(@m), " $m[-1] $pool\n"; # if (0) { # XcuteComm("dpns-ls -ld", # "$dpmRoot/$pfxPath", "LSD", "BLOB", 0); # XcuteComm("dpns-ls -l", # "$dpmRoot/$pfxPath", "LSL", "BLOB", 0); # my $finit1 = "$ENV{PWD}/gilb-OLD"; # my $lfn1 = "ggtglob$sfile"; # XcuteComm("lcg-cr", # "-v --vo dteam -d $fmach -l lfn:$lfn1 -P $pfxPath/$lfn1 file:$finit1", # "LCR", 0, # "Alias registered in Catalog:", "lfn:$lfn1", # "Destination URL registered in Catalog:") # } EXITE: print " OVERALL Score: OK=$globOK FAILED=$globFD\n"; ## Keep it to the bottom ... restoreStdouterr($fhlRef); print " OVERALL Score: OK=$globOK FAILED=$globFD\n"; print " Log File available in: $logFile\n"; exit 0; #################################################################################################### sub XcuteComm { $operation = shift; my $cargs = shift; my $label = shift; my $fatalXit = shift; my $trigStat = shift; my $xpectStat = shift; my $trigRslt = shift; if ( ! $statusLocal && "$trigStat" ne "BLOCK") { $xCount++; } my $filter = "| perl -pe 's/\\s+\\d+ bytes.*sec inst//'"; $status = "[UNDEF]"; $result = " "; @res = (); $command = "$operation $cargs"; my $keyP = '++++'; my $keyS = 'STEP'; my $keyO = 'Operation'; my $keyR = 'Result'; if ( $statusLocal ) { $keyP .= '0'; $keyS .= '0'; $keyO .= '0'; $keyR .= '0'; } if ( "$trigStat" eq "BLOCK" ) { $keyP .= 'H'; $keyS .= 'H'; $keyO .= 'H'; $keyR .= 'H'; } chomp($dateST = `date '+%y%m%d-%H%M%S'`); print "\n$keyP $$ $dateST\n"; print " ${keyS}: $xCount OPERATION: $operation CMD: $command\n"; my $tStart; my $tEnd; my $tElapse; if ( ! $ENV{DPM_TESTAREA} ) { ## Normal case ... $tStart = time(); if ( $operation eq "lcg-cr" ) { open RES, "$command 2>&1 $filter |"; } else { open RES, "$command 2>&1 |"; } while ( ) { ## To fit new gridftp reply ... # if ( $_ =~ /^226 Transfer Complete./ ) { $_ = '226 Transfer complete.'; } ## $_ =~ s/Transfer Complete/Transfer complete/; if ( ! /^\s+$|^\.\.\.$/ ) { print "$label: $_"; } push @res, $_; } $tEnd = time(); $tElapse = $tEnd - $tStart; close RES; } else { ## Called from MainScript ... $tStart = time(); if ( $operation eq "lcg-cr" ) { @res = `$command 2>&1 $filter`; } else { @res = `$command 2>&1`; } $tEnd = time(); $tElapse = $tEnd - $tStart; foreach ( @res ) { if ( ! /^\s+$|^\.\.\.$/ ) { print "$label: $_"; } } } $flat = "@res"; if ( "$trigStat" eq "EMPTY" ) { $status = ( "$flat" eq "" ) ? "[OK]" : "[FAILED]" ; } elsif ( "$trigStat" ne "BLOCK" ) { ## if ( "$xpectStat" ) { if ( "$xpectStat" || "YYY$xpectStat" eq "YYY0" ) { $status = ( "XXX$xpectStat" eq "XXX".XtractVal($trigStat) ) ? "[OK]" : "[FAILED]" ; } else { $status = ( XtractVal($trigStat) ) ? "[OK]" : "[FAILED]" ; } } if ( "$trigRslt" ne "BLOB" ) { $result = XtractVal($trigRslt); if ( $operation eq "lcg-cr" && $result eq "" ) { $status = "[FAILED]"; } } if ( ! $statusLocal ) { if ( $status eq "[OK]" ) { $globOK++; } if ( $status eq "[FAILED]" ) { $globFD++; } } else { if ( $status eq "[FAILED]" ) { $statusLocal = "[FAILED]"; } } if ( $status ne "[OK]" && $fatalXit) { foreach ( @res ) { print " FAILURE: $_"; } exit 1; } else { my $operationP = "$operation"; if ( $label eq 'SRV22' && $operationP eq 'srmv2Suite' ) { $operationP = 'srmv22Suite'; } print " ${keyO}: $operationP = $status Duration: $tElapse sec.\n"; print "<_________________________________________________________________________>\n\n"; } print " ${keyR}: $result Status: $status\n"; # print " Result: $result Status: $status -- $xCount $globOK $globFD\n"; return 0; ## ($result, $status); } #################################################################################################### sub XcuteCommGOOD { $operation = shift; my $cargs = shift; my $label = shift; my $fatalXit = shift; my $trigStat = shift; my $xpectStat = shift; my $trigRslt = shift; if ( ! $statusLocal ) { $xCount++; } my $filter = "| perl -pe 's/\\s+\\d+ bytes.*sec inst//'"; ##OLDundef $status; $status = "[UNDEF]"; $result = " "; @res = (); ##$usage = `$operation 2>&1`; $command = "$operation $cargs"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); print "\n++++ $$ $dateST\n"; ##OLDprint " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; print " STEP: $xCount OPERATION: $operation CMD: $command\n"; my $tStart = time(); if ( $operation eq "lcg-cr" ) { @res = `$command 2>&1 $filter`; } else { @res = `$command 2>&1`; } my $tEnd = time(); my $tElapse = $tEnd - $tStart; ## my $exitFlag = 0; foreach ( @res ) { ##OLD$_ =~ s/req.*TURL/TURL/; if ( ! /^\s+$|^\.\.\.$/ ) { print "$label: $_"; } if (0) { my @m = split; if ( /$trigStat/ ) { $status = ( "$xpectStat" eq "$m[-1]" ) ? "[OK]" : "[FAILED]" ; } if ( /$trigRslt/ ) { $result = $m[-1]; } } } $flat = "@res"; ## my $lstat = XtractVal($trigStat); ## $status = ( "$xpectStat" eq "$lstat" ) ? "[OK]" : "[FAILED]" ; if ( "$trigStat" eq "EMPTY" ) { ## $status = ( "$res[0]" eq "" ) ? "[OK]" : "[FAILED]" ; $status = ( "$flat" eq "" ) ? "[OK]" : "[FAILED]" ; } elsif ( "$trigStat" ne "BLOCK" ) { if ( "$xpectStat" ) { $status = ( "$xpectStat" eq XtractVal($trigStat) ) ? "[OK]" : "[FAILED]" ; } else { $status = ( XtractVal($trigStat) ) ? "[OK]" : "[FAILED]" ; } } if ( "$trigRslt" ne "BLOB" ) { $result = XtractVal($trigRslt); } if ( ! $statusLocal ) { if ( $status eq "[OK]" ) { $globOK++; } if ( $status eq "[FAILED]" ) { $globFD++; } } else { if ( $status eq "[FAILED]" ) { $statusLocal = "[FAILED]"; } } if ( $status ne "[OK]" && $fatalXit) { foreach ( @res ) { print " FAILURE: $_"; } exit 1; } else { print " Operation: $operation = $status Duration: $tElapse sec.\n"; print "<_________________________________________________________________________>\n\n"; } print " Result: $result Status: $status\n"; # print " Result: $result Status: $status -- $xCount $globOK $globFD\n"; return 0; ## ($result, $status); } #################################################################################################### sub XcuteCommOLD { $operation = shift; my $cargs = shift; my $label = shift; my $xpectStat = shift; my $fatalXit = shift; $xCount++; undef $status; @res = (); ##$usage = `$operation 2>&1`; $command = "$operation $cargs"; chomp($dateST = `date '+%y%m%d-%H%M%S'`); print "\n++++ $$ $dateST\n"; ##print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; print " STEP: $xCount OPERATION: $operation CMD: $command\n"; my $tStart = time(); @res = `$command 2>&1`; my $tEnd = time(); my $tElapse = $tEnd - $tStart; ## my $exitFlag = 0; foreach ( @res ) { $_ =~ s/req.*TURL/TURL/; if ( ! /^\s+$|^\.\.\.$/ ) { print "$label: $_"; } my @m = split; if ( /request state/ ) { $status = ( "$xpectStat" eq "$m[2]" ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" && $fatalXit) { foreach ( @res ) { print " FAILURE: $_"; } exit 1; } else { print " Operation: $operation = $status Duration: $tElapse \n"; print "<_________________________________________________________________________>\n\n"; } return 0; } #################################################################################################### # Same as above, but requires that the proxy will still be valid # for the duration (hours) provided as 1st arg (def: 1 hour) sub checkProxyTime { my $time = shift; # if ( $time eq "" ) { $time = 1; } $time ||= 1; my $trash = `grid-proxy-info -exists -h $time `; my $rc = $?; return $rc; } #################################################################################################### # A utility to temporarily switch the STDOUT and STDERR to a file sub switchStdouterr { local *SAVEOUT; local *SAVEERR; my ($file) = @_; #p print " Sending STDOUT to $file \n"; open SAVEOUT, ">&STDOUT" ; open SAVEERR, ">&STDERR" ; open STDOUT, ">$file" or die "Can't redirect STDOUT \n"; open STDERR, ">&STDOUT" or die "Can't dup STDOUT \n"; select STDERR; $|=1; select STDOUT; $|=1; my @fhl = (*SAVEOUT, *SAVEERR); return \@fhl; } #################################################################################################### # A utility to restore the STDOUT and STDERR to their initial state sub restoreStdouterr { local *SAVEOUT; local *SAVEERR; # (*FH) = @_; my ($arrayref) = @_; (*SAVEOUT, *SAVEERR) = @$arrayref; close STDOUT; close STDERR; open STDOUT, ">&SAVEOUT"; open STDERR, ">&SAVEERR"; } #################################################################################################### sub RemCols { foreach my $n (0 .. $#res) { $res[$n] =~ s/\s+:/:/g; ## print " RemCols:: >>$res[$n]<< \n"; } } #################################################################################################### sub RemDots { foreach my $n (0 .. $#res) { $res[$n] =~ s/\.{2,}//g; ## print " RemDots:: >>$res[$n]<< \n"; } } #################################################################################################### sub dicomTests { ##dpm/dpm-register --user '/DC=org/DC=doegrids/OU=People/CN=Gilbert Grosdidier 378567' --filesize 641 --server `hostname --fqdn` --group dteam --status N --pfn dicom:///tmp/grodid/dicom_testgg_sleep_10.008 /dpm/cern.ch/home/dteam/grodid/tglob/Mlxb5407/dicom-tgg.013 ##rfio/rfdir /dpm/cern.ch/home/dteam/grodid/tglob/Mlxb5407 | grep dicom ##rfio/rfcp /dpm/cern.ch/home/dteam/grodid/tglob/Mlxb5407/dicom-tgg.013 /var/tmp/grodid/global/lxb5407/2007-12-22/fil140003/dicom-tgg.007r chomp(my $currSubject = `voms-proxy-info -identity`); if (0) { ## Crosscheck ... Template ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath | grep \"`date '+%b %d'`\" ", "LSD10", 0, "${lfn10}_R3b", "", "BLOB"); } ## Creation of dicom files ... my $dicomR = "dicom_testgg"; my $dicomS = "dicom_testgg_sleep_"; my $dicom1 = "$tempDir/${dicomR}.001"; my $dicom2 = "$tempDir/${dicomR}.002"; my $dicom3 = "$tempDir/${dicomR}.003"; my $dicom10 = "$tempDir/${dicomR}.010"; my $dicom12 = "$tempDir/${dicomR}.012"; my $dicom14 = "$tempDir/${dicomR}.014"; system("cp -p $finit1 $dicom1"); system("cp -p $finit1 $dicom2"); system("cp -p $finit1 $dicom3"); system("cp -p $finit1 $dicom10"); system("cp -p $finit1 $dicom12"); system("cp -p $finit1 $dicom14"); ## with sleep option my $dicoms20 = "$tempDir/${dicomS}20.004"; my $dicoms40 = "$tempDir/${dicomS}40.005"; my $dicoms26 = "$tempDir/${dicomS}20.006"; my $dicoms47 = "$tempDir/${dicomS}40.007"; my $dicoms28 = "$tempDir/${dicomS}20.008"; my $dicoms49 = "$tempDir/${dicomS}40.009"; my $dicoms21 = "$tempDir/${dicomS}20.021"; my $dicoms23 = "$tempDir/${dicomS}20.023"; my $dicoms25 = "$tempDir/${dicomS}20.025"; system("cp -p $finit1 $dicoms20"); system("cp -p $finit1 $dicoms40"); system("cp -p $finit1 $dicoms26"); system("cp -p $finit1 $dicoms47"); system("cp -p $finit1 $dicoms28"); system("cp -p $finit1 $dicoms49"); system("cp -p $finit1 $dicoms21"); system("cp -p $finit1 $dicoms23"); system("cp -p $finit1 $dicoms25"); my @m = split /\s+/, `ls -l $finit1`; ## Registration ... XcuteComm("rfmkdir", "-m 755 -p $fmach:/tmp/$pfxPath", "DICM01", 0, "EMPTY", "", "BLOB"); ## R001 XcuteComm("rfcp", "$tempDir/${dicomR}.001 $fmach:/tmp/$pfxPath/${dicomR}.001", "DICC01", 1, "seconds through local", "", "BLOB"); ## "--user \"${currSubject}\" --filesize $m[4] --server $fmach --group $choiceVO --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.001 $dpmRoot/$pfxPath/${dicomR}.001", ## "--user \"${currSubject}\" --filesize $m[4] --server $fmach --group \'dteam/Role=operator\' --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.001 $dpmRoot/$pfxPath/${dicomR}.001", XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.001 $dpmRoot/$pfxPath/${dicomR}.001", "DICR01", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP01", 0, "${dicomR}.001", "", "BLOB"); ## R002 XcuteComm("rfcp", "$tempDir/${dicomR}.002 $fmach:/tmp/$pfxPath/${dicomR}.002", "DICC02", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.002 $dpmRoot/$pfxPath/${dicomR}.002", "DICR02", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP02", 0, "${dicomR}.002", "", "BLOB"); ## R003 XcuteComm("rfcp", "$tempDir/${dicomR}.003 $fmach:/tmp/$pfxPath/${dicomR}.003", "DICC03", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.003 $dpmRoot/$pfxPath/${dicomR}.003", "DICR03", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP03", 0, "${dicomR}.003", "", "BLOB"); ## Get the file and wait for it if (0) { XcuteComm("rfcp", "$dpmRoot/$pfxPath/${dicomR}.001 $tempDir/${dicomR}.001r", "DICF01", 1, "seconds through eth", "", "BLOB"); } ## File with 20s delay ... ## S020 XcuteComm("rfcp", "$tempDir/${dicomS}20.004 $fmach:/tmp/$pfxPath/${dicomS}20.004", "DICC04", 1, "seconds through local", "", "BLOB"); ## "--user \"${currSubject}\" --filesize $m[4] --server $fmach --group $choiceVO --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.004 $dpmRoot/$pfxPath/${dicomS}20.004", XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.004 $dpmRoot/$pfxPath/${dicomS}20.004", "DICR04", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP04", 0, "${dicomS}20.004", "", "BLOB"); ## S026 XcuteComm("rfcp", "$tempDir/${dicomS}20.006 $fmach:/tmp/$pfxPath/${dicomS}20.006", "DICC06", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.006 $dpmRoot/$pfxPath/${dicomS}20.006", "DICR06", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP06", 0, "${dicomS}20.006", "", "BLOB"); ## S028 XcuteComm("rfcp", "$tempDir/${dicomS}20.004 $fmach:/tmp/$pfxPath/${dicomS}20.008", "DICC08", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.008 $dpmRoot/$pfxPath/${dicomS}20.008", "DICR08", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP08", 0, "${dicomS}20.008", "", "BLOB"); if (0) { ## Get the file and DON'T wait for it system("rfcp $dpmRoot/$pfxPath/${dicomS}20.004 $tempDir/${dicomS}20.004r &"); ## Cross-check ... system("ls -l $tempDir/${dicomS}20.004r"); } ## uses srmv1 ... if (0) { XcuteComm("srm_testget", "srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}20.004", "DICS04", 0, "request state", "", "BLOB"); XcuteComm("srm_testget", "srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomR}.001", "DICS01", 0, "request state", "", "BLOB"); } ## Work with srmv1 ... .................................................................................. ## Get both files and wait ... (all Nearline) XcuteComm("srm_testget", "srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}20.008 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomR}.003", "DICG0R3", 0, "request state", "Ready", "BLOB"); sleep 5; ## File with 40s delay ... XcuteComm("rfcp", "$tempDir/${dicomS}40.009 $fmach:/tmp/$pfxPath/${dicomS}40.009", "DICC09", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}40.009 $dpmRoot/$pfxPath/${dicomS}40.009", "DICR09", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP09", 0, "${dicomS}40.009", "", "BLOB"); ## Get 3 files and wait ... (one Nearline) XcuteComm("srm_testget", "srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}20.008 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomR}.003 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}40.009", "DICG09", 0, "request state", "Ready", "BLOB"); sleep 15; ## Get 3 files and wait again ... (all Online already) XcuteComm("srm_testget", "srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}20.008 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomR}.003 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}40.009", "DICG03", 0, "request state", "Ready", "BLOB"); ## Get 3 files and wait (3rd time) ... (all Online already) sleep 15; XcuteComm("srm_testget", "srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}20.008 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomR}.003 srm://${fmach}:8443/$dpmRoot/$pfxPath/${dicomS}40.009", "DICG04", 0, "request state", "Ready", "BLOB"); ## Work with srmv2 ... .................................................................................. ## Get both files and wait ... (all Nearline) XcuteComm("srm2_testGet", "gsiftp - srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}20.006 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomR}.002", "DICG0R2", 0, "request state", "0", "BLOB"); sleep 5; ## File with 40s delay ... XcuteComm("rfcp", "$tempDir/${dicomS}40.007 $fmach:/tmp/$pfxPath/${dicomS}40.007", "DICC07", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}40.007 $dpmRoot/$pfxPath/${dicomS}40.007", "DICR07", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP07", 0, "${dicomS}40.007", "", "BLOB"); ## Get 3 files and wait ... (one Nearline) XcuteComm("srm2_testGet", "gsiftp - srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}20.006 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomR}.002 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}40.007", "DICG07", 0, "request state", "0", "BLOB"); sleep 15; ## Get 3 files and wait again ... (all Online already) XcuteComm("srm2_testGet", "rfio - srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}20.006 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomR}.002 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}40.007", "DICG03", 0, "request state", "0", "BLOB"); ## Get 3 files and wait (3rd time) ... (all Online already) ... sleep 15; XcuteComm("srm2_testGet", "rfio - srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}20.006 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomR}.002 srm://${fmach}:8444/$dpmRoot/$pfxPath/${dicomS}40.007", "DICG04", 0, "request state", "0", "BLOB"); ## Work with srmv2.2 ... ............................................................................. $ENV{PATH} = "$relPath/test/srmv2.2:$ENV{PATH}"; ## Get both files and wait ... (all Nearline) XcuteComm("srm2_testGet", "gsiftp - 25 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.004 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.001", "DICG01", 0, "request state", "0", "BLOB"); sleep 5; ## File with 40s delay ... XcuteComm("rfcp", "$tempDir/${dicomS}40.005 $fmach:/tmp/$pfxPath/${dicomS}40.005", "DICC05", 1, "seconds through local", "", "BLOB"); ## "--user \"${currSubject}\" --filesize $m[4] --server $fmach --group $choiceVO --status N --pfn dicom:///tmp/$pfxPath/${dicomS}40.005 $dpmRoot/$pfxPath/${dicomS}40.005", XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}40.005 $dpmRoot/$pfxPath/${dicomS}40.005", "DICR05", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP05", 0, "${dicomS}40.005", "", "BLOB"); ## Get 3 files and wait ... (one Nearline) XcuteComm("srm2_testGet", "gsiftp - 55 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.004 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.001 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}40.005", "DICG02", 0, "request state", "0", "BLOB"); sleep 15; ## Get 3 files and wait again ... (all Online already) XcuteComm("srm2_testGet", "rfio - 10 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.004 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.001 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}40.005", "DICG03", 0, "request state", "0", "BLOB"); ## Get 3 files and wait (3rd time) ... (all Online already) sleep 15; XcuteComm("srm2_testGet", "rfio - 1 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.004 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.001 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}40.005", "DICG04", 0, "request state", "0", "BLOB"); ## AbortRequest + AbortFiles sequence ... under srmv2.2 ## R010 XcuteComm("rfcp", "$tempDir/${dicomR}.010 $fmach:/tmp/$pfxPath/${dicomR}.010", "DICC10", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.010 $dpmRoot/$pfxPath/${dicomR}.010", "DICR10", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP10", 0, "${dicomR}.010", "", "BLOB"); ## S021 XcuteComm("rfcp", "$tempDir/${dicomS}20.021 $fmach:/tmp/$pfxPath/${dicomS}20.021", "DICC21", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.021 $dpmRoot/$pfxPath/${dicomS}20.021", "DICR21", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP21", 0, "${dicomS}20.021", "", "BLOB"); my $stat26 = 0; my $endPoint = "srm://${fmach}:8446"; ## The '+' after 'gsiftp' is to indicate that testGet must NOT wait for the PTGet operation to complete XcuteComm("srm2_testGet", "gsiftp + - srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.021 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.010", "DICTARa", 0, 'pstate\[1\] =', '17,', "BLOB"); my $gr_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr_token", "DICTARb", 0, 'state\[0\] =', '18,', "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testAbortRequest", "$endPoint $gr_token", "DICTARar", 0, "request state", "0", "BLOB"); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr_token", "DICTARd", 0, "request getstate", "20", "BLOB"); $status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } ## R012 XcuteComm("rfcp", "$tempDir/${dicomR}.012 $fmach:/tmp/$pfxPath/${dicomR}.012", "DICC12", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.012 $dpmRoot/$pfxPath/${dicomR}.012", "DICR12", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP12", 0, "${dicomR}.012", "", "BLOB"); ## S023 XcuteComm("rfcp", "$tempDir/${dicomS}20.023 $fmach:/tmp/$pfxPath/${dicomS}20.023", "DICC23", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.023 $dpmRoot/$pfxPath/${dicomS}20.023", "DICR23", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP23", 0, "${dicomS}20.023", "", "BLOB"); XcuteComm("srm2_testGet", "gsiftp + - srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.023 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.012", "DICTAFa", 0, 'pstate\[1\] =', '17,', "BLOB"); $gr_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr_token", "DICTAFb", 0, 'state\[0\] =', '18,', "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testAbortFiles", "$gr_token srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.023 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.012", "DICTAFaf", 0, "request state", "0", "BLOB"); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr_token", "DICTAFd", 0, "request getstate", "20", "BLOB"); $status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } ## Concurrent get ... ## R014 XcuteComm("rfcp", "$tempDir/${dicomR}.014 $fmach:/tmp/$pfxPath/${dicomR}.014", "DICC14", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomR}.014 $dpmRoot/$pfxPath/${dicomR}.014", "DICR14", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP14", 0, "${dicomR}.014", "", "BLOB"); ## S025 XcuteComm("rfcp", "$tempDir/${dicomS}20.025 $fmach:/tmp/$pfxPath/${dicomS}20.025", "DICC25", 1, "seconds through local", "", "BLOB"); XcuteComm("dpm-register", "--filesize $m[4] --server $fmach --status N --pfn dicom:///tmp/$pfxPath/${dicomS}20.025 $dpmRoot/$pfxPath/${dicomS}20.025", "DICR25", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$dpmRoot/$pfxPath | grep dicom", "DICP25", 0, "${dicomS}20.025", "", "BLOB"); if (0) { ## The '+' after 'gsiftp' is to indicate that testGet must NOT wait for the PTGet operation to complete XcuteComm("srm2_testGet", "gsiftp + - srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.025 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.014", "DICTCGa1", 0, 'pstate\[1\] =', '17,', "BLOB"); my $gr1_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr1_token", "DICTCGb1", 0, 'state\[0\] =', '18,', "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGet", "gsiftp + - srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.025 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.014", "DICTCGa2", 0, 'pstate\[1\] =', '17,', "BLOB"); my $gr2_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr2_token", "DICTCGb2", 0, 'state\[0\] =', '18,', "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testAbortRequest", "$endPoint $gr1_token", "DICTCGar", 0, "request state", "0", "BLOB"); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr1_token", "DICTCGd1", 0, "request getstate", "20", "BLOB"); $status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr2_token", "DICTCGd2", 0, "request getstate", "18", "BLOB"); $status = ( XtractVal('state\[0\]:') eq '18' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGet", "gsiftp - 50 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.025 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomR}.014", "DICTCGa3", 0, 'pstate\[1\] =', '22,', "BLOB"); my $gr3_token = XtractVal('r_token'); ##sleep(20); ## gr2 should be successful ... XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr1_token $gr2_token $gr3_token", "DICTCGe", 0, "request state", "0", "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; } else { ## Case with one sleep file only in the PTGet requests .... ## The '+' after 'gsiftp' is to indicate that testGet must NOT wait for the PTGet operation to complete XcuteComm("srm2_testGet", "gsiftp + - srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.025", "DICTCGa1", 0, 'pstate\[0\] =', '17,', "BLOB"); my $gr1_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr1_token", "DICTCGb1", 0, 'state\[0\] =', '18,', "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGet", "gsiftp + - srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.025", "DICTCGa2", 0, 'pstate\[0\] =', '17,', "BLOB"); my $gr2_token = XtractVal('r_token'); XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr2_token", "DICTCGb2", 0, 'state\[0\] =', '18,', "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq "$stat26" ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } if (0) { ## Not any more ... XcuteComm("srm2_testAbortRequest", "$endPoint $gr1_token", "DICTCGar", 0, "request state", "0", "BLOB"); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr1_token", "DICTCGd1", 0, "request getstate", "20", "BLOB"); $status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr2_token", "DICTCGd2", 0, "request getstate", "18", "BLOB"); $status = ( XtractVal('state\[0\]:') eq '18' ) ? '[OK]' : '[FAILED]'; ##if ( $status ne '[OK]' ) { &printAndCExit(); } XcuteComm("srm2_testGet", "gsiftp - 50 srm://${fmach}:8446/$dpmRoot/$pfxPath/${dicomS}20.025", "DICTCGa3", 0, 'pstate\[0\] =', '22,', "BLOB"); my $gr3_token = XtractVal('r_token'); sleep(20); ## gr2 should be successful ... XcuteComm("srm2_testGetRequestStatus", "$endPoint $gr1_token $gr2_token $gr3_token", "DICTCGe", 0, "request state", "0", "BLOB"); ##$status = ( XtractVal('state\[0\]:') eq '20' ) ? '[OK]' : '[FAILED]'; } ## Crosscheck ... XcuteComm("dpns-ls -il", "$dpmRoot/$pfxPath | grep \"`date '+%b %d'`\" ", "DICLSD10", 0, "BLOCK", "", "BLOB"); } #################################################################################################### sub XtractVal { my $string = shift; ## $flat =~ m/$string\s+(.+?)\s+/; my $val = ""; foreach (@res) { if ( /$string\s+(\S+?)\s+/ ) { $val = $1; } elsif ( /($string\S*?)\s+/ ) { $val = $1; } } print " XtractVal: >$string< >$val< \n"; return $val; } #################################################################################################### sub XtractValPREV { my $string = shift; $flat =~ m/$string\s+(.+?)\s+/; return $1; } #################################################################################################### sub XtractGoodTurl { my $TURL = shift; my $sTURL; if ( $TURL =~ /rfio/ ) { $TURL =~ m[(.*?)://.*?/(.*)]; $TURL =~ m[(.*?)://(.*)]; $sTURL = $2; $sTURL =~ s;//;:/; ; if ( $ENV{NEW_RFIO_SYNTAX} ) { $sTURL = $TURL; ### For the NEW RFIOD 30/11/05 } } else { $TURL =~ m[(.*?://.*?)(/.*?:)(/.*)]; $sTURL = $1 . $3; $sTURL = $TURL; ### For the NEW FTPD 23/05/05 } print " Xtract\n INPUT: $TURL\n OUTPUT: $sTURL\n"; return $sTURL; } #################################################################################################### sub createGftest { my $file = shift; open SCRIPT, ">$file"; print SCRIPT <<'END' dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpb dteam001-gfal-S11018-I0000-CElxb2018-WNlxb1715-26136-050524-095725.jpbNN END ; close SCRIPT; chmod 0444, $file; } #################################################################################################### sub createDpmSource { my $file = shift; open SCRIPT, ">$file"; if (1) { print SCRIPT <<'END' #setenv LD_LIBRARY_PATH /afs/cern.ch/user/g/grodid/public/lfc-4-gilbert:/opt/lcg/lib:/opt/globus/lib:/opt/edg/lib:/usr/local/lib:/usr/local/lib:/usr/local/lib:/opt/d-cache/dcap/lib:/opt/d-cache/dcap/lib:/opt/d-cache/dcap/lib:/opt/globus/lib:/opt/edg/lib:/opt/globus/lib:/opt/edg/lib ##setenv LCG_GFAL_INFOSYS lxgate22.cern.ch:2135 setenv DPNS_HOST lxb1706 setenv DPM_HOST lxb1706 setenv LCG_RFIO_TYPE dpm ##setenv LFC_HOST ?? END ; } if (0) { print SCRIPT <<'END' ##setenv END ; } close SCRIPT; chmod 0444, $file; } #################################################################################################### sub createGfalTestC { my $file = shift; open SCRIPT, ">$file"; print SCRIPT <<'EOC' /* * Copyright (C) 2003 by CERN Jean-Philippe Baud * Copyright (C) 2004-2007 by LAL/IN2P3/CNRS Gilbert Grosdidier */ #include #include #include "gfal_api.h" #define BLKLEN 65536 #define DEFPOLLINT 10 #include //#include /* GG/RM 25/06/07 */ #include #include extern char* optarg; extern int optind, opterr, optopt; main(int argc, char **argv) { int in_fd; int out_fd; int i, j; char ibuf[BLKLEN]; char obuf[BLKLEN]; int rc; int count; int in_fdc, out_fdc; char grogfal[256]; int ic; struct stat statbuf; char gstring[128]; //char* hstring; char *fnorig; //241107static char **surl = NULL; char **surl = NULL; // Getting options ... int iget; // optind = 1; /*char**/ int optiong; static char *surlu = {"srm://lxgate22.cern.ch:8443//dpm/cern.ch/home/dteam/dteam001B"}; char *workdir; /* srm_get test block */ #ifdef SRM //#define SRM 2 #if SRM == 1 struct srm_filestatus *filestatuses; #else struct srmv2_filestatus *filestatuses; int bufsiz = 0; int timeout = 100; char* r_token; #endif int nbfiles; int nbprotocols; int nbreplies; char *protocols[] = {"rfio","gsidcap",""}; //static char *protocols[] = {"gsidcap"}; int r = 0; int reqid; int fc = 0; // ready file count int extra; #endif int igmul; int igMul = 1; //fflush(NULL); while ( (iget = getopt(argc, argv, "+g:D:RW")) != EOF) { switch (iget) { case 'g': { optiong = atoi(optarg); printf ("option %c %d\n", iget, optiong); break; } case 'R': case 'W': { printf ("option %c\n", iget); break; } case 'D': { workdir = optarg; printf ("option %c %s\n", iget, workdir); break; } default: { /* dummy = optarg; */ } } } /* if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } */ // End of Options stuff fflush(NULL); if (argc != 2+optind) { fprintf (stderr, "usage: %s unix-filename gfal-filename [%d]\n", argv[0], argc); exit (1); } // Test string read ... /* scanf("%s", gstring); printf (" Some string to read: %s \n", gstring); */ // End of Read test for (i = 0; i < BLKLEN; i++) obuf[i] = i; printf ("reading file %s\n", argv[optind]); if ((in_fdc = open (argv[optind], O_RDONLY)) < 0) { perror ("unix_open"); exit (1); } printf ("unix open successful, in_fdc = %d\n", in_fdc); //grogfal = "/tmp/grogfal"; sprintf(grogfal, "%s/grogfal", workdir); printf ("creating file %s\n", grogfal); //exit (0); //grogfal = "grogfal"; //printf ("creating file %s\n", grogfal); if ((out_fdc = open (grogfal, O_WRONLY|O_CREAT, 0644)) < 0) { perror ("grogfal_open_write"); exit (1); } printf ("grogfal open_write successful, out_fdc = %d\n", out_fdc); while ((i = read(in_fdc, obuf, BLKLEN)) > 0 ) { count++; //for ( ic = 0; ic<15000; ic++ ) { for ( ic = 0; ic<150; ic++ ) { if ((rc = write (out_fdc, obuf, i)) != i) { if (rc < 0) perror ("write"); else fprintf (stderr, "write %d returns %d\n", count, rc); (void) close (out_fdc); exit (1); } //PR printf ("grogfal write %d successful_ic\n", ic); } printf ("grogfal write %d successful_count\n", count); } if ((rc = close (in_fdc)) < 0) { perror ("unix_close"); exit (1); } printf ("unix close successful\n"); if ((rc = close (out_fdc)) < 0) { perror ("close"); exit (1); } printf ("grogfal close successful\n"); printf ("reading file %s\n", grogfal); if ((in_fd = open (grogfal, O_RDONLY)) < 0) { perror ("grogfal_open_read"); exit (1); } printf ("grogfal open_read successful, in_fd = %d\n", in_fd); surl = (char **) malloc(optiong*sizeof(char*)); //surl[0] = (char *) malloc(optiong*sizeof(char*)); fnorig = malloc((size_t) (optiong+1+strlen(argv[1+optind]))); //fnorig = (char *) malloc(sizeof(char*)*(optiong+1+strlen(argv[1+optind]))); strcpy(fnorig, argv[1+optind]); /* ======================= START of LOOP */ for (j=0; j%s<\n", fnorig); */ /* printf ("stored filename >%s<\n", surl[j]); */ /* printf ("writing file %s\n", argv[1+optind]); */ /* if ((out_fd = gfal_open (argv[1+optind], O_WRONLY|O_CREAT, 0644)) < 0) { */ printf ("writing file %s\n", fnorig); if ((out_fd = gfal_open64 (fnorig, O_WRONLY|O_CREAT, 0644)) < 0) { perror ("gfal_open64"); exit (1); } printf ("gfal_open64 successful, out_fd = %d\n", out_fd); count = 0; if ( j == 0 ) igMul = 1; else igMul *= 3; /* igMul *= 13;*/ while ((i = read(in_fd, obuf, BLKLEN)) > 0 ) { count++; for ( igmul = 0; igmul < igMul; igmul++ ) { if ((rc = gfal_write (out_fd, obuf, i)) != i) { if (rc < 0) perror ("gfal_write"); else fprintf (stderr, "gfal_write %d returns %d\n", count, rc); (void) gfal_close (out_fd); exit (1); } } } printf ("gfal_write %d successful\n", count); /* if ((rc = close (in_fd)) < 0) { */ /* perror ("unix_close"); */ /* exit (1); */ /* } */ /* printf ("unix close successful\n"); */ if ((rc = gfal_close (out_fd)) < 0) { perror ("gfal_close"); exit (1); } printf ("gfal_close successful\n"); strcat(fnorig, "Y"); close(in_fd); in_fd = open (grogfal, O_RDONLY); } /* ======================= END of LOOP */ #if 0 printf ("writing file %s\n", surlu); if ((out_fd = gfal_open (surlu, O_WRONLY|O_CREAT, 0644)) < 0) { perror ("gfal_open"); exit (1); } printf ("gfal_open successful, out_fd = %d\n", out_fd); count = 0; while ((i = read(in_fd, obuf, BLKLEN)) > 0 ) { count++; if ((rc = gfal_write (out_fd, obuf, i)) != i) { if (rc < 0) perror ("gfal_write"); else fprintf (stderr, "gfal_write %d returns %d\n", count, rc); (void) gfal_close (out_fd); exit (1); } } printf ("gfal_write %d successful\n", count); /* if ((rc = close (in_fd)) < 0) { */ /* perror ("unix_close"); */ /* exit (1); */ /* } */ /* printf ("unix close successful\n"); */ if ((rc = gfal_close (out_fd)) < 0) { perror ("gfal_close"); exit (1); } printf ("gfal_close successful\n"); #endif if ((rc = close (in_fd)) < 0) { perror ("unix_close"); exit (1); } printf ("unix close successful\n"); count = 0; printf ("reading back %s\n", grogfal); if ((in_fd = open (grogfal, O_RDONLY, 0)) < 0) { perror ("unix_open"); exit (1); } printf ("unix open successful, in_fd = %d\n", in_fd); if ((out_fd = gfal_open (argv[1+optind], O_RDONLY, 0)) < 0) { perror ("gfal_open"); exit (1); } printf ("gfal_open successful, out_fd = %d\n", out_fd); while ((i = read(in_fd, ibuf, BLKLEN)) > 0 ) { count++; if ((rc = gfal_read (out_fd, obuf, i)) != i) { if (rc < 0) perror ("gfal_read"); else fprintf (stderr, "gfal_read %d returns %d\n", count, rc); (void) gfal_close (out_fd); exit (1); } //printf ("gfal read %d successful\n", count); for (j = 0; j < i; j++) { if (ibuf[j] != obuf[j]) { fprintf (stderr, "compare %d failed at offset %d\n", count, j); exit (1); } } } printf ("compare %d successful\n", count); if ((rc = close (in_fd)) < 0) { perror ("unix_close"); exit (1); } printf ("unix close successful\n"); if ((rc = gfal_close (out_fd)) < 0) { perror ("gfal_close"); exit (1); } printf ("gfal_close successful\n"); // grid or home ? // rc = system("nsls -l /castor/cern.ch/home/dteam"); // rc = system("nsls -l /castor/cern.ch/grid/dteam"); if (gfal_stat (argv[1+optind], &statbuf) < 0) { perror ("gfal_stat"); exit (1); } printf ("\ngfal_stat successful\n"); printf ("mode = %o\n", statbuf.st_mode); printf ("nlink = %d\n", statbuf.st_nlink); printf ("uid = %d\n", statbuf.st_uid); printf ("gid = %d\n", statbuf.st_gid); printf ("size = %ld\n", statbuf.st_size); rc = unlink(grogfal); for (j=0; jstatus == 1) { /* file ready */ /* process it if not yet done */ printf(" srm_get: %d %s \n", i, (filestatuses+i)->turl); //printf(" srm_get: %d %d %d \n", i, (filestatuses+i)->surl, (filestatuses+i)->turl); fc++; } if ((filestatuses+i)->surl) free ((filestatuses+i)->surl); if ((filestatuses+i)->turl) free ((filestatuses+i)->turl); /*(filestatuses+i)->turl = NULL;*/ } free (filestatuses); /* if processing complete, break */ /*if (r) break;*/ /* if processing complete, break */ if (fc==nbreplies) break; sleep ((r++ == 0) ? 1 : DEFPOLLINT); #if SRM == 1 //#ifdef SRM printf(" Calling srm_getstatus \n"); if ((nbreplies = srm_getstatus (nbfiles, (const char **) surl, reqid, NULL, &filestatuses, extra)) < 0) { perror ("srm_getstatus"); exit (1); } #else printf(" Calling srmv2_getstatus \n"); if ((nbreplies = srmv2_getstatus (nbfiles, (const char **) surl, r_token, &filestatuses, NULL, bufsiz, timeout)) < 0) { perror ("srmv2_getstatus"); exit (1); } #endif fc = 0; } #endif if ((rc = gfal_unlink(argv[1+optind])) < 0) { perror ("gfal_unlink"); exit (1); } printf ("gfal_unlink successful\n"); exit (0); } EOC ; close SCRIPT; chmod 0444, $file; } #################################################################################################### sub createGfalTestCOLD { my $file = shift; open SCRIPT, ">$file"; print SCRIPT <<'EOC' /* * Copyright (C) 2003 by CERN Jean-Philippe Baud * Copyright (C) 2004-2006 by LAL/IN2P3/CNRS Gilbert Grosdidier */ #include #include #include "gfal_api.h" #define BLKLEN 65536 #define DEFPOLLINT 10 #include //#include extern char* optarg; extern int optind, opterr, optopt; main(int argc, char **argv) { int in_fd; int out_fd; int i, j; char ibuf[BLKLEN]; char obuf[BLKLEN]; int rc; int count; int in_fdc, out_fdc; char grogfal[256]; int ic; struct stat statbuf; char gstring[128]; //char* hstring; char *fnorig; static char **surl = NULL; // Getting options ... int iget; // optind = 1; /*char**/ int optiong; static char *surlu = {"srm://lxgate22.cern.ch:8443//dpm/cern.ch/home/dteam/dteam001B"}; char *workdir; /* srm_get test block */ #if 1 struct srm_filestatus *filestatuses; int nbfiles; int nbprotocols; int nbreplies; static char *protocols[] = {"rfio","gsidcap"}; //static char *protocols[] = {"gsidcap"}; int r = 0; int reqid; int fc = 0; // ready file count int extra; #endif int igmul; int igMul = 1; //fflush(NULL); while ( (iget = getopt(argc, argv, "+g:D:RW")) != EOF) { switch (iget) { case 'g': { optiong = atoi(optarg); printf ("option %c %d\n", iget, optiong); break; } case 'R': case 'W': { printf ("option %c\n", iget); break; } case 'D': { workdir = optarg; printf ("option %c %s\n", iget, workdir); break; } default: { /* dummy = optarg; */ } } } /* if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } */ // End of Options stuff fflush(NULL); if (argc != 2+optind) { fprintf (stderr, "usage: %s unix-filename gfal-filename [%d]\n", argv[0], argc); exit (1); } // Test string read ... /* scanf("%s", gstring); printf (" Some string to read: %s \n", gstring); */ // End of Read test for (i = 0; i < BLKLEN; i++) obuf[i] = i; printf ("reading file %s\n", argv[optind]); if ((in_fdc = open (argv[optind], O_RDONLY)) < 0) { perror ("unix_open"); exit (1); } printf ("unix open successful, in_fdc = %d\n", in_fdc); //grogfal = "/tmp/grogfal"; sprintf(grogfal, "%s/grogfal", workdir); printf ("creating file %s\n", grogfal); //exit (0); //grogfal = "grogfal"; //printf ("creating file %s\n", grogfal); if ((out_fdc = open (grogfal, O_WRONLY|O_CREAT, 0644)) < 0) { perror ("grogfal_open_write"); exit (1); } printf ("grogfal open_write successful, out_fdc = %d\n", out_fdc); while ((i = read(in_fdc, obuf, BLKLEN)) > 0 ) { count++; //for ( ic = 0; ic<15000; ic++ ) { for ( ic = 0; ic<150; ic++ ) { if ((rc = write (out_fdc, obuf, i)) != i) { if (rc < 0) perror ("write"); else fprintf (stderr, "write %d returns %d\n", count, rc); (void) close (out_fdc); exit (1); } //PR printf ("grogfal write %d successful_ic\n", ic); } printf ("grogfal write %d successful_count\n", count); } if ((rc = close (in_fdc)) < 0) { perror ("unix_close"); exit (1); } printf ("unix close successful\n"); if ((rc = close (out_fdc)) < 0) { perror ("close"); exit (1); } printf ("grogfal close successful\n"); printf ("reading file %s\n", grogfal); if ((in_fd = open (grogfal, O_RDONLY)) < 0) { perror ("grogfal_open_read"); exit (1); } printf ("grogfal open_read successful, in_fd = %d\n", in_fd); surl = malloc(optiong*sizeof(char*)); fnorig = malloc((size_t) (optiong+1+strlen(argv[1+optind]))); strcpy(fnorig, argv[1+optind]); /* ======================= START of LOOP */ for (j=0; j%s<\n", fnorig); */ /* printf ("stored filename >%s<\n", surl[j]); */ /* printf ("writing file %s\n", argv[1+optind]); */ /* if ((out_fd = gfal_open (argv[1+optind], O_WRONLY|O_CREAT, 0644)) < 0) { */ printf ("writing file %s\n", fnorig); if ((out_fd = gfal_open (fnorig, O_WRONLY|O_CREAT, 0644)) < 0) { perror ("gfal_open"); exit (1); } printf ("gfal_open successful, out_fd = %d\n", out_fd); count = 0; if ( j == 0 ) igMul = 1; else igMul *= 3; while ((i = read(in_fd, obuf, BLKLEN)) > 0 ) { count++; for ( igmul = 0; igmul < igMul; igmul++ ) { if ((rc = gfal_write (out_fd, obuf, i)) != i) { if (rc < 0) perror ("gfal_write"); else fprintf (stderr, "gfal_write %d returns %d\n", count, rc); (void) gfal_close (out_fd); exit (1); } } } printf ("gfal_write %d successful\n", count); /* if ((rc = close (in_fd)) < 0) { */ /* perror ("unix_close"); */ /* exit (1); */ /* } */ /* printf ("unix close successful\n"); */ if ((rc = gfal_close (out_fd)) < 0) { perror ("gfal_close"); exit (1); } printf ("gfal_close successful\n"); strcat(fnorig, "Y"); close(in_fd); in_fd = open (grogfal, O_RDONLY); } /* ======================= END of LOOP */ #if 0 printf ("writing file %s\n", surlu); if ((out_fd = gfal_open (surlu, O_WRONLY|O_CREAT, 0644)) < 0) { perror ("gfal_open"); exit (1); } printf ("gfal_open successful, out_fd = %d\n", out_fd); count = 0; while ((i = read(in_fd, obuf, BLKLEN)) > 0 ) { count++; if ((rc = gfal_write (out_fd, obuf, i)) != i) { if (rc < 0) perror ("gfal_write"); else fprintf (stderr, "gfal_write %d returns %d\n", count, rc); (void) gfal_close (out_fd); exit (1); } } printf ("gfal_write %d successful\n", count); /* if ((rc = close (in_fd)) < 0) { */ /* perror ("unix_close"); */ /* exit (1); */ /* } */ /* printf ("unix close successful\n"); */ if ((rc = gfal_close (out_fd)) < 0) { perror ("gfal_close"); exit (1); } printf ("gfal_close successful\n"); #endif if ((rc = close (in_fd)) < 0) { perror ("unix_close"); exit (1); } printf ("unix close successful\n"); count = 0; printf ("reading back %s\n", grogfal); if ((in_fd = open (grogfal, O_RDONLY, 0)) < 0) { perror ("unix_open"); exit (1); } printf ("unix open successful, in_fd = %d\n", in_fd); if ((out_fd = gfal_open (argv[1+optind], O_RDONLY, 0)) < 0) { perror ("gfal_open"); exit (1); } printf ("gfal_open successful, out_fd = %d\n", out_fd); while ((i = read(in_fd, ibuf, BLKLEN)) > 0 ) { count++; if ((rc = gfal_read (out_fd, obuf, i)) != i) { if (rc < 0) perror ("gfal_read"); else fprintf (stderr, "gfal_read %d returns %d\n", count, rc); (void) gfal_close (out_fd); exit (1); } //printf ("gfal read %d successful\n", count); for (j = 0; j < i; j++) { if (ibuf[j] != obuf[j]) { fprintf (stderr, "compare %d failed at offset %d\n", count, j); exit (1); } } } printf ("compare %d successful\n", count); if ((rc = close (in_fd)) < 0) { perror ("unix_close"); exit (1); } printf ("unix close successful\n"); if ((rc = gfal_close (out_fd)) < 0) { perror ("gfal_close"); exit (1); } printf ("gfal_close successful\n"); // grid or home ? // rc = system("nsls -l /castor/cern.ch/home/dteam"); // rc = system("nsls -l /castor/cern.ch/grid/dteam"); if (gfal_stat (argv[1+optind], &statbuf) < 0) { perror ("gfal_stat"); exit (1); } printf ("\ngfal_stat successful\n"); printf ("mode = %o\n", statbuf.st_mode); printf ("nlink = %d\n", statbuf.st_nlink); printf ("uid = %d\n", statbuf.st_uid); printf ("gid = %d\n", statbuf.st_gid); printf ("size = %ld\n", statbuf.st_size); rc = unlink(grogfal); for (j=0; jstatus == 1) { /* file ready */ /* process it if not yet done */ printf(" srm_get: %d %s \n", i, (filestatuses+i)->turl); //printf(" srm_get: %d %d %d \n", i, (filestatuses+i)->surl, (filestatuses+i)->turl); fc++; } if ((filestatuses+i)->surl) free ((filestatuses+i)->surl); if ((filestatuses+i)->turl) free ((filestatuses+i)->turl); /*(filestatuses+i)->turl = NULL;*/ } free (filestatuses); /* if processing complete, break */ /*if (r) break;*/ /* if processing complete, break */ if (fc==nbreplies) break; sleep ((r++ == 0) ? 1 : DEFPOLLINT); if ((nbreplies = srm_getstatus (nbfiles, surl, reqid, NULL, &filestatuses, extra)) < 0) { perror ("srm_getstatus"); exit (1); } fc = 0; } #endif if ((rc = gfal_unlink(argv[1+optind])) < 0) { perror ("gfal_unlink"); exit (1); } printf ("gfal_unlink successful\n"); exit (0); } EOC ; close SCRIPT; chmod 0444, $file; } #################################################################################################### sub CreateProxy { unless ( $ENV{GSI_PASSWORD} ) { print STDERR "ERROR in GSI_PASSWORD checking: please define the GSI_PASSWORD variable (your GSI certificate pwd) ...\n"; exit 1; } ## Special to voms-proxy-init testing ... my $specialGlite = 0; my $savePathLIB = $ENV{LD_LIBRARY_PATH}; my $savePathBIN = $ENV{PATH}; if ( $specialGlite ) { $ENV{LD_LIBRARY_PATH} = "/opt/lcg/RpmDir/opt/glite/lib:$savePathLIB"; $ENV{PATH} = "/opt/lcg/RpmDir/opt/glite/bin:$savePathBIN"; } ## Special to voms-proxy-init testing ... system("which voms-proxy-init"); system("which voms-proxy-info"); ## Creating the vomses file ... open VMS, ">vomses"; printf VMS <<'EVMS'; "dteam" "lcg-voms.cern.ch" "15004" "/C=CH/O=CERN/OU=GRID/CN=host/lcg-voms.cern.ch" "dteam" "lhcb" "lcg-voms.cern.ch" "15003" "/C=CH/O=CERN/OU=GRID/CN=host/lcg-voms.cern.ch" "lhcb" "ops" "lcg-voms.cern.ch" "15009" "/C=CH/O=CERN/OU=GRID/CN=host/lcg-voms.cern.ch" "ops" EVMS close VMS; ## Just in case ... ## "dteam" "voms.cern.ch" "15004" "/DC=ch/DC=cern/OU=computers/CN=voms.cern.ch" "dteam" ## "lhcb" "voms.cern.ch" "15003" "/DC=ch/DC=cern/OU=computers/CN=voms.cern.ch" "lhcb" ## Building the command string ... my $savePath; my $rcp; my $vomsCom; my $certIN = " "; my $vomsVO = 'dteam'; ## Some specificities ... if ( $certA eq 'lhcb' ) { if ( $proxyT ne 'voms' ) { print STDERR " Proxy Type error: $proxyT for $certA \n"; exit 1; } $certA = 'ppdg'; $vomsVO = 'lhcb'; } elsif ( $certA eq 'ops' ) { if ( $proxyT ne 'voms' ) { print STDERR " Proxy Type error: $proxyT for $certA \n"; exit 1; } $certA = 'cern'; $vomsVO = 'ops'; } if ( $ENV{USER} eq 'grodid' && $certA ne 'NADA' ) { $certIN = "$ENV{GSI_AREA}/${certA}-2008"; $certIN = " -cert ${certIN}/usercert.pem -key ${certIN}/userkey.pem "; } ##OLD my $proxyF = "${tempDir}/x509up_u1110_${proxyT}_${sfile}"; my $proxyF = "${tempDir}/x509up_u1110_${proxyT}_${certA}_${vomsVO}_${sfile}"; if ( $proxyT eq "globus" ) { $vomsCom = "voms-proxy-init -valid 300:00 -out $proxyF -pwstdin"; $proxyI = 'G'; ##@res = `echo $ENV{GSI_PASSWORD} | $vomsCom 2>&1`; ##$rcp = XtractVal("Creating proxy"); } elsif ( $proxyT eq "voms" ) { ##$vomsCom = "voms-proxy-init -valid 300:00 -voms dteam -out $proxyF -confile vomses -pwstdin"; $vomsCom = "voms-proxy-init -valid 300:00 -voms $vomsVO -out $proxyF -pwstdin"; $proxyI = 'V'; } elsif ( $proxyT eq "vomsR" ) { $vomsCom = "voms-proxy-init -valid 300:00 -voms dteam:/dteam/Role=operator -vomslife 4:00 -out $proxyF -confile vomses -pwstdin"; $proxyI = 'R'; } elsif ( $proxyT eq "extern" ) { print STDOUT " Proxy Type extern: $ENV{X509_USER_PROXY} \n"; $proxyF = $ENV{X509_USER_PROXY}; $proxyI = 'T'; } elsif ( $proxyT eq "expired" ) { $savePath = "$ENV{LD_LIBRARY_PATH}"; $ENV{LD_LIBRARY_PATH} = "/opt/glite/lib:$savePath"; ## This one will be valid for 1 minute only ... $vomsCom = "/opt/glite/bin/voms-proxy-init -valid 300:00 -voms dteam:/dteam/Role=operator -vomslife 00:01 -noregen -confile /afs/cern.ch/project/gd/grodid/SLC3-CVS-dpm-142gk/LCG-DM/test/dpm/vomsesdir -out $proxyF -pwstdin"; $proxyI = 'X'; } else { print STDERR " Proxy Type error: $proxyT \n"; exit 1; } ## Creating the proxy ... $vomsCom .= "$certIN"; if ( $proxyT ne "extern" ) { print STDOUT " VomsCMD: $vomsCom \n"; @res = `echo $ENV{GSI_PASSWORD} | $vomsCom 2>&1`; &RemDots(); $rcp = XtractVal("Creating proxy"); if ( $rcp ne "Done" ) { print STDERR " Proxy does not seem to be properly created: $rcp \n"; foreach ( @res ) { print STDERR " FAILURE: $_"; } exit 1; } # else { # foreach ( @res ) { # print; # } # } $ENV{X509_USER_PROXY} = "$proxyF"; } ## Checking the proxy is valid ... if ( $proxyT eq "expired" ) { $ENV{LD_LIBRARY_PATH} = "$savePath"; sleep 380; } @res = `voms-proxy-info -all 2>&1`; &RemCols(); $rcp = XtractVal("path:"); if ( $rcp ne "$proxyF" ) { print STDERR " Proxy does not seem to have the right path: $rcp \n"; foreach ( @res ) { print STDERR " FAILURE: $_"; } exit 1; } if ( $proxyT eq "expired" ) { $rcp = XtractVal("timeleft:"); if ( $rcp ne "0:00:00" ) { print STDERR " Proxy does not seem to be expired, since timeleft: $rcp \n"; foreach ( @res ) { print STDERR " FAILURE: $_"; } exit 1; } } ## Special to voms-proxy-init testing ... if ( $specialGlite ) { $ENV{LD_LIBRARY_PATH} = "$savePathLIB"; $ENV{PATH} = "$savePathBIN"; } ## Special to voms-proxy-init testing ... #### exit 0; } #################################################################################################### sub createGilbOld { my $file = shift; my $orig = shift; system("cat $orig $orig > $file"); chmod 0444, $file; } #################################################################################################### sub rfioSuite { my $direct = shift; my $fmach = shift; if ( $dServer0 && $direct eq 'NODPM' ) { $fmach = $dServer0; } my $suite = 'rfioSuite'; ##$xCount++; chomp($dateST = `date '+%y%m%d-%H%M%S'`); print "\n++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $suite CMD: $suite $direct $fmach\n"; my $tStart = time(); my $rinitS1 = "DPMsource.flxb1706S1"; ####createDpmSource($rinit2); ##my $finit2 = "file:$ENV{PWD}/$rinit2"; ####my $finit2 = "file:$tempDir/$rinit2"; my $lfnS1 = "rfcp_Tfile.${sfile}S1"; my $frrootS1 = "$fmach:/tmp/$pfxPath"; if ( $direct eq "DPM" ) { $frrootS1 = "$dpmRoot/$pfxPath"; } my $fremotS1 = "$frrootS1/$lfnS1"; my $rinitS2 = "DPMsource.flxb1706S2"; my $lfnS2 = "rfcp_Tfile.${sfile}S2"; my $frrootS2 = "$fmach:/tmp/$pfxPath/subfDirS1"; if ( $direct eq "DPM" ) { $frrootS2 = "$dpmRoot/$pfxPath/subfDirS1"; } my $fremotS2 = "$frrootS2/$lfnS2"; if (0) { my $lfnS2 = "rfcp_Tfile.${sfile}S2"; my $frrootS2 = "$fmach:/tmp/$pfxPath/subfDirS1"; if ( $direct eq "DPM" ) { $frrootS2 = "$dpmRoot/$pfxPath/subfDirS1"; } } my $fremotS3 = "$frrootS2/$lfnS1"; system("cat $rinit2 $rinit2 > $rinitS1"); system("cat $rinit2 $rinit2 $rinit2 > $rinitS2"); my $flinitS1 = "$tempDir/$rinitS1"; my $flinitS2 = "$tempDir/$rinitS2"; $statusLocal = "[OK]"; if ( "$direct" ne "DPM" ) { XcuteComm("rfmkdir", "-m 755 -p $frrootS1", "RFMKS0", 0, "EMPTY", "", "BLOB"); } ## Direct rfcp ... XcuteComm("rfcp", "$flinitS1 $fremotS1", "RFCPS1", 0, "seconds through local", "", "BLOB"); XcuteComm("rfstat", "$fremotS1", "RFSTS1", 0, "Last stat. mod. :", "", "BLOB"); my $fremodS1 = "$frrootS1/subfDirS1"; XcuteComm("rfmkdir", "-m 777 -p $fremodS1", "RFMKS1", 0, "EMPTY", "", "BLOB"); ## rfcp -v2 ... in the new dir XcuteComm("rfcp", "-v2 $flinitS2 $fremotS2", "RFCPS2", 0, "seconds through local", "", "BLOB"); XcuteComm("rfrename", "$fremotS1 $fremotS3", "RFMVS1", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$fremodS1", "RFLSS1", 0, "$lfnS1", "", "BLOB"); ##exit 0; XcuteComm("rfrm", "$fremodS1", "RFRMS1", 0, "$fremodS1", "directory", "BLOB"); XcuteComm("rfcp", "-v2 $fremotS2 $tempDir/fcrapS2$direct", "RFFRS2", 0, "seconds through eth", "", "BLOB"); XcuteComm("rfcp", "$fremotS3 $tempDir/fcrapS1$direct", "RFFRS3", 0, "seconds through eth", "", "BLOB"); if (0) { XcuteComm("rfrm", "$fremotS2", "RFRMS2", 0, "EMPTY", "", "BLOB"); XcuteComm("rfrm", "$fremotS3", "RFRMS3", 0, "EMPTY", "", "BLOB"); } XcuteComm("rfrm", "-rf $fremodS1", "RFRFS1", 0, "EMPTY", "", "BLOB"); XcuteComm("rfdir", "$fremodS1", "RFLSS2", 0, "No such file or directory", "", "BLOB"); XcuteComm("diff", "-s $flinitS1 $tempDir/fcrapS1$direct", "RFCMS1", 0, "$tempDir/fcrapS1$direct are", "identical", "BLOB"); XcuteComm("diff", "-s $flinitS2 $tempDir/fcrapS2$direct", "RFCMS2", 0, "$tempDir/fcrapS2$direct are", "identical", "BLOB"); if (0) { XcuteComm("rfcp", "$dpmRoot/$pfxPath/$lfn2 $tempDir/fcrap2", "FCPR", 0, "seconds through eth", "", "BLOB"); } my $tEnd = time(); my $tElapse = $tEnd - $tStart; print "\n Operation: rfioSuite with $direct = $statusLocal Duration: $tElapse sec. \n"; print "<_________________________________________________________________________>\n\n"; print " Result: Status: $statusLocal\n"; $xCount++; if ( $statusLocal eq "[OK]" ) { $globOK++; } if ( $statusLocal eq "[FAILED]" ) { $globFD++; } undef $statusLocal; } #################################################################################################### sub gsiftpSuite { my $direct = shift; my $fmach = shift; if ( $dServer0 ) { $fmach = $dServer0; } my $gVers = $gsiftpV{$fmach}; my $suite = 'gsiftpSuite'; ##$xCount++; chomp($dateST = `date '+%y%m%d-%H%M%S'`); print "\n++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $suite CMD: $suite $direct $fmach\n"; my $tStart = time(); my $rinitS1 = "DPMsource.glxb1706S1"; ####createDpmSource($rinit2); ##my $finit2 = "file:$ENV{PWD}/$rinit2"; ####my $finit2 = "file:$tempDir/$rinit2"; my $lfnS1 = "gsiftp_Tfile.${sfile}S1"; my $frrootS1 = "gsiftp://$fmach/$fmach:/tmp/$pfxPath"; if ( $direct eq "DPM" ) { $frrootS1 = "gsiftp://${fmach}$dpmRoot/$pfxPath"; } my $fremotS1 = "$frrootS1/$lfnS1"; my $rinitS2 = "DPMsource.lxb1706S2"; my $lfnS2 = "gsiftp_Tfile.${sfile}S2"; my $frrootS2 = "gsiftp://$fmach/$fmach:/tmp/$pfxPath/subgDirS1"; if ( $direct eq "DPM" ) { $frrootS2 = "gsiftp://${fmach}$dpmRoot/$pfxPath/subgDirS1"; } my $fremotS2 = "$frrootS2/$lfnS2"; if (0) { my $lfnS2 = "gsiftp_Tfile.${sfile}S2"; my $frrootS2 = "gsiftp://$fmach/$fmach:/tmp/$pfxPath/subgDirS1"; if ( $direct eq "DPM" ) { $frrootS2 = "gsiftp://${fmach}$dpmRoot/$pfxPath/subgDirS1"; } } my $fremotS3 = "$frrootS2/$lfnS1"; system("cat $rinit2 $rinit2 $rinit2 $rinit2 > $rinitS1"); system("cat $rinit2 $rinit2 $rinit2 $rinit2 $rinit2 > $rinitS2"); my $flinitS1 = "$tempDir/$rinitS1"; my $flinitS2 = "$tempDir/$rinitS2"; $statusLocal = "[OK]"; ## Direct rfcp ... XcuteComm("globus-url-copy", "-dbg file:$flinitS1 $fremotS1", "GTCPS1", 0, "$gsiTrfMs{$gVers}", "", "BLOB"); ## "226 Transfer complete.", "", XcuteComm("edg-gridftp-exists", "$fremotS1", "GTSTS1", 0, "EMPTY", "", "BLOB"); my $fremodS1 = "$frrootS1/subgDirS1"; XcuteComm("edg-gridftp-mkdir", "--parents $fremodS1", "GTMKS1", 0, "EMPTY", "", "BLOB"); if (0) { ## rfcp -v2 ... in the new dir XcuteComm("rfcp", "-v2 $flinitS2 $fremotS2", "GTCPS2", 0, "seconds through local", "", "BLOB"); } XcuteComm("edg-gridftp-rename", "$fremotS1 $fremotS3", "GTMVS1", 0, "EMPTY", "", "BLOB"); XcuteComm("edg-gridftp-ls", "--verbose $fremodS1", "GTLSS1", 0, "$lfnS1", "", "BLOB"); ## For JPB comfort ... if (1) { XcuteComm("edg-gridftp-rmdir", "$fremodS1", "GTRMS1", 0, "$gsiRmdMs{$gVers}", "", "BLOB"); } ## "subgDirS1:", "Directory", if (0) { XcuteComm("rfcp", "-v2 $fremotS2 $tempDir/fcrapS2$direct", "GTFRS2", 0, "seconds through eth", "", "BLOB"); } XcuteComm("globus-url-copy", "-dbg $fremotS3 file:$tempDir/gcrapS1$direct", "GTFRS3", 0, "$gsiTrfMs{$gVers}", "", "BLOB"); ## "226 Transfer complete.", "", if (0) { XcuteComm("edg-gridftp-rm", "$fremotS2", "GTRMS2", 0, "EMPTY", "", "BLOB"); } XcuteComm("edg-gridftp-rm", "$fremotS3", "GTRMS3", 0, "EMPTY", "", "BLOB"); ## For JPB comfort as well ... if (1) { XcuteComm("edg-gridftp-rmdir", "$fremodS1", "GTRFS1", 0, "EMPTY", "", "BLOB"); } XcuteComm("edg-gridftp-ls", "--verbose $fremodS1", "GTLSS2", 0, "$gsiLsMs{$gVers}", "", "BLOB"); # "No such file or directory.", "", XcuteComm("diff", "-s $flinitS1 $tempDir/gcrapS1$direct", "GTCMS1", 0, "$tempDir/gcrapS1$direct are", "identical", "BLOB"); if (0) { XcuteComm("diff", "-s $flinitS2 $tempDir/fcrapS2$direct", "GTCMS2", 0, "$tempDir/fcrapS2$direct are", "identical", "BLOB"); } if (0) { XcuteComm("rfcp", "$dpmRoot/$pfxPath/$lfn2 $tempDir/fcrap2", "FCPR", 0, "seconds through eth", "", "BLOB"); } my $tEnd = time(); my $tElapse = $tEnd - $tStart; print "\n Operation: gsiftpSuite with $direct = $statusLocal Duration: $tElapse sec. \n"; print "<_________________________________________________________________________>\n\n"; print " Result: Status: $status\n"; $xCount++; if ( $statusLocal eq "[OK]" ) { $globOK++; } if ( $statusLocal eq "[FAILED]" ) { $globFD++; } undef $statusLocal; } lcgdm-1.8.7/test/dpm/dpm_testget.c0000644000175000017500000000506110141654633016404 0ustar ellertellert#include #include #include #include "dpm_api.h" #include "serrno.h" #define DEFPOLLINT 10 main(argc, argv) int argc; char **argv; { static char *f_stat[] = {"Success", "Queued", "Active", "Ready", "Running", "Done", "Failed", "Aborted"}; struct dpm_getfilestatus *filestatuses; int i; int nbfiles; int nbprotocols; int nbreplies; static char *protocols[] = {"rfio"}; int r = 0; char r_token[CA_MAXDPMTOKENLEN+1]; struct dpm_getfilereq *reqfiles; int status; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if ((reqfiles = calloc (nbfiles, sizeof(struct dpm_getfilereq))) == NULL) { perror ("calloc"); exit (1); } for (i = 0; i < nbfiles; i++) reqfiles[i].from_surl = argv[i+1]; nbprotocols = sizeof(protocols) / sizeof(char *); if ((status = dpm_get (nbfiles, reqfiles, nbprotocols, protocols, NULL, 0, r_token, &nbreplies, &filestatuses)) < 0) { sperror ("dpm_get"); exit (1); } printf ("dpm_get returned r_token: %s\n", r_token); /* wait for request status "Done" or "Failed" */ while (status == DPM_QUEUED || status == DPM_ACTIVE) { for (i = 0; i < nbreplies; i++) { if ((filestatuses+i)->from_surl) free ((filestatuses+i)->from_surl); if ((filestatuses+i)->turl) free ((filestatuses+i)->turl); if ((filestatuses+i)->errstring) free ((filestatuses+i)->errstring); } free (filestatuses); printf("request state Pending\n"); sleep ((r++ == 0) ? 1 : DEFPOLLINT); if ((status = dpm_getstatus_getreq (r_token, 0, NULL, &nbreplies, &filestatuses)) < 0) { sperror ("dpm_getstatus_getreq"); exit (1); } } printf ("request state %s\n", status == DPM_DONE ? "Done" : "Failed"); if (status == DPM_FAILED) exit (1); for (i = 0; i < nbreplies; i++) { if ((filestatuses+i)->turl) printf ("state[%d] = %s, TURL = %s\n", i, f_stat[(filestatuses+i)->status >> 12], (filestatuses+i)->turl); else if (((filestatuses+i)->status & DPM_FAILED) == DPM_FAILED) printf ("state[%d] = %s, serrno = %d, errstring = <%s>\n", i, f_stat[(filestatuses+i)->status >> 12], (filestatuses+i)->status & 0xFFF, (filestatuses+i)->errstring ? (filestatuses+i)->errstring : ""); else printf ("state[%d] = %s\n", i, f_stat[(filestatuses+i)->status >> 12]); if ((filestatuses+i)->from_surl) free ((filestatuses+i)->from_surl); if ((filestatuses+i)->turl) free ((filestatuses+i)->turl); if ((filestatuses+i)->errstring) free ((filestatuses+i)->errstring); } free (filestatuses); exit (0); } lcgdm-1.8.7/test/dpm/Imakefile0000644000175000017500000000346610335135453015540 0ustar ellertellertCOMM COMM Copyright (C) 2004-2005 by CERN COMM All rights reserved COMM COMM @(#)$RCSfile: Imakefile,v $ $Revision: 1.7 $ $Date: 2005/11/11 15:39:23 $ CERN Jean-Philippe Baud COMM Make dpm socket tests #if BuildSecurity LIBCSEC = -ldl #endif INCLUDES = FileName(FileName(..,..),h) #if SOLARIS LIBS = -L../../lib -ldpm -lsocket -lnsl #else LIBS = -L../../lib -ldpm $(LIBCSEC) #endif RFIOFLG = -DGFAL_ENABLE_RFIO prefixsocket = $(prefix)/test/sbin/ COMM######################### FLAGS ############################## CFLAGS = -I$(INCLUDES) COMM######################### RULES ############################## PROGS = ProgramTargetName(dpm_testcopy) \ ProgramTargetName(dpm_testget) \ ProgramTargetName(dpm_testgetprotocols) \ ProgramTargetName(dpm_testput) \ ProgramTargetName(dpm_testputdone) SCRIPTS = socketSuite \ socketStress PROGSBIN = $(addprefix $(prefixsocket),$(PROGS) $(SCRIPTS)) all: $(PROGS) NormalProgramTarget(dpm_testcopy,dpm_testcopy.Osuf,$(DEPLIBS),$(LIBS) $(SECLIB)) NormalProgramTarget(dpm_testget,dpm_testget.Osuf,$(DEPLIBS),$(LIBS) $(SECLIB)) NormalProgramTarget(dpm_testgetprotocols,dpm_testgetprotocols.Osuf,$(DEPLIBS),$(LIBS) $(SECLIB)) NormalProgramTarget(dpm_testput,dpm_testput.Osuf,$(DEPLIBS),$(LIBS) $(SECLIB)) NormalProgramTarget(dpm_testputdone,dpm_testputdone.Osuf,$(DEPLIBS),$(LIBS) $(SECLIB)) install: $(PROGSBIN) install.man: $(prefixsocket)%: % cp $? $@ COMM###################### CLEANING RULES ######################## clean: -@RemoveFiles(FilesToClean) clobber: clean -@RemoveFiles($(PROGS)) #if _WIN32 depend: @echo Not supported on this platform #else depend: makedepend -Y$(INCLUDES) *.c 2> /dev/null #endif Makefiles: FORCE: COMM###################### DEPENDENCIES ########################## COMM DO NOT DELETE THIS LINE -- make depend depends on it. lcgdm-1.8.7/test/dpm/dpm_testputdone.c0000644000175000017500000000240110141704340017265 0ustar ellertellert#include #include #include #include "dpm_api.h" #include "serrno.h" #define DEFPOLLINT 10 main(argc, argv) int argc; char **argv; { static char *f_stat[] = {"Success", "Queued", "Active", "Ready", "Running", "Done", "Failed", "Aborted"}; struct dpm_filestatus *filestatuses; int i; int nbfiles; int nbreplies; int r = 0; char *r_token; char **surls; int status; if (argc < 3) { fprintf (stderr, "usage: %s r_token SURLs\n", argv[0]); exit (1); } nbfiles = argc - 2; r_token = argv[1]; surls = &argv[2]; if ((status = dpm_putdone (r_token, nbfiles, surls, &nbreplies, &filestatuses)) < 0) { sperror ("dpm_putdone"); exit (1); } for (i = 0; i < nbreplies; i++) { if (((filestatuses+i)->status & DPM_FAILED) == DPM_FAILED) printf ("state[%d] = %s, serrno = %d, errstring = <%s>\n", i, f_stat[(filestatuses+i)->status >> 12], (filestatuses+i)->status & 0xFFF, (filestatuses+i)->errstring ? (filestatuses+i)->errstring : ""); else printf ("state[%d] = %s\n", i, f_stat[(filestatuses+i)->status >> 12]); if ((filestatuses+i)->surl) free ((filestatuses+i)->surl); if ((filestatuses+i)->errstring) free ((filestatuses+i)->errstring); } free (filestatuses); exit (0); } lcgdm-1.8.7/test/dpm/dpm_testcopy.c0000644000175000017500000000712111066421615016575 0ustar ellertellert#include #include #include #include #include "dpm_api.h" #include "serrno.h" #define DEFPOLLINT 10 extern char *optarg; extern int optind; main(argc, argv) int argc; char **argv; { char buf[4096]; int c; FILE *df; char *dirfile = NULL; int errflg = 0; static char *f_stat[] = {"Success", "Queued", "Active", "Ready", "Running", "Done", "Failed", "Aborted"}; struct dpm_copyfilestatus *filestatuses = NULL; char *fromsurl; int i; int nbfiles = 0; int nbreplies; int r = 0; char r_token[CA_MAXDPMTOKENLEN+1]; struct dpm_copyfilereq *reqfiles; int status; char *tosurl; while ((c = getopt (argc, argv, "i:")) != EOF) { switch (c) { case 'i': dirfile = optarg; break; case '?': errflg++; break; default: break; } } if ((optind > argc - 2 && dirfile == NULL) || (optind < argc && dirfile != NULL)) { errflg++; } if (errflg) { fprintf (stderr, "usage: %s from_SURL to_SURL\n\t%s -i directive_file\n", argv[0], argv[0]); exit (1); } if (dirfile == NULL) nbfiles = 1; else { if ((df = fopen (dirfile, "r")) == NULL) { perror ("dirfile open"); exit (1); } while (fgets (buf, sizeof(buf), df)) { if (buf[strlen (buf)-1] != '\n') { fprintf (stderr, "directive %d too long\n", nbfiles + 1); exit (1); } nbfiles++; } rewind (df); } if ((reqfiles = calloc (nbfiles, sizeof(struct dpm_copyfilereq))) == NULL) { perror ("calloc"); exit (1); } if (dirfile == NULL) { reqfiles[0].from_surl = argv[1]; reqfiles[0].to_surl = argv[2]; } else { i = 0; while (fgets (buf, sizeof(buf), df)) { buf[strlen (buf)-1] = '\0'; if ((fromsurl = strtok (buf, " ")) == NULL || (tosurl = strtok (NULL, " ")) == NULL) { fprintf (stderr, "directive %d does not contain a fromSURL and a toSURL\n", nbfiles + 1); exit (1); } if ((reqfiles[i].from_surl = strdup (fromsurl)) == NULL || (reqfiles[i].to_surl = strdup (tosurl)) == NULL) { perror ("malloc"); exit (1); } i++; } fclose (df); } r_token[0] = '\0'; status = dpm_copy (nbfiles, reqfiles, NULL, 0, 0, r_token, &nbreplies, &filestatuses); if (*r_token) printf ("dpm_copy returned r_token: %s\n", r_token); if (! filestatuses) { sperror ("dpm_copy"); exit (1); } /* wait for request status "Done" or "Failed" */ while (status == DPM_QUEUED4COPY || status == DPM_ACTIVE) { dpm_free_cfilest (nbreplies, filestatuses); printf("request state Pending\n"); sleep ((r++ == 0) ? 1 : DEFPOLLINT); filestatuses = NULL; if ((status = dpm_getstatus_copyreq (r_token, 0, NULL, NULL, &nbreplies, &filestatuses)) < 0) { if (filestatuses) break; sperror ("dpm_getstatus_copyreq"); exit (1); } } printf ("request state %s\n", f_stat[status >> 12]); for (i = 0; i < nbreplies; i++) { if (((filestatuses+i)->status & DPM_FAILED) == DPM_FAILED) printf ("state[%d] = %s, serrno = %d, errstring = <%s>\n", i, f_stat[(filestatuses+i)->status >> 12], (filestatuses+i)->status & 0xFFF, (filestatuses+i)->errstring ? (filestatuses+i)->errstring : ""); else { printf ("state[%d] = %s", i, f_stat[(filestatuses+i)->status >> 12]); if ((filestatuses+i)->f_lifetime == 0x7FFFFFFF) printf (" f_lifetime = Inf\n"); else printf (" f_lifetime = %d\n", (filestatuses+i)->f_lifetime); } if ((filestatuses+i)->from_surl) free ((filestatuses+i)->from_surl); if ((filestatuses+i)->to_surl) free ((filestatuses+i)->to_surl); if ((filestatuses+i)->errstring) free ((filestatuses+i)->errstring); } free (filestatuses); exit (0); } lcgdm-1.8.7/test/dpm/dpm_testgetprotocols.c0000644000175000017500000000074610133143462020350 0ustar ellertellert#include #include "dpm_api.h" #include "serrno.h" main() { int i; int nb_supported_protocols; char **supported_protocols; if (dpm_getprotocols (&nb_supported_protocols, &supported_protocols) < 0) { sperror ("dpm_getprotocols"); exit (2); } printf ("Supported protocols are:"); for (i = 0; i < nb_supported_protocols; i++) { printf (" %s", supported_protocols[i]); free (supported_protocols[i]); } printf ("\n"); free (supported_protocols); exit (0); } lcgdm-1.8.7/test/dpm/socketSuite0000755000175000017500000006077410717450012016157 0ustar ellertellert#!/usr/bin/perl -w ########################################################################################## # # Suite.pl # # A Perl script to test the DPM (socket interface) # # Author: Gilbert Grosdidier, LAL (Universite Paris-Sud, Orsay) # Creation Date: 3/11/2004 # Last rev: 18/07/2007 (GG) + 16/11/2007 # ########################################################################################## ### ### Copyright (C) 2004-2006 by CERN/IT/GD/CT & CNRS/IN2P3/LAL ### All rights reserved ### # $Id: socketSuite,v 1.26 2007/11/17 02:20:58 grodid Exp $ use strict; ##use File::CounterFile; ###################### ## The following functions are tested or used, in raw: # $operation = "dpm-put"; # $operation = "globus-url-copy"; # $operation = "rfcp"; # $operation = "dpm-putdone"; # $operation = "dpm-get"; # $operation = "dpm-getreqsummary"; # $operation = "dpm-getreqstatus"; # $operation = "dpm-extendfilelife"; # $operation = "dpm-getreqstatus"; # $operation = "dpm-extendfilelife"; # $operation = "dpm-getreqstatus"; # $operation = "dpm-relfiles"; # $operation = "dpm-getreqstatus"; # $operation = "dpm-getreqid --format=dpmsurl:30,dpmrtyp,dpmpint,dpmfsiz:10,dpmmode,dpmstatus,dpmfstat:6,dpmturl:35"; # $operation = "OVERALL SUITE"; ###################### my $target = shift; my $tstNAME = shift; my $sfileH = shift; my $subTree = shift; my $s_token = shift; my $Counter; my $value; my $valinc; my $sfile; my $args; my $xCount = 0; my $usage; my $dateST; chomp(my $dday = `date '+%j'`); my $tStart = time(); if ( ! $sfileH ) { require File::CounterFile; $Counter = File::CounterFile->new("./CounterFile", 1000+$dday); $value = $Counter->value(); $valinc = $Counter->inc(); # $sfile = "socket_Tfile.fil$valinc"; $sfile = "fil$valinc"; $sfileH = $sfile; print " Counter Start Value: $sfileH \n"; $sfile = "socket_Tfile.${sfileH}S0"; # exit 0; } else { print " Counter Start Value: $sfileH \n"; $sfile = "socket_Tfile.${sfileH}S0"; } ##20$ENV{DPM_HOST} = "lxb1902"; ##20my $target = $ENV{DPM_HOST}; ## Run this with something like: ## srmv2Suite lxb1902.cern.ch baud # my $target = shift; # my $tstNAME = shift; ##BAD$target =~ m/(\w*?)\.(.*)/; $target =~ m/([-\w]*?)\.(.*)/; my $site_domain = $2; chomp(my $fullname = `hostname -f`); if ( ! $target || ! $tstNAME || ! $site_domain ) { print STDERR " Wrong ARGS ! \n"; print STDERR " Usage: $0 Target_FullNodeName UserName [InitFileName] \n"; exit 1; } else { print STDOUT " The target Host is: $target \n"; print STDOUT " The target Domain is: $site_domain \n"; print STDOUT " The current Host is: $fullname \n"; } $ENV{DPNS_HOST} = $target; $ENV{DPM_HOST} = $target; print " Target Servers: DPNS: $ENV{DPNS_HOST} DPM, srmV2: $ENV{DPM_HOST} \n"; chomp(my $day = `date '+%b%d'`); # my $u_token = "gilbert_${day}_v$valinc"; my $u_token = "gilbert_${day}_T${sfileH}"; my $struct; my $voteam; if ( $ENV{VOTEAM} ) { $voteam = $ENV{VOTEAM}; } else { $voteam = 'dteam'; } ##my $baseDpm = "/dpm/dteam/${tstNAME}"; # my $baseDpm = "/dpm/cern.ch/home/dteam"; my $baseDteam = "/dpm/$site_domain/home/$voteam"; my $baseDpm = $baseDteam; if ( $subTree ) { $baseDpm = "$baseDteam/$subTree"; } my $file = "${baseDpm}/$sfile"; my @Lfile = (); foreach (1..3) { ##$valinc = $Counter->inc(); my $short = "socket_Tfile.${sfileH}S$_"; push @Lfile, "${baseDpm}/$short"; } $struct->{$file}->{input} = "/etc/ldap.conf"; $struct->{$Lfile[0]}->{input} = "/etc/termcap"; ## Which kind of host are we running on ? if ( -e "/boot/vmlinux-2.4.20-30.7.legacysmp" ) { ## This is RH73 $struct->{$Lfile[1]}->{input} = "/boot/vmlinux-2.4.20-30.7.legacysmp"; print STDOUT " The Current Host is a RH73 one: $fullname \n"; } elsif ( -e "/boot/vmlinux-2.4.21-20.EL.cernsmp" ) { ## This is SLC3 ##20if ( $ENV{HOST} eq "lxb1902" ) { ##21chomp(my $fullname = `hostname -f`); ##21if ( "$fullname" eq "$SLhost" ) { $struct->{$Lfile[1]}->{input} = "/boot/vmlinux-2.4.21-20.EL.cernsmp"; $struct->{$Lfile[2]}->{input} = "/boot/initrd-2.4.21-20.EL.cernsmp.img"; print STDOUT " The Current Host is a SLC3 one: $fullname \n"; } else { print STDOUT " Host type unidentified: $fullname \n"; my @bList = `ls -dl /boot/* | sort -rn -k 5,5`; foreach ( @bList ) { my @m = split /\s+/; if ( ! $struct->{$Lfile[1]}->{input} ) { $struct->{$Lfile[1]}->{input} = $m[8]; } elsif ( $m[4]>100000 && $m[4]<900000 ) { $struct->{$Lfile[2]}->{input} = $m[8]; last; } } } print STDOUT " \n"; foreach my $kfile ( sort keys %{$struct} ) { my $rls = `ls -l $struct->{$kfile}->{input}`; print STDOUT " File: $kfile Orig: $struct->{$kfile}->{input} \n$rls"; } print STDOUT " \n"; ## Path setup ... one must start it from test/dpm for the time being ... $ENV{PATH} = "../../rfio:$ENV{PATH}"; $ENV{PATH} = "$ENV{PATH}:../../socket/dpmcli"; $struct->{$file}->{fflag} = 1; $struct->{$Lfile[0]}->{fflag} = 2; $struct->{$Lfile[1]}->{fflag} = 2; $struct->{$Lfile[2]}->{fflag} = 2; $struct->{$file}->{pin} = 111000; $struct->{$Lfile[0]}->{pin} = 222000; $struct->{$Lfile[1]}->{pin} = 333000; $struct->{$Lfile[2]}->{pin} = 444000; ## Sizes in kbytes (1024) my $dss; ($struct->{$file}->{size}, $dss) = split /\s+/, `ls -s $struct->{$file}->{input} | awk '{print \$1}'`; ##($struct->{$Ffile}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Ffile}->{input} | awk '{print \$1}'`; ($struct->{$Lfile[0]}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Lfile[0]}->{input} | awk '{print \$1}'`; ($struct->{$Lfile[1]}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Lfile[1]}->{input} | awk '{print \$1}'`; ($struct->{$Lfile[2]}->{size}, $dss) = split /\s+/, `ls -s $struct->{$Lfile[2]}->{input} | awk '{print \$1}'`; print " VERIF0: $file $struct->{$file}->{input} $struct->{$file}->{size} \n"; my $f1stfproc = "gsiftp"; ##### SPECIAL: must be [rfio|gsiftp] ## REVERTED on 10/05/05 $f1stfproc = "rfio"; ## TEMP on 13/04/05 my $foperation; if ( $f1stfproc eq "rfio" ) { $foperation = "rfcp"; } else { $foperation = "globus-url-copy"; } system("which rfcp"); #system("echo 1 \$PATH; which rfcp"); #system("echo 2 \$PATH; hash rfcp; which rfcp"); print STDOUT " \n"; ##PREVmy $u_token = "gilbert_dec13"; ##PREVmy @res = `dpm-put --dpmproto gsiftp --dpmutoken=$u_token --dpmreqsize 100 $file`; my $fflag = 1; #test my @res = `~baud/w0/DPNS_MYSQL/ns/nsls -l /dpm/dteam/grodid`; my $r_token; my $f_token; my $g_token; my $TURL; my $lTURL; my $status; my $tstatus; my $sTURL; my $command; my $findex; my $operation = "dpm-put"; $command = "$operation --dpmproto gsiftp --dpmutoken=$u_token --dpmreqsize 100 $file"; if ( $s_token ) { $command = "$operation --dpmproto $f1stfproc --dpmstoken=$s_token --dpmutoken=$u_token --dpmreqsize $struct->{$file}->{size} $file"; } else { $command = "$operation --dpmproto $f1stfproc --dpmutoken=$u_token --dpmreqsize 100 $file"; } $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; my @res = `$command`; foreach ( @res ) { print "L1: $_"; my @m = split; if ( /r_token:/ ) { $r_token = $m[3]; } # if ( /TURL =/ ) { $lTURL = $_; $tstatus = $m[2]; $TURL = $m[5]; } if ( /state\[(\d+?)\]/ ) { $findex = $1; $lTURL = $_; $tstatus = $m[2]; $TURL = $m[5]; ##PREV$TURL =~ m[(.*?)://(.*)]; if ( $f1stfproc eq "rfio" ) { ##### SPECIAL $TURL =~ m[(.*?)://.*?/(.*)]; $TURL =~ m[(.*?)://(.*)]; $sTURL = $2; $sTURL =~ s;//;:/; ; if ( $ENV{NEW_RFIO_SYNTAX} ) { $sTURL = $TURL; ### For the NEW RFIOD 30/11/05 } } else { $TURL =~ m[(.*?://.*?)(/.*?:)(/.*)]; $sTURL = $1 . $3; $sTURL = $TURL; ### For the NEW FTPD 23/05/05 } my $lfile; if ( $fflag == 1 ) { $lfile = $file; } else { $lfile = $Lfile[$findex]; } $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{sTURL} = $sTURL; ## $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{r_token} = $r_token; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" || $tstatus ne "Ready," ) { print " Put FAILED: $lTURL \n"; exit 1; } else { print " Operation: $operation = $status \n"; } ##$TURL =~ m[(.*?)://(.*)]; ##my $sTURL = $2; undef $status; @res = (); ##PREV@res = `dpm-put --dpmutoken=$u_token --dpmproto rfio --dpmreqsize 100 @Lfile`; $fflag = 2; if ( $s_token ) { $command = "$operation --dpmutoken=$u_token --dpmstoken=$s_token --dpmproto rfio --dpmreqsize 10 @Lfile"; $command = "$operation --dpmutoken=$u_token --dpmstoken=$s_token --dpmproto rfio --dpmtosurls $struct->{$Lfile[0]}->{size},$struct->{$Lfile[1]}->{size},$struct->{$Lfile[2]}->{size} @Lfile"; $command = "$operation --dpmutoken=$u_token --dpmstoken=$s_token --dpmproto rfio --dpmfsizes $struct->{$Lfile[0]}->{size},$struct->{$Lfile[1]}->{size},$struct->{$Lfile[2]}->{size} @Lfile"; } else { $command = "$operation --dpmutoken=$u_token --dpmproto rfio --dpmreqsize 100 @Lfile"; } $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { print "L3: $_"; my @m = split; if ( /r_token:/ ) { $r_token = $m[3]; } # if ( /TURL =/ ) { $lTURL = $_; $tstatus = $m[2]; $TURL = $m[5]; } if ( /state\[(\d+?)\]/ ) { $findex = $1; $lTURL = $_; $tstatus = $m[2]; $TURL = $m[5]; ##PREV$TURL =~ m[(.*?)://(.*)]; ##PREV$TURL =~ m[(.*?)://.*?/(.*)]; $TURL =~ m[(.*?)://(.*)]; $sTURL = $2; $sTURL =~ s;//;:/; ; if ( $ENV{NEW_RFIO_SYNTAX} ) { $sTURL = $TURL; ### For the NEW RFIOD 30/11/05 } my $lfile; if ( $fflag == 1 ) { $lfile = $file; } else { $lfile = $Lfile[$findex]; } $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{sTURL} = $sTURL; #p print " VERIF: $TURL $2 $sTURL $lfile $struct->{$lfile}->{sTURL}\n"; ## $struct->{$lfile}->{TURL} = $TURL; $struct->{$lfile}->{r_token} = $r_token; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" || $tstatus ne "Ready," ) { print " Put FAILED: $lTURL \n"; exit 1; } else { print " Operation: $operation = $status \n"; } foreach my $kfile ( sort keys %{$struct} ) { ##BADforeach my $kfile ( @Lfile ) { if ( $kfile eq $file ) { ## For the first file of the stack undef $status; @res = (); ##PREV$command = "$operation file://".$ENV{PWD}."/$struct->{$file}->{input} $struct->{$file}->{TURL}"; if ( $f1stfproc eq "rfio" ) { $operation = "rfcp"; $command = "$operation $struct->{$file}->{input} $struct->{$file}->{sTURL}"; } else { $operation = "globus-url-copy"; $command = "$operation file://$struct->{$file}->{input} $struct->{$file}->{sTURL}"; } $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { print "C: $_"; my @m = split; } $status = $? ? "[FAILED]" : "[OK]" ; if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } else { ## For the rest of the stack undef $status; $operation = "rfcp"; @res = (); #@res = `rfcp /etc/ldap.conf $sTURL`; #@res = `rfcp /etc/termcap $sTURL`; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: rfcp $struct->{$kfile}->{input} $struct->{$kfile}->{sTURL}\n"; @res = `rfcp $struct->{$kfile}->{input} $struct->{$kfile}->{sTURL}`; foreach ( @res ) { if ( /bytes/ ) { $status = "[OK]"; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } $operation = "dpm-putdone"; undef $status; my $SURL; @res = (); $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: dpm-putdone --dpmrtoken=$struct->{$kfile}->{r_token} $kfile \n"; @res = `dpm-putdone --dpmrtoken=$struct->{$kfile}->{r_token} $kfile`; foreach ( @res ) { print "D: $_"; my @m = split; if ( /SURL =/ ) { $SURL = $m[5]; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } if ( $SURL ne $kfile ) { print " Mismatch: $SURL $kfile \n"; ####exit 1; } #good} my $fTURL; $TURL = $struct->{$kfile}->{TURL}; undef $status; $operation = "dpm-get"; @res = (); $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: dpm-get --dpmutoken=$u_token --dpmproto:rfio $kfile \n"; @res = `dpm-get --dpmutoken=$u_token --dpmproto:rfio $kfile`; foreach ( @res ) { print "GF: $_"; my @m = split; if ( /r_token:/ ) { $f_token = $m[3]; } if ( /TURL =/ ) { $fTURL = $m[5]; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } my @TURL_ = ($TURL =~ m[\w+?://(.*)]); my @fTURL_ = ($fTURL =~ m[\w+?://(.*)]); if ( "@TURL_" ne "@fTURL_" ) { print " Mismatch: >@TURL_< >@fTURL_< \n"; print " Mismatch: $TURL $fTURL \n"; ####exit 1; } else { print " TURL[rfio]: $TURL $fTURL\n"; } my $gTURL; undef $status; @res = (); $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: dpm-get --dpmutoken=$u_token --dpmproto:gsiftp $kfile \n"; @res = `dpm-get --dpmutoken=$u_token --dpmproto:gsiftp $kfile`; foreach ( @res ) { print "GG: $_"; my @m = split; if ( /r_token:/ ) { $g_token = $m[3]; } if ( /TURL =/ ) { $gTURL = $m[5]; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } @TURL_ = ($TURL =~ m[\w+?://(.*)]); @fTURL_ = ($gTURL =~ m[\w+?://(.*)]); if ( "@TURL_" ne "@fTURL_" ) { print " Mismatch: >@TURL_< >@fTURL_< \n"; print " Mismatch: $TURL $gTURL \n"; #####exit 1; } else { print " TURL[gsiftp]: $TURL $gTURL \n"; } $struct->{$kfile}->{f_token} = $f_token; $struct->{$kfile}->{g_token} = $g_token; } foreach my $kfile ( sort keys %{$struct} ) { undef $status; $operation = "dpm-getreqsummary"; @res = (); ##PREV@res = `dpm-getreqsummary $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}`; $command = "$operation $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /state/ ) { next; } my @m = split; print "S: $_"; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } foreach my $kfile ( sort keys %{$struct} ) { undef $status; $operation = "dpm-getreqstatus"; @res = (); ##PREV@res = `dpm-getreqstatus $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}`; $command = "$operation $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /state/ ) { next; } my @m = split; # print "S: $_"; if ( /request, state/ ) { my $l = $_; $l =~ s/req.*TURL/TURL/; # $l =~ s/TURL.*fsz/fsz/; print "S: $l"; } else { print "S: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } $operation = "dpm-extendfilelife"; foreach my $kfile ( sort keys %{$struct} ) { undef $status; @res = (); ##PREV @res = `dpm-extendfilelife --dpmrtoken $struct->{$kfile}->{f_token} --dpmlifet=$struct->{$kfile}->{pin} $kfile`; $command = "$operation --dpmrtoken $struct->{$kfile}->{f_token} --dpmlifet=$struct->{$kfile}->{pin} $kfile"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /stat/ ) { next; } my @m = split; #print "E: $_"; if ( /new/ ) { print "E: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } undef $status; @res = (); my $lt = 2*$struct->{$kfile}->{pin}; ##PREV @res = `dpm-extendfilelife --dpmrtoken $struct->{$kfile}->{g_token} --dpmlifet=$lt $kfile`; $command = "$operation --dpmrtoken $struct->{$kfile}->{g_token} --dpmlifet=$lt $kfile"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /stat/ ) { next; } my @m = split; if ( /new/ ) { print "E: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } foreach my $kfile ( sort keys %{$struct} ) { undef $status; $operation = "dpm-getreqstatus"; @res = (); ##PREV@res = `dpm-getreqstatus $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}`; $command = "$operation $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /state/ ) { next; } my @m = split; # print "S: $_"; if ( /request, state/ ) { my $l = $_; $l =~ s/req.*TURL/TURL/; # $l =~ s/TURL.*fsz/fsz/; print "S: $l"; } else { print "S: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } $operation = "dpm-extendfilelife"; foreach my $kfile ( sort keys %{$struct} ) { undef $status; @res = (); my $lt = 3*$struct->{$kfile}->{pin}; ##PREV @res = `dpm-extendfilelife --dpmrtoken $struct->{$kfile}->{f_token} --dpmlifet=$lt $kfile`; $command = "$operation --dpmrtoken $struct->{$kfile}->{f_token} --dpmlifet=$lt $kfile"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /stat/ ) { next; } my @m = split; #print "E: $_"; if ( /new/ ) { print "E: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } undef $status; @res = (); $lt = 5*$struct->{$kfile}->{pin}; ##PREV @res = `dpm-extendfilelife --dpmrtoken $struct->{$kfile}->{g_token} --dpmlifet=$lt $kfile`; $command = "$operation --dpmrtoken $struct->{$kfile}->{g_token} --dpmlifet=$lt $kfile"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /stat/ ) { next; } my @m = split; #print "E: $_"; if ( /new/ ) { print "E: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } foreach my $kfile ( sort keys %{$struct} ) { undef $status; $operation = "dpm-getreqstatus"; @res = (); ##PREV@res = `dpm-getreqstatus $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}`; $command = "$operation $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /state/ ) { next; } my @m = split; # print "S: $_"; if ( /request, state/ ) { my $l = $_; $l =~ s/req.*TURL/TURL/; # $l =~ s/TURL.*fsz/fsz/; print "S: $l"; } else { print "S: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } $operation = "dpm-relfiles"; foreach my $kfile ( sort keys %{$struct} ) { undef $status; @res = (); ##PREV print " CMD: dpm-relfiles --dpmrtoken $struct->{$kfile}->{f_token} $kfile \n"; ##PREV @res = `dpm-relfiles --dpmrtoken $struct->{$kfile}->{f_token} $kfile`; $command = "$operation --dpmrtoken $struct->{$kfile}->{f_token} $kfile"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { print "R: $_"; my @m = split; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } foreach my $kfile ( sort keys %{$struct} ) { undef $status; $operation = "dpm-getreqstatus"; @res = (); ##PREV@res = `dpm-getreqstatus $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}`; $command = "$operation $struct->{$kfile}->{r_token} $struct->{$kfile}->{f_token} $struct->{$kfile}->{g_token}"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " CMD: $command\n"; @res = `$command`; foreach ( @res ) { if ( ! /state/ ) { next; } my @m = split; # print "S: $_"; if ( /request, state/ ) { my $l = $_; $l =~ s/req.*TURL/TURL/; # $l =~ s/TURL.*fsz/fsz/; print "S: $l"; } else { print "S: $_"; } if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } } $operation = "dpm-getreqid"; undef $status; @res = (); $command = "$operation --format=dpmsurl:46,dpmrtyp,dpmpint,dpmfsiz:10,dpmmode,dpmstatus,dpmfstat:16,dpmturl:55 $u_token"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { ## if ( /Stat problem/||/send2nsd: NS009/||/Array Control/ ) { next; } print "GID2: $_"; my @m = split; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } $args = ""; foreach my $kfile ( sort keys %{$struct} ) { if ( $kfile eq $file ) { next; } if ( $kfile eq $Lfile[-1] ) { next; } $args .= " $kfile"; } XcuteComm("dpm-rm", "$args", "RM1", "Done", 1); # Try to add dpmmode $operation = "dpm-getreqid"; undef $status; @res = (); $command = "$operation --format=dpmsurl:46,dpmrtyp,dpmpint,dpmfsiz:10,dpmmode,dpmstatus,dpmfstat:16,dpmturl:55 $u_token"; $xCount++; $usage = `$operation 2>&1`; print "<_________________________________________________________________________>\n\n"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { ## if ( /Stat problem/||/send2nsd: NS009/||/Array Control/ ) { next; } print "GID3: $_"; my @m = split; if ( /request state/ ) { $status = ( "Done" eq $m[2] ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" ) { exit 1; } else { print " Operation: $operation = $status \n"; } my $tAlmost = time() - $tStart; $operation = "OVERALL SUITE"; print " Operation: $operation = $status Duration: $tAlmost sec.\n"; exit 0; #################################################################################################### sub XcuteComm { $operation = shift; my $cargs = shift; my $label = shift; my $xpectStat = shift; my $fatalXit = shift; $xCount++; undef $status; @res = (); $usage = `$operation 2>&1`; $command = "$operation $cargs"; $dateST = `date '+%y%m%d-%H%M%S'`; print "++++ $$ $dateST\n"; print " STEP: $xCount OPERATION: $operation USAGE: $usage CMD: $command\n"; @res = `$command 2>&1`; foreach ( @res ) { $_ =~ s/req.*TURL/TURL/; if ( ! /^\s+$|^\.\.\.$/ ) { print "$label: $_"; } my @m = split; if ( /request state/ ) { $status = ( "$xpectStat" eq "$m[2]" ) ? "[OK]" : "[FAILED]" ; } } if ( $status ne "[OK]" && $fatalXit) { exit 1; } else { print " Operation: $operation = $status \n"; print "<_________________________________________________________________________>\n\n"; } return 0; } lcgdm-1.8.7/test/dpm/dpm_testput.c0000644000175000017500000000505210141654633016435 0ustar ellertellert#include #include #include #include "dpm_api.h" #include "serrno.h" #define DEFPOLLINT 10 main(argc, argv) int argc; char **argv; { static char *f_stat[] = {"Success", "Queued", "Active", "Ready", "Running", "Done", "Failed", "Aborted"}; struct dpm_putfilestatus *filestatuses; int i; int nbfiles; int nbprotocols; int nbreplies; static char *protocols[] = {"rfio"}; int r = 0; char r_token[CA_MAXDPMTOKENLEN+1]; struct dpm_putfilereq *reqfiles; int status; if (argc < 2) { fprintf (stderr, "usage: %s SURLs\n", argv[0]); exit (1); } nbfiles = argc - 1; if ((reqfiles = calloc (nbfiles, sizeof(struct dpm_putfilereq))) == NULL) { perror ("calloc"); exit (1); } for (i = 0; i < nbfiles; i++) reqfiles[i].to_surl = argv[i+1]; nbprotocols = sizeof(protocols) / sizeof(char *); if ((status = dpm_put (nbfiles, reqfiles, nbprotocols, protocols, NULL, 0, 0, r_token, &nbreplies, &filestatuses)) < 0) { sperror ("dpm_put"); exit (1); } printf ("dpm_put returned r_token: %s\n", r_token); /* wait for request status "Done" or "Failed" */ while (status == DPM_QUEUED || status == DPM_ACTIVE) { for (i = 0; i < nbreplies; i++) { if ((filestatuses+i)->to_surl) free ((filestatuses+i)->to_surl); if ((filestatuses+i)->turl) free ((filestatuses+i)->turl); if ((filestatuses+i)->errstring) free ((filestatuses+i)->errstring); } free (filestatuses); printf("request state Pending\n"); sleep ((r++ == 0) ? 1 : DEFPOLLINT); if ((status = dpm_getstatus_putreq (r_token, 0, NULL, &nbreplies, &filestatuses)) < 0) { sperror ("dpm_getstatus_putreq"); exit (1); } } printf ("request state %s\n", status == DPM_DONE ? "Done" : "Failed"); if (status == DPM_FAILED) exit (1); for (i = 0; i < nbreplies; i++) { if ((filestatuses+i)->turl) printf ("state[%d] = %s, TURL = %s\n", i, f_stat[(filestatuses+i)->status >> 12], (filestatuses+i)->turl); else if (((filestatuses+i)->status & DPM_FAILED) == DPM_FAILED) printf ("state[%d] = %s, serrno = %d, errstring = <%s>\n", i, f_stat[(filestatuses+i)->status >> 12], (filestatuses+i)->status & 0xFFF, (filestatuses+i)->errstring ? (filestatuses+i)->errstring : ""); else printf ("state[%d] = %s\n", i, f_stat[(filestatuses+i)->status >> 12]); if ((filestatuses+i)->to_surl) free ((filestatuses+i)->to_surl); if ((filestatuses+i)->turl) free ((filestatuses+i)->turl); if ((filestatuses+i)->errstring) free ((filestatuses+i)->errstring); } free (filestatuses); exit (0); } lcgdm-1.8.7/test/dpm/socketStress0000755000175000017500000000176410253556677016366 0ustar ellertellert#!/usr/bin/perl -w ########################################################################################## # # Socket-stressSuite # # A Perl script to test the socket interface of DPM # # Author: Gilbert Grosdidier, LAL (Universite Paris-Sud, Orsay) # Creation Date : 3/11/2004 # Migration : 27/12/2004 # Last rev: 14/06/2005 (GG) # ########################################################################################## ### ### Copyright (C) 2004-2005 by CERN/IT/GD/CT & CNRS/IN2P3/LAL ### All rights reserved ### # $Id: socketStress,v 1.2 2005/06/14 13:38:06 grodid Exp $ # Usage: socketStress lxgate22 50 2100 [domain] use strict; my $mach = shift; my $many = shift; my $label = shift; my $domain = shift || "cern.ch"; $label--; my $command = "time socketSuite ${mach}.${domain} grodid > /tmp/suite-SLC3-${mach}-sec.lis"; foreach my $cn ( 1 .. $many ) { my $lab = $label + $cn; my $cm = "nohup $command$lab 2>&1 &"; print "CM: >> $cm << \n"; system ("$cm"); } exit 0; lcgdm-1.8.7/test/File/0000755000175000017500000000000012202120643014003 5ustar ellertellertlcgdm-1.8.7/test/File/CounterFile.pm0000644000175000017500000001357610173736633016615 0ustar ellertellertpackage File::CounterFile; # $Id: CounterFile.pm,v 1.1 2005/01/20 14:18:03 grodid Exp $ require 5.004; use strict; use Carp qw(croak); use Symbol qw(gensym); use Fcntl qw(LOCK_EX O_RDWR O_CREAT); BEGIN { # older version of Fcntl did not know about SEEK_SET if ($] < 5.006) { *SEEK_SET = sub () { 0 }; } else { Fcntl->import("SEEK_SET"); } } use vars qw($VERSION $MAGIC $DEFAULT_INITIAL $DEFAULT_DIR); sub Version { $VERSION; } $VERSION = "1.04"; $MAGIC = "#COUNTER-1.0\n"; # first line in counter files $DEFAULT_INITIAL = 0; # default initial counter value # default location for counter files $DEFAULT_DIR = $ENV{TMPDIR} || "/usr/tmp"; # Experimental overloading. use overload ('++' => \&inc, '--' => \&dec, '""' => \&value, fallback => 1, ); sub new { my($class, $file, $initial) = @_; croak("No file specified\n") unless defined $file; $file = "$DEFAULT_DIR/$file" unless $file =~ /^[\.\/]/; $initial = $DEFAULT_INITIAL unless defined $initial; my $value; local($/, $\) = ("\n", undef); local *F; sysopen(F, $file, O_RDWR|O_CREAT) or croak("Can't open $file: $!"); flock(F, LOCK_EX) or croak("Can't flock: $!"); my $first_line = ; if (defined $first_line) { croak "Bad counter magic '$first_line' in $file" unless $first_line eq $MAGIC; $value = ; chomp($value); } else { seek(F, 0, SEEK_SET); print F $MAGIC; print F "$initial\n"; $value = $initial; } close(F) || croak("Can't close $file: $!"); bless { file => $file, # the filename for the counter 'value' => $value, # the current value updated => 0, # flag indicating if value has changed # handle => XXX, # file handle symbol. Only present when locked }; } sub locked { exists shift->{handle}; } sub lock { my($self) = @_; $self->unlock if $self->locked; my $fh = gensym(); my $file = $self->{file}; open($fh, "+<$file") or croak "Can't open $file: $!"; flock($fh, LOCK_EX) or croak "Can't flock: $!"; # 2 = exlusive lock local($/) = "\n"; my $magic = <$fh>; if ($magic ne $MAGIC) { $self->unlock; croak("Bad counter magic '$magic' in $file"); } chomp($self->{'value'} = <$fh>); $self->{handle} = $fh; $self->{updated} = 0; $self; } sub unlock { my($self) = @_; return unless $self->locked; my $fh = $self->{handle}; if ($self->{updated}) { # write back new value local($\) = undef; seek($fh, 0, SEEK_SET) or croak "Can't seek to beginning: $!"; print $fh $MAGIC; print $fh "$self->{'value'}\n"; } close($fh) or warn "Can't close: $!"; delete $self->{handle}; $self; } sub inc { my($self) = @_; if ($self->locked) { $self->{'value'}++; $self->{updated} = 1; } else { $self->lock; $self->{'value'}++; $self->{updated} = 1; $self->unlock; } $self->{'value'}; # return value } sub dec { my($self) = @_; if ($self->locked) { unless ($self->{'value'} =~ /^\d+$/) { $self->unlock; croak "Autodecrement is not magical in perl"; } $self->{'value'}--; $self->{updated} = 1; } else { $self->lock; unless ($self->{'value'} =~ /^\d+$/) { $self->unlock; croak "Autodecrement is not magical in perl"; } $self->{'value'}--; $self->{updated} = 1; $self->unlock; } $self->{'value'}; # return value } sub value { my($self) = @_; my $value; if ($self->locked) { $value = $self->{'value'}; } else { $self->lock; $value = $self->{'value'}; $self->unlock; } $value; } sub DESTROY { my $self = shift; $self->unlock; } 1; __END__ =head1 NAME File::CounterFile - Persistent counter class =head1 SYNOPSIS use File::CounterFile; $c = File::CounterFile->new("COUNTER", "aa00"); $id = $c->inc; open(F, ">F$id"); =head1 DESCRIPTION This module implements a persistent counter class. Each counter is represented by a separate file in the file system. File locking is applied, so multiple processes can attempt to access a counter simultaneously without risk of counter destruction. You give the file name as the first parameter to the object constructor (C). The file is created if it does not exist. If the file name does not start with "/" or ".", then it is interpreted as a file relative to C<$File::CounterFile::DEFAULT_DIR>. The default value for this variable is initialized from the environment variable C, or F if no environment variable is defined. You may want to assign a different value to this variable before creating counters. If you pass a second parameter to the constructor, it sets the initial value for a new counter. This parameter only takes effect when the file is created (i.e. it does not exist before the call). When you call the C method, you increment the counter value by one. When you call C, the counter value is decremented. In both cases the new value is returned. The C method only works for numerical counters (digits only). You can peek at the value of the counter (without incrementing it) by using the C method. The counter can be locked and unlocked with the C and C methods. Incrementing and value retrieval are faster when the counter is locked, because we do not have to update the counter file all the time. You can query whether the counter is locked with the C method. There is also an operator overloading interface to the File::CounterFile object. This means that you can use the C<++> operator for incrementing and the C<--> operator for decrementing the counter, and you can interpolate counters directly into strings. =head1 COPYRIGHT Copyright (c) 1995-1998,2002,2003 Gisle Aas. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Gisle Aas =cut lcgdm-1.8.7/test/python/0000755000175000017500000000000012202120643014445 5ustar ellertellertlcgdm-1.8.7/test/python/lfc/0000755000175000017500000000000012202120643015211 5ustar ellertellertlcgdm-1.8.7/test/python/lfc/lfc-readdirg-grs.py0000755000175000017500000001034010556456371020724 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script lists the files, their # mode, their size and their replicas with optimized performance. # # It uses the lfc_opendirg, lfc_readdirg and lfc_getreplicas methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirg_grs #============================================================================= def readdirg_grs(*args): if len(args) < 1: folder = '' else: folder = args[0] if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) files = [] guids = [] listp = lfc.lfc_list() #--------------------------------------------------------------------------- # Loop on the entries of the folder to build : # - the list of all files with Name, Filemode and GUID, # - the list of GUID for all regular files. #--------------------------------------------------------------------------- while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break if entry.filemode & 040000: marker = '/' elif entry.filemode & 020000: # not entry.guid: marker = '@' else: marker = '' files.append({'name': entry.d_name + marker, 'mode': entry.filemode, 'guid': entry.guid}) if not (entry.filemode & 060000): # Exclude folders and symbolic links guids.append(entry.guid) lfc.lfc_closedir(dir) #--------------------------------------------------------------------------- # Get all replicas at once and build dictionaries per GUID #--------------------------------------------------------------------------- guidSizes = {} guidReplicas = {} (res, rep_entries) = lfc.lfc_getreplicas(guids, '') if res != 0: print 'lfc_getreplicas : Error ' + str(res) + "\n" else: for entry in rep_entries: if entry.errcode == 0: if entry.guid in guidReplicas: guidReplicas[entry.guid].append(entry.sfn) else: guidSizes[entry.guid] = entry.filesize guidReplicas[entry.guid] = [entry.sfn] #--------------------------------------------------------------------------- # Loop on the list of files to print their Filemode, Name and Replicas #--------------------------------------------------------------------------- for myfile in files: print ('%06o' % myfile['mode']) + ' ' + myfile['name'] guid = myfile['guid'] if guid in guidReplicas: nb_replicas = 0 for replica in guidReplicas[guid]: if replica != '': nb_replicas += 1 print ' ==>', replica print 'Found ' + str(nb_replicas) + ' replica(s) Size=' + \ str(guidSizes[guid]) print #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirg_grs(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/unit_tests.py0000644000175000017500000001146310517104314017775 0ustar ellertellert#!/usr/bin/python import sys import lfc import commands import os # # test entry # directory = "/grid/dteam/my_test_dir/" name = "/grid/dteam/my_test_dir/my.test" replica1 = "sfn://my_se.in2p3.fr/hpss/in2p3.fr/group/sophie/tests_python/dir/my.test" replica2 = "srm://my_other_se.cern.ch/castor/cern.ch/grid/sophie/tests_python/dir/my.test" replica3 = "sfn://my_se.in2p3.fr/hpss/in2p3.fr/group/sophie/tests_python/dir/my.test2" status = '-' f_type = 'D' # # delete test entry, if exists # stat1 = lfc.lfc_filestatg() if (lfc.lfc_statg(name,"",stat1)) == 0: if (lfc.lfc_delreplica(stat1.guid, None, replica1)) != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print "error"+ str(err_num) + " (" + err_string + ")" lfc.lfc_delreplica(stat1.guid, None, replica2) lfc.lfc_delreplica(stat1.guid, None, replica3) lfc.lfc_unlink(name) lfc.lfc_rmdir(directory) # # create entry in LFC for following tests # guid = commands.getoutput('uuidgen').split('\n')[0] print guid lfc.lfc_mkdir(directory, 0755) if (lfc.lfc_creatg(name, guid, 0644)) != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print "Error when creating " + name + ": Error " + str(err_num) + " (" + err_string + ")" #sys.exit(1) # # stat this entry in the LFC and print the GUID # stat3 = lfc.lfc_filestatg() if (lfc.lfc_statg(name,"",stat3)) == 0: guid = stat3.guid print "The GUID for " + name + " is " + guid else: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print "There was an error while looking for " + name + ": Error " + str(err_num) + " (" + err_string + ")" #sys.exit(1) # # add replicas # lfc.lfc_addreplica(guid, None, os.getenv("LFC_HOST"), replica1, status, f_type, "", "") lfc.lfc_addreplica(guid, None, os.getenv("LFC_HOST"), replica2, status, f_type, "", "") lfc.lfc_addreplica(guid, None, os.getenv("LFC_HOST"), replica3, status, f_type, "", "") # # Using the lfc_getacl and lfc_setacl methods to add a user ACL # nentries, acls_list = lfc.lfc_getacl(name, lfc.CA_MAXACLENTRIES) print "nentries = " + str(nentries) print len(acls_list) for i in acls_list: print i.a_type print i.a_id print i.a_perm # When adding a first ACL for a given user, you also need to add the mask # When adding the second user ACL, it is not necessary anymore acl_user = lfc.lfc_acl() acl_mask = lfc.lfc_acl() acl_user.a_type=2 # 2 corresponds to CNS_ACL_USER acl_user.a_id=18701 # user id acl_user.a_perm=5 acl_mask.a_type=5 # 5 corresponds to CNS_ACL_MASK acl_mask.a_id=0 # no user id specified acl_mask.a_perm=5 acls_list.append(acl_user) acls_list.append(acl_mask) if (lfc.lfc_setacl(name, acls_list)) == 0: print "OK" else: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print "Error " + str(err_num) + " (" + err_string + ")" #sys.exit(1) # # Using the lfc_getacl and lfc_setacl methods to remove a user ACL # nentries, acls_list = lfc.lfc_getacl(name, lfc.CA_MAXACLENTRIES) # Note: you cannot remove the owner ACL (i.e. for CNS_ACL_USER_OBJ type) if ACLs for other users exist. # ====== if all the other user ACLs are deleted, the owner ACL is automatically removed. print "nentries 2 =" + str(nentries) for i in acls_list: print i.a_type print i.a_id print i.a_perm del acls_list[1] # delete a given user ACL from the list of ACLs if (lfc.lfc_setacl(name, acls_list)) == 0: print "OK" else: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print "Error " + str(err_num) + " (" + err_string + ")" #sys.exit(1) # # list replicas, starting from the GUID # listp = lfc.lfc_list() flag = lfc.CNS_LIST_BEGIN print "Listing replicas for GUID " + guid num_replicas=0 while(1): res = lfc.lfc_listreplica("",guid,flag,listp) flag = lfc.CNS_LIST_CONTINUE if res == None: break else: rep_name = res.sfn print "Replica: " + rep_name num_replicas = num_replicas + 1 lfc.lfc_listreplica("",guid,lfc.CNS_LIST_END,listp) print "Found " + str(num_replicas) + " replica(s)" # # using the lfc_getreplica method # result, list = lfc.lfc_getreplica(name, "", "") print "result = " + str(result) print "len(list) = " + str(len(list)) + " replicas found" if (result == 0): for i in list: print i.host print i.sfn # # using lfc_readdirxr method # dir = lfc.lfc_opendirg(directory,"") while 1: read_pt = lfc.lfc_readdirxr(dir,"") if (read_pt == None) or (read_pt == 0): break entry,list=read_pt print entry.d_name try: for i in range(len(list)): print " ==> %s" % list[i].sfn except TypeError, x: print " ==> None" lfc.lfc_closedir(dir) # # delete test entry # stat4 = lfc.lfc_filestatg() if (lfc.lfc_statg(name,"",stat4)) == 0: lfc.lfc_delreplica(stat4.guid, None, replica1) lfc.lfc_delreplica(stat4.guid, None, replica2) lfc.lfc_delreplica(stat4.guid, None, replica3) lfc.lfc_unlink(name) lfc.lfc_rmdir(directory) lcgdm-1.8.7/test/python/lfc/lfc-readdirg-lr-recurse-timestamp.py0000644000175000017500000000752010533347531024210 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script recursively lists the files # and their replicas WITHOUT minimizing the number of simultaneous sessions. # # It uses the lfc_opendirg, lfc_readdirg and lfc_listreplica methods. # # For large file trees, it crashes. In order to facilitate crash analysis : # For each line, it displays the current timestamp and flushes the output. # #============================================================================= import sys import os import time import lfc #============================================================================= # Function readdirg_lr_recurse_timestamp #============================================================================= def readdirg_lr_recurse_timestamp(*args): if len(args) < 1: folder = '' prefix = '' else: folder = args[0] prefix = folder + '/' if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + prefix else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') time_format = '%Y/%m/%d %H:%M:%S %Z' #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) listp = lfc.lfc_list() #--------------------------------------------------------------------------- # Loop on the entries of the folder #--------------------------------------------------------------------------- while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break name = prefix + entry.d_name sys.stdout.write(time.strftime(time_format) + ' ' + name + "\n") sys.stdout.flush() #------------------------------------------------------------------------- # If the entry is a regular file, list its replicas using its GUID #------------------------------------------------------------------------- if not (entry.filemode & 060000): # Exclude folders and symbolic links flag = lfc.CNS_LIST_BEGIN while 1: res = lfc.lfc_listreplica('', entry.guid, flag, listp) if res == None: break else: flag = lfc.CNS_LIST_CONTINUE sys.stdout.write(time.strftime(time_format) + ' ==> ' + res.sfn + "\n") sys.stdout.flush() lfc.lfc_listreplica('', entry.guid, lfc.CNS_LIST_END, listp) #------------------------------------------------------------------------- # If the entry is a folder, recurse #------------------------------------------------------------------------- if entry.filemode & 040000: readdirg_lr_recurse_timestamp(name) lfc.lfc_closedir(dir) #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirg_lr_recurse_timestamp(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/lfc-readdirg.py0000755000175000017500000000504410533270676020135 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script lists the files and their # mode. # # It uses the lfc_opendirg and lfc_readdirg methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirg #============================================================================= def readdirg(*args): if len(args) < 1: folder = '' else: folder = args[0] if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) #--------------------------------------------------------------------------- # Loop on the entries of the folder #--------------------------------------------------------------------------- while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break if entry.filemode & 040000: marker = '/' elif entry.filemode & 020000: # not entry.guid: marker = '@' else: marker = '' print ('%06o' % entry.filemode) + ' ' + entry.d_name + marker lfc.lfc_closedir(dir) #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirg(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/lfc-lr.py0000755000175000017500000000755710533270667017004 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the files given as parameters, this script displays the GUID, the # comment and the list of replicas. # # It uses the lfc_statg, lfc_getcomment and lfc_listreplica methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function list_replicas #============================================================================= def list_replicas(*names): #--------------------------------------------------------------------------- # Loop on the file names given as parameters #--------------------------------------------------------------------------- for name in names: if name[0] != '/': if 'LFC_HOME' in os.environ: name = os.environ['LFC_HOME'] + '/' + name else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #------------------------------------------------------------------------- # stat an existing entry in the LFC and print the GUID #------------------------------------------------------------------------- statg = lfc.lfc_filestatg() res = lfc.lfc_statg(name, '', statg) if res != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' while looking for ' + name + ': ' + err_string) if statg.filemode & 040000: print ('%06o' % statg.filemode), name, 'is a folder' guid = statg.guid if guid: print ('%06o' % statg.filemode), name, 'has guid:' + guid else: print ('%06o' % statg.filemode), name, 'has NO guid' #------------------------------------------------------------------------- # retrieve the comment on a file #------------------------------------------------------------------------- buffer = ' ' * lfc.CA_MAXCOMMENTLEN res = lfc.lfc_getcomment(name, buffer) if res != 0: err_num = lfc.cvar.serrno if err_num != 2: err_string = lfc.sstrerror(err_num) print 'Error ' + str(err_num) + ' while reading the comment for ' + name + ': ' + err_string else: print "Comment: '" + buffer.rstrip(' ') + "'" #------------------------------------------------------------------------- # list the replicas of a given entry, starting from the GUID #------------------------------------------------------------------------- listp = lfc.lfc_list() flag = lfc.CNS_LIST_BEGIN num_replicas = 0 while 1: res = lfc.lfc_listreplica('', guid, flag, listp) if res == None: break else: flag = lfc.CNS_LIST_CONTINUE print ' ==>', res.sfn num_replicas += 1 lfc.lfc_listreplica('', guid, lfc.CNS_LIST_END, listp) print 'Found ' + str(num_replicas) + ' replica(s)\n' #============================================================================= # Main program #============================================================================= if __name__ == '__main__': if len(sys.argv) <= 1: sys.exit('Usage: ' + sys.argv[0] + ' path ...') list_replicas(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/lfc-readdirg-recurse-grs.py0000755000175000017500000001132610556456374022402 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script recursively lists the files # and their replicas with optimized performance. # # It uses the lfc_opendirg, lfc_readdirg and lfc_getreplicas methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirg_recurse #============================================================================= def readdirg_recurse(*args): if len(args) < 1: folder = '' prefix = '' else: folder = args[0] prefix = folder + '/' if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + prefix else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) files = [] listp = lfc.lfc_list() #--------------------------------------------------------------------------- # Loop on the entries of the folder to build the list of files #--------------------------------------------------------------------------- while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break files.append({'name': prefix + entry.d_name, 'mode': entry.filemode, 'guid': entry.guid}) lfc.lfc_closedir(dir) #--------------------------------------------------------------------------- # Loop on the current file list : If the entry is a folder, recurse #--------------------------------------------------------------------------- for myfile in files[:]: # Local copy is mandatory if myfile['mode'] & 040000: files.extend(readdirg_recurse(myfile['name'])) return files #============================================================================= # Function get_all_replicas #============================================================================= def get_all_replicas(files): #--------------------------------------------------------------------------- # Build the list of GUID for all regular files #--------------------------------------------------------------------------- guids = [ myfile['guid'] \ for myfile in files \ if not (myfile['mode'] & 060000) ] # Exclude folders and symbolic links #--------------------------------------------------------------------------- # Get all replicas at once and build dictionaries per GUID #--------------------------------------------------------------------------- guidSizes = {} guidReplicas = {} (res, rep_entries) = lfc.lfc_getreplicas(guids, '') if res != 0: print 'lfc_getreplicas : Error ' + str(res) + "\n" else: for entry in rep_entries: if entry.errcode == 0: if entry.guid in guidReplicas: guidReplicas[entry.guid].append(entry.sfn) else: guidSizes[entry.guid] = entry.filesize guidReplicas[entry.guid] = [entry.sfn] #--------------------------------------------------------------------------- # Loop on the list of files to print their Filemode, Name and Replicas #--------------------------------------------------------------------------- for myfile in files: print myfile['name'] guid = myfile['guid'] if guid in guidReplicas: for replica in guidReplicas[guid]: if replica != '': print ' ==>', replica #============================================================================= # Main program #============================================================================= if __name__ == '__main__': get_all_replicas(readdirg_recurse(*sys.argv[1:])) lcgdm-1.8.7/test/python/lfc/lfc-gr.py0000755000175000017500000000723710533270666016771 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the files given as parameters, this script displays the GUID, the # comment and the list of replicas. # # It uses the lfc_statg, lfc_getcomment and lfc_getreplica methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function get_replicas #============================================================================= def get_replicas(*names): #--------------------------------------------------------------------------- # Loop on the file names given as parameters #--------------------------------------------------------------------------- for name in names: if name[0] != '/': if 'LFC_HOME' in os.environ: name = os.environ['LFC_HOME'] + '/' + name else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #------------------------------------------------------------------------- # stat an existing entry in the LFC and print the GUID #------------------------------------------------------------------------- statg = lfc.lfc_filestatg() res = lfc.lfc_statg(name, '', statg) if res != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' while looking for ' + name + ': ' + err_string) if statg.filemode & 040000: print ('%06o' % statg.filemode), name, 'is a folder' guid = statg.guid if guid: print ('%06o' % statg.filemode), name, 'has guid:' + guid else: print ('%06o' % statg.filemode), name, 'has NO guid' #------------------------------------------------------------------------- # retrieve the comment on a file #------------------------------------------------------------------------- buffer = ' ' * lfc.CA_MAXCOMMENTLEN res = lfc.lfc_getcomment(name, buffer) if res != 0: err_num = lfc.cvar.serrno if err_num != 2: err_string = lfc.sstrerror(err_num) print 'Error ' + str(err_num) + ' while reading the comment for ' + name + ': ' + err_string else: print "Comment: '" + buffer.rstrip(' ') + "'" #------------------------------------------------------------------------- # list the replicas of a given entry, starting from the GUID #------------------------------------------------------------------------- (res, replicas) = lfc.lfc_getreplica('', guid, '') if res == 0: for replica in replicas: print ' ==>', replica.sfn print 'Found ' + str(len(replicas)) + ' replica(s)' print #============================================================================= # Main program #============================================================================= if __name__ == '__main__': if len(sys.argv) <= 1: sys.exit('Usage: ' + sys.argv[0] + ' path ...') get_replicas(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/lfc-perf-symlinks-parselog.pl0000644000175000017500000002422710602513437022745 0ustar ellertellert#!/usr/bin/perl -w #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # This script parses the log file generated by lfc-perf-symlinks.sh to # generate a file in TSV format (tab separated values). # #============================================================================= use strict ; #----------------------------------------------------------------------------- # Constants #----------------------------------------------------------------------------- my @uniqueCommands = ( 'lcg-cr', 'lfc-mkdir', 'lfc-rm', 'lcg-del' ) ; my $uniquePattern = '^(' . join('|', @uniqueCommands) . ')' ; my @multipleCommands = ( 'create symlinks:', 'lfc-ls: ', 'list symlinks:', 'delete symlinks:' ) ; my $multiplePattern = '^(?:(python3?2? +lfc-create-symlinks\\.py) +[^ ]+|'. '(lfc-ls)|'. '(python3?2? +lfc-readdirg\\.py)|'. '(python3?2? +lfc-rm-symlinks-of-dir)\\.py)' ; my $timestamp = ' ' x 19 ; my $hostname = ' ' x 30 ; my $version = ' ' x 7 ; my $se_host = ' ' x 30 ; my $ce_host = ' ' x 30 ; my $log_host = ' ' x 30 ; #----------------------------------------------------------------------------- # Variables #----------------------------------------------------------------------------- my $lfc_host ; my @hosts ; my $command ; my $commandLine ; my $b_unique_OK ; my $index ; my $number ; my %commands ; my %results ; my %uniqueErrors ; my %multipleErrors ; my $time ; my %times ; my %nb ; my %total ; #----------------------------------------------------------------------------- # Loop on the lines of the log file #----------------------------------------------------------------------------- while ( <> ) { #--------------------------------------------------------------------------- # Environment #--------------------------------------------------------------------------- if ( m/^TIMESTAMP=(.*)/ ) { $timestamp = $1 } elsif ( m/^HOSTNAME=(.*)/ ) { $hostname = sprintf('%-30s', $1) } elsif ( m/^GLITE_VERSION=(.*)/ ) { $version = sprintf('%-7s', $1) } elsif ( m/^SE_HOST=(.*)/ ) { $se_host = sprintf('%-30s', $1) } elsif ( m/^GlueCEUniqueID=([^:]*):/ ) { $ce_host = sprintf('%-30s', $1) } elsif ( m/^GLITE_WMS_LOG_DESTINATION=(.*)/ ) { $log_host = sprintf('%-30s', $1) } elsif ( m/^LFC_HOST=([^#\n].*)/ ) { $lfc_host = sprintf('%-30s', $1) ; if ( not defined($nb{$lfc_host}) ) { push(@hosts, $lfc_host) ; foreach $command ( @uniqueCommands ) { $nb{$lfc_host}{$command} = 0 ; $total{$lfc_host}{$command} = 0 ; } } } #--------------------------------------------------------------------------- # RTT (Round Trip Time) #--------------------------------------------------------------------------- elsif ( m|^(rtt)\s+.*\s+=\s+[0-9\.]+/([0-9\.]+)/| ) { $times{$lfc_host}{$1} = sprintf("%9s\tms", $2) } #--------------------------------------------------------------------------- # Commands on an unique folder or file #--------------------------------------------------------------------------- elsif ( m/$uniquePattern / ) { $command = $1 ; $commandLine = $_ ; $b_unique_OK = 1 ; } #--------------------------------------------------------------------------- # Commands on multiples file #--------------------------------------------------------------------------- elsif ( m/^$multiplePattern +_folder_([0-9]+)_files/ ) { $index = (grep(defined($-[$_]), 1..$#-))[0] - 1 ; $command = $multipleCommands[$index] ; $number = sprintf('%9s', $+) ; push(@{$commands{$lfc_host}}, [$command, $number]) ; $results{$lfc_host}{$command}{$number} = '' ; } #--------------------------------------------------------------------------- # Error messages #--------------------------------------------------------------------------- elsif ( m/^Error|^send2nsd:|error:/i and defined($lfc_host) and defined($command) ) { if ( defined($number) ) { push(@{$multipleErrors{$lfc_host}{$command}{$number}}, $_) } else { if ( $b_unique_OK ) { push(@{$uniqueErrors{$lfc_host}{$command}}, 'LFC_HOST=', $lfc_host, "\n", $commandLine) } push(@{$uniqueErrors{$lfc_host}{$command}}, $_) ; $b_unique_OK = 0 ; } } #--------------------------------------------------------------------------- # Result messages #--------------------------------------------------------------------------- elsif ( m/^ *([0-9]+)$/ or m/_folder_[0-9]+_files *: *([0-9]+)( +symbolic +links +(created|deleted)|$)/ ) { $results{$lfc_host}{$command}{$number} = sprintf("%9s", $1) } #--------------------------------------------------------------------------- # Elapsed time #--------------------------------------------------------------------------- elsif ( m/^real\s+(.*)/ ) { $time = $1 ; if ( $time =~ m/^([0-9\.]+) *s/ ) { $time = $1 } elsif ( $time =~ m/^([0-9]+)m([0-9\.]+)s/ ) { $time = (60 * $1) + $2 } if ( defined($number) ) { $times{$lfc_host}{$command}{$number} = sprintf("%9s\ts ", $time) } elsif ( $b_unique_OK ) { $nb{$lfc_host}{$command} ++ ; $total{$lfc_host}{$command} += $time ; } undef $number ; undef $command ; } } #----------------------------------------------------------------------------- # Print header #----------------------------------------------------------------------------- if ( $ce_host eq (' ' x 30) ) { $ce_host = $log_host } printf "%-16s\t%9s\t%9s\t%9s\t \t%-30s\t%-30s\t%-30s\t%-30s\t%-7s\t%-19s\n", 'Command', 'Number', 'Result', 'Time', 'LFC_host', 'CE_host', 'WN_host', 'SE_host', 'Version', 'Timestamp' ; #----------------------------------------------------------------------------- # Loop on the LFC hosts to print lines #----------------------------------------------------------------------------- my $b_OK = 1 ; my $result ; my $errorsRef ; foreach $lfc_host ( @hosts ) { #--------------------------------------------------------------------------- # RTT (Round Trip Time) #--------------------------------------------------------------------------- if ( defined($times{$lfc_host}{'rtt'}) ) { print "rtt: ", " \t" x 3, $times{$lfc_host}{'rtt'}, "\t", $lfc_host, "\t", $ce_host, "\t", $hostname, "\t", $se_host, "\t", $version, "\t", $timestamp, "\n" } #--------------------------------------------------------------------------- # Commands on an unique folder or file #--------------------------------------------------------------------------- foreach $command ( @uniqueCommands ) { if ( defined($total{$lfc_host}{$command}) and ($total{$lfc_host}{$command} > 0) ) { printf "%-16s\t \t \t%9.3f\ts \t". "%s\t%s\t%s\t%s\t%s\t%s\n", $command.':', $total{$lfc_host}{$command} / $nb{$lfc_host}{$command}, $lfc_host, $ce_host, $hostname, $se_host, $version, $timestamp } $errorsRef = $uniqueErrors{$lfc_host}{$command} ; if ( defined($errorsRef) ) { print STDERR @{$errorsRef}, "\n" } } #--------------------------------------------------------------------------- # Commands on multiples file #--------------------------------------------------------------------------- foreach my $commandAndNumber ( @{$commands{$lfc_host}} ) { ($command, $number) = @{$commandAndNumber} ; $result = $results{$lfc_host}{$command}{$number} ; print $command, "\t", $number, "\t", $result, "\t", $times{$lfc_host}{$command}{$number}, "\t", $lfc_host, "\t", $ce_host, "\t", $hostname, "\t", $se_host, "\t", $version, "\t", $timestamp, "\n" ; #------------------------------------------------------------------------- # Error messages and Erroneous results #------------------------------------------------------------------------- $errorsRef = $multipleErrors{$lfc_host}{$command}{$number} ; if ( defined($errorsRef) or ($result ne $number) ) { if ( $b_OK ) { printf STDERR "%-16s\t%9s\t%9s\t%9s\t \t". "%-30s\t%-30s\t%-30s\t%-30s\t%-7s\t%-19s\n\n", 'Command', 'Number', 'Result', 'Time', 'LFC_host', 'CE_host', 'WN_host', 'SE_host', 'Version', 'Timestamp' ; $b_OK = 0 ; } if ( $result ne $number ) { print STDERR $command, "\t", $number, "\t", $result, "\t", $times{$lfc_host}{$command}{$number}, "\t", $lfc_host, "\t", $ce_host, "\t", $hostname, "\t", $se_host, "\t", $version, "\t", $timestamp, "\n" } if ( defined($errorsRef) ) { print STDERR @{$errorsRef}, "\n" } } } } lcgdm-1.8.7/test/python/lfc/lfc-create-subfolders.py0000644000175000017500000000376310674231540021761 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2007 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # This script creates subfolders in the folder given as first parameter. # The number of subfolders is the second parameter. # # It uses the lfc_mkdir method. # #============================================================================= import sys import os import lfc if len(sys.argv) <= 2: sys.exit('Usage: ' + sys.argv[0] + ' folder_path number_of_subfolders') (folder, nb_subfolders) = (sys.argv[1], int(sys.argv[2])) if nb_subfolders < 1: sys.exit(folder + ' : 0 subfolders created') if folder[0] != '/': if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') targetname = folder + '/subfolder' nb_char = len(str(nb_subfolders-1)) if lfc.lfc_startsess('', '') != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' starting LFC session: ' + err_string) for number in range(nb_subfolders): name = targetname + str(number).zfill(nb_char) res = lfc.lfc_mkdir(name, 0775) if res != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print 'Error ' + str(err_num) + ' while creating ' + name + ': ' + err_string number -= 1 break lfc.lfc_endsess() print folder, ': ', (number+1), 'subfolders created' lcgdm-1.8.7/test/python/lfc/lfc-readdirg-recurse-readdirxr.py0000644000175000017500000001277010533541222023552 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script recursively lists the files, # creates a dictionary of files per folder, then loops on the folders to list # the files and their replicas. # # It minimizes the number of simultaneous sessions. # # It uses the lfc_opendirg, lfc_readdirg and lfc_readdirxr methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirg_recurse #============================================================================= def readdirg_recurse(*args): if len(args) < 1: folder = '' prefix = '' else: folder = args[0] prefix = folder + '/' if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + prefix else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) listp = lfc.lfc_list() folderFiles = {prefix: []} #--------------------------------------------------------------------------- # Append the entries of the folder to the current list #--------------------------------------------------------------------------- files = [] while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break files.append({'name': entry.d_name, 'mode': entry.filemode}) lfc.lfc_closedir(dir) #--------------------------------------------------------------------------- # Loop on the entries of the current file list to build the dictionary #--------------------------------------------------------------------------- for myfile in files: folderFiles[prefix].append(myfile['name']) #------------------------------------------------------------------------- # If the entry is a folder, recurse #------------------------------------------------------------------------- if myfile['mode'] & 040000: folderFiles.update(readdirg_recurse(prefix + myfile['name'])) return folderFiles #============================================================================= # Function readdirxr #============================================================================= def readdirxr(folderFiles): folderKeys = folderFiles.keys() folderKeys.sort() #print folderKeys #--------------------------------------------------------------------------- # Loop on the folders #--------------------------------------------------------------------------- for folder in folderKeys: prefix = folder #print '\n' + prefix + ':', folderFiles[prefix] if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #------------------------------------------------------------------------- # Open the folder #------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) #------------------------------------------------------------------------- # Loop on the entries of the folder which are in the dictionary #------------------------------------------------------------------------- while 1: read_pt = lfc.lfc_readdirxr(dir, '') if read_pt == None: break entry, replicas = read_pt if entry.d_name not in folderFiles[prefix]: break if entry.filemode & 040000: comment = ' (Folder)' elif entry.nbreplicas == 0: comment = ' (No replica)' else: comment = '' print prefix + entry.d_name #----------------------------------------------------------------------- # If the entry is a regular file, list its replicas #----------------------------------------------------------------------- if comment == '': for replica in replicas: print ' ==>', replica.sfn lfc.lfc_closedir(dir) #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirxr(readdirg_recurse(*sys.argv[1:])) lcgdm-1.8.7/test/python/lfc/lfc-perf-symlinks-purge-hosts.jdl.template0000644000175000017500000000323510535623532025360 0ustar ellertellert#============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # This template permits to create a JDL for a job purging the files left by # performance tests on symbolic links. # # Following variable must be substituted by an adequate value : # # $LFC_HOSTS_FILE : File containing the list of LFC hosts # #============================================================================= Type = "Job"; JobType = "Normal"; Executable = "lfc-perf-symlinks-purge-hosts.sh"; Arguments = "$LFC_HOSTS_FILE"; InputSandbox = { "lfc-perf-symlinks-purge-hosts.sh", "$LFC_HOSTS_FILE", "lfc-rmdir-of-symlinks.py" }; StdOutput = "lfc-perf-symlinks-purge-hosts.log"; StdError = "lfc-perf-symlinks-purge-hosts.err.log"; OutputSandbox = { "lfc-perf-symlinks-purge-hosts.log", "lfc-perf-symlinks-purge-hosts.err.log" }; RetryCount = 0; ShallowRetryCount = 1; lcgdm-1.8.7/test/python/lfc/lfc-create-symlinks.py0000755000175000017500000000474210533270665021470 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the file given as first parameter, this script creates symbolic links # in the folder given as second parameter. The number of symbolic links is # the third parameter. # # It uses the lfc_symlink method. # #============================================================================= import sys import os import lfc if len(sys.argv) <= 3: sys.exit('Usage: ' + sys.argv[0] + ' source_path folder_path number_of_symlinks') (source, folder, nb_symlinks) = (sys.argv[1], sys.argv[2], int(sys.argv[3])) if nb_symlinks < 1: sys.exit(folder + ' : 0 symbolic links created') nb_char = len(str(nb_symlinks-1)) if source[0] != '/': if 'LFC_HOME' in os.environ: source = os.environ['LFC_HOME'] + '/' + source else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') if folder[0] != '/': if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') pos1 = source.rfind('/') sourcename = source[pos1+1:] pos2 = sourcename.rfind('.') if pos2 > -1: targetname = folder + '/' + sourcename[:pos2] suffix = sourcename[pos2:] else: targetname = folder + '/' + sourcename suffix = '' if lfc.lfc_startsess('', '') != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' starting LFC session: ' + err_string) for number in range(nb_symlinks): name = targetname + str(number).zfill(nb_char) + suffix res = lfc.lfc_symlink(source, name) if res != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print 'Error ' + str(err_num) + ' while creating ' + name + ': ' + err_string number -= 1 break lfc.lfc_endsess() print folder, ': ', (number+1), 'symbolic links created' lcgdm-1.8.7/test/python/lfc/lfc-readdirg-lr.py0000755000175000017500000000653510533270672020552 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script lists the files, their # mode and their replicas. # # It uses the lfc_opendirg, lfc_readdirg and lfc_listreplica methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirg_lr #============================================================================= def readdirg_lr(*args): if len(args) < 1: folder = '' else: folder = args[0] if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) listp = lfc.lfc_list() #--------------------------------------------------------------------------- # Loop on the entries of the folder #--------------------------------------------------------------------------- while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break if entry.filemode & 040000: marker = '/' elif entry.filemode & 020000: # not entry.guid: marker = '@' else: marker = '' print ('%06o' % entry.filemode) + ' ' + entry.d_name + marker #------------------------------------------------------------------------- # If the entry is a regular file, list its replicas using its GUID #------------------------------------------------------------------------- if not (entry.filemode & 060000): # Exclude folders and symbolic links flag = lfc.CNS_LIST_BEGIN num_replicas = 0 while 1: res = lfc.lfc_listreplica('', entry.guid, flag, listp) if res == None: break else: flag = lfc.CNS_LIST_CONTINUE print ' ==>', res.sfn num_replicas += 1 lfc.lfc_listreplica('', entry.guid, lfc.CNS_LIST_END, listp) print 'Found ' + str(num_replicas) + ' replica(s)' print lfc.lfc_closedir(dir) #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirg_lr(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/lfc-readdirxr-recurse.py0000644000175000017500000000642710533541222021775 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script recursively lists the files # and their replicas, minimizing the number of simultaneous sessions. # # It uses the lfc_opendirg and lfc_readdirxr methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirxr_recurse #============================================================================= def readdirxr_recurse(*args): if len(args) < 1: folder = '' prefix = '' else: folder = args[0] prefix = folder + '/' if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + prefix else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) #--------------------------------------------------------------------------- # Loop on the entries of the folder #--------------------------------------------------------------------------- folders = [] while 1: read_pt = lfc.lfc_readdirxr(dir, '') if read_pt == None: break entry, replicas = read_pt name = prefix + entry.d_name if entry.filemode & 040000: folders.append(name) comment = ' (Folder)' elif entry.nbreplicas == 0: comment = ' (No replica)' else: comment = '' print name + comment #------------------------------------------------------------------------- # If the entry is a regular file, list its replicas #------------------------------------------------------------------------- if comment == '': for replica in replicas: print ' ==>', replica.sfn lfc.lfc_closedir(dir) #--------------------------------------------------------------------------- # Recurse on subfolders #--------------------------------------------------------------------------- for name in folders: readdirxr_recurse(name) #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirxr_recurse(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/lfc-rm-symlinks-of-dir.py0000644000175000017500000001007710533270701022003 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # This script deletes all symbolic links of a folder. # # It uses the lfc_readdirg and lfc_unlink methods. # #============================================================================= import sys import os import lfc if len(sys.argv) <= 1: sys.exit('Usage: ' + sys.argv[0] + ' folder_path') #----------------------------------------------------------------------------- # First parameter is the path of the folder to delete # If it is a relative path, prepend $LFC_HOME #----------------------------------------------------------------------------- folder = sys.argv[1] if folder[0] != '/': if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #----------------------------------------------------------------------------- # Open the folder to get the list of its files #----------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) #----------------------------------------------------------------------------- # Loop on the files contained by the folder. # If they are neither subfolders nor regular files, we suppose they are # symbolic links, and we put their name in the 'symlinks' list. #----------------------------------------------------------------------------- b_OK = True symlinks = [] while 1: entry = lfc.lfc_readdirg(dir) if entry == None: break if (entry.filemode & 040000): print ' ', entry.d_name, 'is a folder' b_OK = False elif entry.guid: print ' ', entry.d_name, 'is a regular file' b_OK = False if b_OK: symlinks.append(entry.d_name) #----------------------------------------------------------------------------- # Close the folder. # If at least one file found is not a symbolic link, stop. #----------------------------------------------------------------------------- lfc.lfc_closedir(dir) if not b_OK: sys.exit(1) print folder, ': ', len(symlinks), 'symbolic links found' if len(symlinks) > 0: #--------------------------------------------------------------------------- # Here all files inside the folder are symbolic links. # Open an LFC session. #--------------------------------------------------------------------------- res = lfc.lfc_startsess('', '') if res != 0: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' starting LFC session: ' + err_string) #--------------------------------------------------------------------------- # Loop on the symbolic links contained by the folder to delete them #--------------------------------------------------------------------------- number = 0 for name in symlinks: name = folder + '/' + name res = lfc.lfc_unlink(name) if res == 0: number += 1 else: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) print "Error " + str(err_num) + " while deleting " + name + ": " + err_string print folder, ': ', number, 'symbolic links deleted' #--------------------------------------------------------------------------- # Close the LFC session. #--------------------------------------------------------------------------- lfc.lfc_endsess() lcgdm-1.8.7/test/python/lfc/lfc-readdirxr.py0000755000175000017500000000560510533270700020327 0ustar ellertellert#!/usr/bin/python #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the folder given as parameter, this script lists the files and their # replicas. # # It uses the lfc_opendirg and lfc_readdirxr methods. # #============================================================================= import sys import os import lfc #============================================================================= # Function readdirxr #============================================================================= def readdirxr(*args): if len(args) < 1: folder = '' else: folder = args[0] if (folder == '') or (folder[0] != '/'): if 'LFC_HOME' in os.environ: folder = os.environ['LFC_HOME'] + '/' + folder else: sys.exit('Relative folder path requires LFC_HOME to be set and exported') #--------------------------------------------------------------------------- # Open the folder #--------------------------------------------------------------------------- dir = lfc.lfc_opendirg(folder, '') if dir == None: err_num = lfc.cvar.serrno err_string = lfc.sstrerror(err_num) sys.exit('Error ' + str(err_num) + ' on folder ' + folder + ': ' + err_string) #--------------------------------------------------------------------------- # Loop on the entries of the folder #--------------------------------------------------------------------------- while 1: read_pt = lfc.lfc_readdirxr(dir, '') if read_pt == None: break entry, replicas = read_pt if entry.filemode & 040000: comment = ' (Folder)' elif entry.nbreplicas == 0: comment = ' (No replica)' else: comment = '' print ('%06o' % entry.filemode) + ' ' + entry.d_name + comment #------------------------------------------------------------------------- # If the entry is a regular file, list its replicas #------------------------------------------------------------------------- if comment == '': for replica in replicas: print ' ==>', replica.sfn lfc.lfc_closedir(dir) #============================================================================= # Main program #============================================================================= if __name__ == '__main__': readdirxr(*sys.argv[1:]) lcgdm-1.8.7/test/python/lfc/compare-perf.sh0000644000175000017500000001166710564356770020165 0ustar ellertellert#!/bin/bash #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # This script displays the performance of the commands given in parameter. # Commands can begin with bash, perl or python scripts, java classes, # or executables. # # Parameters : # 1: Number of runs # 2: Number of decimals to display for elapsed time # 3 and following : Commands to test # #============================================================================= #----------------------------------------------------------------------------- # Verify that there are at least 3 parameters #----------------------------------------------------------------------------- if [[ $# -lt 3 ]] then echo "Usage: $0 Runs Decimals Command ..." exit 1 fi #----------------------------------------------------------------------------- # First 2 parameters #----------------------------------------------------------------------------- NB_RUNS="$1" DECIMALS="$2" shift 2 #----------------------------------------------------------------------------- # Select the adequate PYTHON interpreter #----------------------------------------------------------------------------- if type python32 > /dev/null 2>&1 then PYTHON=python32 else PYTHON=python fi #----------------------------------------------------------------------------- # Following parameters are commands. # For each one, define the adequate interpreter. # Calculate the length of the longest command. #----------------------------------------------------------------------------- NUM=0 LENGTH_MAX=0 for COMMAND in "$@" do PROGRAM=${COMMAND%% *} SUFFIX=${PROGRAM##*.} case "$SUFFIX" in (class) INTERPRETER[$NUM]='java ' ;; (pl) INTERPRETER[$NUM]='perl -w ' ;; (py) INTERPRETER[$NUM]="$PYTHON " ;; (sh) INTERPRETER[$NUM]='bash ' ;; (*) INTERPRETER[$NUM]='' ;; esac LENGTH=${#COMMAND} if [[ $LENGTH_MAX -lt $LENGTH ]] then LENGTH_MAX=$LENGTH fi ELAPSED_SUM[$NUM]=0 NUM=$(( NUM + 1 )) done #----------------------------------------------------------------------------- # Function nano_to_float (nano, variable_name) # # This function divides the (integer) first argument by 10**9 and sets the # result in the variable whose name is given as second argument #----------------------------------------------------------------------------- function nano_to_float () { local GIGA=1000000000 local NANO=$1 local INTEGER=$(( NANO / GIGA )) if [[ $NANO -ge $GIGA ]] then NANO=$(( NANO - (INTEGER * $GIGA ) )) fi export $2=$INTEGER.$(printf '%09d' $NANO) } #----------------------------------------------------------------------------- # Function remove_dot_class (path, variable_name) # # This function removes the first '.class' from the first token of the first # argument and sets the result in the variable whose name is given as second # argument #----------------------------------------------------------------------------- function remove_dot_class () { local PROGRAM=${1%% *} local SUFFIX=${PROGRAM##*.} if [[ "$SUFFIX" = "class" ]] then export $2="${1/.class/}" fi } #----------------------------------------------------------------------------- # Loop on runs # Loop on commands #----------------------------------------------------------------------------- for (( RUN=0; RUN<$NB_RUNS; RUN++ )) do NUM=0 echo for COMMAND in "$@" do remove_dot_class "$COMMAND" COMMAND printf "%-8s%-${LENGTH_MAX}s " "${INTERPRETER[$NUM]}" "$COMMAND" TIME_NANO=$(date '+%s%N') NB_LINES=$(sh -c "${INTERPRETER[$NUM]}$COMMAND" | wc -l) ELAPSED_NANO=$(( $(date '+%s%N') - TIME_NANO )) ELAPSED_SUM[$NUM]=$(( ELAPSED_SUM[$NUM] + ELAPSED_NANO )) nano_to_float $ELAPSED_NANO ELAPSED_FLOAT printf "%5.${DECIMALS}f s %5s lines\n" $ELAPSED_FLOAT $NB_LINES NUM=$(( NUM + 1 )) done done #----------------------------------------------------------------------------- # Loop on commands #----------------------------------------------------------------------------- echo echo 'Mean elapsed times' echo '------------------' NUM=0 for COMMAND in "$@" do remove_dot_class "$COMMAND" COMMAND nano_to_float $(( ELAPSED_SUM[$NUM] / NB_RUNS )) ELAPSED_FLOAT printf "%-8s%-${LENGTH_MAX}s %5.${DECIMALS}f s\n" \ "${INTERPRETER[$NUM]}" "$COMMAND" $ELAPSED_FLOAT NUM=$(( NUM + 1 )) done echo lcgdm-1.8.7/test/python/lfc/lfc-perf-symlinks-count.sh0000644000175000017500000000672210535323137022261 0ustar ellertellert#!/bin/bash #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # For the LFC hosts listed in the file given as first parameter or else # specified in the LFC_HOSTS_FILE environment variable, this script counts # the files left by performance tests on symbolic links. # # It handles correcly paths containing blanks. # #============================================================================= #----------------------------------------------------------------------------- # If the file containing the list of the LFC hosts is not given as first # parameter, it should be in the LFC_HOSTS_FILE environment variable. #----------------------------------------------------------------------------- if [[ "$1" == "" ]] then if [[ "$LFC_HOSTS_FILE" == "" ]] then echo "Usage: $0 [file_containing_list_of_LFC_hosts]" echo ' By default, $LFC_HOSTS_FILE' exit 1 else echo "LFC_HOSTS_FILE=$LFC_HOSTS_FILE" fi else LFC_HOSTS_FILE="$1" fi #----------------------------------------------------------------------------- # Extract the user's VO from his proxy #----------------------------------------------------------------------------- export LCG_GFAL_VO="$(voms-proxy-info -vo)" if [[ "$LCG_GFAL_VO" == "" ]] then echo "HOSTNAME=$HOSTNAME" >> /dev/stderr exit 1 fi #----------------------------------------------------------------------------- # Extract the user CN from his proxy #----------------------------------------------------------------------------- SUBMITTER="$(voms-proxy-info -subject)" SUBMITTER="${SUBMITTER//CN=limited proxy/}" SUBMITTER="${SUBMITTER//CN=proxy/}" SUBMITTER="${SUBMITTER#*CN=}" SUBMITTER="${SUBMITTER%%/*}" SUBMITTER="${SUBMITTER// /_}" export LFC_HOME="/grid/$LCG_GFAL_VO/$SUBMITTER" #----------------------------------------------------------------------------- # Loop on the LFC hosts listed in the file #----------------------------------------------------------------------------- while read LFC_HOST do if [[ ("$LFC_HOST" != "") && ("${LFC_HOST:0:1}" != "#") ]] then export LFC_HOST echo echo "LFC_HOST=$LFC_HOST" #------------------------------------------------------------------------- # Folders at the first level should be names of worker nodes #------------------------------------------------------------------------- lfc-ls | while read WN_HOST do echo echo " WN_HOST=$WN_HOST" #----------------------------------------------------------------------- # Second level #----------------------------------------------------------------------- lfc-ls "$WN_HOST" | while read FOLDER do if [[ "$FOLDER" != _regular_file_for_symbolic_links.txt ]] then echo -n " $FOLDER : " lfc-ls "$WN_HOST/$FOLDER" | wc -l fi done done echo fi done < "$LFC_HOSTS_FILE" || exit 1 lcgdm-1.8.7/test/python/lfc/lfc-perf-symlinks-submit.pl0000644000175000017500000001323710671750046022440 0ustar ellertellert#!/usr/bin/perl -w #============================================================================= # # Copyright 2006 Etienne URBAH for the EGEE project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details at # http://www.gnu.org/licenses/gpl.html # # This script uses the 'lfc-perf-symlinks.jdl.template' file to create a JDL, # then submits it to all computing elements in the same domain as the LFC # hosts listed in the file given as second parameter or else specified in the # 'LFC_HOSTS_FILE' environment variable. # # Optional first parameter : Number of steps to test (by default 8) # Optional second parameter : File containing the list of LFC hosts # #============================================================================= use strict ; #----------------------------------------------------------------------------- # Constants #----------------------------------------------------------------------------- my $jdlTemplate = 'lfc-perf-symlinks.jdl.template' ; my $vo = $ENV{'LCG_GFAL_VO'} or die "Environment variable 'LCG_GFAL_VO' must be set\n" ; my @linePatterns = ( 'Connecting\s+to\s+the\s+service\s+'. 'https://[^:/]+:7443/glite_wms_wmproxy_server', '=+\s+glite-wms-job-submit\s+Success\s+=+', 'The\s+job\s+has\s+been\s+successfully\s+submitted\s+to\s+the\s+WMProxy', 'Your\s+job\s+identifier\s+is\s*:', '=*' ) ; #----------------------------------------------------------------------------- # Variables to be substituded inside the template #----------------------------------------------------------------------------- my %vars ; $vars{'NB_STEPS'} = ( scalar(@ARGV) ? shift @ARGV : 8 ) ; $vars{'LFC_HOSTS_FILE'} = ( scalar(@ARGV) ? shift @ARGV : ( defined($ENV{'LFC_HOSTS_FILE'}) ? $ENV{'LFC_HOSTS_FILE'} : die "Usage: $0 [Nb_Steps [file_containing_list_of_LFC_hosts]]\n", " By default, 8 \$LFC_HOSTS_FILE\n" ) ) ; print "\nLFC performance test with ".$vars{'NB_STEPS'}.' steps : Max '. (4**($vars{'NB_STEPS'}-1))." symbolic links for '", $vars{'LFC_HOSTS_FILE'}, "'\n\n" ; #----------------------------------------------------------------------------- # Read the template and substitute variables #----------------------------------------------------------------------------- my @jdlLines ; open(TEMPLATE, $jdlTemplate) or die $! ; while (