fix: allow 10 seconds to shutdown, fixing shutdown error (#204)

* Allow 15 seconds to shut down

v2.0.0 and above crashes with message "Error during shutdowncontext deadline exceeded" and exit code 1
upon SIGINT being received.

v1.2.1 seems to be unaffected.

* Add bats test

* Reduce to 10 seconds, define directly

Co-Authored-By: andytson-inviqa <andytson-inviqa@users.noreply.github.com>

* style: gofmt -s

* chore: bump golang to 1.17 and fix golangci

Co-authored-by: andytson-inviqa <andytson-inviqa@users.noreply.github.com>
Co-authored-by: Enrico Stahn <enrico.stahn@gmail.com>
This commit is contained in:
Kieren Evans 2022-02-09 00:45:36 +02:00 committed by GitHub
parent 98e0072b39
commit ea4a929fa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View file

@ -20,7 +20,7 @@ test-coverage-html: ## Create a code coverage report in HTML
go tool cover -html .cover/cover.out go tool cover -html .cover/cover.out
test-e2e: test-e2e:
bats tests/e2e.bats bats test/e2e.bats
lint: ## Run linters lint: ## Run linters
golangci-lint run golangci-lint run

View file

@ -200,7 +200,7 @@ brew install docker-compose bats-core kaos/shell/bats-assert kaos/shell/bats-sup
After the components are installed run the E2E tests: After the components are installed run the E2E tests:
```bash ```bash
make tests-e2e make test-e2e
``` ```
## Contributing ## Contributing

View file

@ -102,7 +102,7 @@ to quickly create a Cobra application.`,
<-c <-c
// Create a deadline to wait for. // Create a deadline to wait for.
var wait time.Duration wait := time.Second * 10
ctx, cancel := context.WithTimeout(context.Background(), wait) ctx, cancel := context.WithTimeout(context.Background(), wait)
defer cancel() defer cancel()
// Doesn't block if no connections, but will otherwise wait // Doesn't block if no connections, but will otherwise wait

View file

@ -32,3 +32,8 @@ teardown() {
assert_output --partial 'phpfpm_up{pool="www",scrape_uri="tcp://phpfpm2:9000/status"} 1' assert_output --partial 'phpfpm_up{pool="www",scrape_uri="tcp://phpfpm2:9000/status"} 1'
assert_output --partial 'phpfpm_up{pool="www",scrape_uri="tcp://phpfpm3:9000/status"} 1' assert_output --partial 'phpfpm_up{pool="www",scrape_uri="tcp://phpfpm3:9000/status"} 1'
} }
@test "Should exit cleanly" {
run docker-compose -f ./test/docker-compose-e2e.yml stop exporter
docker-compose -f ./test/docker-compose-e2e.yml ps exporter | grep -q "Exit 0"
}