Skip to content

Commit fb5182d

Browse files
authored
Merge pull request #30 from turkenh/e2e-with-uptest
Add e2e testing with uptest
2 parents 3faebab + 1f590e9 commit fb5182d

File tree

8 files changed

+111
-8
lines changed

8 files changed

+111
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212

1313
jobs:
1414
detect-noop:
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-22.04
1616
outputs:
1717
noop: ${{ steps.noop.outputs.should_skip }}
1818
steps:
@@ -25,7 +25,7 @@ jobs:
2525
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
2626

2727
publish-artifacts:
28-
runs-on: ubuntu-20.04
28+
runs-on: ubuntu-22.04
2929
needs: detect-noop
3030
if: needs.detect-noop.outputs.noop != 'true'
3131

.github/workflows/e2e.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: End to End Test
2+
3+
on:
4+
workflow_dispatch: {}
5+
pull_request:
6+
types: [opened]
7+
issue_comment:
8+
types: [created]
9+
10+
env:
11+
UPTEST_GCP_PROJECT: ${{ secrets.UPTEST_GCP_PROJECT }}
12+
UPTEST_GCP_CREDS: ${{ secrets.UPTEST_GCP_CREDS }}
13+
14+
jobs:
15+
detect-noop:
16+
runs-on: ubuntu-22.04
17+
outputs:
18+
noop: ${{ steps.noop.outputs.should_skip }}
19+
steps:
20+
- name: Detect No-op Changes
21+
id: noop
22+
uses: fkirc/[email protected]
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
paths_ignore: '["**.md", "**.png", "**.jpg"]'
26+
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
27+
28+
e2e:
29+
runs-on: ubuntu-22.04
30+
needs: detect-noop
31+
if: needs.detect-noop.outputs.noop != 'true'
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
with:
37+
submodules: true
38+
39+
- name: Fetch History
40+
run: git fetch --prune --unshallow
41+
42+
- uses: khan/[email protected]
43+
if: ${{ github.event_name != 'workflow_dispatch' }}
44+
id: check
45+
with:
46+
trigger: '/test-e2e'
47+
reaction: rocket
48+
env:
49+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
50+
51+
- name: End to end
52+
run: make e2e
53+
env:
54+
UPTEST_GCP_PROJECT: ${{ secrets.UPTEST_GCP_PROJECT }}
55+
UPTEST_GCP_CREDS: ${{ secrets.UPTEST_GCP_CREDS }}

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PLATFORMS ?= linux_amd64
1111
# ====================================================================================
1212
# Setup Kubernetes tools
1313

14-
UP_VERSION = v0.13.0
14+
UP_VERSION = v0.14.0
1515
UP_CHANNEL = stable
1616

1717
-include build/makelib/k8s_tools.mk
@@ -26,6 +26,7 @@ XPKGS = $(PROJECT_NAME)
2626

2727
CROSSPLANE_NAMESPACE = upbound-system
2828
-include build/makelib/local.xpkg.mk
29+
-include build/makelib/controlplane.mk
2930

3031
# ====================================================================================
3132
# Targets
@@ -48,4 +49,13 @@ submodules:
4849

4950
# We must ensure up is installed in tool cache prior to build as including the k8s_tools machinery prior to the xpkg
5051
# machinery sets UP to point to tool cache.
51-
build.init: $(UP)
52+
build.init: $(UP)
53+
54+
# ====================================================================================
55+
# End to End Testing
56+
uptest: build $(UPTEST) $(KUBECTL) $(KUTTL) local.xpkg.deploy.configuration.$(PROJECT_NAME)
57+
@$(INFO) running automated tests
58+
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/cluster-claim.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
59+
@$(OK) running automated tests
60+
61+
e2e: controlplane.up uptest

examples/cluster-claim.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ apiVersion: gcp.platformref.upbound.io/v1alpha1
22
kind: Cluster
33
metadata:
44
name: platform-ref-gcp-cluster
5+
namespace: default
6+
annotations:
7+
uptest.upbound.io/post-assert-hook: testhooks/delete-release.sh
58
spec:
69
compositionSelector:
710
matchLabels:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -aeuo pipefail
3+
4+
# Delete the release before deleting the cluster not to orphan the release object
5+
# Note(turkenh): This is a workaround for the infamous dependency problem during deletion.
6+
${KUBECTL} delete release --all

package/crossplane.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ metadata:
3535
customize to meet the exact needs of your organization!
3636
spec:
3737
crossplane:
38-
version: ">=v1.7.0-0"
38+
version: ">=v1.9.0-0"
3939
dependsOn:
4040
- provider: xpkg.upbound.io/upbound/provider-gcp
4141
version: ">=v0.13.0"
42-
- provider: xpkg.upbound.io/crossplane/provider-helm
43-
version: ">=v0.11.1"
42+
- provider: xpkg.upbound.io/crossplane-contrib/provider-helm
43+
version: ">=v0.12.0"

test/setup.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -aeuo pipefail
3+
4+
UPTEST_GCP_PROJECT=${UPTEST_GCP_PROJECT:-crossplane-playground}
5+
6+
echo "Running setup.sh"
7+
echo "Waiting until configuration package is healthy/installed..."
8+
${KUBECTL} wait configuration.pkg platform-ref-gcp --for=condition=Healthy --timeout 5m
9+
${KUBECTL} wait configuration.pkg platform-ref-gcp --for=condition=Installed --timeout 5m
10+
11+
echo "Creating cloud credential secret"
12+
${KUBECTL} -n upbound-system create secret generic gcp-creds --from-literal=credentials="${UPTEST_GCP_CREDS}" \
13+
--dry-run=client -o yaml | ${KUBECTL} apply -f -
14+
15+
echo "Creating a default provider config"
16+
cat <<EOF | ${KUBECTL} apply -f -
17+
apiVersion: gcp.upbound.io/v1beta1
18+
kind: ProviderConfig
19+
metadata:
20+
name: default
21+
spec:
22+
credentials:
23+
secretRef:
24+
key: credentials
25+
name: gcp-creds
26+
namespace: upbound-system
27+
source: Secret
28+
projectID: ${UPTEST_GCP_PROJECT}
29+
EOF

0 commit comments

Comments
 (0)