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

Introduce a Dockerfile for running integration tests #156

Merged
merged 2 commits into from
Jul 13, 2020
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
10 changes: 1 addition & 9 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: deps
run: sudo apt-get update -y && sudo apt-get install stunnel4 redis -y

- name: build and push docker image
run: |
redis-server --port 6380 &
redis-server --port 6381 --requirepass password123 &
redis-server --port 6382 --requirepass password123 &
redis-server --port 6384 --requirepass password123 &
redis-server --port 6385 --requirepass password123 &
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
make bootstrap bootstrap_redis_tls docker_push
make docker_push
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/pullrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: deps
run: sudo apt-get update -y && sudo apt-get install stunnel4 redis -y

- name: build and test
run: |
redis-server --port 6380 &
redis-server --port 6381 --requirepass password123 &
redis-server --port 6382 --requirepass password123 &
redis-server --port 6384 --requirepass password123 &
redis-server --port 6385 --requirepass password123 &
make bootstrap bootstrap_redis_tls tests_unit tests
make docker_tests
10 changes: 1 addition & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: deps
run: sudo apt-get update -y && sudo apt-get install stunnel4 redis -y

- name: build and push docker image
run: |
redis-server --port 6380 &
redis-server --port 6381 --requirepass password123 &
redis-server --port 6382 --requirepass password123 &
redis-server --port 6384 --requirepass password123 &
redis-server --port 6385 --requirepass password123 &
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
make bootstrap bootstrap_redis_tls docker_push
make docker_push
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
17 changes: 17 additions & 0 deletions Dockerfile.integration
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Running this docker image runs the integration tests.
FROM golang:1.14

RUN apt-get update -y && apt-get install sudo stunnel4 redis -y && rm -rf /var/lib/apt/lists/*

WORKDIR /workdir

ENV GOPROXY=https://proxy.golang.org
COPY go.mod go.sum /workdir/
RUN go mod download

COPY Makefile /workdir
RUN make bootstrap

COPY src /workdir/src
COPY test /workdir/test
CMD make tests_with_redis
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export GO111MODULE=on
PROJECT = ratelimit
REGISTRY ?= envoyproxy
IMAGE := $(REGISTRY)/$(PROJECT)
INTEGRATION_IMAGE := $(REGISTRY)/$(PROJECT)_integration
MODULE = github.com/envoyproxy/ratelimit
GIT_REF = $(shell git describe --tags || git rev-parse --short=8 --verify HEAD)
VERSION ?= $(GIT_REF)
Expand Down Expand Up @@ -70,8 +71,23 @@ tests_unit: compile
tests: compile
go test -race -tags=integration $(MODULE)/...

.PHONY: tests_with_redis
tests_with_redis: bootstrap_redis_tls tests_unit
redis-server --port 6379 &
redis-server --port 6380 &
redis-server --port 6381 --requirepass password123 &
redis-server --port 6382 --requirepass password123 &
redis-server --port 6384 --requirepass password123 &
redis-server --port 6385 --requirepass password123 &
go test -race -tags=integration $(MODULE)/...

.PHONY: docker_tests
docker_tests:
docker build -f Dockerfile.integration . -t $(INTEGRATION_IMAGE):$(VERSION) && \
docker run $$(tty -s && echo "-it" || echo) $(INTEGRATION_IMAGE):$(VERSION)

.PHONY: docker_image
docker_image: tests
docker_image: docker_tests
docker build . -t $(IMAGE):$(VERSION)

.PHONY: docker_push
Expand Down