Install the allure-pytest package globally in sonic-mgmt docker (#10216)

Why I did it
This fix is to address issue: Azure/sonic-mgmt#5280

In the sonic-mgmt Dockerfile, python package allure-pytest is installed after ENV USER $user.
Consequently the package is installed to path /home/$user/.local and is only available to the $user
account. If we use root account in sonic-mgmt docker container to run tests, any script importing
the allure package will fail with ImportError. We need to install the allure-pytest package to global
directory instead of user local directory.

How I did it
Update the sonic-mgmt Dockerfile to ensure that the allure-pytest package is installed to global directory

How to verify it
Build a new sonic-mgmt docker image based on the changes.
Use sonic-mgmt docker container of the newly built image to run test scripts that depend on the
allure-pytest package. No ImportError is raised.
This commit is contained in:
xwjiang2021 2022-03-12 20:18:12 +08:00 committed by GitHub
parent ebe2d19623
commit b73da484c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,6 @@ RUN apt-get update && apt-get install -y build-essential \
python \ python \
python-dev \ python-dev \
python-scapy \ python-scapy \
python-setuptools \
python-pip \ python-pip \
python3-pip \ python3-pip \
python3-venv \ python3-venv \
@ -33,6 +32,7 @@ RUN apt-get update && apt-get install -y build-essential \
telnet \ telnet \
vim vim
RUN pip install setuptools==44.1.1
RUN pip install cffi==1.10.0 \ RUN pip install cffi==1.10.0 \
contextlib2==0.6.0.post1 \ contextlib2==0.6.0.post1 \
cryptography==3.3.2 \ cryptography==3.3.2 \
@ -74,6 +74,7 @@ RUN pip install cffi==1.10.0 \
virtualenv \ virtualenv \
retry \ retry \
thrift==0.11.0 \ thrift==0.11.0 \
allure-pytest==2.8.22 \
&& git clone https://github.com/p4lang/scapy-vxlan.git \ && git clone https://github.com/p4lang/scapy-vxlan.git \
&& cd scapy-vxlan \ && cd scapy-vxlan \
&& python setup.py install \ && python setup.py install \
@ -182,10 +183,6 @@ RUN python3 -m venv env-python3
# the end until we figure that out. # the end until we figure that out.
RUN pip install pycryptodome==3.9.8 RUN pip install pycryptodome==3.9.8
# Install allure-pytest library
RUN pip install --upgrade setuptools \
&& pip install allure-pytest==2.8.22
# Activating a virtualenv. The virtualenv automatically works for RUN, ENV and CMD. # Activating a virtualenv. The virtualenv automatically works for RUN, ENV and CMD.
ENV VIRTUAL_ENV=env-python3 ENV VIRTUAL_ENV=env-python3
ARG BACKUP_OF_PATH="$PATH" ARG BACKUP_OF_PATH="$PATH"