Skip to content

Commit 398dcb1

Browse files
committed
Add integration test workflow
1 parent e7a9357 commit 398dcb1

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: integration-test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
integration-test:
12+
name: Run Integration- Test
13+
runs-on: ubuntu-latest
14+
environment: Integration Test
15+
steps:
16+
- name: Configure AWS credentials
17+
uses: aws-actions/configure-aws-credentials@v1
18+
with:
19+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
20+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
21+
aws-region: us-west-2
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
- name: Set up Go
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: 1.17
28+
- name: Set up env
29+
run: source ~/.bashrc
30+
- name: Start clean
31+
run: make integration-cleanup
32+
- name: Set up cluster
33+
run: make integration-setup
34+
- name: Run tests
35+
run: make integration-run
36+
- name: Clean up clusters
37+
run: make integration-cleanup

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,21 @@ vet: ## Run go vet against code.
5555
go vet ./...
5656

5757
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
58-
test: manifests generate generate-mocks fmt vet ## Run tests.
58+
test: manifests generate generate-mocks fmt vet test-setup ## Run tests.
59+
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out -covermode=atomic
60+
61+
test-setup: # setup test environment
5962
mkdir -p ${ENVTEST_ASSETS_DIR}
6063
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
61-
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out -covermode=atomic
64+
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR)
6265

63-
integration-setup: ## Setup the integration test using kind clusters
66+
integration-setup: build kind test-setup ## Setup the integration test using kind clusters
6467
@./integration/scripts/setup-kind.sh
6568

6669
integration-run: ## Run the integration test controller
6770
@./integration/scripts/run-tests.sh
6871

69-
integration-cleanup: ## Cleanup integration test resources in Cloud Map and local kind cluster
72+
integration-cleanup: kind ## Cleanup integration test resources in Cloud Map and local kind cluster
7073
@./integration/scripts/cleanup-cloudmap.sh
7174
@./integration/scripts/cleanup-kind.sh
7275

@@ -126,6 +129,9 @@ MOCKGEN = $(shell pwd)/bin/mockgen
126129
mockgen: ## Download mockgen
127130
$(call go-get-tool,$(MOCKGEN),github.com/golang/mock/[email protected])
128131

132+
KIND = $(shell pwd)/bin/kind
133+
kind: ## Download kind
134+
$(call go-get-tool,$(KIND),sigs.k8s.io/[email protected])
129135

130136
# go-get-tool will 'go get' any package $2 and install it to $1.
131137
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

integration/scripts/cleanup-cloudmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
set -eo pipefail
66
source ./integration/scripts/common.sh
77

8-
go run ./integration/janitor/runner/main.go "$NAMESPACE"
8+
go run ./integration/janitor/runner/main.go "$NAMESPACE"

integration/scripts/cleanup-kind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
set -eo pipefail
66
source ./integration/scripts/common.sh
77

8-
$KIND_BIN delete cluster --name "$KIND_SHORT"
8+
$KIND_BIN delete cluster --name "$KIND_SHORT"

integration/scripts/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
KIND_BIN='kind'
3+
KIND_BIN='./bin/kind'
44
KUBECTL_BIN='./testbin/bin/kubectl'
55
LOGS='./integration/testlog'
66
CONFIGS='./integration/configs'
@@ -11,4 +11,4 @@ ENDPT_PORT=80
1111
KIND_SHORT='cloud-map-e2e'
1212
CLUSTER='kind-cloud-map-e2e'
1313
IMAGE='kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729'
14-
EXPECTED_ENDPOINT_COUNT=5
14+
EXPECTED_ENDPOINT_COUNT=5

integration/scripts/poll-endpoints.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ do
2121
continue
2222
fi
2323

24-
endpts=$(echo "$addresses" | tr -s " " "$addresses" | cut -f 3 -d " ")
24+
endpts=$(echo "$addresses" | tr -s " " | cut -f 3 -d " ")
2525

2626
endpt_count=$(echo "$endpts" | tr ',' '\n' | wc -l | xargs)
2727
done
2828

2929
echo "$endpts"
30-
exit 0
30+
exit 0

integration/scripts/run-tests.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ $KUBECTL_BIN apply -f "$CONFIGS/e2e-export.yaml"
1313
endpts=$(./integration/scripts/poll-endpoints.sh "$EXPECTED_ENDPOINT_COUNT")
1414

1515
mkdir -p "$LOGS"
16-
make
1716
./bin/manager &> "$LOGS/ctl.log" &
1817
CTL_PID=$!
1918

2019
go run $SCENARIOS/runner/main.go $NAMESPACE $SERVICE $ENDPT_PORT "$endpts"
2120

22-
kill $CTL_PID
21+
kill $CTL_PID

0 commit comments

Comments
 (0)