Skip to content

Commit

Permalink
chore: add integration test for UpdateStrategyInMemory
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Oct 10, 2023
1 parent 9426940 commit 4417c23
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/test_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ integration:
kind: 'v1.28.0'
kong-oss: '3.4'
kong-ee: '3.4'

kongintegration:
kong-oss: '3.4.1'
44 changes: 44 additions & 0 deletions .github/workflows/_kongintegration_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: kong integration tests

on:
workflow_call: {}

jobs:
kongintegration-tests:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: setup golang
uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: set kong version
run: |
echo "TEST_KONG_IMAGE=kong" >> $GITHUB_ENV
echo "TEST_KONG_TAG=$(cat .github/test_dependencies.yaml | yq -ojson -r '.kongintegration.kong-oss')" >> $GITHUB_ENV
- name: debug
run: env | grep TEST_KONG_

- name: run kong integration tests
run: make test.kongintegration
env:
GOTESTSUM_JUNITFILE: kongintegration-tests.xml

- name: collect test coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: "coverage.*.out"

- name: collect test report
if: always()
uses: actions/upload-artifact@v3
with:
name: tests-report
path: "*-tests.xml"
7 changes: 7 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ jobs:
uses: ./.github/workflows/_envtest_tests.yaml
secrets: inherit

kongintegration-tests:
needs:
- up-to-date
if: needs.up-to-date.outputs.status != 'true'
uses: ./.github/workflows/_kongintegration_tests.yaml
secrets: inherit

integration-tests:
needs:
- should-run-with-secrets
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,26 @@ test.expression_router: gotestsum
-parallel 1 \
./test/expressionrouter

.PHONY: test.kongintegration
test.kongintegration:
$(MAKE) _test.kongintegration GOTESTSUM_FORMAT=standard-verbose

.PHONY: test.kongintegration.pretty
test.kongintegration.pretty:
$(MAKE) _test.kongintegration GOTESTSUM_FORMAT=testname

.PHONY: _test.kongintegration
_test.kongintegration: gotestsum go-junit-report
GOTESTSUM_FORMAT=$(GOTESTSUM_FORMAT) \
$(GOTESTSUM) -- $(GOTESTFLAGS) \
-v \
-race \
-parallel $(NCPU) \
-coverpkg=$(PKG_LIST) \
-coverprofile=coverage.kongintegration.out \
./test/kongintegration | \
$(GOJUNIT) -iocopy -out $(JUNIT_REPORT) -parser gotest

# ------------------------------------------------------------------------------
# Operations - Local Deployment
# ------------------------------------------------------------------------------
Expand Down
34 changes: 34 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,40 @@ make test.integration.dbless GOTESTFLAGS="-count 1 -run TestUDPRouteEssentials"
[integration_test_suite]: https://github.com/Kong/kubernetes-ingress-controller/blob/61e06ee64ff913aa9952816121125fca7ed59ba5/test/integration/suite_test.go#L36
[manager_run]: https://github.com/Kong/kubernetes-ingress-controller/blob/5abc699aeee552945a76c82e3f7abb3e1b2fabf1/internal/cmd/rootcmd/run.go#L14-L22

### Kong integration tests

Tests located under `test/kongintegration/` allow verifying individual components of KIC
against a running Kong Gateway instance.

Every test in this package requires a Kong instance to be running, but do not require
a Kubernetes cluster nor a full KIC deployment. Each test is responsible for setting up
its own Kong instance and cleaning it up after the test is finished. [testcontainers-go]
is used for that purpose.

Examples of tests that could fit into this category are:

- Ensuring that a component responsible for configuring Kong Gateway works as expected
- Ensuring that configuration generated by a parser is accepted by Kong Gateway

#### How to run

The only requirement for running Kong integration tests is to have a docker daemon running.

All tests can be run using the following Makefile targets:

```shell
# Verbose output
make test.kongintegration

# Pretty output
make test.kongintegration.pretty
```

By default, `kong:latest` image is used for running Kong Gateway. This can be changed
by setting the `TEST_KONG_IMAGE` and `TEST_KONG_TAG` environment variables.

[testcontainers-go]: https://golang.testcontainers.org/

### End-to-End (E2E) tests

End to end tests in KIC are used to test features or use cases which rely on KIC
Expand Down
21 changes: 16 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.25.0
google.golang.org/api v0.146.0
k8s.io/api v0.28.2
k8s.io/apiextensions-apiserver v0.28.2
Expand All @@ -62,13 +63,23 @@ require (
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/hcsshim v0.11.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/bombsimon/logrusr/v3 v3.1.0 // indirect
github.com/containerd/containerd v1.7.6 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/gammazero/deque v0.2.0 // indirect
github.com/gammazero/workerpool v1.1.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/puzpuzpuz/xsync/v2 v2.4.1 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
go.uber.org/zap v1.26.0 // indirect
Expand All @@ -87,7 +98,7 @@ require (
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/adrg/strutil v0.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
Expand Down Expand Up @@ -145,29 +156,29 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.7 // indirect
github.com/shirou/gopsutil/v3 v3.23.8 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0
github.com/spf13/cast v1.5.1 // indirect
github.com/ssgelm/cookiejarparser v1.0.1 // indirect
github.com/tidwall/gjson v1.16.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand Down
Loading

0 comments on commit 4417c23

Please sign in to comment.