1 | #!/bin/ksh |
---|
2 | |
---|
3 | while getopts ":c:t:flradgh" opt |
---|
4 | do |
---|
5 | case $opt in |
---|
6 | c ) CONTROL_URL=$OPTARG ;; |
---|
7 | t ) TEST_URL=$OPTARG ;; |
---|
8 | f ) FUNC_TESTS=true ;; |
---|
9 | l ) LOCAL_TESTS=true ;; |
---|
10 | r ) REMOTE_TESTS=true ;; |
---|
11 | a ) FUNC_TESTS=true |
---|
12 | LOCAL_TESTS=true |
---|
13 | REMOTE_TESTS=true ;; |
---|
14 | d ) DELETE=true ;; |
---|
15 | g ) DEBUG=true ;; |
---|
16 | h ) HELP=true ;; |
---|
17 | \? ) echo "Invalid option" |
---|
18 | HELP=true |
---|
19 | break ;; |
---|
20 | esac |
---|
21 | done |
---|
22 | if [[ $# != $(($OPTIND - 1)) ]]; then |
---|
23 | echo "Invalid argument" |
---|
24 | HELP=true |
---|
25 | fi |
---|
26 | |
---|
27 | if [[ $HELP == true ]]; then |
---|
28 | echo 'Usage: run_tests [options]' |
---|
29 | echo 'Valid options:' |
---|
30 | echo '-c URL' |
---|
31 | echo ' Generate the control results using the version of FCM at "URL"' |
---|
32 | echo '-t URL' |
---|
33 | echo ' Generate the test results using the version of FCM at "URL"' |
---|
34 | echo '-f' |
---|
35 | echo ' Perform the functional tests' |
---|
36 | echo '-l' |
---|
37 | echo ' Perform the local performance tests' |
---|
38 | echo '-r' |
---|
39 | echo ' Perform the remote performance tests' |
---|
40 | echo '-a' |
---|
41 | echo ' Perform all the tests (equivalent to -flr)' |
---|
42 | echo '-d' |
---|
43 | echo ' Remove any previous test results before starting' |
---|
44 | echo '-g' |
---|
45 | echo ' Output additional diagnostics' |
---|
46 | echo '-h' |
---|
47 | echo ' Print this help message' |
---|
48 | exit 1 |
---|
49 | fi |
---|
50 | |
---|
51 | if [[ -n "$CONTROL_URL" ]]; then |
---|
52 | TYPES="control" |
---|
53 | fi |
---|
54 | if [[ -n "$TEST_URL" ]]; then |
---|
55 | TYPES="$TYPES test" |
---|
56 | fi |
---|
57 | if [[ -z "$TYPES" ]]; then |
---|
58 | echo "Either a control or a test URL must be specified" |
---|
59 | exit 1 |
---|
60 | fi |
---|
61 | |
---|
62 | export HPC=hpc1e |
---|
63 | export BASE_DIR_HPC=$(ssh $HPC 'echo $PWD')/fcm_test_suite |
---|
64 | |
---|
65 | export BASE_DIR=$LOCALTEMP/fcm_test_suite |
---|
66 | if [[ $DELETE == true ]]; then |
---|
67 | if [[ $DEBUG == true ]]; then |
---|
68 | echo "Removing any previous test directory ..." |
---|
69 | fi |
---|
70 | rm -rf $BASE_DIR |
---|
71 | ssh $HPC "rm -rf $BASE_DIR_HPC" |
---|
72 | fi |
---|
73 | mkdir -p $BASE_DIR |
---|
74 | |
---|
75 | export REPOS_DIR=$BASE_DIR/test_svn |
---|
76 | export REPOS_URL="file://$REPOS_DIR" |
---|
77 | if [[ ! -d $REPOS_DIR ]]; then |
---|
78 | echo "$(date): Creating test repository ..." |
---|
79 | ./create_repos > $BASE_DIR/repos.stdout 2> $BASE_DIR/repos.stderr |
---|
80 | fi |
---|
81 | |
---|
82 | cp compare_results $BASE_DIR |
---|
83 | PATH_BASE=$PWD/wrapper_scripts:$PATH:~opsrc/ops0/mpi/mpich2-1.0.8p1-ukmo-v2/ifort-10/bin |
---|
84 | |
---|
85 | export DEBUG |
---|
86 | export TYPE |
---|
87 | for TYPE in $TYPES |
---|
88 | do |
---|
89 | if [[ $TYPE == test ]]; then |
---|
90 | URL=$TEST_URL |
---|
91 | else |
---|
92 | URL=$CONTROL_URL |
---|
93 | fi |
---|
94 | URL_BASE=${URL%@*} |
---|
95 | REV=${URL#$URL_BASE} |
---|
96 | URL=$URL_BASE$REV |
---|
97 | fcm ls $URL/bin/fcm >/dev/null 2>&1 |
---|
98 | if [[ $? != 0 ]]; then |
---|
99 | echo 'URL must be a URL or the path to a working copy of the FCM project tree' |
---|
100 | exit 1 |
---|
101 | fi |
---|
102 | echo FCM version to be used: |
---|
103 | fcm info $URL | grep URL |
---|
104 | fcm info $URL | grep Revision |
---|
105 | |
---|
106 | export RUN_DIR=$BASE_DIR/$TYPE |
---|
107 | rm -rf $RUN_DIR |
---|
108 | mkdir $RUN_DIR |
---|
109 | |
---|
110 | if [[ $DEBUG == true ]]; then |
---|
111 | echo "Creating local copy of FCM ..." |
---|
112 | fi |
---|
113 | fcm export -q $URL $RUN_DIR/fcm |
---|
114 | echo "set::url::test_suite $REPOS_URL" >>$RUN_DIR/fcm/etc/fcm.cfg |
---|
115 | export PATH=$RUN_DIR/fcm/bin:$PATH_BASE |
---|
116 | |
---|
117 | if [[ $FUNC_TESTS == true ]]; then |
---|
118 | . ./tests_functional.list |
---|
119 | export COMPARE_TIMES=false |
---|
120 | let failed=0 |
---|
121 | for TEST in $TESTS |
---|
122 | do |
---|
123 | ./test_scripts/$TEST |
---|
124 | if [[ $? != 0 ]]; then |
---|
125 | let failed=failed+1 |
---|
126 | fi |
---|
127 | done |
---|
128 | |
---|
129 | echo "$(date): Functional tests finished" |
---|
130 | if [[ $failed == 0 ]]; then |
---|
131 | echo "SUMMARY: All functional tests succeeded" |
---|
132 | else |
---|
133 | echo "SUMMARY: $failed functional tests failed" |
---|
134 | fi |
---|
135 | fi |
---|
136 | |
---|
137 | if [[ $LOCAL_TESTS == true ]]; then |
---|
138 | . ./tests_perf_local.list |
---|
139 | export COMPARE_TIMES=true |
---|
140 | let failed=0 |
---|
141 | for TEST in $TESTS |
---|
142 | do |
---|
143 | ./test_scripts/$TEST |
---|
144 | if [[ $? != 0 ]]; then |
---|
145 | let failed=failed+1 |
---|
146 | fi |
---|
147 | done |
---|
148 | |
---|
149 | echo "$(date): Local performance tests finished" |
---|
150 | if [[ $failed == 0 ]]; then |
---|
151 | echo "SUMMARY: All local performance tests succeeded" |
---|
152 | else |
---|
153 | echo "SUMMARY: $failed local performance tests failed" |
---|
154 | fi |
---|
155 | fi |
---|
156 | |
---|
157 | if [[ $REMOTE_TESTS == true ]]; then |
---|
158 | if [[ $DEBUG == true ]]; then |
---|
159 | echo "Copying files to HPC platform ..." |
---|
160 | fi |
---|
161 | export RUN_DIR_HPC=$BASE_DIR_HPC/$TYPE |
---|
162 | ssh $HPC "rm -rf $RUN_DIR_HPC" |
---|
163 | ssh $HPC "mkdir -p $RUN_DIR_HPC" |
---|
164 | rsync -a --rsh="ssh" $RUN_DIR/fcm $HPC:$RUN_DIR_HPC |
---|
165 | rsync -a --rsh="ssh" compare_results report_hpc_results $HPC:$BASE_DIR_HPC |
---|
166 | |
---|
167 | BATCH_SCRIPT_NAME=hpc_batch.sh |
---|
168 | export BATCH_DIRS_NAME=hpc_dirs.sh |
---|
169 | export BATCH_SCRIPT=$RUN_DIR/$BATCH_SCRIPT_NAME |
---|
170 | ./create_hpc_batch_script |
---|
171 | export BATCH_DIRS=$RUN_DIR/$BATCH_DIRS_NAME |
---|
172 | |
---|
173 | echo 'TESTS="' >$BATCH_DIRS |
---|
174 | . ./tests_perf_remote.list |
---|
175 | let failed=0 |
---|
176 | for TEST in $TESTS |
---|
177 | do |
---|
178 | ./test_scripts/$TEST |
---|
179 | if [[ $? != 0 ]]; then |
---|
180 | let failed=failed+1 |
---|
181 | else |
---|
182 | SUBMIT_REMOTE=true |
---|
183 | fi |
---|
184 | done |
---|
185 | echo '"' >>$BATCH_DIRS |
---|
186 | |
---|
187 | if [[ $SUBMIT_REMOTE == true ]]; then |
---|
188 | echo "$(date): Submitting HPC build job ..." |
---|
189 | rsync -a --rsh="ssh" $BATCH_SCRIPT $BATCH_DIRS $HPC:$RUN_DIR_HPC |
---|
190 | ssh $HPC "llsubmit $RUN_DIR_HPC/$BATCH_SCRIPT_NAME" |
---|
191 | fi |
---|
192 | |
---|
193 | echo "$(date): HPC performance tests finished" |
---|
194 | if [[ $failed == 0 ]]; then |
---|
195 | echo "SUMMARY: All HPC performance tests succeeded" |
---|
196 | else |
---|
197 | echo "SUMMARY: $failed HPC performance tests failed" |
---|
198 | fi |
---|
199 | fi |
---|
200 | done |
---|