Skip to content

Commit

Permalink
Add Integration Test for REST API (#141)
Browse files Browse the repository at this point in the history
* integration

* added testcontainers

* fixed make deps

* docker file

* integration

* added testcontainers

* fixed make deps

* docker file

* integration tests

* added testcontainers-go to test

* added integration test to make file & ran  make deps

* Clean up test

* add tests for nginx details & moved docker files

* add tests for nginx details & moved docker files

* move files, add integration test to make format & run make format

* remove sleep, add invalid values

* Add retry condition

* integration

* added testcontainers

* fixed make deps

* docker file

* integration

* added testcontainers

* fixed make deps

* docker file

* integration tests

* added testcontainers-go to test

* added integration test to make file & ran  make deps

* Clean up test

* add tests for nginx details & moved docker files

* add tests for nginx details & moved docker files

* move files, add integration test to make format & run make format

* remove sleep, add invalid values

* Add retry condition

* move docker and conf files

* add integration test to pipeline

* remove print

* improve dockerfile

* changes to makefile

* make deps

* add nfpm to integration test

* make deps

* make deps

* make deps issues

* deps error

* make file changes for swagger

* passing test

* downgrade godog to v0.11.0

* ignore vendor folder in PR diff

* ignore vendor folder in PR diff

* remove previous changes

Co-authored-by: o.omahony <o.omahony@f5.com>
  • Loading branch information
aphralG and o.omahony committed Jan 24, 2023
1 parent 9c14457 commit 13a9088
Show file tree
Hide file tree
Showing 6,828 changed files with 1,603,025 additions and 11,850 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitattributes
@@ -1 +1,2 @@
**/vendor/* -diff

14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -64,6 +64,20 @@ jobs:
- name: Run Component Tests
run: make component-test

integration-test:
name: Integration Tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run Integration Tests
run: |
sudo apt-get update
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
make integration-test
performance-test:
name: Performance Tests
if: "!github.event.pull_request.head.repo.fork"
Expand Down
20 changes: 14 additions & 6 deletions Makefile
Expand Up @@ -34,6 +34,7 @@ PACKAGE_PREFIX := nginx-agent
PACKAGES_REPO := "pkgs.nginx.com"
UNAME_M = $(shell uname -m)
TEST_BUILD_DIR := build/test
PACKAGE_NAME := ${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}
# override this value if you want to change the architecture. GOOS options here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
LOCAL_ARCH := amd64

Expand Down Expand Up @@ -68,7 +69,8 @@ build: ## Build agent executable
GOWORK=off CGO_ENABLED=0 go build -ldflags=${LDFLAGS} -o ./build/nginx-agent

deps: ## Update dependencies in vendor folders
cd sdk && make generate && go mod tidy && go mod vendor
cd sdk && go mod tidy && go mod vendor && make generate && go mod tidy && go mod vendor
cd test/integration && go mod tidy && go mod vendor
cd test/performance && go mod tidy && go mod vendor
go mod tidy && go mod vendor && go mod download && go work sync
make generate-swagger
Expand All @@ -79,18 +81,21 @@ lint: ## Run linter
cd sdk && make lint

format: ## Format code
go fmt ./... && cd sdk && go fmt ./... && cd ../test/performance && go fmt ./...
go fmt ./... && cd sdk && go fmt ./... && cd ../test/performance && go fmt ./... && cd ../../test/integration && go fmt ./...
buf format -w ./sdk/proto/

install-tools: ## Install dependencies in tools.go
@echo "Getting Tools"
@grep _ ./scripts/tools.go | awk '{print $$2}' | xargs -tI % go get %
@echo "Installing Tools"
@grep _ ./scripts/tools.go | awk '{print $$2}' | xargs -tI % go install %

generate-swagger: ## Generates swagger.json from source code
swagger generate spec -o ./docs/swagger.json --scan-models
go run github.com/go-swagger/go-swagger/cmd/swagger generate spec -o ./docs/swagger.json --scan-models

launch-swagger-ui: generate-swagger ## Launch Swagger UI
swagger serve ./docs/swagger.json -F=swagger --port=8082 --no-open

go run github.com/go-swagger/go-swagger/cmd/swagger serve ./docs/swagger.json -F=swagger --port=8082 --no-open
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Local Packaging #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down Expand Up @@ -162,6 +167,9 @@ test-component-run: ## Run component tests
performance-test: ## Run performance tests
docker run -v ${PWD}:/home/nginx/ --rm nginx-agent-benchmark:1.0.0

integration-test: local-deb-package
PACKAGE=${PACKAGE_NAME} go test ./test/integration/api

test-bench: ## Run benchmark tests
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 1 -bench=. -benchmem user_workflow_test.go
Expand Down Expand Up @@ -213,7 +221,7 @@ certs: ## Generate TLS certificates
build-docker: # Build agent docker image for NGINX Plus, need nginx-repo.crt and nginx-repo.key in build directory
@echo Building Docker; \
DOCKER_BUILDKIT=1 docker build -t ${DOCKER_TAG} . \
--no-cache -f ./scripts/docker/${OS_RELEASE}/Dockerfile \
--no-cache -f ./scripts/docker/nginx-plus/${OS_RELEASE}/Dockerfile \
--secret id=nginx-crt,src=build/nginx-repo.crt \
--secret id=nginx-key,src=build/nginx-repo.key \
--build-arg AGENT_CONF="$$(cat nginx-agent.conf)" \
Expand Down
73 changes: 57 additions & 16 deletions go.mod
Expand Up @@ -4,8 +4,8 @@ go 1.19

require (
github.com/alvaroloes/enumer v1.1.2
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/fsnotify/fsnotify v1.5.4
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/fsnotify/fsnotify v1.6.0
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
Expand All @@ -24,7 +24,7 @@ require (
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.12.0
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.1
github.com/trivago/grok v1.0.0
github.com/vardius/message-bus v1.1.5
Expand All @@ -38,19 +38,28 @@ require (
)

require (
github.com/bufbuild/buf v1.11.0
github.com/bufbuild/buf v1.12.0
github.com/go-resty/resty/v2 v2.7.0
github.com/go-swagger/go-swagger v0.30.4
github.com/nginx/agent/sdk/v2 v2.0.0-00010101000000-000000000000
github.com/prometheus/client_golang v1.13.0
github.com/pseudomuto/protoc-gen-doc v1.5.1
github.com/rs/cors v1.8.2
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig v2.15.0+incompatible // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/aokoli/goutils v1.0.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bufbuild/connect-go v1.4.0 // indirect
github.com/bufbuild/connect-go v1.4.1 // indirect
github.com/bufbuild/protocompile v0.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
Expand All @@ -61,32 +70,56 @@ require (
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/envoyproxy/protoc-gen-validate v0.3.0-java // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-chi/chi/v5 v5.0.8 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.25.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid v4.3.1+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-containerregistry v0.12.1 // indirect
github.com/google/pprof v0.0.0-20221203041831-ce31453925ec // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jdxcode/netrc v0.0.0-20221124155335-4616370d1a84 // indirect
github.com/jessevdk/go-flags v1.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.13 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20220517141722-cf486979b281 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nginxinc/nginx-go-crossplane v0.4.1 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/pascaldekloe/name v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.7.0 // indirect
Expand All @@ -95,32 +128,40 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/pseudomuto/protokit v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/toqueteos/webbrowser v1.2.0 // indirect
github.com/trivago/tgo v1.0.7 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.mongodb.org/mongo-driver v1.11.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.11.2 // indirect
go.opentelemetry.io/otel/metric v0.34.0 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
golang.org/x/tools v0.4.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/tools v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gotest.tools/v3 v3.4.0 // indirect
)

replace github.com/nginx/agent/sdk/v2 => ./sdk

0 comments on commit 13a9088

Please sign in to comment.