diff --git a/tests/tesflinger/fake_testflinger.py b/tests/tesflinger/fake_testflinger.py index 3de2e846..98038799 100644 --- a/tests/tesflinger/fake_testflinger.py +++ b/tests/tesflinger/fake_testflinger.py @@ -65,7 +65,11 @@ def mock_result_error(): if count_calls_result < 3: return jsonify({"job_state":"waiting"}) else: - return jsonify({"job_state":"cancelled"}) + return jsonify({"job_state":"cancelled", + "allocate_output":"test_allocate", + "provision_output":"test_provision", + "reserve_output":"test_reserve", + "setup_output":"test_setup"}) # Complete scenario diff --git a/tests/tesflinger/task.yaml b/tests/tesflinger/task.yaml index 68f9e17a..0f6bf3d5 100644 --- a/tests/tesflinger/task.yaml +++ b/tests/tesflinger/task.yaml @@ -4,6 +4,8 @@ environment: TF_ENDPOINT: http://127.0.0.1:5005 TF_API_VERSION: v1 +kill-timeout: 20m + prepare: | if [ ! -f .spread-reuse.yaml ]; then touch /run/spread-reuse.yaml @@ -21,7 +23,7 @@ restore: | apt remove -y python3-flask jq # Clean all the data files generated by the mock - rm *.data mock.log + rm -f *.data mock.log .spread*.log debug: | cat /tmp/task.out || true @@ -39,11 +41,14 @@ execute: | kill -9 "$pid" done fi + sleep 1 } # Basic scenario rpi4 with url start_mock 00000000-0000-0000-0000-000000000001 ! spread -reuse -resend testflinger:ubuntu-core-22-rpi4: &> /tmp/task.out + stop_mock + cat /tmp/task.out | grep 'TestFlinger job 00000000-0000-0000-0000-000000000001 created for' cat /tmp/task.out | grep 'Waiting for TestFlinger ubuntu-core-22-rpi4 to have an address...' cat /tmp/task.out | grep 'Allocated device with ip 127.0.0.1' @@ -52,27 +57,31 @@ execute: | test "$(jq -r '.action' action_00000000-0000-0000-0000-000000000001.data)" = "cancel" test "$(jq -r '.provision_data.url' job_00000000-0000-0000-0000-000000000001.data)" = "https://url/pi.img.xz" test -z "$(jq -r '.provision_data | keys[]' job_00000000-0000-0000-0000-000000000001.data | grep distro)" - stop_mock # Cancel scenario with distro start_mock 00000000-0000-0000-0000-000000000002 ! spread -reuse -resend testflinger:ubuntu-core-22-64: &> /tmp/task.out + stop_mock + cat /tmp/task.out | grep 'TestFlinger job 00000000-0000-0000-0000-000000000002 created for' cat /tmp/task.out | grep 'Waiting for TestFlinger ubuntu-core-22-64 to have an address...' cat /tmp/task.out | grep 'Job state is either cancelled or completed' + cat /tmp/task.out | grep 'result output saved to file .spread-output.000000000002.log' test "$(jq -r '.job_queue' job_00000000-0000-0000-0000-000000000002.data)" = "x64" test "$(jq -r '.provision_data.distro' job_00000000-0000-0000-0000-000000000002.data)" = "jammy" test -z "$(jq -r '.provision_data | keys[]' job_00000000-0000-0000-0000-000000000002.data | grep url)" ! test -f action_00000000-0000-0000-0000-000000000002.data - stop_mock - + test -f ".spread-output.000000000002.log" + grep "test_allocate" .spread-output.000000000002.log + # Complete scenario start_mock 00000000-0000-0000-0000-000000000003 ! spread -reuse -resend testflinger:ubuntu-core-22-rpi4: &> /tmp/task.out + stop_mock + cat /tmp/task.out | grep 'TestFlinger job 00000000-0000-0000-0000-000000000003 created for' cat /tmp/task.out | grep 'Waiting for TestFlinger ubuntu-core-22-rpi4 to have an address...' cat /tmp/task.out | grep 'Job state is either cancelled or completed' - stop_mock # Garbage collection scenario # Job 4: has to be deleted (it is active and halt-timeout exceeded) @@ -81,8 +90,10 @@ execute: | # Job 7: has not to be deleted (it is not active) start_mock 00000000-0000-0000-0000-000000000004 spread -gc &> /tmp/task.out + stop_mock + cat /tmp/task.out | grep 'Checking 00000000-0000-0000-0000-000000000004' cat /tmp/task.out | grep 'Job 00000000-0000-0000-0000-000000000004 exceeds halt-timeout. Shutting it down...' cat /tmp/task.out | grep 'Checking 00000000-0000-0000-0000-000000000005' test "$(jq -r '.action' action_00000000-0000-0000-0000-000000000004.data)" = "cancel" - stop_mock +