Skip to content

Commit

Permalink
Add Dockerfile for running e2e tests (#97)
Browse files Browse the repository at this point in the history
* Add Dockerfile for running e2e tests

- Local e2e tests rely on having an ldap setup which is incredibly difficult to setup locally as the versions keep changing and with it some of the configurations. Hence, keeping the local dockerfile aligned with the os used on travis node will keep local development aligned with CI builds.
- Changes to os versions on travis node can then be upgraded organically

* Address PR comments fixing some commands in the dockerfile.
  • Loading branch information
supreethrao authored Mar 4, 2024
1 parent 47dfb9d commit 1f72b12
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,24 @@ All `Dex` instances from the different environments will talk to the single

For cloud end-to-end tests, a mocked OIDC server is created and used to authenticate with.

#### Running E2E tests locally
There's a docker file called `Dockerfile.localtest` which sets up the test environment similar to the one used by travis.
Travis uses ubuntu 16.04 (xenial) as the default node to run build on unless changed with a `dist` directive.
More details available [here](https://docs.travis-ci.com/user/reference/linux/)

To run the test locally, run the following command

1. Build the local image
`cd <osprey root>/e2e && docker build -f Dockerfile.localtest -t local-osprey-e2etest:1 .`
2. Run the container with bash as the entry point
`docker run -it -v <osprey root folder>:/osprey local-osprey-e2etest:1`
3. Inside the container run make test
```
cd /osprey
export PATH=$PATH:/osprey/build/bin/linux_amd64
make test
```

## HTTPS/ProtocolBuffers

Given that aws ELBs do not support HTTP/2 osprey needs to run over HTTP.
Expand Down
15 changes: 15 additions & 0 deletions e2e/Dockerfile.localtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:16.04

# DEBIAN_FRONTEND=noninteractive is needed in order for slapd not waiting for an interactive password to be supplied.
RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends slapd && \
apt-get -y install --no-install-recommends ldap-utils && \
apt-get -y install tree && \
apt-get -y install curl && \
apt-get -y install build-essential && \
apt-get -y install git-all

RUN curl -fsSL https://go.dev/dl/go1.18.10.linux-amd64.tar.gz -o /tmp/go1.18.10.linux-amd64.tar.gz && \
tar -C /usr/local -xzf /tmp/go1.18.10.linux-amd64.tar.gz

ENV PATH=$PATH:/usr/local/go/bin
12 changes: 9 additions & 3 deletions e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@ var _ = AfterSuite(func() {
for _, aDex := range dexes {
dextest.Stop(aDex)
}
oidcTestServer.Stop()
apiTestServer.Stop()
ldaptest.Stop(ldapServer)
if oidcTestServer != nil {
oidcTestServer.Stop()
}
if apiTestServer != nil {
apiTestServer.Stop()
}
if ldapServer != nil {
ldaptest.Stop(ldapServer)
}
os.RemoveAll(testDir)
})

Expand Down

0 comments on commit 1f72b12

Please sign in to comment.