diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 000000000..498d04834 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,5 @@ +FROM scratch + +ADD bin/arangodb_operator_test /usr/bin/ + +ENTRYPOINT [ "/usr/bin/arangodb_operator_test" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 15b8d4bd1..60c000fe3 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,13 @@ PULSAR := $(GOBUILDDIR)/bin/pulsar$(shell go env GOEXE) ifndef DOCKERNAMESPACE DOCKERNAMESPACE := arangodb endif -ifndef DOCKERFILE - DOCKERFILE := Dockerfile - #DOCKERFILE := Dockerfile.debug -endif +DOCKERFILE := Dockerfile +DOCKERTESTFILE := Dockerfile.test BINNAME := $(PROJECT) BIN := $(BINDIR)/$(BINNAME) +TESTBINNAME := $(PROJECT)_test +TESTBIN := $(BINDIR)/$(TESTBINNAME) RELEASE := $(GOBUILDDIR)/bin/release GHRELEASE := $(GOBUILDDIR)/bin/github-release @@ -124,6 +124,29 @@ $(BIN): $(GOBUILDDIR) $(SOURCES) docker: $(BIN) docker build -f $(DOCKERFILE) -t arangodb/arangodb-operator . +# Testing + +$(TESTBIN): $(GOBUILDDIR) $(SOURCES) + @mkdir -p $(BINDIR) + @docker run \ + --rm \ + -v $(SRCDIR):/usr/code \ + -e GOPATH=/usr/code/.gobuild \ + -e GOOS=linux \ + -e GOARCH=amd64 \ + -e CGO_ENABLED=0 \ + -w /usr/code/ \ + golang:$(GOVERSION) \ + go test -c -installsuffix cgo -ldflags "-X main.projectVersion=$(VERSION) -X main.projectBuild=$(COMMIT)" -o /usr/code/bin/$(TESTBINNAME) $(REPOPATH)/tests + +docker-test: $(TESTBIN) + docker build --quiet -f $(DOCKERTESTFILE) -t arangodb/arangodb-operator-test . + +run-tests: docker-test + kubectl run arangodb-operator-test -i --rm --quiet --restart=Never --image=arangodb/arangodb-operator-test + +# Release building + docker-push: docker ifneq ($(DOCKERNAMESPACE), arangodb) docker tag arangodb/arangodb-operator $(DOCKERNAMESPACE)/arangodb-operator diff --git a/tests/single_test.go b/tests/single_test.go new file mode 100644 index 000000000..7e16a7300 --- /dev/null +++ b/tests/single_test.go @@ -0,0 +1,12 @@ +package tests + +import ( + "testing" + "time" +) + +func TestSimpleSingle(t *testing.T) { + time.Sleep(time.Second * 5) + t.Log("TODO") + t.Error("foo") +}