Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 6f7cec8

Browse files
authored
Merge pull request #345 from galasa-dev/reenable-runs-reset-test
Reenable test of the `runs reset` CLI command using new TestSleep
2 parents a617511 + 1b43cac commit 6f7cec8

File tree

1 file changed

+105
-108
lines changed

1 file changed

+105
-108
lines changed

test-scripts/runs-tests.sh

Lines changed: 105 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -303,110 +303,110 @@ function runs_download_check_folder_names_during_test_run {
303303
success "Downloading artifacts from a running test results in folder names with a timestamp. OK"
304304
}
305305

306-
# function runs_reset_check_retry_present {
307-
308-
# h2 "Performing runs reset on an active test run..."
309-
310-
# run_name=$1
311-
312-
# h2 "First, launching test on an ecosystem without a portfolio in a background process, so it can be reset."
313-
314-
# mkdir -p ${BASEDIR}/temp
315-
# cd ${BASEDIR}/temp
316-
317-
# runs_submit_log_file="runs-submit-output-for-reset.txt"
318-
319-
# cmd="${BINARY_LOCATION} runs submit \
320-
# --bootstrap $bootstrap \
321-
# --class dev.galasa.ivts/dev.galasa.ivts.core.CoreManagerIVT \
322-
# --stream ivts
323-
# --throttle 1 \
324-
# --poll 1 \
325-
# --progress 1 \
326-
# --noexitcodeontestfailures \
327-
# --log ${runs_submit_log_file}"
328-
329-
# info "Command is: $cmd"
330-
331-
# set -o pipefail # Fail everything if anything in the pipeline fails. Else we are just checking the 'tee' return code.
332-
333-
# # Start the test running inside a background process... so we can try to reset it while it's running
334-
# $cmd &
335-
336-
# run_name_found="false"
337-
# retries=0
338-
# max=100
339-
# target_line=""
340-
341-
# # Loop waiting until we can extract the name of the test run which is running in the background.
342-
# while [[ "${run_name_found}" == "false" ]]; do
343-
# if [[ -e $runs_submit_log_file ]]; then
344-
# success "file exists"
345-
# # Check the run has been submitted before attempting to reset
346-
# target_line=$(cat ${runs_submit_log_file} | grep "submitted")
347-
348-
# if [[ "$target_line" != "" ]]; then
349-
# info "Target line is found - the test has been submitted."
350-
# run_name_found="true"
351-
# fi
352-
# fi
353-
# sleep 1
354-
# ((retries++))
355-
# if (( $retries > $max )); then
356-
# error "Too many retries."
357-
# exit 1
358-
# fi
359-
# done
360-
361-
# run_name=$(echo $target_line | cut -f4 -d' ')
362-
# info "Run name is $run_name"
363-
364-
# h2 "Now attempting to reset the run while it's running in the background process."
365-
366-
# while [[ "${test_reset}" == "false" ]]; do
367-
368-
369-
# cmd="${BINARY_LOCATION} runs reset \
370-
# --name ${run_name} \
371-
# --bootstrap ${bootstrap}"
372-
373-
# info "Command is: $cmd"
374-
# $cmd
375-
376-
# h2 "Now using runs get to check when the two runs finish, two show up in the runs get output."
377-
378-
# runs_get_log_file="runs-get-output-for-reset.txt"
379-
380-
# # Now poll runs get to check when the tests are finished
381-
# cmd="${BINARY_LOCATION} runs get \
382-
# --name ${run_name} \
383-
# --bootstrap ${bootstrap}"
384-
385-
# are_tests_finished="false"
386-
# retries=0
387-
# max=100
388-
# target_line=""
389-
# while [[ "${are_tests_finished}" == "false" ]]; do
390-
# sleep 2
391-
392-
# # Run the runs get command
393-
# $cmd | tee $runs_get_log_file
394-
# # Check for line in the runs get output to signify the 2 tests are finished
395-
# target_line=$(cat ${runs_get_log_file} | grep "Total:2 Passed:2")
396-
# if [[ "$target_line" != "" ]]; then
397-
# success "Target line is found - both tests are finished."
398-
# are_tests_finished="true"
399-
# fi
400-
401-
# # Give up if we've been waiting for the test to finish for too long. Test could be stuck.
402-
# ((retries++))
403-
# if (( $retries > $max )); then
404-
# error "Too many retries."
405-
# exit 1
406-
# fi
407-
# done
408-
409-
# }
306+
function runs_reset_check_retry_present {
307+
308+
h2 "Performing runs reset on an active test run..."
309+
310+
run_name=$1
311+
312+
h2 "First, launching test on an ecosystem without a portfolio in a background process, so it can be reset."
313+
314+
mkdir -p ${BASEDIR}/temp
315+
cd ${BASEDIR}/temp
316+
317+
runs_submit_log_file="runs-submit-output-for-reset.txt"
318+
319+
cmd="${BINARY_LOCATION} runs submit \
320+
--bootstrap $bootstrap \
321+
--class dev.galasa.ivts/dev.galasa.ivts.core.TestSleep \
322+
--stream ivts
323+
--throttle 1 \
324+
--poll 10 \
325+
--progress 1 \
326+
--noexitcodeontestfailures \
327+
--log ${runs_submit_log_file}"
328+
329+
info "Command is: $cmd"
330+
331+
set -o pipefail # Fail everything if anything in the pipeline fails. Else we are just checking the 'tee' return code.
332+
333+
# Start the test running inside a background process... so we can try to reset it while it's running
334+
$cmd &
335+
336+
run_name_found="false"
337+
retries=0
338+
max=100
339+
target_line=""
340+
341+
# Loop waiting until we can extract the name of the test run which is running in the background.
342+
while [[ "${run_name_found}" == "false" ]]; do
343+
if [[ -e $runs_submit_log_file ]]; then
344+
success "file exists"
345+
# Check the run has been submitted before attempting to reset
346+
target_line=$(cat ${runs_submit_log_file} | grep "submitted")
347+
348+
if [[ "$target_line" != "" ]]; then
349+
info "Target line is found - the test has been submitted."
350+
run_name_found="true"
351+
fi
352+
fi
353+
sleep 3
354+
((retries++))
355+
if (( $retries > $max )); then
356+
error "Too many retries."
357+
exit 1
358+
fi
359+
done
360+
361+
# sleep for 10 seconds to allow the test to reach an active stage
362+
sleep 10
363+
364+
run_name=$(echo $target_line | cut -f4 -d' ')
365+
info "Run name is $run_name"
366+
367+
h2 "Now attempting to reset the run while it's running in the background process."
368+
369+
cmd="${BINARY_LOCATION} runs reset \
370+
--name ${run_name} \
371+
--bootstrap ${bootstrap}"
372+
373+
info "Command is: $cmd"
374+
$cmd
375+
376+
h2 "Now using runs get to check that two different runs show up in the runs get output."
377+
378+
runs_get_log_file="runs-get-output-for-reset.txt"
379+
380+
# Now poll runs get to check when the tests are finished
381+
cmd="${BINARY_LOCATION} runs get \
382+
--name ${run_name} \
383+
--bootstrap ${bootstrap}"
384+
385+
two_tests_found="false"
386+
retries=0
387+
max=100
388+
target_line=""
389+
while [[ "${two_tests_found}" == "false" ]]; do
390+
sleep 5
391+
392+
# Run the runs get command
393+
$cmd | tee $runs_get_log_file
394+
# Check for line in the runs get output to signify that there are 2 tests
395+
target_line=$(cat ${runs_get_log_file} | grep "Total:2")
396+
if [[ "$target_line" != "" ]]; then
397+
success "Target line is found - two runs were found."
398+
two_tests_found="true"
399+
fi
400+
401+
# Give up if we've been waiting for the test to finish for too long. Test could be stuck.
402+
((retries++))
403+
if (( $retries > $max )); then
404+
error "Too many retries."
405+
exit 1
406+
fi
407+
done
408+
409+
}
410410

411411
#--------------------------------------------------------------------------
412412
function get_result_with_runname {
@@ -1036,11 +1036,8 @@ function test_runs_commands {
10361036

10371037
runs_download_check_folder_names_during_test_run
10381038

1039-
# NOTE: Temporarily commenting out this test scenario as the CoreManagerIVT
1040-
# completes too quickly to allow us a time window to reset it in.
1041-
# Will create a test case that has sufficient time and uncomment this then.
10421039
# Attempt to reset an active run...
1043-
# runs_reset_check_retry_present
1040+
runs_reset_check_retry_present
10441041

10451042
# Attempt to delete a run...
10461043
runs_delete_check_run_can_be_deleted $RUN_NAME

0 commit comments

Comments
 (0)