From b73da484c4d834f17a8563f39556e617fbc6869c Mon Sep 17 00:00:00 2001 From: xwjiang2021 <96218837+xwjiang2021@users.noreply.github.com> Date: Sat, 12 Mar 2022 20:18:12 +0800 Subject: [PATCH] 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. --- dockers/docker-sonic-mgmt/Dockerfile.j2 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/dockers/docker-sonic-mgmt/Dockerfile.j2 b/dockers/docker-sonic-mgmt/Dockerfile.j2 index e2054ae81b..8349df8e43 100755 --- a/dockers/docker-sonic-mgmt/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt/Dockerfile.j2 @@ -21,7 +21,6 @@ RUN apt-get update && apt-get install -y build-essential \ python \ python-dev \ python-scapy \ - python-setuptools \ python-pip \ python3-pip \ python3-venv \ @@ -33,6 +32,7 @@ RUN apt-get update && apt-get install -y build-essential \ telnet \ vim +RUN pip install setuptools==44.1.1 RUN pip install cffi==1.10.0 \ contextlib2==0.6.0.post1 \ cryptography==3.3.2 \ @@ -74,6 +74,7 @@ RUN pip install cffi==1.10.0 \ virtualenv \ retry \ thrift==0.11.0 \ + allure-pytest==2.8.22 \ && git clone https://github.com/p4lang/scapy-vxlan.git \ && cd scapy-vxlan \ && python setup.py install \ @@ -182,10 +183,6 @@ RUN python3 -m venv env-python3 # the end until we figure that out. 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. ENV VIRTUAL_ENV=env-python3 ARG BACKUP_OF_PATH="$PATH"