Repository navigation
329 lines (323 loc) · 12.2 KB
/
Copy pathpredict-e2e.yml
File metadata and controls
329 lines (323 loc) · 12.2 KB
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: Predict E2E Testing
on:
workflow_call:
inputs:
orica_server_version:
type: string
default: latest
description: Version of the orica-server to test
orica_server_chart_version:
type: string
default: 1.0.0
description: Version of the orica-server chart to use
orica_predict_version:
type: string
default: latest
description: Version of the orica-redict to test
orica_predict_chart_version:
type: string
default: 1.0.0
description: Version of the orica-redict chart to use
storage_account_name:
type: string
default: oreprohubussa
description: Name of the storage account to use for the test
storage_container_name:
type: string
default: predict-test
description: Name of the storage account container to use for the test
docker_registry:
type: string
default: oreprohub
description: Name of the docker registry to use
docker_registry_username:
type: string
default: oreprohub
description: Username of the docker registry to use
azure_tenant_id:
type: string
description: Azure tenant id to use
azure_subscription_id:
type: string
description: Azure subscription id to use
azure_resource_group:
type: string
description: Azure resource group to use
secrets:
storage_account_key:
description: Key for the storage account
azure_client_id:
description: Azure client id
azure_client_secret:
description: Azure client secret
docker_registry_password:
description: Password of the docker registry to use
GH_PAT:
description: Token to pull other repos
env:
TF_BRANCH: preprod
ARM_CLIENT_ID: ${{ secrets.azure_client_id }}
ARM_CLIENT_SECRET: ${{ secrets.azure_client_secret }}
ARM_SUBSCRIPTION_ID: ${{ inputs.azure_subscription_id }}
ARM_RESOURCE_GROUP: ${{ inputs.azure_resource_group }}
ARM_TENANT_ID: ${{ inputs.azure_tenant_id }}
jobs:
setup-k8s-cluster:
name: Setup Kubernetes Cluster
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/infrastructure
ref: ${{ env.TF_BRANCH }}
token: ${{ secrets.GH_PAT }}
- uses: hashicorp/setup-terraform@v2
- name: Terraform Init
shell: bash
working-directory: deploy/predict_testing
run: terraform init
- name: Terraform Apply
working-directory: deploy/predict_testing
shell: bash
run: |
terraform apply \
-auto-approve \
-var="resource_group"="${{ env.ARM_RESOURCE_GROUP }}" \
-var="subscription_id"="${{ env.ARM_SUBSCRIPTION_ID }}" \
-var="kubeconfig_path"="kubeconfig"
- uses: actions/upload-artifact@v3
name: Store Kubeconfig in Artifacts
with:
name: kubeconfig
path: deploy/predict_testing/kubeconfig
- uses: actions/upload-artifact@v3
name: Store TF State in Artifacts
with:
name: terraform.tfstate
path: deploy/predict_testing/terraform.tfstate
setup-rmq:
name: Setup Rabbitmq on the K8S Cluster
needs:
- setup-k8s-cluster
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/predict-testing
ref: main
token: ${{ secrets.GH_PAT }}
- uses: actions/download-artifact@v3
with:
name: kubeconfig
path: .
- name: Create Rabbitmq Secret
shell: bash
run: |
kubectl --kubeconfig ./kubeconfig create secret generic rabbitmq-secret --from-file="load_definition.json"="./charts/rabbitmq/definition.json"
- name: Install Bitnami Repo
shell: bash
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Install Rabbitmq
shell: bash
run: |
helm install --kubeconfig ./kubeconfig rabbitmq \
bitnami/rabbitmq \
--wait \
-n default \
--set loadDefinition.enabled=true,loadDefinition.existingSecret=rabbitmq-secret
setup-docker-secrets:
name: Setup docker-secrets on the K8S Cluster
needs:
- setup-k8s-cluster
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/predict-testing
ref: main
token: ${{ secrets.GH_PAT }}
- uses: actions/download-artifact@v3
with:
name: kubeconfig
path: .
- name: Create Docker Secret
shell: bash
run: |
kubectl --kubeconfig ./kubeconfig create secret docker-registry regcred --docker-server="https://${{ inputs.docker_registry }}.azurecr.io" --docker-username="${{ inputs.docker_registry_username }}" --docker-password="${{ secrets.docker_registry_password }}"
deploy-orica-server:
name: Deploy orica-server on the K8S Cluster
needs:
- setup-docker-secrets
runs-on: ubuntu-latest
outputs:
node_ip: ${{ steps.install.outputs.node_ip }}
node_port: ${{ steps.install.outputs.node_port }}
client_id: ${{ steps.install.outputs.client_id }}
client_secret: ${{ steps.install.outputs.client_secret }}
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/predict-testing
ref: main
token: ${{ secrets.GH_PAT }}
- uses: actions/download-artifact@v3
with:
name: kubeconfig
path: .
- name: Login to container registries
shell: bash
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Create Orica Server Secrets
shell: bash
run: |
kubectl --kubeconfig ./kubeconfig create secret generic orica-server-htpasswd --from-file="htpasswd"="./charts/orica-server/htpasswd"
- name: Install Orica Server
id: install
shell: bash
run: |
helm --kubeconfig ./kubeconfig install server \
oci://ghcr.io/foresightminingsoftwarecorporation/charts/orica-server \
-n default \
--version ${{ inputs.orica_server_chart_version }} \
--wait \
--timeout 60m0s \
--values ./charts/orica-server/values.yaml \
--set image.tag=${{ inputs.orica_server_version }},storage.azure.storage_account_name=${{ inputs.storage_account_name }},storage.azure.storage_account_key="${{ secrets.storage_account_key }}",storage.azure.storage_container_name=${{ inputs.storage_container_name }}
echo "node_ip=$(kubectl get svc --kubeconfig ./kubeconfig --namespace default server-orica-server --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")" >> $GITHUB_OUTPUT
echo "node_port=80" >> $GITHUB_OUTPUT
echo "client_id=server" >> $GITHUB_OUTPUT
echo "client_secret=server" >> $GITHUB_OUTPUT
deploy-predict-simulation:
name: Deploy predict-simulation on the K8S Cluster
needs:
- setup-docker-secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/predict-testing
ref: main
token: ${{ secrets.GH_PAT }}
- uses: actions/download-artifact@v3
with:
name: kubeconfig
path: .
- name: Login to container registries
shell: bash
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Install Predict Simulation
shell: bash
run: |
helm --kubeconfig ./kubeconfig install simulation \
oci://ghcr.io/foresightminingsoftwarecorporation/charts/orica-predict \
-n default \
--version ${{ inputs.orica_predict_chart_version }} \
--wait \
--timeout 60m0s \
--values ./charts/orica-predict/values.yaml \
--set image.tag=${{ inputs.orica_predict_version }},storage.azure.storage_account_name=${{ inputs.storage_account_name }},storage.azure.storage_account_key="${{ secrets.storage_account_key }}",storage.azure.storage_container_name=${{ inputs.storage_container_name }},rabbitmq.queue=predict_simulation
deploy-predict-tuning:
name: Deploy predict-tuning on the K8S Cluster
needs:
- setup-docker-secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/predict-testing
ref: main
token: ${{ secrets.GH_PAT }}
- uses: actions/download-artifact@v3
with:
name: kubeconfig
path: .
- name: Login to container registries
shell: bash
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Install Orica Server
shell: bash
run: |
helm --kubeconfig ./kubeconfig install tuning \
oci://ghcr.io/foresightminingsoftwarecorporation/charts/orica-predict \
-n default \
--version ${{ inputs.orica_predict_chart_version }} \
--wait \
--timeout 60m0s \
--values ./charts/orica-predict/values.yaml \
--set image.tag=${{ inputs.orica_predict_version }},storage.azure.storage_account_name=${{ inputs.storage_account_name }},storage.azure.storage_account_key="${{ secrets.storage_account_key }}",storage.azure.storage_container_name=${{ inputs.storage_container_name }},rabbitmq.queue=predict_tuning
tests:
name: Tests
needs:
- deploy-orica-server
- deploy-predict-simulation
- deploy-predict-tuning
- setup-rmq
runs-on: ubuntu-latest
env:
NODE_IP: ${{ needs.deploy-orica-server.outputs.node_ip }}
NODE_PORT: ${{ needs.deploy-orica-server.outputs.node_port }}
CLIENT_ID: ${{ needs.deploy-orica-server.outputs.client_id }}
CLIENT_SECRET: ${{ needs.deploy-orica-server.outputs.client_secret }}
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/predict-testing
ref: main
token: ${{ secrets.GH_PAT }}
- name: Install Node
uses: actions/setup-node@v1
- name: Install newman
shell: bash
run: |
npm install -g newman newman-reporter-htmlextra
- name: Substitute env
shell: bash
run: |
envsubst < newman-env.json.tmpl > newman-env.json
- name: Make Directory for results
shell: bash
run: mkdir -p testResults
- name: Run POSTMAN collection
shell: bash
run: |
newman run postman_collection.json -e newman-env.json -d request.json -r htmlextra --reporter-htmlextra-export testResults/htmlreport.html --reporter-htmlextra-darkTheme
- name: Output the run Details
uses: actions/upload-artifact@v2
with:
name: RunReports
path: testResults
teardown-k8s-cluster:
name: Tear down Kubernetes Cluster
needs:
- tests
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ForesightMiningSoftwareCorporation/infrastructure
ref: ${{ env.TF_BRANCH }}
token: ${{ secrets.GH_PAT }}
- uses: hashicorp/setup-terraform@v2
- uses: actions/download-artifact@v3
with:
name: terraform.tfstate
path: deploy/predict_testing
- name: Terraform Init
shell: bash
working-directory: deploy/predict_testing
run: terraform init
- name: Terraform destroy
working-directory: deploy/predict_testing
if: always()
shell: bash
run: |
terraform destroy \
-auto-approve \
-var="resource_group"="${{ env.ARM_RESOURCE_GROUP }}" \
-var="subscription_id"="${{ env.ARM_SUBSCRIPTION_ID }}" \
-var="kubeconfig_path"="$GITHUB_WORKSPACE/kubeconfig"