Unit tests: fix authentication to localstack (#2106)
This commit is contained in:
parent
c7014dba8f
commit
e63a3ab92b
4 changed files with 15 additions and 10 deletions
6
.github/workflows/go-tests.yml
vendored
6
.github/workflows/go-tests.yml
vendored
|
@ -27,8 +27,6 @@ env:
|
||||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||||
AWS_REGION: us-east-1
|
AWS_REGION: us-east-1
|
||||||
# and to override our endpoint in aws sdk
|
|
||||||
AWS_ENDPOINT_FORCE: http://localhost:4566
|
|
||||||
KINESIS_INITIALIZE_STREAMS: "stream-1-shard:1,stream-2-shards:2"
|
KINESIS_INITIALIZE_STREAMS: "stream-1-shard:1,stream-2-shards:2"
|
||||||
CROWDSEC_FEATURE_DISABLE_HTTP_RETRY_BACKOFF: true
|
CROWDSEC_FEATURE_DISABLE_HTTP_RETRY_BACKOFF: true
|
||||||
|
|
||||||
|
@ -142,9 +140,7 @@ jobs:
|
||||||
go install github.com/kyoh86/richgo@v0.3.10
|
go install github.com/kyoh86/richgo@v0.3.10
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
make build
|
make build
|
||||||
go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models \
|
make go-acc | richgo testfilter
|
||||||
| sed 's/ *coverage:.*of statements in.*//' \
|
|
||||||
| richgo testfilter
|
|
||||||
|
|
||||||
- name: Build and run tests (static)
|
- name: Build and run tests (static)
|
||||||
run: |
|
run: |
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -15,7 +15,7 @@
|
||||||
# Test binaries, built from *_test.go
|
# Test binaries, built from *_test.go
|
||||||
pkg/csplugin/tests/cs_plugin_test*
|
pkg/csplugin/tests/cs_plugin_test*
|
||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of go-acc
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
# Development artifacts, backups, etc
|
# Development artifacts, backups, etc
|
||||||
|
|
16
Makefile
16
Makefile
|
@ -106,12 +106,22 @@ testclean: bats-clean
|
||||||
@$(RM) pkg/cwhub/install $(WIN_IGNORE_ERR)
|
@$(RM) pkg/cwhub/install $(WIN_IGNORE_ERR)
|
||||||
@$(RM) pkg/types/example.txt $(WIN_IGNORE_ERR)
|
@$(RM) pkg/types/example.txt $(WIN_IGNORE_ERR)
|
||||||
|
|
||||||
.PHONY: test
|
export AWS_ENDPOINT_FORCE=http://localhost:4566
|
||||||
test: export AWS_ENDPOINT_FORCE=http://localhost:4566
|
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
|
||||||
test: goversion
|
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||||
|
|
||||||
|
testenv:
|
||||||
@echo 'NOTE: You need Docker, docker-compose and run "make localstack" in a separate shell ("make localstack-stop" to terminate it)'
|
@echo 'NOTE: You need Docker, docker-compose and run "make localstack" in a separate shell ("make localstack-stop" to terminate it)'
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: testenv goversion
|
||||||
$(GOTEST) $(LD_OPTS) ./...
|
$(GOTEST) $(LD_OPTS) ./...
|
||||||
|
|
||||||
|
.PHONY: go-acc
|
||||||
|
go-acc: testenv goversion
|
||||||
|
go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models -- $(LD_OPTS) | \
|
||||||
|
sed 's/ *coverage:.*of statements in.*//'
|
||||||
|
|
||||||
.PHONY: localstack
|
.PHONY: localstack
|
||||||
localstack:
|
localstack:
|
||||||
docker-compose -f test/localstack/docker-compose.yml up
|
docker-compose -f test/localstack/docker-compose.yml up
|
||||||
|
|
|
@ -22,7 +22,6 @@ services:
|
||||||
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
|
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
|
||||||
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
||||||
AWS_REGION: "us-east-1"
|
AWS_REGION: "us-east-1"
|
||||||
AWS_ENDPOINT_FORCE: "http://localhost:4566"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- "${TMPDIR:-/tmp}/localstack:/var/lib/localstack"
|
- "${TMPDIR:-/tmp}/localstack:/var/lib/localstack"
|
||||||
|
|
Loading…
Reference in a new issue