Skip to content

Commit d342b29

Browse files
committed
CI: Run test (and test.summary) locally
The test.summary rule was causing errors in our Gitlab testing due to multiple runs (concurrent or otherwise) in the same workspace directory. This patch removes the WORKSPACE directory variable, and each .testing run happens in its own directory. Other minor changes: - The script to generate the summary was moved out of the Makefile and into a separate script. - Unrelated to these changes, error output was extended from 20 to 40 lines, to provide more readable backtrace output.
1 parent 1bb8852 commit d342b29

3 files changed

Lines changed: 55 additions & 33 deletions

File tree

.gitlab-ci.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ stages:
1010
# We use the "fetch" strategy to speed up the startup of stages
1111
variables:
1212
JOB_DIR: "/lustre/f2/scratch/oar.gfdl.ogrp-account/runner/builds/$CI_PIPELINE_ID"
13-
WORKSPACE: "/lustre/f2/scratch/oar.gfdl.ogrp-account/runner/$CI_RUNNER_ID"
1413
GIT_STRATEGY: fetch
1514

1615
# Always eport value of $JOB_DIR
@@ -185,9 +184,9 @@ actions:gnu:
185184
- make -s -j
186185
- MPIRUN= make preproc -s -j
187186
- echo -e "\e[0Ksection_end:`date +%s`:compile\r\e[0K"
188-
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" WORKSPACE=$WORKSPACE test -s -j') > job.sh
189-
- sbatch --clusters=c5 --nodes=2 --time=0:10:00 --account=gfdl_o --qos=debug --job-name=MOM6.gnu.testing --output=log.$CI_JOB_ID --wait job.sh || ( cat log.$CI_JOB_ID ; exit 911 ) && make WORKSPACE=$WORKSPACE test -s
190-
- make WORKSPACE=$WORKSPACE test.summary
187+
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
188+
- sbatch --clusters=c5 --nodes=2 --time=0:10:00 --account=gfdl_o --qos=debug --job-name=MOM6.gnu.testing --output=log.$CI_JOB_ID --wait job.sh || ( cat log.$CI_JOB_ID ; exit 911 ) && make test -s
189+
- make test.summary
191190

192191
actions:intel:
193192
stage: tests
@@ -205,9 +204,9 @@ actions:intel:
205204
- make -s -j
206205
- MPIRUN= make preproc -s -j
207206
- echo -e "\e[0Ksection_end:`date +%s`:compile\r\e[0K"
208-
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" WORKSPACE=$WORKSPACE test -s -j') > job.sh
209-
- sbatch --clusters=c5 --nodes=2 --time=0:10:00 --account=gfdl_o --qos=debug --job-name=MOM6.intel.testing --output=log.$CI_JOB_ID --wait job.sh || ( cat log.$CI_JOB_ID ; exit 911 ) && make WORKSPACE=$WORKSPACE test -s
210-
- make WORKSPACE=$WORKSPACE test.summary
207+
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
208+
- sbatch --clusters=c5 --nodes=2 --time=0:10:00 --account=gfdl_o --qos=debug --job-name=MOM6.intel.testing --output=log.$CI_JOB_ID --wait job.sh || ( cat log.$CI_JOB_ID ; exit 911 ) && make test -s
209+
- make test.summary
211210

212211
# Tests
213212
#

.testing/Makefile

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ $(WORKSPACE)/work/%/$(1)/ocean.stats $(WORKSPACE)/work/%/$(1)/chksum_diag: build
554554
&& $(TIME) $(5) $(MPIRUN) -n $(6) $(abspath $$<) 2> std.err > std.out \
555555
|| !( \
556556
mkdir -p ../../../results/$$*/ ; \
557-
cat std.out | tee ../../../results/$$*/std.$(1).out | tail -n 20 ; \
558-
cat std.err | tee ../../../results/$$*/std.$(1).err | tail -n 20 ; \
557+
cat std.out | tee ../../../results/$$*/std.$(1).out | tail -n 40 ; \
558+
cat std.err | tee ../../../results/$$*/std.$(1).err | tail -n 40 ; \
559559
rm ocean.stats chksum_diag ; \
560560
echo -e "$(FAIL): $$*.$(1) failed at runtime." \
561561
)
@@ -630,8 +630,8 @@ $(WORKSPACE)/work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
630630
# Run the first half-period
631631
cd $(@D) && $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> std1.err > std1.out \
632632
|| !( \
633-
cat std1.out | tee ../../../results/$*/std.restart1.out | tail -n 20 ; \
634-
cat std1.err | tee ../../../results/$*/std.restart1.err | tail -n 20 ; \
633+
cat std1.out | tee ../../../results/$*/std.restart1.out | tail -n 40 ; \
634+
cat std1.err | tee ../../../results/$*/std.restart1.err | tail -n 40 ; \
635635
echo -e "$(FAIL): $*.restart failed at runtime." \
636636
)
637637
# Setup the next inputs
@@ -641,8 +641,8 @@ $(WORKSPACE)/work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
641641
# Run the second half-period
642642
cd $(@D) && $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> std2.err > std2.out \
643643
|| !( \
644-
cat std2.out | tee ../../../results/$*/std.restart2.out | tail -n 20 ; \
645-
cat std2.err | tee ../../../results/$*/std.restart2.err | tail -n 20 ; \
644+
cat std2.out | tee ../../../results/$*/std.restart2.out | tail -n 40 ; \
645+
cat std2.err | tee ../../../results/$*/std.restart2.err | tail -n 40 ; \
646646
echo -e "$(FAIL): $*.restart failed at runtime." \
647647
)
648648

@@ -652,26 +652,7 @@ $(WORKSPACE)/work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
652652
# Not a true rule; only call this after `make test` to summarize test results.
653653
.PHONY: test.summary
654654
test.summary:
655-
@if ls $(WORKSPACE)/results/*/* &> /dev/null; then \
656-
if ls $(WORKSPACE)/results/*/std.*.err &> /dev/null; then \
657-
echo "The following tests failed to complete:" ; \
658-
ls $(WORKSPACE)/results/*/std.*.out \
659-
| awk '{split($$0,a,"/"); split(a[3],t,"."); v=t[2]; if(length(t)>3) v=v"."t[3]; print a[2],":",v}'; \
660-
fi; \
661-
if ls $(WORKSPACE)/results/*/ocean.stats.*.diff &> /dev/null; then \
662-
echo "The following tests report solution regressions:" ; \
663-
ls $(WORKSPACE)/results/*/ocean.stats.*.diff \
664-
| awk '{split($$0,a,"/"); split(a[3],t,"."); v=t[3]; if(length(t)>4) v=v"."t[4]; print a[2],":",v}'; \
665-
fi; \
666-
if ls $(WORKSPACE)/results/*/chksum_diag.*.diff &> /dev/null; then \
667-
echo "The following tests report diagnostic regressions:" ; \
668-
ls $(WORKSPACE)/results/*/chksum_diag.*.diff \
669-
| awk '{split($$0,a,"/"); split(a[3],t,"."); v=t[2]; if(length(t)>3) v=v"."t[3]; print a[2],":",v}'; \
670-
fi; \
671-
false ; \
672-
else \
673-
echo -e "$(PASS): All tests passed!"; \
674-
fi
655+
@./tools/report_test_results.sh $(WORKSPACE)/results
675656

676657

677658
#---
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
RESULTS=${1:-${PWD}/results}
3+
4+
GREEN="\033[0;32m"
5+
RESET="\033[0m"
6+
PASS="${GREEN}PASS${RESET}"
7+
8+
if [ -d ${RESULTS} ]; then
9+
if ls ${RESULTS}/*/std.*.err &> /dev/null; then
10+
echo "The following tests failed to complete:"
11+
ls ${RESULTS}/*/std.*.out \
12+
| awk '{ \
13+
split($$0,a,"/"); \
14+
split(a[length(a)],t,"."); \
15+
v=t[2]; \
16+
if(length(t)>4) v=v"."t[4]; print a[length(a)-1],":",v}'
17+
fi
18+
19+
if ls ${RESULTS}/*/ocean.stats.*.diff &> /dev/null; then
20+
echo "The following tests report solution regressions:"
21+
ls ${RESULTS}/*/ocean.stats.*.diff \
22+
| awk '{ \
23+
split($$0,a,"/"); \
24+
split(a[length(a)],t,"."); \
25+
v=t[3]; \
26+
if(length(t)>4) v=v"."t[4]; print a[length(a)-1],":",v}'
27+
fi
28+
29+
if ls ${RESULTS}/*/chksum_diag.*.diff &> /dev/null; then
30+
echo "The following tests report diagnostic regressions:"
31+
ls ${RESULTS}/*/chksum_diag.*.diff \
32+
| awk '{ \
33+
split($$0,a,"/"); \
34+
split(a[length(a)],t,"."); \
35+
v=t[2]; \
36+
if(length(t)>4) v=v"."t[4]; print a[length(a)-1],":",v}'
37+
fi
38+
39+
exit 1
40+
else
41+
printf "${PASS}: All tests passed!\n"
42+
fi

0 commit comments

Comments
 (0)