Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Azure Pipeline for Python 2.6 & 3.4 Unit Tests #3284

Merged
merged 7 commits into from
Jan 9, 2025

Conversation

narrieta
Copy link
Member

@narrieta narrieta commented Jan 6, 2025

We use an Ubuntu 16 container to run the unit tests using Python 2.6 (the tests for 3.4 were also added to that container), but Github Actions does not support this version of Ubuntu anymore.

Create a Pipeline within our DevOps project to execute those tests.

narrieta@microsoft added 5 commits January 2, 2025 17:04
@@ -437,7 +437,7 @@ def _get_current_cpu_quota(unit_name):

# Calculate CPU percentage
cpu_percentage = (cpu_quota_us / 1000000) * 100
return "{:g}%".format(cpu_percentage) # :g Removes trailing zeros after decimal point
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is not supported on 2.6

@@ -4,7 +4,7 @@
#
python=$(command -v python 2> /dev/null)

if [ -z "$PYTHON" ]; then
if [ -z "$python" ]; then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing typo

@@ -301,7 +301,7 @@ def mock_popen(command, *args, **kwargs):
shell=True,
timeout=300,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were failing on the new runs for 3.4. The reason is that they have a dependency on the "python3" executable; on Github actions we were installing Python 3 even on runs that were using our 3.4 venv, so there was a "python3" in the system PATH and the tests were able to run. Now, we no longer install Python 3 for the 3.4 test runs, and "python3" is only in the PATH for the venv. These tests need to inherit the environment from the test runner (nosetests) in order to have the correct PATH. The Agent does something similar (adding os.environ) when invoking extensions.

@@ -868,7 +868,7 @@ def get_completed_process():
return completed

agent_processes = [os.getppid(), os.getpid()] + agent_command_processes + [start_extension.systemd_run_pid]
other_processes = [1, get_completed_process()] + extension_processes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When starting a process in a container, it gets PID 1. Github Actions starts containers using a dummy process ("tail -f /dev/null", which gets PID 1) and then uses "docker exec" to execute the actual tests.

In the new pipeline, we invoke "nosetests" directly, and that gets PID 1.

As a result, the Agent code identifies nosetests (PID 1) as the Daemon and it does not include it in the list of unexpected processes, causing this test to fail. "1" does not add anything significant to this test, so I just removed it.

@narrieta narrieta merged commit 029e5b9 into Azure:develop Jan 9, 2025
9 checks passed
@narrieta narrieta deleted the unit-tests branch January 9, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants