Skip to content

Commit

Permalink
Add testing suite cleanup to Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: David Son <[email protected]>
  • Loading branch information
sondavidb committed May 13, 2024
1 parent 2924990 commit 1142aec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ COMPRESSION_FBS_GO_FILES=$(wildcard $(COMPRESSION_FBS_DIR)/zinfo/*.go)
COMMIT=$(shell git rev-parse HEAD)
STARGZ_BINARY?=/usr/local/bin/containerd-stargz-grpc

INTEG_TEST_CONTAINERS=$(strip $(shell docker ps -aqf name="soci-integration-*"))
SOCI_BASE_IMAGE_IDS=$(shell docker image ls -qf reference="*:soci_test")

CMD=soci-snapshotter-grpc soci

CMD_BINARIES=$(addprefix $(OUTDIR)/,$(CMD))

GO_BENCHMARK_TESTS?=.

.PHONY: all build check flatc add-ltag install uninstall tidy vendor clean \
test integration release benchmarks build-benchmarks \
clean-integration test integration release benchmarks build-benchmarks \
benchmarks-perf-test benchmarks-comparison-test

all: build
Expand Down Expand Up @@ -89,12 +92,28 @@ uninstall:
@echo "$@"
@rm -f $(addprefix $(CMD_DESTDIR)/bin/,$(notdir $(CMD_BINARIES)))

clean:
clean: clean-integration
@echo "🧹 ... 🗑️"
@rm -rf $(OUTDIR)
@rm -rf $(CURDIR)/release/
@echo "All clean!"

clean-integration:
@echo "🧹 Cleaning leftover integration test artifacts..."

@echo "🐳 Cleaning Docker artifacts..."
ifneq ($(INTEG_TEST_CONTAINERS),)
docker stop $(INTEG_TEST_CONTAINERS)
docker rm $(INTEG_TEST_CONTAINERS)
docker network rm $(shell docker network ls -qf name="soci-integration-*")
docker image rm $(SOCI_BASE_IMAGE_IDS)
@echo "🐳 All SOCI containers, networks, and images cleaned!"
else
@echo "🐳 No leftover Docker artifacts."
endif

@echo "All testing artifacts cleaned!"

tidy:
@GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
@cd ./cmd ; GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
Expand Down
2 changes: 1 addition & 1 deletion integration/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func withPlainHTTP() registryConfigOpt {

func newRegistryConfig(opts ...registryConfigOpt) registryConfig {
rc := registryConfig{
host: fmt.Sprintf("registry-%s.test", xid.New().String()),
host: fmt.Sprintf("%s-registry-%s.test", compose.TestContainerBaseName, xid.New().String()),
user: "dummyuser",
pass: "dummypass",
}
Expand Down
7 changes: 6 additions & 1 deletion util/dockershell/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package compose
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"os/exec"
Expand All @@ -45,6 +46,10 @@ import (
"github.com/rs/xid"
)

const (
TestContainerBaseName string = "soci-integration"
)

// Supported checks if this pkg can run on the current system.
func Supported() error {
return exec.Command("docker", "--version").Run()
Expand Down Expand Up @@ -133,7 +138,7 @@ func Up(dockerComposeYaml string, opts ...Option) (*Compose, error) {
for _, o := range opts {
o(&cOpts)
}
tmpContext, err := os.MkdirTemp("", "compose"+xid.New().String())
tmpContext, err := os.MkdirTemp("", fmt.Sprintf("%s-compose-%s", TestContainerBaseName, xid.New().String()))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1142aec

Please sign in to comment.