-
Notifications
You must be signed in to change notification settings - Fork 2
229 lines (209 loc) · 10.5 KB
/
integration-tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Based on integration tests in prometheus-service
# https://github.com/keptn-contrib/prometheus-service/blob/master/.github/workflows/integration-tests.yaml
name: Integration Tests
on:
workflow_dispatch: # run integration tests only when triggered manually
# schedule:
# * is a special character in YAML, so you have to quote this string
# - cron: "0 3 * * 1-5" # run integration tests at 3 AM, monday to friday (1-5)
defaults:
run:
shell: bash
jobs:
integration_test:
name: "Integration Tests"
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
keptn-version: ["1.0.0"] # https://github.com/keptn/keptn/releases
splunk-version: ["0.2.0"] # chart version
env:
GO_VERSION: 1.17
GOPROXY: "https://proxy.golang.org"
GO111MODULE: "on"
BRANCH: ${{ github.head_ref || github.ref_name }}
ENABLE_E2E_TEST: true
JES_VERSION: "0.3.0"
JES_NAMESPACE: keptn-jes
GITEA_PROVISIONER_VERSION: "0.1.1"
GITEA_ADMIN_USERNAME: GiteaAdmin
GITEA_NAMESPACE: gitea
KUBECONFIG: "${{ github.workspace }}/.kube/config"
TEST_REPORT_FILENAME: test-report-${{ github.run_id }}-keptn-${{ matrix.keptn-version }}-splunk-${{ matrix.splunk-version }}.json
SPLUNK_HOST: $(hostname -I | awk '{print $1}')
SPLUNK_PORT: 8089
SPLUNK_USERNAME: admin
steps:
# Checkout code for the integrations tests in test/e2e
- name: Check out code.
uses: actions/[email protected]
- name: Setup Go
uses: actions/[email protected]
with:
go-version-file: "go.mod"
- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@latest
- name: Generate Gitea credentials
id: gitea_credentials
run: |
password=$(date +%s | sha256sum | base64 | head -c 32)
echo "::add-mask::$password"
echo "GITEA_ADMIN_PASSWORD=$password" >> "$GITHUB_OUTPUT"
- name: Generate splunk credentials
id: splunk_credentials
run: |
password=$(date +%s | sha256sum | base64 | head -c 32)
echo "::add-mask::$password"
echo "SPLUNK_PASSWORD=$password" >> "$GITHUB_OUTPUT"
# Prepare minikube + Keptn environment
- name: Install and start minikube
run: |
# wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
# wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
# echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee -a /etc/apt/sources.list.d/virtualbox.list
curl -LO https://storage.googleapis.com/minikube/releases/v1.24.0/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
/usr/local/bin/minikube start --cpus=2 --memory=5GB
minikube tunnel &> /dev/null &
echo "minikube ready!"
- name: Install Gitea
id: gitea
env:
GITEA_ADMIN_PASSWORD: ${{ steps.gitea_credentials.outputs.GITEA_ADMIN_PASSWORD }}
run: |
export GITEA_ENDPOINT="http://gitea-http.${GITEA_NAMESPACE}:3000"
helm repo add gitea-charts https://dl.gitea.io/charts/
helm repo update
helm install -n ${GITEA_NAMESPACE} gitea gitea-charts/gitea \
--create-namespace \
--set memcached.enabled=false \
--set postgresql.enabled=false \
--set gitea.config.database.DB_TYPE=sqlite3 \
--set gitea.admin.username=${GITEA_ADMIN_USERNAME} \
--set gitea.admin.password=${GITEA_ADMIN_PASSWORD} \
--set gitea.config.server.OFFLINE_MODE=true \
--set gitea.config.server.ROOT_URL=${GITEA_ENDPOINT}/ \
--wait
# Export Gitea connection details
echo "GITEA_ENDPOINT=${GITEA_ENDPOINT}" >> "$GITHUB_OUTPUT"
- name: Install gitea provisioner-service
env:
GITEA_ADMIN_PASSWORD: ${{ steps.gitea_credentials.outputs.GITEA_ADMIN_PASSWORD }}
GITEA_ENDPOINT: ${{ steps.gitea.outputs.GITEA_ENDPOINT }}
run: |
helm install keptn-gitea-provisioner-service \
https://github.com/keptn-sandbox/keptn-gitea-provisioner-service/releases/download/${GITEA_PROVISIONER_VERSION}/keptn-gitea-provisioner-service-${GITEA_PROVISIONER_VERSION}.tgz \
--set gitea.endpoint=${GITEA_ENDPOINT} \
--set gitea.admin.create=true \
--set gitea.admin.username=${GITEA_ADMIN_USERNAME} \
--set gitea.admin.password=${GITEA_ADMIN_PASSWORD} \
--wait
- name: Install Keptn
id: install_keptn
# This action is a patched version of github.com/keptn-sandbox/action-install-keptn
# which is being used here in the interest of time
# TODO: this change should go into github.com/keptn-sandbox/action-install-keptn
uses: vadasambar/[email protected]
timeout-minutes: 10
with:
KEPTN_VERSION: ${{ matrix.keptn-version }}
HELM_VALUES: |
wait: true
# Keptn 0.17 and newer
apiGatewayNginx:
type: LoadBalancer
features:
automaticProvisioning:
serviceURL: http://keptn-gitea-provisioner-service.default
# Keptn 0.16 compatibility
control-plane:
apiGatewayNginx:
type: LoadBalancer
features:
automaticProvisioningURL: http://keptn-gitea-provisioner-service.default
# For Keptn 0.18 (to make room for more CPU)
statisticsService:
enabled: false
webhookService:
enabled: false
# For Keptn 1.0.0 (to make room for more resources and reduce helm installation time)
approvalService:
enabled: false
KUBECONFIG: ${{ env.KUBECONFIG }}
HELM_TIMEOUT: "10m"
- name: Test connection to keptn
run: |
curl -X GET "${{ steps.install_keptn.outputs.KEPTN_API_URL }}/v1/metadata" -H "accept: application/json" -H "x-token: ${{ steps.install_keptn.outputs.KEPTN_API_TOKEN }}"
- name: Create splunk secret
env:
SPLUNK_PASSWORD: ${{ steps.splunk_credentials.outputs.SPLUNK_PASSWORD }}
run: |
kubectl -n keptn create secret generic splunk-sli-provider-secret --from-literal=SP_HOST=${{ env.SPLUNK_HOST }} --from-literal=SP_PORT=${{ ENV.SPLUNK_PORT }} --from-literal=SP_USERNAME=${{ env.SPLUNK_USERNAME }} --from-literal=SP_PASSWORD=$SPLUNK_PASSWORD -o yaml
- name: Install splunk-sli-provider
env:
SPLUNK_PASSWORD: ${{ steps.splunk_credentials.outputs.SPLUNK_PASSWORD }}
run: |
tar -czvf splunk-sli-provider.tgz chart/
helm upgrade --install -n keptn --create-namespace splunk-sli-provider \
splunk-sli-provider.tgz \
--set splunkservice.existingSecret=splunk-sli-provider-secret
kubectl -n keptn get deployment splunk-sli-provider -o wide
- name: Install splunk enterprise with docker
env:
SPLUNK_PASSWORD: ${{ steps.splunk_credentials.outputs.SPLUNK_PASSWORD }}
run: |
docker pull splunk/splunk:latest
docker run -d -p 8089:${{ env.SPLUNK_PORT }} -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_PASSWORD=$SPLUNK_PASSWORD" --name splunk-entreprise splunk/splunk:latest
# Install job executor from downloaded helm chart
- name: Install Job-executor-service
env:
KEPTN_API_PROTOCOL: http
KEPTN_API_TOKEN: ${{ steps.install_keptn.outputs.KEPTN_API_TOKEN }}
KEPTN_ENDPOINT: ${{ steps.install_keptn.outputs.KEPTN_HTTP_ENDPOINT }}
TASK_SUBSCRIPTION: "sh.keptn.event.deployment.triggered\\,sh.keptn.event.test.triggered"
run: |
helm upgrade --install \
--create-namespace -n ${JES_NAMESPACE} \
job-executor-service \
"https://github.com/keptn-contrib/job-executor-service/releases/download/${JES_VERSION}/job-executor-service-${JES_VERSION}.tgz" \
--set remoteControlPlane.autoDetect.enabled="false" \
--set remoteControlPlane.topicSubscription=${TASK_SUBSCRIPTION} \
--set remoteControlPlane.api.token=${KEPTN_API_TOKEN} \
--set remoteControlPlane.api.hostname=${KEPTN_ENDPOINT} \
--set remoteControlPlane.api.protocol=${KEPTN_API_PROTOCOL} \
--wait
kubectl apply \
-f test/data/helm-serviceAccount.yaml \
-f test/data/helm-clusterRole.yaml \
-f test/data/helm-clusterRoleBinding.yaml
- name: Create splunk-hec secret
env:
SPLUNK_HEC_PORT: 8088
SPLUNK_PASSWORD: ${{ steps.splunk_credentials.outputs.SPLUNK_PASSWORD }}
run: |
kubectl -n keptn-jes create secret generic splunk-secret --from-literal=SPLUNK_HOST=${{ env.SPLUNK_HOST }} --from-literal=SPLUNK_HEC_PORT=$SPLUNK_HEC_PORT --from-literal=SPLUNK_USERNAME=${{ env.SPLUNK_USERNAME }} --from-literal=SPLUNK_PASSWORD=$SPLUNK_PASSWORD -o yaml
# If we failed any previous step we might have a problem and not reporting anything for the version
- name: Create pipeline failure report
if: failure()
run: |
echo "Failed to run integration tests!"
echo '{"Test": "TestGitHub Pipeline", "Action": "fail"}' >> $TEST_REPORT_FILENAME
- name: Run Integration tests
env:
KEPTN_ENDPOINT: ${{ steps.install_keptn.outputs.KEPTN_API_URL }}
KEPTN_API_TOKEN: ${{ steps.install_keptn.outputs.KEPTN_API_TOKEN }}
GITEA_ADMIN_PASSWORD: ${{ steps.gitea_credentials.outputs.GITEA_ADMIN_PASSWORD }}
GITEA_ENDPOINT: ${{ steps.gitea.outputs.GITEA_ENDPOINT }}
run: |
kubectl apply -f test/e2e/temporary-lb-service.yaml
export GITEA_ENDPOINT_TOKEN="http://$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}'):$(kubectl get svc temporary-lb-service-gitea -n $GITEA_NAMESPACE -o jsonpath='{.spec.ports[0].nodePort}')"
gotestsum --format testname --jsonfile $TEST_REPORT_FILENAME -- -timeout=120m ./test/e2e/...
# Upload the report files, so we can use them in later jobs
- name: Upload test report as an artifact
if: always()
uses: actions/upload-artifact@v2
with:
name: test-report
path: test-report-*.json