aws-deadline / deadline-cloud-test-fixtures

This package contains pytest fixtures that are used to test AWS Deadline Cloud Python packages
Apache License 2.0
9 stars 13 forks source link

feat: linux ec2-based tests test installer-based user creation #138

Closed ddneilson closed 1 month ago

ddneilson commented 1 month ago

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

The linux ec2-based tests are currently structured to create the worker-agent user during instance startup using ec2-userdata scripting. The worker agent installer contains code that will create the agent-user if it does not exist. The current test setup prevents writing tests that test that functionality

What was the solution? (How)

Refactor the scripting that is materialized in the PosixInstanceWorker. Now, user-creation-wise the ec2-userdata only creates the job users and their groups. The 'worker configuration' scripting is now responsible for letting the install script create the worker agent user, and adding it to the required groups & sudoers rules.

What is the impact of this change?

Increased confidence that the deadline cloud worker agent's installer script on Linux correctly creates the agent-user if it needs to.

How was this change tested?

  1. Followed the instructions for running the e2e tests for the Deadline Cloud worker agent.
  2. To make the e2e tests use the Before running the tests:
    1. Modified the agent's requirements-testing.txt to point at my built whl file for the test-fixtures. ( deadline-cloud-test-fixtures @ file:///home/<user>/deadline-cloud-test-fixtures/dist/deadline_cloud_test_fixtures-0.0.post98+g6d4023d.d20240813-py3-none-any.whl)
    2. Force pip installed the requirements-testing.txt into my testing venv.
    3. Set the WORKER_AGENT_WHL_PATH env var to point to my locally built agent whl file.
    4. Pruned all hatch environments, and then ran the e2e tests as prescribed.

I then checked command history in Systems Manager to ensure that the expected RunCommands were run (as a verification that my test fixtures changes were being tested).

All Linux tests pass:

============================================================================= slowest 5 durations =============================================================================
174.11s setup    test/e2e/linux/test_credential_handling.py::test_access_worker_credential_file_from_job[linux]
42.03s call     test/e2e/linux/test_job_submissions.py::TestJobSubmission::test_success[linux]
25.38s call     test/e2e/linux/test_job_submissions.py::TestJobSubmission::test_job_run_as_user[linux]
10.30s call     test/e2e/linux/test_credential_handling.py::test_access_worker_credential_file_from_job[linux]
5.71s teardown test/e2e/linux/test_job_submissions.py::TestJobSubmission::test_job_run_as_user[linux]
================================================================== 4 passed, 1 warning in 263.58s (0:04:23)

Was this change documented?

There is no documentation to update.

Is this a breaking change?

It should not be.


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