Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better developer experience: ability to run tests inside docker containers #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions utilities/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM openvswitch/ovn:2.12_e60f2f2_debian_master
Copy link
Contributor

Choose a reason for hiding this comment

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

2.12 is rather old version, before OVS and OVN split.

Copy link
Contributor Author

@vjayaramrh vjayaramrh Jan 12, 2021

Choose a reason for hiding this comment

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

I used that image as the starting point as it was available in dockerhub at https://hub.docker.com/search?q=openvswitch%2Fovn&type=image, I am hoping that OVN images get regulary pushed as per the request at ovn-org/ovn#67 This dockerfile can be updated once the OVN release images gets published regularly, what do you think?


ARG GOVERPKG=go1.13.9.linux-amd64.tar.gz
RUN apt-get update
RUN apt-get install -y wget git gcc python3-pip python3-dev build-essential autoconf automake libtool
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the purpose of installing the tools such as gcc, python, build-essential, etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test.sh script in the .travis folder needs them when executed inside the container

Copy link
Contributor

Choose a reason for hiding this comment

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

but according to the steps you put in README, the test.sh script is not used. Your approach is supposed to run "go test" directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The README captures the native go way of running tests. Do you think that the README should also capture the alternate way i.e executing the .travis/test.sh? If you think that would be useful to capture as well, I can certainly update the README


RUN wget -P /tmp https://dl.google.com/go/$GOVERPKG

RUN tar -C /usr/local -xzf /tmp/$GOVERPKG
RUN rm /tmp/$GOVERPKG

ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"

WORKDIR $GOPATH

RUN apt-get install -y supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

ENTRYPOINT ["/usr/bin/supervisord"]
21 changes: 21 additions & 0 deletions utilities/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- Goal: Add ability to run the go-ovn tests inside of a docker container which in turn would make it easy to run on
non-linux systems that have docker installed. The docker image installs `go` binaries and sets the `GOPATH` environment
variable.

- To build the docker image execute the below on a system where docker is installed

```docker build -t <image_name>:<tag_name> .```

- To execute the tests,
a)first, mount the path to the go-ovn repo when running the container as below:

```
docker run -itd -v <PATH_TO_GO_OVN_REPO>:/go/src/github.com/eBay/go-ovn <image_name>:<tag_name>
```

b)next, exec into shell of the running container ( `docker exec -it <running_container_name> bash`) and execute the
below command to run the tests

```
OVS_RUNDIR=/var/run/ovn OVN_NB_DB=unix:ovnnb_db.sock OVN_SB_DB=unix:ovnsb_db.sock go test -v ./...
```
11 changes: 11 additions & 0 deletions utilities/docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[supervisord]
nodaemon=true

[program:ovn-nb-tcp]
command=/bin/start-ovn ovn-nb-tcp

[program:ovn-sb-tcp]
command=/bin/start-ovn ovn-sb-tcp

[program:ovn-northd-tcp]
command=/bin/start-ovn ovn-northd-tcp
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we don't need northd for go-ovn testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct, but convenient to have a running container built from this image that has all the relevant services running