Skip to content

Commit

Permalink
[docker-ptf] Add support for spytest to ptf container (#4410)
Browse files Browse the repository at this point in the history
- Install apt and pip dependencies
- Define traffic generator service

Signed-off-by: Danny Allen <daall@microsoft.com>
  • Loading branch information
daall authored Apr 13, 2020
1 parent 2beca91 commit 2872d80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
16 changes: 10 additions & 6 deletions dockers/docker-ptf/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debs/
ENV DEBIAN_FRONTEND=noninteractive

## Set the apt source, update package cache and install necessary packages
## TODO: Clean up this step
RUN sed --in-place 's/httpredir.debian.org/debian-archive.trafficmanager.net/' /etc/apt/sources.list \
&& apt-get update \
&& apt-get upgrade -y \
Expand All @@ -39,7 +40,6 @@ RUN sed --in-place 's/httpredir.debian.org/debian-archive.trafficmanager.net/' /
unzip \
pkg-config \
binutils \
net-tools \
build-essential \
libssl-dev \
libffi-dev \
Expand All @@ -53,7 +53,6 @@ RUN sed --in-place 's/httpredir.debian.org/debian-archive.trafficmanager.net/' /
iputils-ping \
hping3 \
curl \
tcpdump \
tmux \
python \
python-dev \
Expand All @@ -64,14 +63,17 @@ RUN sed --in-place 's/httpredir.debian.org/debian-archive.trafficmanager.net/' /
rsyslog \
ntp \
ntpstat \
ntpdate
ntpdate \
arping \
bridge-utils

RUN dpkg -i \
{% for deb in docker_ptf_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %}

# Install all python modules from pypi. python-scapy is exception, ptf debian package requires python-scapy
# TODO: Clean up this step
RUN rm -rf /debs \
&& apt-get -y autoclean \
&& apt-get -y autoremove \
Expand Down Expand Up @@ -115,6 +117,7 @@ RUN rm -rf /debs \
&& pip install flask \
&& pip install exabgp==3.4.17\
&& pip install pyaml \
&& pip install pybrctl pyro4 rpyc yabgp \
&& mkdir -p /opt \
&& cd /opt \
&& wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py
Expand All @@ -126,15 +129,16 @@ RUN mkdir /var/run/sshd \
&& sed -ri '/^#?UsePAM/c\UsePAM no' /etc/ssh/sshd_config \
&& sed -ri '/^#?UseDNS/c\UseDNS no' /etc/ssh/sshd_config

COPY ["supervisord.conf", "/etc/supervisor/"]
COPY ["conf.d/supervisord.conf", "conf.d/sshd.conf", "conf.d/ptf_nn_agent.conf", "/etc/supervisor/conf.d/"]
COPY supervisord.conf /etc/supervisor/
COPY conf.d/ /etc/supervisor/conf.d/
COPY ptf_tgen.sh /ptf_tgen/

# Move tcpdump into /usr/bin Otherwise it's impossible to run tcpdump due to a docker bug
RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump
RUN ln -s /usr/bin/tcpdump /usr/sbin/tcpdump

RUN mkdir -p /var/log/supervisor

EXPOSE 22
EXPOSE 22 8009

ENTRYPOINT ["/usr/local/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
10 changes: 10 additions & 0 deletions dockers/docker-ptf/conf.d/ptf_tgen.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[program:ptf_tgen]
command=/ptf_tgen/ptf_tgen.sh
process_name=ptf_tgen
stdout_logfile=/tmp/ptf_tgen.out.log
stderr_logfile=/tmp/ptf_tgen.err.log
redirect_stderr=false
autostart=false
autorestart=true
startsecs=1
numprocs=1
1 change: 1 addition & 0 deletions dockers/docker-ptf/ptf_tgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# PLACEHOLDER - This file is intended to be overwritten by SPYTest.

0 comments on commit 2872d80

Please sign in to comment.