Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to makefile & update circleci to use make #179

Merged
merged 19 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
- run: e2e/setup/setup_kube_config_ci.sh
- run: docker run -d --expose=6379 --network=host redis
- run: docker run -d --expose=50051 --network=host gresearchdev/armada-server-dev:branch-${CIRCLE_BRANCH}-${CIRCLE_SHA1}
- run: docker run -d --network=host -v ~/.kube/config:/kube/config -e KUBECONFIG=/kube/config gresearchdev/armada-executor-dev:branch-${CIRCLE_BRANCH}-${CIRCLE_SHA1}
- run: docker run -d --network=host -v $(pwd)/.kube/config:/kube/config -e KUBECONFIG=/kube/config gresearchdev/armada-executor-dev:branch-${CIRCLE_BRANCH}-${CIRCLE_SHA1}
- restore_cache:
keys:
- machine-go-mod-v1-{{ checksum "go.sum" }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.vscode
.idea
.kube

# Binaries for programs and plugins
*.exe
Expand Down
2 changes: 2 additions & 0 deletions build/armada/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM alpine:3.10
COPY ./bin/linux/server /app/
COPY /config/armada/ /app/config/armada

RUN apk update && apk add --no-cache ca-certificates

WORKDIR /app

ENTRYPOINT ["./server"]
4 changes: 4 additions & 0 deletions e2e/setup/setup_cluster_ci.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if curl -s --fail http://127.0.0.1:10080/kubernetes-ready; then
exit 0
fi

docker run -d --name kube --privileged -p 8443:8443 -p 10080:10080 bsycorp/kind:v1.15.1
until curl -s --fail http://127.0.0.1:10080/kubernetes-ready; do
sleep 1;
Expand Down
6 changes: 3 additions & 3 deletions e2e/setup/setup_kube_config_ci.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mkdir ~/.kube
chmod 777 ~/.kube
wget -P ~/.kube http://localhost:10080/config
mkdir .kube || true
rm .kube/config || true
wget -P .kube http://localhost:10080/config
6 changes: 3 additions & 3 deletions internal/armada/repository/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/go-redis/redis"
"github.com/gogo/protobuf/proto"
"github.com/prometheus/common/log"
log "github.com/sirupsen/logrus"

"github.com/G-Research/k8s-batch/internal/armada/api"
"github.com/G-Research/k8s-batch/internal/common/util"
Expand Down Expand Up @@ -394,9 +394,9 @@ func (repo *RedisJobRepository) leaseJobs(clusterId string, jobs []jobIdentity)
if e != nil {
log.Error(e)
} else if value == alreadyAllocatedByDifferentCluster {
log.With("jobId", jobId).Info("Job Already allocated to different cluster")
log.WithField("jobId", jobId).Info("Job Already allocated to different cluster")
} else if value == jobCancelled {
log.With("jobId", jobId).Info("Trying to renew cancelled job")
log.WithField("jobId", jobId).Info("Trying to renew cancelled job")
} else {
leasedJobs = append(leasedJobs, jobId)
}
Expand Down
40 changes: 38 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# use bash for running:
export SHELL:=/bin/bash
export SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit
.ONESHELL:

gobuildlinux = GOOS=linux GARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w"
gobuild = go build

Expand All @@ -17,13 +22,44 @@ build: build-server build-executor build-armadactl build-load-tester

build-docker-server:
$(gobuildlinux) -o ./bin/linux/server cmd/armada/main.go
docker build -t armada -f ./build/armada/Dockerfile .
docker build $(dockerFlags) -t armada -f ./build/armada/Dockerfile .

build-docker-executor:
$(gobuildlinux) -o ./bin/linux/executor cmd/executor/main.go
docker build -t armada-executor -f ./build/executor/Dockerfile .
docker build $(dockerFlags) -t armada-executor -f ./build/executor/Dockerfile .

build-docker: build-docker-server build-docker-executor

build-ci: gobuild=$(gobuildlinux)
build-ci: build-docker build-armadactl build-load-tester

tests:
docker start test-redis || docker run -d --name test-redis -p=6379:6379 redis
function tearDown {
docker stop test-redis
docker rm test-redis
}
trap tearDown EXIT
go test -v ./internal/...

e2e-start-cluster:
./e2e/setup/setup_cluster_ci.sh
./e2e/setup/setup_kube_config_ci.sh

e2e-stop-cluster:
docker stop kube
docker rm kube

tests-e2e: build-docker e2e-start-cluster
docker run -d --name redis -p=6379:6379 redis
docker run -d --name server --network=host -p=50051:50051 armada
docker run -d --name executor --network=host -v $(shell pwd)/.kube/config:/kube/config -e KUBECONFIG=/kube/config armada-executor
function tearDown {
docker logs executor
docker logs server
docker stop executor server redis
docker rm executor server redis
}
trap tearDown EXIT
INTEGRATION_ENABLED=true go test ./e2e/test/... -count=1