This repository was archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
179 lines (154 loc) · 6.41 KB
/
TomcatIntegrationTest.yml
File metadata and controls
179 lines (154 loc) · 6.41 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
name: Tomcat integration test
on:
push:
branches:
- "*"
jobs:
tomcat_integration_test:
runs-on: ubuntu-latest
env:
KIND_CL_NAME: tomcat-integration
steps:
- name: Checkout
uses: actions/checkout@v2
- name: clean resident local docker
if: ${{ env.ACT }}
continue-on-error: true
run: |
for DIMG in "$KIND_CL_NAME-control-plane "; do
docker stop $DIMG ; docker rm $DIMG ;
done ;
sleep 1
- name: Create kind cluster
uses: helm/kind-action@v1.2.0
with:
cluster_name: ${{ env.KIND_CL_NAME }}
- name: Apply CRDs
run: kubectl apply -f tomcat/k8s/crd.yaml
- name: Set up Java and Maven
uses: actions/setup-java@v2
with:
java-version: 15
distribution: adopt-hotspot
- name: cache
uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-m2
- name: Set up Maven
uses: stCarolas/setup-maven@v4
if: ${{ env.ACT }}
with:
maven-version: 3.8.1
- name: Run unit tests
if: ${{ env.ACT }}
run: mvn --version
- name: Run unit tests
run: mvn -B failsafe:integration-test --file tomcat/pom.xml
tomcat_local_apply_setup_test:
runs-on: ubuntu-latest
env:
KIND_CL_NAME: tomcat-local-apply
steps:
- name: Checkout
uses: actions/checkout@v2
- name: clean resident local docker
if: ${{ env.ACT }}
continue-on-error: true
run: |
for DIMG in "$KIND_CL_NAME-control-plane "; do
docker stop $DIMG ; docker rm $DIMG ;
done ;
sleep 1
- name: Create Kubernetes KinD Cluster
uses: container-tools/kind-action@v1.5.0
with:
cluster_name: ${{ env.KIND_CL_NAME }}
registry: false
# for DIMG in "tomcat-local-apply-control-plane kind-registry tomcat_local_apply_setup_test "; do docker stop $DIMG ; docker rm $DIMG ; done ; sleep 1
- name: Set up Java and Maven
uses: actions/setup-java@v2
with:
# java-version: ${{ matrix.java }}
java-version: 15
distribution: adopt-hotspot
- name: cache
uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up Maven for local ACT
uses: stCarolas/setup-maven@v4
if: ${{ env.ACT }}
with:
maven-version: 3.8.1
- name: build jib
run: |
mvn -B package jib:dockerBuild jib:buildTar -Djib-maven-image=tomcat-operator --file tomcat/pom.xml -DskipTests
kind load image-archive tomcat/target/jib-image.tar --name=${{ env.KIND_CL_NAME }}
- name: Apply CRDs
run: kubectl apply -f tomcat/k8s/crd.yaml
- name: install tomcat operator
run: |
kubectl apply -f tomcat/k8s/operator.yaml
- name: create ns tomcatoperator-sample
run: kubectl create ns tomcatoperator-sample
- name: debug local kind
if: ${{ env.ACT }}
run: |
kubectl get pods -n tomcat-operator -l app=tomcat-operator -o yaml | tee -a debug.log
- name: wait for operators ready
run: |
LOOP=0 &&\
while [[ $(kubectl get pods -n tomcat-operator -l app=tomcat-operator -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do \
echo "waiting for pod" &&\
kubectl logs -n tomcat-operator -l app=tomcat-operator &&\
(( LOOP++ )) &&\
if [[ $LOOP -gt 10 ]]; then exit 1; fi &&\
echo "loop number $LOOP" &&\
sleep 5; \
done
- name: install sample operators
run: |
for sample in $(ls tomcat/k8s/*sample*); do
kubectl -n tomcatoperator-sample apply -f $sample;
done
- name: check pod correctly started
run: |
LOOP=0 &&\
while [[ $(kubectl get pods -n tomcatoperator-sample -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True True True True True True" ]]; do \
echo "waiting for pod" &&\
kubectl logs -n tomcat-operator -l app=tomcat-operator &&\
kubectl get pods -n tomcatoperator-sample &&\
(( LOOP++ )) &&\
if [[ $LOOP -gt 10 ]]; then exit 1; fi &&\
echo "loop number $LOOP" &&\
sleep 10; \
done
#Waiting 5 seconds for Tomcat to unpack the downloaded war
sleep 5;
- name: Get webapps
run: |
kubectl get tomcats,webapps -A -o yaml | tee -a debug
kubectl -n tomcatoperator-sample -c tomcat logs -l app=test-tomcat1 | grep startup
- name: check code
run: |
kubectl -n tomcatoperator-sample run sample1 --labels=app=curl --image=curlimages/curl:7.78.0 --restart=Never --timeout=30s --command -- curl -s -v http://test-tomcat1/mysample/;
kubectl -n tomcatoperator-sample run sample2 --labels=app=curl --image=curlimages/curl:7.78.0 --restart=Never --timeout=30s --command -- curl -s -v http://test-tomcat2/othercontext/;
LOOP=0 &&\
while [[ $(kubectl get pods -n tomcatoperator-sample -l app=curl -o 'jsonpath={..status.phase}') != "Succeeded Succeeded" ]]; do \
echo "waiting for pod" &&\
kubectl logs -n tomcatoperator-sample -l app=curl &&\
(( LOOP++ )) &&\
if [[ $LOOP -gt 5 ]]; then exit 1; fi &&\
echo "loop number $LOOP" &&\
sleep 5; \
done
if [[ $(kubectl logs -n tomcatoperator-sample sample1 --tail=500 | grep tomcat.gif | wc -l) -ne 1 ]]; then exit 1; fi
if [[ $(kubectl logs -n tomcatoperator-sample sample2 --tail=500 | grep dog.jpeg | wc -l) -ne 1 ]]; then exit 1; fi