Skip to content

Commit 1effff9

Browse files
authored
Enable system-site-packages for ptf docker and install thrift for test_qos_sai (#12094)
Why I did it test_sai_qos failed because of the following error: "stderr_lines": [ "Traceback (most recent call last):", " File \"/usr/bin/ptf\", line 522, in <module>", " test_modules = load_test_modules(config)", " File \"/usr/bin/ptf\", line 413, in load_test_modules", " mod = imp.load_module(modname, *imp.find_module(modname, [root]))", " File \"saitests/switch.py\", line 19, in <module>", " import switch_sai_thrift", "ImportError: No module named switch_sai_thrift" ], It's because test_sai_qos runs ptf script which imports switch_sai_thrift, switch_sai_thrift is installed from python-saithrift_0.9.4_amd64.deb. For master image, the deb file is for python3, but ptf only has virtual python3 environment, that's why we add --system-site-packages to allow virtual env to access system site-packeges. Add thrift package in docker ptf virtual python3 env, because currently env-python3 doesn't have thrift module which is needed in switch_sai_thrift. How I did it Enable --system-site-packages for virtual py3 env in ptf docker and install thrift for test_qos_sai How to verify it load and login ptf conatiner dpkg - i python-saithrift_0.9.4_amd64.deb source /root/env-python3/bin/activate python import switch_sai_thrift.switch_sai_rpc Signed-off-by: Zhaohui Sun <[email protected]>
1 parent 5650762 commit 1effff9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dockers/docker-ptf/Dockerfile.j2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ RUN rm -rf /debs \
136136
&& cd /opt \
137137
&& wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py
138138

139-
RUN python3 -m venv env-python3
139+
RUN python3 -m venv --system-site-packages env-python3
140140

141141
# Activating a virtualenv. The virtualenv automatically works for RUN, ENV and CMD.
142142
ENV VIRTUAL_ENV=/root/env-python3
@@ -173,7 +173,8 @@ RUN python3 -m pip install setuptools \
173173
&& pip3 install itsdangerous \
174174
&& pip3 install retrying \
175175
&& pip3 install jinja2 \
176-
&& pip3 install scapy==2.4.5
176+
&& pip3 install scapy==2.4.5 \
177+
&& pip3 install thrift
177178

178179
{% if docker_ptf_whls.strip() -%}
179180
# Copy locally-built Python wheel dependencies

0 commit comments

Comments
 (0)