Skip to content
This repository was archived by the owner on Sep 7, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ image-build-builder/ubuntu/bionic:
image-build-tests-runner:
extends: .image-build

image-build-boardfarm-ci:
extends: .image-build

.in-prplmesh-builder:
image:
name: $CI_REGISTRY_IMAGE/prplmesh-builder-ubuntu-bionic:$CI_PIPELINE_ID
Expand Down Expand Up @@ -213,6 +216,21 @@ run-tests:
- job: image-build-tests-runner
- job: image-build-runner

boardfarm-tests:
stage: test
image: $CI_REGISTRY_IMAGE/prplmesh-boardfarm-ci:$CI_PIPELINE_ID
script:
- export USER=''
- tests/run_bf.sh
artifacts:
paths:
- logs
- results
needs:
- job: build-in-docker
tags:
- boardfarm

.build-for-openwrt:
stage: build
script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@
from boardfarm.devices import linux


class CommandError(Exception):
"""Raised on failed execution"""
pass


class PrplMeshBase(linux.LinuxDevice):
"""PrplMesh abstract device."""

def _run_shell_cmd(self, cmd: str = "", args: list = None, timeout: int = 30):
"""Wrapper that executes command with specified args on host machine and logs output."""

res = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8")
res, exitstatus = pexpect.run(cmd, args=args, timeout=timeout, encoding="utf-8",
withexitstatus=1)
entry = " ".join((cmd, " ".join(args)))
if exitstatus != 0:
raise CommandError("Error executing {}:\n{}".format(entry, res))

self.log_calls += entry
self.log += "$ " + entry + "\r\n" + res

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def check_status(self):
It is used by boardfarm to indicate that spawned device instance is ready for test
and also after test - to insure that device still operational.
"""
self._run_shell_cmd(os.path.join(rootdir, "tools", "docker", "test.sh"),
["-v", "-n", self.name])
self._run_shell_cmd("printf",
["device_get_info", "|", "nc", "-w", "1", "controller-rme", "8002"])

def isalive(self):
"""Method required by boardfarm.
Expand Down
2 changes: 1 addition & 1 deletion tests/run_bf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ else
fi
export PYTHONPATH

exec python3 "${bf_dir}"/bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config.json -n prplmesh_docker -x test_flows
exec bft -c "${bf_plugins_dir}"/boardfarm_prplmesh/prplmesh_config.json -n prplmesh_docker -x test_flows
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Oleksii originally integrated boardfarm, I asked not do to this exactly because it requires installing boardfarm, which I wanted to avoid :-)

But I guess it's OK now that we have it in docker.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is actually bogus; I added a script run_bf_compose.sh that still uses the boardfarm in it's local copy, as above

42 changes: 42 additions & 0 deletions tools/docker/boardfarm-ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM python:3.8-slim-buster

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates curl \
curl \
gcc \
git \
gnupg \
gnupg-agent \
libsnmp-dev \
netcat \
software-properties-common \
wireshark-common \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/requirements.txt

WORKDIR app
RUN pip3 install -r requirements.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? Before, we just took the requirements.txt from boardfarm. I.e.


RUN git clone https://github.com/mattsm/boardfarm.git \
    && cd boardfarm \
    && git checkout 100521fde1fb67536682cafecc2f91a6e2e8a6f8 \
    && pip3 install -r requirements.txt
    && python3 setup.py install 

Yes, it does mean that all the pip stuff has to be re-downloaded whenever we change the boardfarm hash, but that's going to be rare anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boardfarm itself is not installed in this setup, it is used from the rootdir/boardfarm dir directly to allow for any changes made locally to be used.

As we do not expect to change boardfarm itself, this will be changed to installing as before, cloning and the rest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arnout good point, I hadn't noticed boardfarm itself also included the requirements, I though it was added by us.

@odkq with these changes, boardfarm is installed in the image itself. Is it something you want to do differently?


# TODO: what needs this?
#RUN pip3 install jsonschema distro


RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
docker-ce \
docker-ce-cli \
containerd.io \
&& rm -rf /var/lib/apt/lists/*

RUN curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
RUN chmod 755 /usr/local/bin/docker-compose
Comment on lines +27 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my info: why isn't all this simply taken from Debian/Ubuntu repos? Are we using such advanced features?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I took the dockerfile from #1483 and tried to make only the changes I needed.
Maybe @odkq needs a more recent version than the base image provides?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, debian stable is 1.21 and I don't think we are going to use later development, but as documentation is not tagged (always the latest) with this we have the mechanism in place for future upgrades (just change the 1.26.0 in the url and test)


RUN git clone https://github.com/mattsm/boardfarm.git \
&& cd boardfarm \
&& git checkout 100521fde1fb67536682cafecc2f91a6e2e8a6f8 \
&& python3 setup.py install
48 changes: 48 additions & 0 deletions tools/docker/boardfarm-ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
aenum
argparse
beautifulsoup4
boto3
cdrouter
debtcollector
distro
dlipower
dnspython
docutils<0.16
easysnmp
elasticsearch>=1.0.0
Faker
future
ipaddress
jira
jsonschema
marshmallow<3
matplotlib
nested_lookup==0.2.19
netaddr
pexpect
pre-commit
psutil
pycountry
pycryptodome
pyflakes
pymongo
pyserial
pysmi
pysnmp
pytest==5.3.5
pytest-html
pytest-mock
pytest-randomly
pyvirtualdisplay
requests
retry
selenium
simplejson
six
sphinx
termcolor
unittest2
xmltodict
xvfbwrapper
yapf
zeep