Skip to content

Commit

Permalink
Merge pull request snyk-labs#383 from ericsmalling/main
Browse files Browse the repository at this point in the history
Adding basic k8s smoke tests
  • Loading branch information
ericsmalling committed Jan 31, 2022
2 parents c11f55a + d144e01 commit a61efa0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/log4shell-goof-server-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ jobs:

- name: Cleanup container
run: docker kill log4shell-server

- name: Start minikube
uses: medyagh/setup-minikube@master
with:
cni: calico

- name: Deploy to minikube
run: |
sed -i 's/${DOCKER_ACCOUNT}\///' k8s/deploy.yaml
sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/' k8s/deploy.yaml
minikube image load log4shell-server:latest
kubectl apply -f k8s/deploy.yaml
- name: Test pods came up cleanly
run: |
kubectl get all --namespace=darkweb && \
kubectl wait --namespace=darkweb --for=condition=ready pod --selector=app=log4shell --timeout=90s
- name: Dump pod description
if: ${{ failure() }}
run: |
kubectl describe pod --namespace=darkweb --selector=app=log4shell
kubectl describe deploy --namespace=darkweb --selector=app=log4shell
29 changes: 25 additions & 4 deletions .github/workflows/todolist-goof-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: todolost-goof Docker image build and test
name: todolist-goof Docker image build and test

on:
push:
Expand Down Expand Up @@ -33,12 +33,33 @@ jobs:
context: todolist-goof
push: false
tags: java-goof:latest

- name: Run container
run: docker run -d --rm --name java-goof -p 8080:8080 java-goof:latest

- name: Smoke test container
run: sleep 5 && curl -s --retry 5 --retry-delay 1 --retry-max-time 30 http://localhost:8080/todolist/
- name: Cleanup container

- name: Teardown container
run: docker kill java-goof

- name: Start minikube
uses: medyagh/setup-minikube@master
with:
cni: calico

- name: Deploy to minikube
run: |
sed -i 's/${DOCKER_ACCOUNT}\///' k8s/java-goof.yaml
sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/' k8s/java-goof.yaml
minikube image load java-goof:latest
kubectl apply -f k8s/java-goof.yaml
- name: Test pod came up cleanly
run: |
kubectl get all
kubectl wait --for=condition=ready pod --selector=app=goof --timeout=90s
- name: Dump pod description
if: ${{ failure() }}
run: kubectl describe pod --selector=app=goof
1 change: 1 addition & 0 deletions log4shell-goof/log4shell-server/k8s/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
containers:
- name: ldap
image: ${DOCKER_ACCOUNT}/log4shell-server:latest
imagePullPolicy: Always
---
apiVersion: v1
kind: Service
Expand Down

0 comments on commit a61efa0

Please sign in to comment.