-
Notifications
You must be signed in to change notification settings - Fork 19
123 lines (105 loc) · 3.89 KB
/
test.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
---
name: Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
test-kind:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
- name: 'Scenario: with default options'
testdir: 'default-data'
- name: 'Scenario: with all-in-one image'
testdir: 'with-all-in-one-image'
- name: 'Scenario: with extra mounts'
testdir: 'with-extra-mounts'
- name: 'Scenario: with templated annotations'
testdir: 'with-templated-annotations'
env:
KRAKEND_NS: krakend-test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'Install helm'
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Install kind'
uses: helm/[email protected]
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install jq
- name: 'Get k8s nodes'
run: |
kubectl get nodes
- name: 'Create namespace'
run: |
kubectl create namespace $KRAKEND_NS
- name: 'Build image if needed'
if: matrix.config.testdir == 'with-all-in-one-image'
run: |
docker build -t krakend-test:latest -f tests/${{ matrix.config.testdir }}/Dockerfile tests/${{ matrix.config.testdir }}
- name: 'Load image if needed'
if: matrix.config.testdir == 'with-all-in-one-image'
run: |
kind load docker-image --name chart-testing krakend-test:latest
# We copy our license file (which is just the apache license) into a secret with a sole key named LICENSE.
# This will be bind mounted into the krakend container as /etc/krakend/LICENSE.
# We're not testing the functionality of loading an actual krakend license here, just that the extra mount works.
- name: 'Create license secret'
run: |
kubectl create secret generic krakend-license --from-file=LICENSE=LICENSE --namespace $KRAKEND_NS
if: matrix.config.testdir == 'with-extra-mounts'
- name: Install chart
run: |
helm install krakend-test ./ --wait --namespace $KRAKEND_NS --values tests/${{ matrix.config.testdir }}/values.yaml
- name: Wait for krakend deployment
run: |
kubectl wait --namespace $KRAKEND_NS --for=condition=available deployment krakend-test
- name: Port forward service for testing
run: |
kubectl port-forward --namespace $KRAKEND_NS service/krakend-test 8081:80 &
- name: Test that status is OK
run: |
curl -s http://localhost:8081/__health | jq -e '.status == "ok"'
- name: Test that response is correct
run: |
curl -s http://localhost:8081/test | jq -e '.version == "deficient"'
if: matrix.config.testdir != 'with-all-in-one-image'
- name: Test that response is correct
run: |
curl -s http://localhost:8081/directories/1 | jq -e '.version == "flavorless"'
if: matrix.config.testdir == 'with-all-in-one-image'
helm-lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
- name: 'Scenario: with default options'
testdir: 'default-data'
- name: 'Scenario: with all-in-one image'
testdir: 'with-all-in-one-image'
- name: 'Scenario: with extra mounts'
testdir: 'with-extra-mounts'
- name: 'Scenario: with templated annotations'
testdir: 'with-templated-annotations'
env:
KRAKEND_NS: krakend-test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'Install helm'
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: lint
run: |
helm lint --values tests/${{ matrix.config.testdir }}/values.yaml .