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

Add Integration Test for REST API #141

Merged
merged 60 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
00ec408
integration
Nov 29, 2022
68cd746
added testcontainers
aphralG Nov 30, 2022
52bedc1
fixed make deps
Nov 30, 2022
48c8719
docker file
aphralG Dec 5, 2022
c67326a
integration
Nov 29, 2022
5a9d7ee
added testcontainers
aphralG Nov 30, 2022
ead3123
fixed make deps
Nov 30, 2022
e13c85b
docker file
aphralG Dec 5, 2022
f36d7f5
Merge branch 'integration-test' of github.com:nginx/agent into integr…
aphralG Dec 7, 2022
df1c801
integration tests
aphralG Dec 7, 2022
80d7c5d
added testcontainers-go to test
aphralG Dec 7, 2022
df6c055
added integration test to make file & ran make deps
aphralG Dec 8, 2022
719a3f1
Clean up test
aphralG Dec 8, 2022
62db0a0
add tests for nginx details & moved docker files
aphralG Dec 8, 2022
750b6db
add tests for nginx details & moved docker files
aphralG Dec 8, 2022
02292b2
merge main
aphralG Dec 9, 2022
188dbde
move files, add integration test to make format & run make format
aphralG Dec 9, 2022
5be4096
Merge branch 'main' into integration-test
aphralG Dec 9, 2022
caebd97
remove sleep, add invalid values
aphralG Jan 4, 2023
ffa2833
Add retry condition
aphralG Jan 4, 2023
8503e4e
integration
Nov 29, 2022
172196f
added testcontainers
aphralG Nov 30, 2022
a83481e
fixed make deps
Nov 30, 2022
5b92826
docker file
aphralG Dec 5, 2022
a12d5e7
integration
Nov 29, 2022
7bdc919
added testcontainers
aphralG Nov 30, 2022
3b5eb0e
fixed make deps
Nov 30, 2022
ac0e927
docker file
aphralG Dec 5, 2022
9e9a891
integration tests
aphralG Dec 7, 2022
2f6aeaf
added testcontainers-go to test
aphralG Dec 7, 2022
0eb02ea
added integration test to make file & ran make deps
aphralG Dec 8, 2022
8e5b2c5
Clean up test
aphralG Dec 8, 2022
8470a09
add tests for nginx details & moved docker files
aphralG Dec 8, 2022
22256e2
add tests for nginx details & moved docker files
aphralG Dec 8, 2022
09bb521
move files, add integration test to make format & run make format
aphralG Dec 9, 2022
46655d3
remove sleep, add invalid values
aphralG Jan 4, 2023
f7cc42b
Add retry condition
aphralG Jan 4, 2023
4756a83
rebase main
aphralG Jan 5, 2023
3ce747e
Merge branch 'main' into integration-test
aphralG Jan 5, 2023
c4c87a4
Merge branch 'main' into integration-test
aphralG Jan 11, 2023
b3fb484
move docker and conf files
aphralG Jan 12, 2023
cbe31f5
Merge branch 'main' into integration-test
aphralG Jan 13, 2023
5c3360f
add integration test to pipeline
aphralG Jan 13, 2023
d1fe4a3
merge main
aphralG Jan 16, 2023
b030002
remove print
aphralG Jan 16, 2023
5bcce0e
improve dockerfile
aphralG Jan 20, 2023
135380c
changes to makefile
aphralG Jan 20, 2023
4f06b42
make deps
aphralG Jan 20, 2023
f65ce88
add nfpm to integration test
aphralG Jan 20, 2023
c49275e
merge main
aphralG Jan 20, 2023
201fcca
make deps
aphralG Jan 20, 2023
6eebfc6
make deps
aphralG Jan 20, 2023
8857aed
make deps issues
aphralG Jan 23, 2023
07e1d88
deps error
aphralG Jan 23, 2023
cc3fdb9
make file changes for swagger
aphralG Jan 23, 2023
9bb5b9f
passing test
Jan 23, 2023
064bd5e
downgrade godog to v0.11.0
Jan 24, 2023
2429b71
ignore vendor folder in PR diff
aphralG Jan 24, 2023
d192961
ignore vendor folder in PR diff
aphralG Jan 24, 2023
857bfa7
remove previous changes
aphralG Jan 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/vendor/* -diff

14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading