Skip to content

Commit

Permalink
Refactor shutdown function test to be more stable
Browse files Browse the repository at this point in the history
This test has been flaky on Windows because of parallel subjobs all
trying to copy the same file. This refactors the test config to be
simpler and not rely on a copy. The test asserts on both the project
directory file list and file contents at the end of the test, so the
copy is not really necessary.
  • Loading branch information
josephharrington committed Jul 12, 2017
1 parent d0a26aa commit 1475bad
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/functional/job_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ def __init__(self, config, expected_to_fail, expected_num_subjobs, expected_num_
setup_build:
- echo "Doing build setup."
- sleep 1
- echo "setup." > $PROJECT_DIR/build_setup.txt
- echo "setup." >> $PROJECT_DIR/build_setup.txt
commands:
- echo "Doing subjob $SUBJOB_NUMBER."
- sleep 1
- MY_SUBJOB_FILE=$PROJECT_DIR/subjob_file_${SUBJOB_NUMBER}.txt
- cp build_setup.txt $MY_SUBJOB_FILE
- echo "subjob $SUBJOB_NUMBER." >> $MY_SUBJOB_FILE
atomizers:
Expand All @@ -111,8 +110,7 @@ def __init__(self, config, expected_to_fail, expected_num_subjobs, expected_num_
teardown_build:
- echo "Doing build teardown."
- sleep 1
- ALL_SUBJOB_FILES=$(ls $PROJECT_DIR/subjob_file_*.txt || mktemp -t clusterrunnerXXXX)
- echo "teardown." | tee -a $ALL_SUBJOB_FILES
- echo "teardown." >> $PROJECT_DIR/build_teardown.txt
""",
'nt': """
Expand All @@ -123,13 +121,12 @@ def __init__(self, config, expected_to_fail, expected_num_subjobs, expected_num_
setup_build:
- echo Doing build setup.
- ping 127.0.0.1 -n 2 >nul
- echo setup.> !PROJECT_DIR!\\build_setup.txt
- echo setup.>> !PROJECT_DIR!\\build_setup.txt
commands:
- echo Doing subjob !SUBJOB_NUMBER!.
- ping 127.0.0.1 -n 2 >nul
- set MY_SUBJOB_FILE=!PROJECT_DIR!\\subjob_file_!SUBJOB_NUMBER!.txt
- COPY build_setup.txt !MY_SUBJOB_FILE! >nul
- echo subjob !SUBJOB_NUMBER!.>> !MY_SUBJOB_FILE!
atomizers:
Expand All @@ -138,17 +135,18 @@ def __init__(self, config, expected_to_fail, expected_num_subjobs, expected_num_
teardown_build:
- echo Doing build teardown.
- ping 127.0.0.1 -n 2 >nul
- FOR /l %n in (1,1,3) DO @echo teardown.>> !PROJECT_DIR!\\subjob_file_%n.txt
- echo teardown.>> !PROJECT_DIR!\\teardown.txt
""",
},
expected_to_fail=False,
expected_num_subjobs=3,
expected_num_atoms=3,
expected_project_dir_contents=[
File('build_setup.txt', contents='setup.\n'),
File('subjob_file_1.txt', contents='setup.\nsubjob 1.\nteardown.\n'),
File('subjob_file_2.txt', contents='setup.\nsubjob 2.\nteardown.\n'),
File('subjob_file_3.txt', contents='setup.\nsubjob 3.\nteardown.\n'),
File('subjob_file_1.txt', contents='subjob 1.\n'),
File('subjob_file_2.txt', contents='subjob 2.\n'),
File('subjob_file_3.txt', contents='subjob 3.\n'),
File('build_teardown.txt', contents='teardown.\n'),
],
)

Expand Down

0 comments on commit 1475bad

Please sign in to comment.