File tree Expand file tree Collapse file tree 3 files changed +103
-0
lines changed Expand file tree Collapse file tree 3 files changed +103
-0
lines changed Original file line number Diff line number Diff line change
1
+ #
2
+ # Environment to execute the WALinuxAgent unit tests for some versions of Python that have reached EOL and are no longer available
3
+ # in the official repositories.
4
+ #
5
+ # To build the image, set the PYTHON_VERSION argument to 2.6 or 3.4:
6
+ #
7
+ # * docker build -t python2.6 --build-arg PYTHON_VERSION=2.6 .
8
+ # * docker build -t python3.4 --build-arg PYTHON_VERSION=3.4 .
9
+ #
10
+ # Sample commands (note that the convenience functions defined in the profile assume the root of the source code has been mounted at /home/waagent/WALinuxAgent):
11
+ #
12
+ # * Start an interactive session: docker run --rm -it -v WALinuxAgent:/home/waagent/WALinuxAgent bash --login
13
+ # * Run unit tests: docker run --rm -v WALinuxAgent:/home/waagent/WALinuxAgent python2.6 bash --login -c run-tests
14
+ # * Run tests that require root: docker run --user root --rm -v WALinuxAgent:/home/waagent/WALinuxAgent python2.6 bash --login -c run-sudo-tests
15
+ #
16
+ FROM ubuntu:16.04
17
+ ARG PYTHON_VERSION
18
+ LABEL description="Test environment for WALinuxAgent"
19
+
20
+ SHELL ["/bin/bash" , "-c" ]
21
+
22
+ RUN \
23
+ groupadd waagent && \
24
+ useradd --shell /bin/bash --create-home -g waagent waagent && \
25
+ apt-get update && \
26
+ apt-get -y install curl bzip2 sudo python3 && \
27
+ curl -sSf --retry 5 -o /tmp/python-${PYTHON_VERSION}.tar.bz2 https://dcrdata.blob.core.windows.net/python/python-${PYTHON_VERSION}.tar.bz2 && \
28
+ tar xjf /tmp/python-${PYTHON_VERSION}.tar.bz2 --directory / && \
29
+ echo $'\
30
+ cd /home/waagent \n \
31
+ source /home/waagent/virtualenv/python' ${PYTHON_VERSION}/bin/activate$' \n \
32
+ function run-tests { \n \
33
+ nosetests --verbose --ignore-files test_cgroupconfigurator_sudo.py /home/waagent/WALinuxAgent/tests \n \
34
+ } \n \
35
+ function run-sudo-tests { \n \
36
+ nosetests --verbose /home/waagent/WALinuxAgent/tests/ga/test_cgroupconfigurator_sudo.py \n \
37
+ } \n \
38
+ ' | tee -a /home/waagent/.profile >> ~/.profile && \
39
+ :
40
+
41
+ USER waagent:waagent
42
+
43
+
44
+
Original file line number Diff line number Diff line change
1
+ jobs :
2
+ - job : " RunTests"
3
+ timeoutInMinutes : 15
4
+
5
+ steps :
6
+ - task : AzureKeyVault@2
7
+ displayName : " Fetch connection info"
8
+ inputs :
9
+ azureSubscription : $(connection_info)
10
+ KeyVaultName : ' waagenttests'
11
+ SecretsFilter : ' CR-*'
12
+
13
+ - bash : $(Build.SourcesDirectory)/tests/python_eol/run_tests.sh
14
+ displayName : " Run tests"
15
+ continueOnError : true
16
+ env :
17
+ CR_USER : $(CR-USER)
18
+ CR_SECRET : $(CR-SECRET)
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euxo pipefail
4
+
5
+ #
6
+ # UID of 'waagent' in the Docker container
7
+ #
8
+ WAAGENT_UID=1000
9
+
10
+ #
11
+ # Create the directory where the Docker container will create the test logs and give ownership to 'waagent'
12
+ #
13
+ LOGS_DIRECTORY=" $AGENT_TEMPDIRECTORY /logs"
14
+ echo " ##vso[task.setvariable variable=logs_directory]$LOGS_DIRECTORY "
15
+ mkdir " $LOGS_DIRECTORY "
16
+ sudo chown " $WAAGENT_UID " " $LOGS_DIRECTORY "
17
+
18
+ #
19
+ # Give the current user access to the Docker daemon
20
+ #
21
+ sudo usermod -aG docker $USER
22
+ newgrp docker < /dev/null
23
+
24
+ #
25
+ # Pull the container image used to execute the tests
26
+ #
27
+ az acr login --name waagenttests --username " $CR_USER " --password " $CR_SECRET "
28
+
29
+ docker pull waagenttests.azurecr.io/python2.6:latest
30
+
31
+ docker run -rm \
32
+ --user root \
33
+ --volume " $BUILD_SOURCESDIRECTORY :/home/waagent/WALinuxAgent" \
34
+ --volume " $LOGS_DIRECTORY " :/home/waagent/logs \
35
+ waagenttests.azurecr.io/python2.6 \
36
+ bash --login -c run-sudo-tests
37
+
38
+ #
39
+ # Re-take ownership of the log directory
40
+ #
41
+ sudo find " $LOGS_DIRECTORY " -exec chown " $USER " {} \;
You can’t perform that action at this time.
0 commit comments