test: Add cleanup target that removes dangling test containers

This commit is contained in:
Anton Ovchinnikov
2025-05-25 19:46:13 +02:00
parent ae04dea808
commit 51f7ebf3bf
2 changed files with 20 additions and 1 deletions
+19
View File
@@ -64,7 +64,26 @@ ucind-multiarch-image-push:
.PHONY: test
test:
ifeq ($(TEST_NAME),)
go test -v ./...
else
go test -v -run ^$(TEST_NAME)$$ ./...
endif
.PHONY: test-clean
test-clean:
@CONTAINERS=$$(docker ps --filter "name=ucind-test" -q); \
if [ -n "$$CONTAINERS" ]; then \
echo "Killing containers..."; \
docker kill $$CONTAINERS; \
fi; \
CONTAINERS_STOPPED=$$(docker ps -a --filter "name=ucind-test" -q); \
if [ -n "$$CONTAINERS_STOPPED" ]; then \
echo "Removing stopped containers..."; \
docker rm $$CONTAINERS_STOPPED; \
else \
echo "Nothing to clean."; \
fi
.PHONY: vet
vet:
+1 -1
View File
@@ -72,7 +72,7 @@ func (p *Provisioner) CreateCluster(ctx context.Context, name string, opts Creat
ManagedLabel: "",
},
}
// Create a Docker network with the same as the cluster name.
// Create a Docker network with the same name as the cluster name.
if _, err = p.dockerCli.NetworkCreate(ctx, name, netOpts); err != nil {
return c, fmt.Errorf("create Docker network '%s': %w", name, err)
}