Skip to content

Commit 8160eb0

Browse files
committed
Run e2e test using GitHub actions
Signed-off-by: Tamal Saha <[email protected]>
1 parent 4903508 commit 8160eb0

File tree

20 files changed

+335
-52
lines changed

20 files changed

+335
-52
lines changed

.github/workflows/go.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,61 @@ jobs:
2121

2222
- name: Build
2323
env:
24-
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
24+
REGISTRY: appscodeci
25+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
26+
USERNAME: 1gtm
2527
run: |
26-
docker login docker.pkg.github.com --username stashed --password ${DOCKER_TOKEN}
27-
make push REGISTRY=docker.pkg.github.com/stashed/stash
28+
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
29+
make push
30+
31+
- name: Create Kubernetes cluster
32+
id: kind
33+
uses: engineerd/[email protected]
34+
with:
35+
config: hack/kubernetes/kind.yaml
36+
37+
- name: Prepare cluster for testing
38+
id: local-path
39+
env:
40+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
41+
USERNAME: 1gtm
42+
REGISTRY_SECRET: regcred
43+
run: |
44+
export KUBECONFIG="$(kind get kubeconfig-path)"
45+
echo
46+
echo "waiting for nodes to be ready ..."
47+
kubectl wait --for=condition=Ready nodes --all --timeout=5m
48+
kubectl get nodes
49+
echo
50+
echo "installing local-path provisioner ..."
51+
kubectl delete storageclass --all
52+
kubectl apply -f https://github.com/rancher/local-path-provisioner/raw/v0.0.11/deploy/local-path-storage.yaml
53+
kubectl wait --for=condition=Ready pods -n local-path-storage --all --timeout=5m
54+
kubectl apply -f hack/kubernetes/storageclass/standard.yaml
55+
echo
56+
echo "create docker-registry secret"
57+
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
58+
59+
- name: Check out installer
60+
run: |
61+
cd ..
62+
git clone https://github.com/stashed/installer.git
63+
cd installer
64+
git checkout master
65+
66+
- name: Run e2e tests
67+
env:
68+
REGISTRY: appscodeci
69+
REGISTRY_SECRET: regcred
70+
TEST_CREDENTIALS: ${{ secrets.TEST_CREDENTIALS }}
71+
GOOGLE_SERVICE_ACCOUNT_JSON_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON_KEY }}
72+
run: |
73+
export KUBECONFIG="$(kind get kubeconfig-path)"
74+
echo "preparing test credentials"
75+
mkdir -p hack/config
76+
echo -n "$TEST_CREDENTIALS" > hack/config/.env
77+
echo >> hack/config/.env
78+
echo "GOOGLE_SERVICE_ACCOUNT_JSON_KEY=$(echo $GOOGLE_SERVICE_ACCOUNT_JSON_KEY)" >> hack/config/.env
79+
make install
80+
echo
81+
make e2e-tests

Makefile

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ TAG := $(VERSION)_$(OS)_$(ARCH)
7070
TAG_PROD := $(TAG)
7171
TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)
7272

73-
GO_VERSION ?= 1.12.7
73+
GO_VERSION ?= 1.12.10
7474
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)-stretch
7575

7676
OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
@@ -81,7 +81,10 @@ endif
8181
# Directories that we need created to build/test.
8282
BUILD_DIRS := bin/$(OS)_$(ARCH) \
8383
.go/bin/$(OS)_$(ARCH) \
84-
.go/cache
84+
.go/cache \
85+
$(HOME)/.credentials \
86+
$(HOME)/.kube \
87+
$(HOME)/.minikube
8588

8689
DOCKERFILE_PROD = Dockerfile.in
8790
DOCKERFILE_DBG = Dockerfile.dbg
@@ -182,7 +185,7 @@ $(OUTBIN): .go/$(OUTBIN).stamp
182185
"
183186
@if [ $(COMPRESS) = yes ] && [ $(OS) != darwin ]; then \
184187
echo "compressing $(OUTBIN)"; \
185-
docker run \
188+
@docker run \
186189
-i \
187190
--rm \
188191
-u $$(id -u):$$(id -g) \
@@ -255,7 +258,16 @@ unit-tests: $(BUILD_DIRS)
255258
./hack/test.sh $(SRC_PKGS) \
256259
"
257260

258-
STORAGE_CLASS ?= standard
261+
# - e2e-tests can hold both ginkgo args (as GINKGO_ARGS) and program/test args (as TEST_ARGS).
262+
# make e2e-tests TEST_ARGS="--selfhosted-operator=false --storageclass=standard" GINKGO_ARGS="--flakeAttempts=2"
263+
#
264+
# - Minimalist:
265+
# make e2e-tests
266+
#
267+
# NB: -t is used to catch ctrl-c interrupt from keyboard and -t will be problematic for CI.
268+
269+
GINKGO_ARGS ?=
270+
TEST_ARGS ?=
259271

260272
.PHONY: e2e-tests
261273
e2e-tests: $(BUILD_DIRS)
@@ -266,12 +278,15 @@ e2e-tests: $(BUILD_DIRS)
266278
-v $$(pwd):/src \
267279
-w /src \
268280
--net=host \
269-
-v $(HOME)/.kube:/.kube \
281+
-v $(HOME)/.kube:/.kube \
282+
-v $(HOME)/.minikube:$(HOME)/.minikube \
283+
-v $(HOME)/.credentials:$(HOME)/.credentials \
270284
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
271285
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
272286
-v $$(pwd)/.go/cache:/.cache \
273287
--env HTTP_PROXY=$(HTTP_PROXY) \
274288
--env HTTPS_PROXY=$(HTTPS_PROXY) \
289+
--env KUBECONFIG=$(KUBECONFIG) \
275290
--env-file=$$(pwd)/hack/config/.env \
276291
$(BUILD_IMAGE) \
277292
/bin/bash -c " \
@@ -280,10 +295,16 @@ e2e-tests: $(BUILD_DIRS)
280295
VERSION=$(VERSION) \
281296
DOCKER_REGISTRY=$(REGISTRY) \
282297
TAG=$(TAG) \
283-
STORAGE_CLASS=$(STORAGE_CLASS) \
298+
KUBECONFIG=$${KUBECONFIG#$(HOME)} \
299+
GINKGO_ARGS='$(GINKGO_ARGS)' \
300+
TEST_ARGS='$(TEST_ARGS) --image-tag=$(TAG)' \
284301
./hack/e2e.sh \
285302
"
286303

304+
.PHONY: e2e-parallel
305+
e2e-parallel:
306+
@$(MAKE) e2e-tests GINKGO_ARGS="-p -stream" --no-print-directory
307+
287308
ADDTL_LINTERS := goconst,gofmt,goimports,unparam
288309

289310
.PHONY: lint
@@ -311,7 +332,7 @@ $(BUILD_DIRS):
311332
.PHONY: install
312333
install:
313334
@cd ../installer; \
314-
APPSCODE_ENV=dev STASH_DOCKER_REGISTRY=$(REGISTRY) STASH_IMAGE_TAG=$(TAG) ./deploy/stash.sh
335+
APPSCODE_ENV=dev STASH_IMAGE_TAG=$(TAG) ./deploy/stash.sh --docker-registry=$(REGISTRY) --image-pull-secret=$(REGISTRY_SECRET)
315336

316337
.PHONY: uninstall
317338
uninstall:

apis/util.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ const (
2121
KindAppBinding = "AppBinding"
2222
KindDeploymentConfig = "DeploymentConfig"
2323
)
24+
25+
const (
26+
ResourcePluralDeployment = "deployments"
27+
ResourcePluralReplicaSet = "replicasets"
28+
ResourcePluralReplicationController = "replicationcontrollers"
29+
ResourcePluralStatefulSet = "statefulsets"
30+
ResourcePluralDaemonSet = "daemonsets"
31+
ResourcePluralPersistentVolumeClaim = "persistentvolumeclaims"
32+
ResourcePluralAppBinding = "appbindings"
33+
ResourcePluralDeploymentConfig = "deploymentconfigs"
34+
ResourcePluralSecret = "secrets"
35+
)

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.12
44

55
require (
66
github.com/PuerkitoBio/purell v1.1.1 // indirect
7-
github.com/appscode/go v0.0.0-20190808133642-1d4ef1f1c1e0
7+
github.com/appscode/go v0.0.0-20191006073906-e3d193d493fc
88
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2
99
github.com/cenkalti/backoff v2.1.1+incompatible
1010
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27
@@ -40,9 +40,9 @@ require (
4040
k8s.io/kube-openapi v0.0.0-20190502190224-411b2483e503
4141
k8s.io/kubernetes v1.14.0
4242
kmodules.xyz/client-go v0.0.0-20190808141354-bbb9e14f60ab
43-
kmodules.xyz/custom-resources v0.0.0-20190808144301-114abf10dfe2
44-
kmodules.xyz/objectstore-api v0.0.0-20190824212210-196174aa0fc0
45-
kmodules.xyz/offshoot-api v0.0.0-20190808152534-e3dc715f844b
43+
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045
44+
kmodules.xyz/objectstore-api v0.0.0-20191006080053-fc8b57fadcf0
45+
kmodules.xyz/offshoot-api v0.0.0-20190901210649-de049192326c
4646
kmodules.xyz/openshift v0.0.0-20190808144841-c8f9a927f1d1
4747
kmodules.xyz/webhook-runtime v0.0.0-20190808145328-4186c470d56b
4848
)

0 commit comments

Comments
 (0)