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

Enable unit tests for Python 2.6 & 3.4 on Github Actions #3296

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

narrieta
Copy link
Member

@narrieta narrieta commented Jan 10, 2025

The PR also
* removes unnecessary dependency on hashlib
* updates the Azure Pipeline for unit tests to use Ubuntu 24
* patches the Python virtual environments used for unit tests to run on Ubuntu > 16

@@ -385,19 +384,6 @@ def is_str_empty(s):
return is_str_none_or_whitespace(s) or is_str_none_or_whitespace(s.rstrip(' \t\r\n\0'))


def hash_strings(string_list):
Copy link
Member Author

Choose a reason for hiding this comment

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

hash_strings was being used only by the Monitor thread. It has a dependency on hashlib/OpenSSL. The Monitor thread does not really need a cryptographic hash, so I replaced it with Python's own hash function.

@@ -411,8 +411,12 @@ def emulate_assertListEqual(self, seq1, seq2, msg=None, seq_type=None):
diffMsg = '\n' + '\n'.join(
difflib.ndiff(pprint.pformat(seq1).splitlines(),
pprint.pformat(seq2).splitlines()))
standardMsg = self._truncateMessage(standardMsg, diffMsg)
msg = self._formatMessage(msg, standardMsg)
# _truncateMessage and _formatMessage are not defined on Python 2.6; output the entire diff in that case
Copy link
Member Author

@narrieta narrieta Jan 10, 2025

Choose a reason for hiding this comment

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

This issue has always been here. The only reason I noticed it is because a test that uses assertListEqual failed for an unrelated issue and this code raised an exception.

useradd --shell /bin/bash --create-home -g waagent waagent
curl -sSf --retry 5 -o /tmp/python-${PYTHON_VERSION}.tar.bz2 https://dcrdata.blob.core.windows.net/python/python-${PYTHON_VERSION}.tar.bz2
tar xjf /tmp/python-${PYTHON_VERSION}.tar.bz2 --directory /
chown -R waagent:waagent /home/waagent # The UID:GID in the tarball may not match those of the user, so we need to fix that.
Copy link
Member Author

@narrieta narrieta Jan 10, 2025

Choose a reason for hiding this comment

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

Ubuntu 24 has a new user, ubuntu, with PID 1000 so now the PID in the tarball does not match waagent's (which now gets 1001)

@narrieta narrieta changed the title Use Ubuntu 24 for unit tests runs [Python 2.6 & 3.4] Enable unit tests for Python 2.6 & 3.4 on Github Actions Jan 10, 2025
maddieford
maddieford previously approved these changes Jan 13, 2025
setup done by ci_pr.yml is practically identical to the setup done by this Dockerfile, with minor
differences to account for the differences between Github Actions and Azure Pipelines.

NOTE: ci_pr.yml also depends on the patch_python_env.sh script.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
NOTE: ci_pr.yml also depends on the patch_python_env.sh script.
NOTE: ci_pr.yml also depends on the patch_python_venv.sh script.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks; fixed

@narrieta narrieta merged commit 1f3ead2 into Azure:develop Jan 14, 2025
11 checks passed
@narrieta narrieta deleted the unit-tests branch January 14, 2025 18:43
narrieta added a commit to narrieta/WALinuxAgent that referenced this pull request Jan 14, 2025
* Use Ubuntu 24 for unit tests runs [Python 2.6 & 3.4]
---------

Co-authored-by: narrieta@microsoft <narrieta>
(cherry picked from commit 1f3ead2)
narrieta added a commit that referenced this pull request Jan 14, 2025
* Use Ubuntu 24 for unit tests runs [Python 2.6 & 3.4]
---------

Co-authored-by: narrieta@microsoft <narrieta>
(cherry picked from commit 1f3ead2)
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