Add HTTP to DFC tests
[integration.git] / test / mocks / datafilecollector-testharness / simulator-group / setup-http-files-for-image.sh
1 #!/usr/bin/env sh
2
3 # Script to create files for the HTTP server to return upon request.
4 # The file names matches the files names in the events polled from the MR simulator.
5 # Intended for execution in the running http containers in the http-root dir.
6
7 NUM=200 #Default number of files
8 PNFS=1 #Default number of PNFs
9 FSIZE="ALL"
10 PREFIXES="A"
11 HTTP_SERV_INDEX=0
12 NUM_HTTP_SERVERS=1
13
14 if [ $# -ge 1 ]; then
15     NUM=$1
16 fi
17 if [ $# -ge 2 ]; then
18     PNFS=$2
19 fi
20 if [ $# -ge 3 ]; then
21     FSIZE=$3
22     if [ $3 != "1KB" ] && [ $3 != "1MB" ] && [ $3 != "5MB" ]  && [ $3 != "50MB" ]  && [ $3 != "ALL" ]; then
23         echo "File size shall be 1KB|1MB|5MB|50MB|ALL"
24         exit
25     fi
26 fi
27 if [ $# -ge 4 ]; then
28         PREFIXES=$4
29 fi
30 if [ $# -ge 5 ]; then
31         NUM_HTTP_SERVERS=$5
32 fi
33 if [ $# -ge 6 ]; then
34         HTTP_SERV_INDEX=$6
35 fi
36 if [ $# -lt 1 ] || [ $# -gt 6 ]; then
37     echo "Wrong args, usage: setup-http-files-for-image.sh [ <num-files> [ <num-PNFs> [ 1KB|1MB|5MB|50MB [ <comma-separated-file-name-prefixs> [ <number-of-http-servers> <http-server-index> ] ] ] ] ] ]"
38     exit
39 fi
40
41 echo "Running http file creations. " $PNFS " PNFs and " $NUM " files for each PNF with file size(s) " $FSIZE "and file prefixe(s) " $PREFIXES " in http servers with index " $HTTP_SERV_INDEX
42
43 truncate -s 1KB 1KB.tar.gz
44 truncate -s 1MB 1MB.tar.gz
45 truncate -s 5MB 5MB.tar.gz
46 truncate -s 50MB 50MB.tar.gz
47
48 for fnp in ${PREFIXES//,/ }
49 do
50         p=0
51         while [ $p -lt $PNFS ]; do
52                 if [[ $(($p%$NUM_HTTP_SERVERS)) == $HTTP_SERV_INDEX ]]; then
53                 i=0
54                 while [ $i -lt $NUM ]; do  #Problem with for loop and var substituion in curly bracket....so used good old style loop
55                         if [ $FSIZE = "ALL" ] || [ $FSIZE = "1KB" ]; then ln -s 1KB.tar.gz $fnp'20000626.2315+0200-2330+0200_PNF'$p'-'$i'-1KB.tar.gz' >& /dev/null; fi
56                         if [ $FSIZE = "ALL" ] || [ $FSIZE = "1MB" ]; then ln -s 1MB.tar.gz $fnp'20000626.2315+0200-2330+0200_PNF'$p'-'$i'-1MB.tar.gz' >& /dev/null; fi
57                         if [ $FSIZE = "ALL" ] || [ $FSIZE = "5MB" ]; then ln -s 5MB.tar.gz $fnp'20000626.2315+0200-2330+0200_PNF'$p'-'$i'-5MB.tar.gz' >& /dev/null; fi
58                         if [ $FSIZE = "ALL" ] || [ $FSIZE = "50MB" ]; then ln -s 50MB.tar.gz $fnp'20000626.2315+0200-2330+0200_PNF'$p'-'$i'-50MB.tar.gz' >& /dev/null; fi
59                         let i=i+1
60                 done
61         fi
62         let p=p+1
63         done
64 done