aws-deadline / deadline-cloud-worker-agent

The AWS Deadline Cloud worker agent can be used to run a worker in an AWS Deadline Cloud fleet.
Apache License 2.0
15 stars 21 forks source link

test: move scope specification to tests #428

Closed moorec-aws closed 1 month ago

moorec-aws commented 1 month ago

What was the problem/requirement? (What/Why)

Specifying the session_worker at the class level sets the fixture name to be session scoped even though the tests itself is function scoped. This causes issues with our ordering to run session function scoped tasks last. The result is workers from session scoped tests can pickup function scoped tests jobs, vice-versa.

What was the solution? (How)

Remove @pytest.mark.usefixtures("session_worker") and specify the scope on each test.

What is the impact of this change?

This is to prevent function and session scoped tests from running at the same time.

How was this change tested?

On both Linux and Windows:

hatch run e2e-test

Check Collection order:

<Dir deadline-cloud-worker-agent>
  <Dir test>
    <Package e2e>
      <Module test_job_submissions.py>
        <Class TestJobSubmission>
          <Function test_worker_enters_stopping_state_while_draining[linux]>
      <Module test_override_job_user.py>
        <Class TestJobUserOverride>
          <Function test_no_user_override[windows]>
          <Function test_config_file_user_override[windows]>
          <Function test_installer_user_override[windows]>
          <Function test_env_var_user_override[windows]>
      <Module test_worker_status.py>
        <Class TestWorkerStatus>
          <Function test_worker_lifecycle_status_is_expected[linux]>
      <Module test_credential_handling.py>
        <Function test_access_worker_credential_file_from_job[linux]>
      <Module test_installer.py>
        <Class TestInstaller>
          <Function test_installer_shutdown_permission[linux]>
      <Module test_job_submissions.py>
        <Class TestJobSubmission>
          <Function test_success[linux]>
          <Function test_job_reports_failed_session_action[run_actions0-environment_actions0-taskRun-linux]>
          <Function test_job_reports_failed_session_action[run_actions1-environment_actions1-envEnter-linux]>
          <Function test_job_reports_failed_session_action[run_actions2-environment_actions2-envExit-linux]>
          <Function test_worker_fails_session_action_timeout[linux]>
          <Function test_job_reports_canceled_session_action[run_actions0-environment_actions0-taskRun-linux]>
          <Function test_job_reports_canceled_session_action[run_actions1-environment_actions1-envEnter-linux]>
          <Function test_worker_reports_canceled_session_actions_as_canceled[envEnter-linux]>
          <Function test_worker_reports_canceled_session_actions_as_canceled[taskRun-linux]>
          <Function test_worker_reports_canceled_sync_input_actions_as_canceled[linux]>
          <Function test_worker_always_runs_env_exit_despite_failure[linux]>
          <Function test_worker_run_with_number_of_environments[job_environments0-linux]>
          <Function test_worker_run_with_number_of_environments[job_environments1-linux]>
          <Function test_worker_streams_logs_to_cloudwatch[linux]>
          <Function test_worker_uses_job_attachment_configuration[#!/usr/bin/env bash\n\n  echo -n $(cat {{Param.DataDir}}/files/test_input_file){{Param.StringToAppend}} > {{Param.DataDir}}/output_file\n-linux]>
          <Function test_worker_job_attachments_no_outputs_does_not_fail_job[linux]>
          <Function test_worker_uses_job_attachment_sync[#!/usr/bin/env bash\n\nfolder_path={{Param.DataDir}}/files\ncombined_contents=""\nfor file in "$folder_path"/*; do\n   if [ -f "$file" ]; then\n   combined_contents+="$(cat "$file" | tr -d '\\n')"\n   fi\ndone\nsha256_hash=$(echo -n "$combined_contents" | sha256sum | awk '{ print $1 }')\necho -n "$sha256_hash" > {{Param.DataDir}}/output_file.txt-linux]>
          <Function test_worker_reports_task_progress_and_status_message[linux]>
      <Module test_job_user.py>
        <Class TestJobUser>
          <Function test_job_run_as_user[linux]>

Now <Function test_worker_enters_stopping_state_while_draining[linux]> which was previously run with the session scoped tests is now running prior to session scope.

Was this change documented?

No

Is this a breaking change?

No


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud