Skip to content

Commit

Permalink
ci: upgrade e2e-test-ci (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinsRan committed Jul 18, 2022
1 parent 9a6bd92 commit 628abb9
Show file tree
Hide file tree
Showing 27 changed files with 284 additions and 287 deletions.
69 changes: 0 additions & 69 deletions .github/actions/e2e/action.yaml

This file was deleted.

99 changes: 95 additions & 4 deletions .github/workflows/e2e-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,63 @@ jobs:
- 'test/e2e/**/*'
- 'conf/**'
- 'utils/**'
build:
name: Build
runs-on: ubuntu-latest
needs: changes

steps:

- name: Checkout
uses: actions/checkout@v3 # v3.0.2

- name: Set up Go 1.18
id: go
uses: actions/setup-go@v3 # v3.2.0
with:
go-version: '1.18'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2 #v2.0.0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2 # v2.0.0
with:
version: latest

- name: Prepare Host
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Build images
env:
TAG: dev
ARCH: amd64
REGISTRY: localhost:5000
ENABLE_PROXY: "false"
run: |
echo "building images..."
make clean-image build-images
echo "creating images cache..."
docker save \
localhost:5000/apache/apisix:dev \
localhost:5000/bitnami/etcd:dev \
localhost:5000/apache/apisix-ingress-controller:dev \
localhost:5000/kennethreitz/httpbin:dev \
localhost:5000/test-backend:dev \
localhost:5000/jmalloc/echo-server:dev \
localhost:5000/busybox:dev \
| pigz > docker.tar.gz
- name: cache
uses: actions/upload-artifact@v3 # v3.1.0
with:
name: docker.tar.gz
path: docker.tar.gz

prepare:
needs: changes
Expand All @@ -84,15 +141,49 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

e2e-test:
needs: prepare
needs:
- changes
- prepare
- build
runs-on: ubuntu-latest
strategy:
fail-fast: false # If false, GitHub will not cancels all in-progress jobs in the matrix if any matrix job fails.
matrix:
suite: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- uses: ./.github/actions/e2e
- name: Install ginkgo
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.4
sudo cp ~/go/bin/ginkgo /usr/local/bin
- name: cache
uses: actions/download-artifact@v2 # v2
with:
testsuite_name: ${{ matrix.suite }}
name: docker.tar.gz

- name: Create K8s cluster
shell: bash
run: |
make kind-up
kubectl wait --for=condition=Ready nodes --all
- name: Load images from cache
run: |
echo "loading docker images..."
pigz -dc docker.tar.gz | docker load
make push-images
- name: Run E2E test suite
shell: bash
env:
E2E_FOCUS: "${{ matrix.suite }}"
ENABLE_PROXY: "false"
E2E_SKIP_BUILD: "1"
E2E_FLAKE_ATTEMPTS: "2"
run: |
make e2e-test
118 changes: 73 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ VERSYM="github.com/apache/apisix-ingress-controller/pkg/version._buildVersion"
GITSHASYM="github.com/apache/apisix-ingress-controller/pkg/version._buildGitRevision"
BUILDOSSYM="github.com/apache/apisix-ingress-controller/pkg/version._buildOS"
GO_LDFLAGS ?= "-X=$(VERSYM)=$(VERSION) -X=$(GITSHASYM)=$(GITSHA) -X=$(BUILDOSSYM)=$(OSNAME)/$(OSARCH)"
E2E_CONCURRENCY ?= 2
E2E_NODES ?= 4
E2E_FLAKE_ATTEMPTS ?= 0
E2E_SKIP_BUILD ?= 0

### build: Build apisix-ingress-controller
Expand All @@ -49,11 +50,67 @@ build:
-ldflags $(GO_LDFLAGS) \
main.go

### clean-image: clean apisix-ingress-controller image
.PHONY: clean-image
clean-image: ## Removes local image
echo "removing old image $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)"
docker rmi -f $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG) || true

### build-image: Build apisix-ingress-controller image
.PHONY: build-image
build-image:
docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=true .

### pack-ingress-image: Build and push Ingress image used in e2e test suites to kind or custom registry.
.PHONY: pack-ingress-image
pack-ingress-image:
docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) .
docker tag apache/apisix-ingress-controller:$(IMAGE_TAG) $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)
docker push $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)

### pack-images: Build and push images used in e2e test suites to kind or custom registry.
.PHONY: pack-images
pack-images: build-images push-images

### build-image: Build apisix-ingress-controller image
.PHONY: build-images
build-images:
ifeq ($(E2E_SKIP_BUILD), 0)
docker pull apache/apisix:2.13.1-alpine
docker tag apache/apisix:2.13.1-alpine $(REGISTRY)/apache/apisix:$(IMAGE_TAG)

docker pull bitnami/etcd:3.4.14-debian-10-r0
docker tag bitnami/etcd:3.4.14-debian-10-r0 $(REGISTRY)/bitnami/etcd:$(IMAGE_TAG)

docker pull kennethreitz/httpbin
docker tag kennethreitz/httpbin $(REGISTRY)/kennethreitz/httpbin:$(IMAGE_TAG)

docker build -t test-backend:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) ./test/e2e/testbackend
docker tag test-backend:$(IMAGE_TAG) $(REGISTRY)/test-backend:$(IMAGE_TAG)

docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) .
docker tag apache/apisix-ingress-controller:$(IMAGE_TAG) $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)

docker pull jmalloc/echo-server:latest
docker tag jmalloc/echo-server:latest $(REGISTRY)/jmalloc/echo-server:$(IMAGE_TAG)

docker pull busybox:1.28
docker tag busybox:1.28 $(REGISTRY)/busybox:$(IMAGE_TAG)
endif

### push-images: Push images used in e2e test suites to kind or custom registry.
.PHONY: push-images
push-images:
ifeq ($(E2E_SKIP_BUILD), 0)
docker push $(REGISTRY)/apache/apisix:$(IMAGE_TAG)
docker push $(REGISTRY)/bitnami/etcd:$(IMAGE_TAG)
docker push $(REGISTRY)/kennethreitz/httpbin:$(IMAGE_TAG)
docker push $(REGISTRY)/test-backend:$(IMAGE_TAG)
docker push $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)
docker push $(REGISTRY)/jmalloc/echo-server:$(IMAGE_TAG)
docker push $(REGISTRY)/busybox:$(IMAGE_TAG)
endif

### lint: Do static lint check
.PHONY: lint
lint:
Expand All @@ -66,13 +123,13 @@ unit-test:

### e2e-test: Run e2e test cases (in existing clusters directly)
.PHONY: e2e-test
e2e-test: ginkgo-check push-images e2e-wolf-rbac
e2e-test: ginkgo-check pack-images e2e-wolf-rbac
kubectl apply -k $(PWD)/samples/deploy/crd
kubectl apply -f $(PWD)/samples/deploy/gateway-api
cd test/e2e \
&& go mod download \
&& export REGISTRY=$(REGISTRY) \
&& ACK_GINKGO_RC=true ginkgo -cover -coverprofile=coverage.txt -r --randomize-all --randomize-suites --trace --nodes=$(E2E_CONCURRENCY) --focus=$(E2E_FOCUS)
&& ACK_GINKGO_RC=true ginkgo -cover -coverprofile=coverage.txt -r --randomize-all --randomize-suites --trace --nodes=$(E2E_NODES) --focus=$(E2E_FOCUS) --flake-attempts=$(E2E_FLAKE_ATTEMPTS)

### e2e-test-local: Run e2e test cases (kind is required)
.PHONY: e2e-test-local
Expand All @@ -85,47 +142,6 @@ ifeq ("$(wildcard $(GINKGO))", "")
exit 1
endif


### push-ingress-images: Build and push Ingress image used in e2e test suites to kind or custom registry.
.PHONY: push-ingress-images
push-ingress-images:
docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) .
docker tag apache/apisix-ingress-controller:$(IMAGE_TAG) $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)
docker push $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)

### push-images: Push images used in e2e test suites to kind or custom registry.
.PHONY: push-images
push-images:
ifeq ($(E2E_SKIP_BUILD), 0)
docker pull apache/apisix:2.13.1-alpine
docker tag apache/apisix:2.13.1-alpine $(REGISTRY)/apache/apisix:dev
docker push $(REGISTRY)/apache/apisix:dev

docker pull bitnami/etcd:3.4.14-debian-10-r0
docker tag bitnami/etcd:3.4.14-debian-10-r0 $(REGISTRY)/bitnami/etcd:3.4.14-debian-10-r0
docker push $(REGISTRY)/bitnami/etcd:3.4.14-debian-10-r0

docker pull kennethreitz/httpbin
docker tag kennethreitz/httpbin $(REGISTRY)/kennethreitz/httpbin
docker push $(REGISTRY)/kennethreitz/httpbin

docker build -t test-backend:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) ./test/e2e/testbackend
docker tag test-backend:$(IMAGE_TAG) $(REGISTRY)/test-backend:$(IMAGE_TAG)
docker push $(REGISTRY)/test-backend:$(IMAGE_TAG)

docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) .
docker tag apache/apisix-ingress-controller:$(IMAGE_TAG) $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)
docker push $(REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)

docker pull jmalloc/echo-server:latest
docker tag jmalloc/echo-server:latest $(REGISTRY)/jmalloc/echo-server:latest
docker push $(REGISTRY)/jmalloc/echo-server:latest

docker pull busybox:1.28
docker tag busybox:1.28 $(REGISTRY)/busybox:1.28
docker push $(REGISTRY)/busybox:1.28
endif

### kind-up: Launch a Kubernetes cluster with a image registry by Kind.
.PHONY: kind-up
kind-up:
Expand Down Expand Up @@ -225,7 +241,19 @@ ifeq ("$(E2E_FOCUS)", "")
chmod +x ./test/e2e/testdata/wolf-rbac/cmd.sh && ./test/e2e/testdata/wolf-rbac/cmd.sh start
endif
ifneq ("$(E2E_FOCUS)", "")
echo $(E2E_FOCUS) | grep -E 'suite-plugins-authentication|consumer|wolf|suite-plugins' || exit 0 \
echo $(E2E_FOCUS) | grep -E 'suite-plugins-authentication|consumer|wolf' || exit 0 \
&& chmod +x ./test/e2e/testdata/wolf-rbac/cmd.sh \
&& ./test/e2e/testdata/wolf-rbac/cmd.sh start
endif

### kind-load-images: Load the images to the kind cluster
.PHONY: kind-load-images
kind-load-images:
kind load docker-image --name=apisix \
localhost:5000/apache/apisix:dev \
localhost:5000/bitnami/etcd:dev \
localhost:5000/apache/apisix-ingress-controller:dev \
localhost:5000/kennethreitz/httpbin:dev \
localhost:5000/test-backend:dev \
localhost:5000/jmalloc/echo-server:dev \
localhost:5000/busybox:dev
2 changes: 1 addition & 1 deletion pkg/kube/translation/apisix_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func mockTranslatorV2beta3(t *testing.T) (*translator, <-chan struct{}) {
},
}

processCh := make(chan struct{})
processCh := make(chan struct{}, 2)
svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
processCh <- struct{}{}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Run `make e2e-test-local` to run the e2e test suites in your development environ
Run `make e2e-test` to run the e2e test suites in an existing cluster, you can specify custom registry by passing REGISTRY(eg docker.io).

Step `1` and `2` can be skipped by passing `E2E_SKIP_BUILD=1` to this directive, also, you can customize the
running concurrency of e2e test suites by passing `E2E_CONCURRENCY=X` where `X` is the desired number of cases running in parallel.
running concurrency of e2e test suites by passing `E2E_NODES=X` where `X` is the desired number of cases running in parallel.

You can run specific test cases by passing the environment variable `E2E_FOCUS=suite-<suite name>`, where `<suite name>` can be found under `test/e2e` directory.
For example, `E2E_FOCUS=suite-plugins* make e2e-test` will only run test cases in `test/e2e/suite-plugins` directory.
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ package e2e

import (
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-annotations"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-chaos"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-config"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-endpoints"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-chore"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-features"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-gateway"
_ "github.com/apache/apisix-ingress-controller/test/e2e/suite-ingress/suite-ingress-features"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/scaffold/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
tcpSocket:
port: 2379
timeoutSeconds: 2
image: "localhost:5000/bitnami/etcd:3.4.14-debian-10-r0"
image: "localhost:5000/bitnami/etcd:dev"
imagePullPolicy: IfNotPresent
name: etcd-deployment-e2e-test
ports:
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/scaffold/httpbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spec:
tcpSocket:
port: 80
timeoutSeconds: 2
image: "localhost:5000/kennethreitz/httpbin"
image: "localhost:5000/kennethreitz/httpbin:dev"
imagePullPolicy: IfNotPresent
name: httpbin-deployment-e2e-test
ports:
Expand Down
Loading

0 comments on commit 628abb9

Please sign in to comment.