8000 add Waiting 5 seconds for Tomcat to unpack the downloaded war · java-operator-sdk/samples@d5b9048 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit d5b9048

Browse files
add Waiting 5 seconds for Tomcat to unpack the downloaded war
1 parent 716b962 commit d5b9048

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

.github/workflows/TomcatIntegrationTest.yml

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
- name: Run unit tests
4747
run: mvn -B test -q --file tomcat/pom.xml
4848

49+
- name: Get webapps
50+
if: ${{ failure() }}
51+
run: |
52+
kubectl get tomcats,webapps -A -o yaml | tee -a debug
53+
kubectl logs
54+
4955
tomcat_local_apply_setup_test:
5056
runs-on: ubuntu-latest
5157
steps:
@@ -63,20 +69,22 @@ jobs:
6369
mkdir -p /etc/docker
6470
echo -n "{\"exec-opts\": [\"native.cgroupdriver=systemd\"],\"log-driver\": \"json-file\",\"log-opts\": {\"max-size\": \"100m\"},\"storage-driver\": \"overlay2\"}" > /etc/docker/daemon.json
6571
cat /etc/docker/daemon.json
66-
sudo service docker status
72+
#sudo service docker status
67 10000 73
6874
- name: Create Kubernetes KinD Cluster
6975
uses: container-tools/kind-action@v1.5.0
76+
if: ${{ !env.ACT }}
7077
with:
7178
cluster_name: tomcat-local-apply
7279
registry: true
7380

74-
# - name: Create kind cluster
75-
# uses: helm/kind-action@v1.2.0
76-
# with:
77-
# cluster_name: tomcat-local-apply #${{ job.name }}
78-
# registry: true
79-
# # docker stop tomcat-local-apply-control-plane ; docker rm tomcat-local-apply-control-plane ; sleep 1
81+
- name: Create kind cluster without registry
82+
uses: helm/kind-action@v1.2.0
83+
if: ${{ env.ACT }}
84+
with:
85+
cluster_name: tomcat-local-apply #${{ job.name }}
86+
registry: false
87+
# 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
8088

8189
- name: Set up Java and Maven
8290
uses: actions/setup-java@v2
@@ -99,11 +107,6 @@ jobs:
99107
if: ${{ env.ACT }}
100108
with:
101109
maven-version: 3.8.1
102-
103-
- name: check that kube is empty
104-
if: ${{ env.ACT }}
105-
run: kubectl get tomcats,webapps,po
106-
107110

108111
- name: test local registry
109112
if: ${{ env.ACT }}
@@ -114,28 +117,50 @@ jobs:
114117
fi
115118
116119
- name: build jib
120+
if: ${{ !env.ACT }}
117121
run: |
118122
mvn -B install jib:dockerBuild jib:build -Djib.allowInsecureRegistries=true \
119123
-Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT \
120124
--file tomcat/pom.xml -DskipTests
121125
126+
- name: build jib
127+
if: ${{ env.ACT }}
128+
run: |
129+
mvn -B install jib:dockerBuild \
130+
-Djib.to.image=sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests
131+
kind load docker-image sample:1.7.1-SNAPSHOT --name=tomcat-local-apply
132+
122133
- name: Apply CRDs
123134
run: kubectl apply -f tomcat/k8s/crd.yaml
124135

125136
- name: install tomcat operator
126-
run: kubectl apply -f tomcat/k8s/operator.yaml
137+
if: ${{ !env.ACT }}
138+
run: |
139+
sed 's@image\: tomcat-operator@image\: kind-registry\:5000/io.javaoperatorsdk/sample\:1.7.1-SNAPSHOT@g' tomcat/k8s/operator.yaml > tomcat/target/operator.yaml
140+
kubectl apply -f tomcat/target/operator.yaml
141+
142+
- name: install tomcat operator
143+
if: ${{ env.ACT }}
144+
run: |
145+
sed 's@image\: tomcat-operator@image\: sample\:1.7.1-SNAPSHOT@g' tomcat/k8s/operator.yaml > tomcat/target/operator.yaml
146+
kubectl apply -f tomcat/target/operator.yaml
127147
128148
- name: create ns tomcatoperator-sample
129149
run: kubectl create ns tomcatoperator-sample
130150

151+
- name: debug local kind
152+
if: ${{ env.ACT }}
153+
run: |
154+
kubectl get pods -n tomcat-operator -l app=tomcat-operator -o yaml | tee -a debug.log
155+
131156
- name: wait for operators ready
132157
run: |
133158
LOOP=0 &&\
134159
while [[ $(kubectl get pods -n tomcat-operator -l app=tomcat-operator -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do \
135160
echo "waiting for pod" &&\
136161
kubectl logs -n tomcat-operator -l app=tomcat-operator &&\
137162
(( LOOP++ )) &&\
138-
if [[ $LOOP -gt 10 ]]; then break; fi &&\
163+
if [[ $LOOP -gt 10 ]]; then exit 1; fi &&\
139164
echo "loop number $LOOP" &&\
140165
sleep 5; \
141166
done
@@ -146,7 +171,6 @@ jobs:
146171
kubectl -n tomcatoperator-sample apply -f $sample;
147172
done
148173
149-
150174
- name: check pod correctly started
151175
run: |
152176
LOOP=0 &&\
@@ -158,4 +182,5 @@ jobs:
158182
echo "loop number $LOOP" &&\
159183
sleep 5; \
160184
done
161-
185+
186+

tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.slf4j.LoggerFactory;
1414

1515
import static java.util.concurrent.TimeUnit.MINUTES;
16+
import static java.util.concurrent.TimeUnit.SECONDS;
1617
import static org.awaitility.Awaitility.await;
1718
import static org.hamcrest.CoreMatchers.equalTo;
1819
import static org.hamcrest.CoreMatchers.is;
@@ -84,7 +85,17 @@ public void test() {
8485
assertThat(updatedWebapp.getStatus(), is(notNullValue()));
8586
assertThat(updatedWebapp.getStatus().getDeployedArtifact(), is(notNullValue()));
8687
});
87-
88+
89+
log.info("Waiting 5 seconds for Tomcat to unpack the downloaded war");
90+
// this delays is du to allows the tomcat to unpack
91+
// kubectl -n tomcat-test -c war-downloader logs -l app=test-tomcat1
92+
// Deployment of web application archive [/usr/local/tomcat/webapps/webapp1.war] has finished in [xxx] ms
93+
try {
94+
Thread.sleep(5*1000);
95+
} catch (InterruptedException e) {
96+
log.warn(e.getMessage(),e);
97+
}
98+
8899
String url = "http://" + tomcat.getMetadata().getName() + "/" + webapp1.getSpec().getContextPath() + "/";
89100
log.info("Starting curl Pod and waiting 2 minutes for GET of {} to return 200", url);
90101
Pod curlPod = client.run().inNamespace(TEST_NS)

0 commit comments

Comments
 (0)
0