Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
narrieta@microsoft committed Jan 3, 2025
1 parent d76474c commit 4200982
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
37 changes: 20 additions & 17 deletions tests/python_eol/execute_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

set -euo pipefail

if [ "$#" -ne 1 ]; then
echo "Usage: execute_tests.sh <python-version>"
if [[ "$#" -ne 1 || ! "$1" =~ ^2\.6|3\.4$ ]]; then
echo "Usage: execute_tests.sh 2.6|3.4"
exit 1
fi
PYTHON_VERSION=$1

if [[ ! "$PYTHON_VERSION" =~ ^2\.6|3\.4$ ]]; then
echo "Only versions 2.6 and 3.4 are supported"
fi
EXIT_CODE=0
PYTHON_VERSION=$1
CONTAINER_IMAGE="waagenttests.azurecr.io/python$PYTHON_VERSION"
CONTAINER_LOGS_DIRECTORY="/home/waagent/logs"
CONTAINER_SOURCES_DIRECTORY="/home/waagent/WALinuxAgent"
NOSETESTS_OPTIONS="--verbose --with-xunit"

#
# Give ownership of the logs directory to 'waagent' (UID 1000)
Expand All @@ -26,17 +28,11 @@ newgrp docker < /dev/null
#
# Pull the container image and execute the tests
#
CONTAINER_IMAGE="waagenttests.azurecr.io/python$PYTHON_VERSION"
CONTAINER_LOGS_DIRECTORY="/home/waagent/logs"
CONTAINER_SOURCES_DIRECTORY="/home/waagent/WALinuxAgent"
NOSETESTS_OPTIONS="--verbose --with-xunit"


az acr login --name waagenttests --username "$CR_USER" --password "$CR_SECRET"

docker pull "$CONTAINER_IMAGE"

echo "***************************************** Running tests for Python $PYTHON_VERSION *****************************************"
printf "\n***************************************** Running tests for Python $PYTHON_VERSION *****************************************\n\n"

TEST_SUITE_OPTIONS="--xunit-testsuite-name='Python $PYTHON_VERSION' --xunit-file=$CONTAINER_LOGS_DIRECTORY/waagent-$PYTHON_VERSION.junit.xml"

Expand All @@ -45,18 +41,25 @@ docker run --rm \
--volume "$BUILD_SOURCESDIRECTORY":"$CONTAINER_SOURCES_DIRECTORY" \
--volume "$LOGS_DIRECTORY":"$CONTAINER_LOGS_DIRECTORY" \
"$CONTAINER_IMAGE" \
bash --login -c "nosetests $NOSETESTS_OPTIONS $TEST_SUITE_OPTIONS --ignore-files test_cgroupconfigurator_sudo.py $CONTAINER_SOURCES_DIRECTORY/tests"
bash --login -c "nosetests $NOSETESTS_OPTIONS $TEST_SUITE_OPTIONS --ignore-files test_cgroupconfigurator_sudo.py $CONTAINER_SOURCES_DIRECTORY/tests" \
|| EXIT_CODE=$(($EXIT_CODE || $?))
set +x

echo "************************************** Running tests for Python $PYTHON_VERSION [sudo] **************************************"
printf "\n************************************** Running tests for Python $PYTHON_VERSION [sudo] **************************************\n\n"

TEST_SUITE_OPTIONS="--xunit-testsuite-name='Python $PYTHON_VERSION [sudo]' --xunit-file=$CONTAINER_LOGS_DIRECTORY//waagent-sudo-$PYTHON_VERSION.junit.xml"
TEST_SUITE_OPTIONS="--xunit-testsuite-name='Python $PYTHON_VERSION [sudo]' --xunit-file=$CONTAINER_LOGS_DIRECTORY/waagent-sudo-$PYTHON_VERSION.junit.xml"

set -x
docker run --rm \
--user root \
--volume "$BUILD_SOURCESDIRECTORY":"$CONTAINER_SOURCES_DIRECTORY" \
--volume "$LOGS_DIRECTORY":"$CONTAINER_LOGS_DIRECTORY" \
"$CONTAINER_IMAGE" \
bash --login -c "nosetests $NOSETESTS_OPTIONS $TEST_SUITE_OPTIONS $CONTAINER_SOURCES_DIRECTORY/tests/ga/test_cgroupconfigurator_sudo.py"
bash --login -c "nosetests $NOSETESTS_OPTIONS $TEST_SUITE_OPTIONS $CONTAINER_SOURCES_DIRECTORY/tests/ga/test_cgroupconfigurator_sudo.py"\
|| EXIT_CODE=$(($EXIT_CODE || $?))
set +x

# Re-take ownership of the logs directory
find "$LOGS_DIRECTORY" -exec chown "$USER" {} \;

exit "$EXIT_CODE"
5 changes: 0 additions & 5 deletions tests/python_eol/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ jobs:
CR_SECRET: $(CR-SECRET)
LOGS_DIRECTORY: $(Agent.TempDirectory)/logs
# The execute_tests.sh gives ownership of the logs directory to the container user; re-take ownership.
- bash: sudo find "$(Agent.TempDirectory)/logs" -exec chown "$USER" {} \;
displayName: "Change ownership of logs directory"
condition: always()

- task: PublishTestResults@2
displayName: 'Publish test results'
condition: always()
Expand Down

0 comments on commit 4200982

Please sign in to comment.