Skip to content

Commit c01defe

Browse files
Do not record cancelled tests
1 parent bd7f54e commit c01defe

File tree

2 files changed

+18
-43
lines changed

2 files changed

+18
-43
lines changed

joshua/joshua_agent.py

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,6 @@ def stopAgent():
110110
return stop_agent
111111

112112

113-
def trim_jobqueue(cutoff_date, remove_jobs=True):
114-
global job_queue
115-
jobs_pass = 0
116-
jobs_fail = 0
117-
cutoff_string = joshua_model.format_datetime(cutoff_date)
118-
119-
for job_record in list(job_queue.queue):
120-
(result, job_date) = fdb.tuple.unpack(job_record)
121-
if job_date <= cutoff_string:
122-
if remove_jobs:
123-
old_record = job_queue.get_nowait()
124-
elif result == 0:
125-
jobs_pass += 1
126-
else:
127-
jobs_fail += 1
128-
129-
return (jobs_pass + jobs_fail, jobs_pass, jobs_fail)
130-
131-
132113
def log(outputText, newline=True):
133114
return (
134115
print(outputText, file=getFileHandle())
@@ -320,7 +301,8 @@ def remove_old_artifacts(path, age=24 * 60 * 60):
320301

321302
# Returns whether the artifacts should be saved based on run state.
322303
def should_save(retcode, save_on="FAILURE"):
323-
return save_on == "ALWAYS" or save_on == "FAILURE" and retcode != 0
304+
# do not save when cancelled (retcode == -1)
305+
return save_on == "ALWAYS" or save_on == "FAILURE" and retcode != 0 and retcode != -1
324306

325307

326308
# Removes artifacts from the current run, saving them if necessary.
@@ -411,7 +393,6 @@ def run_ensemble(
411393
:param sanity:
412394
:return: 0 for success
413395
"""
414-
global jobs_pass, jobs_fail
415396
if not work_dir:
416397
raise JoshuaError(
417398
"Unable to run function since work_dir is not defined. Exiting. (CWD="
@@ -556,6 +537,11 @@ def run_ensemble(
556537

557538
cleanup(ensemble, where, seed, retcode, save_on, work_dir=work_dir)
558539

540+
if retcode == -1:
541+
# no results to record when cancelled
542+
self._retcode = retcode
543+
return
544+
559545
try:
560546
joshua_model.insert_results(
561547
ensemble,
@@ -582,17 +568,6 @@ def run_ensemble(
582568
duration,
583569
)
584570

585-
# Add the result to the job queue
586-
job_queue.put(fdb.tuple.pack((retcode, done_timestamp)))
587-
588-
# Update the job counts
589-
job_mutex.acquire()
590-
if retcode == 0:
591-
jobs_pass += 1
592-
else:
593-
jobs_fail += 1
594-
job_mutex.release()
595-
596571
self._retcode = retcode
597572

598573

tests/sanity_test_script.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ tar czf test.tar.gz joshua_test joshua_timeout
8181

8282
mkdir /tmp/work
8383

84-
total=0
85-
pass=0
86-
fail=0
84+
total_tests=0
85+
total_passed=0
86+
total_failed=0
8787

8888
for test in one_agent two_agent two_agent_kill_one; do
89-
(( total++ ))
89+
(( total_tests++ ))
9090
echo "=== TEST: ${test} ==="
9191
python -m joshua.joshua start --tarball test.tar.gz --max-runs 6
9292
python -m joshua.joshua list
@@ -107,17 +107,17 @@ for test in one_agent two_agent two_agent_kill_one; do
107107
done
108108
if [ $pass -eq $ended ] && [ $ended -eq $max_runs ]; then
109109
echo "Pass: pass:$pass ended:$ended max_runs:$max_runs"
110-
(( pass++ ))
110+
(( total_passed++ ))
111111
else
112112
echo "Fail: pass:$pass ended:$ended max_runs:$max_runs"
113-
(( fail++ ))
113+
(( total_failed++ ))
114114
fi
115115
python -m joshua.joshua delete -y ${ensemble}
116116
done
117117

118118
# timeout test
119119
for test in two_agent; do
120-
(( total++ ))
120+
(( total_tests++ ))
121121
echo "=== TEST: ${test} TIMEOUT ==="
122122
python -m joshua.joshua start --tarball test.tar.gz --max-runs 6 --timeout 2
123123
python -m joshua.joshua list
@@ -135,17 +135,17 @@ for test in two_agent; do
135135
done
136136
if [ $fail -eq $ended ] && [ $fail -eq 2 ]; then
137137
echo "Pass: fail:$fail == ended:$ended"
138-
(( pass++ ))
138+
(( total_passed++ ))
139139
else
140140
echo "Fail: fail:$fail != ended:$ended or fail:$fail != 2"
141-
(( fail++ ))
141+
(( total_failed++ ))
142142
fi
143143
python -m joshua.joshua delete -y ${ensemble}
144144
done
145145

146146
kill -9 ${fdbpid}
147147

148-
echo "${pass} / ${total} passed"
148+
echo "${total_passed} / ${total_tests} passed"
149149

150-
exit $fail
150+
exit $total_failed
151151

0 commit comments

Comments
 (0)