Skip to content

Commit 17f63e8

Browse files
authored
Docerize unit tests (#472)
* Docerize unit tests * Improve unit tests
1 parent 19cbd8d commit 17f63e8

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

Dockerfile.unittest

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.12.9-alpine AS downloader
2+
3+
# git is required by 'go mod'
4+
RUN apk add git
5+
6+
WORKDIR /app
7+
8+
COPY go.mod .
9+
COPY go.sum .
10+
# It is done only once unless go.mod has been changed
11+
RUN go mod download
12+
13+
FROM downloader
14+
15+
COPY pkg /app/pkg
16+
COPY dashboard /app/dashboard
17+
18+
ARG VERBOSE
19+
RUN CGO_ENABLED=0 go test ${VERBOSE} \
20+
./pkg/apis/... \
21+
./pkg/backup/... \
22+
./pkg/deployment/... \
23+
./pkg/storage/... \
24+
./pkg/util/...

Makefile

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ ifeq ($(LONG), 1)
109109
TESTLENGTHOPTIONS :=
110110
TESTTIMEOUT := 300m
111111
endif
112-
ifdef VERBOSE
113-
TESTVERBOSEOPTIONS := -v
114-
endif
115112

116113
SOURCES := $(shell find $(SRCDIR) -name '*.go' -not -path './test/*')
117114
DASHBOARDSOURCES := $(shell find $(DASHBOARDDIR)/src -name '*.js' -not -path './test/*') $(DASHBOARDDIR)/package.json
@@ -294,18 +291,11 @@ manifests: helm manifests-crd manifests-operator manifests-test chart-crd chart-
294291

295292
.PHONY: run-unit-tests
296293
run-unit-tests: $(SOURCES)
297-
go test $(TESTVERBOSEOPTIONS) \
298-
$(REPOPATH)/pkg/apis/backup/v1alpha \
299-
$(REPOPATH)/pkg/apis/deployment/v1alpha \
300-
$(REPOPATH)/pkg/apis/replication/v1alpha \
301-
$(REPOPATH)/pkg/apis/storage/v1alpha \
302-
$(REPOPATH)/pkg/deployment/... \
303-
$(REPOPATH)/pkg/storage \
304-
$(REPOPATH)/pkg/util/k8sutil \
305-
$(REPOPATH)/pkg/util/k8sutil/test \
306-
$(REPOPATH)/pkg/util/probe \
307-
$(REPOPATH)/pkg/util/validation \
308-
$(REPOPATH)/pkg/backup/...
294+
ifdef VERBOSE
295+
docker build --build-arg VERBOSE=-v -f Dockerfile.unittest .
296+
else
297+
docker build -f Dockerfile.unittest .
298+
endif
309299

310300
$(TESTBIN): $(GOBUILDDIR) $(SOURCES)
311301
@mkdir -p $(BINDIR)

0 commit comments

Comments
 (0)