Skip to content

Commit

Permalink
test/workflow: Update make test commands and related workflows (#657)
Browse files Browse the repository at this point in the history
* update make test commands and workflows

* add TEST_ARGS to unit and integration test commands

* roll back boto3 version for test report upload
  • Loading branch information
ykim-akamai authored Jan 28, 2025
1 parent a8748fc commit 7d14d5c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
python-version: '3.x'

- name: Install Python deps
run: pip3 install requests wheel boto3
run: pip3 install requests wheel boto3==1.35.99

- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly_smoke_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Run smoke tests
id: smoke_tests
run: |
make smoketest
make test-smoke
env:
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-cross-repo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
- name: run tests
run: |
make int-test
make test-int
env:
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ PACKAGES := $(shell go list ./... | grep -v integration)

SKIP_LINT ?= 0

.PHONY: build vet test refresh-fixtures clean clean-cov clean-fixtures lint run_fixtures sanitize fixtures godoc testint testunit testcov tidy
.PHONY: build vet test refresh-fixtures clean clean-cov clean-fixtures lint run_fixtures sanitize fixtures godoc test-int test-unit test-smoke testcov tidy

test: build lint testunit testint
test: build lint test-unit test-int

citest: lint test

testunit:
go test -v $(PACKAGES) $(ARGS)
cd test && make testunit
test-unit:
go test -v $(PACKAGES) $(TEST_ARGS)
cd test && make test-unit $(TEST_ARGS)

testint:
cd test && make testint
test-int:
cd test && make test-int $(TEST_ARGS)

testcov-func:
@go test -v -coverprofile="coverage.txt" . > /dev/null 2>&1
Expand All @@ -39,8 +39,8 @@ testcov-html:
@go test -v -coverprofile="coverage.txt" . > /dev/null 2>&1
@go tool cover -html coverage.txt

smoketest:
cd test && make smoketest
test-smoke:
cd test && make test-smoke

build: vet lint
go build ./...
Expand Down Expand Up @@ -77,7 +77,7 @@ run_fixtures:
LINODE_API_VERSION="v4beta" \
LINODE_URL="$(LINODE_URL)" \
GO111MODULE="on" \
go test --tags $(TEST_TAGS) -timeout=$(TEST_TIMEOUT) -v $(ARGS)
go test --tags $(TEST_TAGS) -timeout=$(TEST_TIMEOUT) -v $(TEST_ARGS)

sanitize:
@echo "* Sanitizing fixtures"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ When performing a `POST` or `PUT` request, multiple field related errors will be

## Tests

Run `make testunit` to run the unit tests.
Run `make test-unit` to run the unit tests.

Run `make testint` to run the integration tests. The integration tests use fixtures.
Run `make test-int` to run the integration tests. The integration tests use fixtures.

To update the test fixtures, run `make fixtures`. This will record the API responses into the `fixtures/` directory.
Be careful about committing any sensitive account details. An attempt has been made to sanitize IP addresses and
dates, but no automated sanitization will be performed against `fixtures/*Account*.yaml`, for example.

To prevent disrupting unaffected fixtures, target fixture generation like so: `make ARGS="-run TestListVolumes" fixtures`.
To prevent disrupting unaffected fixtures, target fixture generation like so: `make TEST_ARGS="-run TestListVolumes" fixtures`.

## Discussion / Help

Expand Down
21 changes: 8 additions & 13 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
.PHONY: testint
.PHONY: test-int

testint:
test-int:
@LINODE_FIXTURE_MODE="play" \
LINODE_TOKEN="awesometokenawesometokenawesometoken" \
LINODE_API_VERSION="v4beta" \
GO111MODULE="on" \
go test -v ./integration $(ARGS)
go test -v ./integration $(TEST_ARGS)

.PHONY: testunit
.PHONY: test-unit

testunit:
go test -v ./unit/...
test-unit:
go test -v ./unit/... $(TEST_ARGS)

.PHONY: smoketest
.PHONY: test-smoke

smoketest:
test-smoke:
@LINODE_FIXTURE_MODE="record" \
LINODE_TOKEN=$(LINODE_TOKEN) \
LINODE_API_VERSION="v4beta" \
LINODE_URL="$(LINODE_URL)" \
GO111MODULE="on" \
go test -v -run smoke ./integration/...


.PHONY: unit-test
unit-test:
go test -v ./unit $(ARGS)

0 comments on commit 7d14d5c

Please sign in to comment.