Bug: Localstack container doesn't stop
lanwen opened this issue · 1 comments
Describe the bug
gnomock.Stop(c)
does nothing
To Reproduce
I use https://github.com/onsi/ginkgo to write tests and faced an issue with active container even after stop was called
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
. "github.com/onsi/ginkgo"
"github.com/orlangure/gnomock"
"github.com/orlangure/gnomock/preset/localstack"
"log"
)
var lsc *gnomock.Container
var config *aws.Config
var _ = SynchronizedBeforeSuite(func() []byte {
lsp := localstack.Preset(localstack.WithServices(localstack.DynamoDB))
lsc, err := gnomock.Start(lsp, gnomock.WithLogWriter(log.Writer()))
if err != nil {
log.Fatalln(err)
}
endpoint := fmt.Sprintf("http://%s/", lsc.Address(localstack.APIPort))
return []byte(endpoint)
}, func(endpoint []byte) {
log.Println("Localstack runs on:", string(endpoint))
config = &aws.Config{
Region: aws.String("us-east-1"),
Endpoint: aws.String(string(endpoint)),
S3ForcePathStyle: aws.Bool(true),
Credentials: credentials.NewStaticCredentials("a", "b", "c"),
}
})
var _ = SynchronizedAfterSuite(func() {
// all nodes - nothing
}, func() {
log.Println("shutdown localstack")
err := gnomock.Stop(lsc)
if err != nil {
log.Println(err)
}
})
var _ = Describe("Status", func() {
It("should return something", func() {
})
})
Expected behavior
Container should be gone
Screenshots
If applicable, add screenshots to help explain your problem.
When I execute the test, it gives me the log:
=== RUN TestStatus
Running Suite: Receipt Suite
============================
Random Seed: 1608770795
Will run 1 of 1 specs
Waiting for all LocalStack services to be ready
2020-12-24 00:46:38,248 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2020-12-24 00:46:38,252 INFO supervisord started with pid 17
2020-12-24 00:46:39,256 INFO spawned: 'dashboard' with pid 23
2020-12-24 00:46:39,260 INFO spawned: 'infra' with pid 24
2020-12-24 00:46:39,266 INFO success: dashboard entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-12-24 00:46:39,266 INFO exited: dashboard (exit status 0; expected)
(. .venv/bin/activate; exec bin/localstack start --host)
Starting local dev environment. CTRL-C to quit.
LocalStack version: 0.12.2
2020-12-24 00:46:40,751 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Waiting for all LocalStack services to be ready
Starting edge router (https port 4566)...
Starting mock DynamoDB service on http port 4566 ...
Starting mock DynamoDB Streams service on http port 4566 ...
Starting mock Kinesis service on http port 4566 ...
[2020-12-24 00:46:45 +0000] [25] [INFO] Running on https://0.0.0.0:4566 (CTRL + C to quit)
2020-12-24T00:46:45:INFO:hypercorn.error: Running on https://0.0.0.0:4566 (CTRL + C to quit)
2020/12/24 01:46:50 Localstack runs on: http://127.0.0.1:55009/
•2020/12/24 01:46:50 shutdown localstack
Ran 1 of 1 Specs in 14.902 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestStatus (14.90s)
PASS
you can notice shutdown localstack
, which is right before the stop, however docker ps
gives me that container as an active one. Debug mode doesn't give any insights on what's happening during the stop.
System (please complete the following information):
- OS: MacOS
- Version v0.10.1
- Docker version
$ docker version
Client: Docker Engine - Community
Version: 20.10.0
API version: 1.41
Go version: go1.13.15
Git commit: 7287ab3
Built: Tue Dec 8 18:55:43 2020
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.0
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: eeddea2
Built: Tue Dec 8 18:58:04 2020
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: v1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Additional context
Add any other context about the problem here.
Since you aware about testcontainers-go, did you consider their ryuk container? That's a nice approach to kill stale containers no matter what.
p.s. Thanks for the lib, this presets api looks really nice
Sorry, my fault
var err error
lsp := localstack.Preset(localstack.WithServices(localstack.DynamoDB))
lsc, err = gnomock.Start(lsp, gnomock.WithLogWriter(log.Writer()))
fixes everything.
However would reopen the ryuk question separately