move e2e test in regular build (#136)

* move e2e test in regular build

* write to summary
This commit is contained in:
Marc Brugger
2022-12-25 10:56:23 +01:00
committed by bakito
parent ec3209bdb3
commit 6b07040ad7
12 changed files with 117 additions and 40 deletions

51
.github/workflows/e2e.yaml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: e2e tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Set up Registry Container
run: |
docker run -d --restart=always -p "127.0.0.1:5001:5000" --name kind-registry registry:2
- name: Build image
run: ./testdata/e2e/bin/build-image.sh
- name: Create kind cluster
uses: helm/kind-action@v1.5.0
with:
version: v0.17.0
kubectl_version: v1.25.3
config: testdata/e2e/kind/config.yaml
- name: Set up Local Registry
run: |
# https://kind.sigs.k8s.io/docs/user/local-registry/
docker network connect kind kind-registry
kubectl apply -f testdata/e2e/kind/configmap-registry.yaml
# image registry: localhost:5001/
- name: Install Helm Chart
run: ./testdata/e2e/bin/install-chart.sh
- name: Wait for sync to finish
run: ./testdata/e2e/bin/wait-for-sync.sh
- name: Show origin Logs
run: ./testdata/e2e/bin/show-origin-logs.sh
- name: Show Replica Logs
run: ./testdata/e2e/bin/show-replica-logs.sh
- name: Show Sync Logs
run: ./testdata/e2e/bin/show-sync-logs.sh

View File

@@ -73,24 +73,4 @@ jobs:
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
test:
needs: images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create kind cluster
uses: helm/kind-action@v1.5.0
with:
version: v0.17.0
kubectl_version: v1.25.3
- name: Install Helm Chart
run: ./testdata/e2e/bin/install-chart.sh
- name: Wait for sync to finish
run: ./testdata/e2e/bin/wait-for-sync.sh
- name: Show origin Logs
run: ./testdata/e2e/bin/show-origin-logs.sh
- name: Show Replica Logs
run: ./testdata/e2e/bin/show-replica-logs.sh
- name: Show Sync Logs
run: ./testdata/e2e/bin/show-sync-logs.sh

4
testdata/e2e/bin/build-image.sh vendored Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
set -e
docker build -f Dockerfile --build-arg VERSION=e2e-tests -t localhost:5001/adguardhome-sync:e2e .
docker push localhost:5001/adguardhome-sync:e2e

View File

@@ -1,5 +1,7 @@
#!/bin/bash
set -e
echo Pod adguardhome-origin logs
kubectl logs adguardhome-origin
echo "## Pod adguardhome-origin logs" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
kubectl logs adguardhome-origin >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

View File

@@ -2,9 +2,17 @@
set -e
for pod in $(kubectl get pods -l bakito.net/adguardhome-sync=replica -o name); do
echo Pod "${pod} logs"
kubectl logs ${pod}
ERRORS=$(kubectl logs ${pod} | grep '\[error\]' | wc -l)
echo "Found ${ERRORS} error(s) in log"
echo "----------------------------------------------"
echo "## Pod ${pod} logs" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
LOGS=$(kubectl logs ${pod})
# ignore certain errors
LOGS=$(echo -e "${LOGS}" | grep -v -e "error.* deleting filter .* no such file or directory" )
# https://github.com/AdguardTeam/AdGuardHome/issues/4944
LOGS=$(echo -e "${LOGS}" | grep -v -e "error.* creating dhcpv4 srv")
echo -e "${LOGS}" >> $GITHUB_STEP_SUMMARY
ERRORS=$(echo -e "${LOGS}"} | grep '\[error\]' | wc -l)
echo '```' >> $GITHUB_STEP_SUMMARY
echo "Found ${ERRORS} error(s) in ${pod} log" >> $GITHUB_STEP_SUMMARY
echo "----------------------------------------------" >> $GITHUB_STEP_SUMMARY
done

View File

@@ -1,8 +1,10 @@
#!/bin/bash
set -e
echo Pod adguardhome-sync logs
kubectl logs adguardhome-sync
echo "## Pod adguardhome-sync logs" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
kubectl logs adguardhome-sync >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
ERRORS=$(kubectl logs adguardhome-sync | grep Error | wc -l)
echo "Found ${ERRORS} error(s) in log";
echo "Found ${ERRORS} error(s) in adguardhome-sync log"; >> $GITHUB_STEP_SUMMARY
if [[ "${ERRORS}" != "0" ]]; then exit 1; fi

21
testdata/e2e/kind/config.yaml vendored Normal file
View File

@@ -0,0 +1,21 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5001"]
endpoint = ["http://kind-registry:5000"]

View File

@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: local-registry-hosting
namespace: kube-public
data:
localRegistryHosting.v1: |
host: "localhost:5001"
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"

View File

@@ -9,9 +9,9 @@ data:
ORIGIN_URL: http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000
ORIGIN_PASSWORD: password
ORIGIN_USERNAME: username
{{ range $i,$_ := .Values.replica.versions }}
{{ range $i,$version := .Values.replica.versions }}
REPLICA{{ $i }}_AUTOSETUP: "true"
REPLICA{{ $i }}_URL: http://service-replica-{{ $i }}.{{ $.Release.Namespace }}.svc.cluster.local:3000
REPLICA{{ $i }}_URL: http://service-replica-{{ $version | toString | replace "." "-" }}.{{ $.Release.Namespace }}.svc.cluster.local:3000
REPLICA{{ $i }}_PASSWORD: password
REPLICA{{ $i }}_USERNAME: username
{{- end }}

View File

@@ -1,11 +1,11 @@
{{ range $i, $version := .Values.replica.versions }}
{{ range $_, $version := .Values.replica.versions }}
apiVersion: v1
kind: Pod
metadata:
name: adguardhome-replica-{{ $i }}
name: adguardhome-replica-{{ $version | toString | replace "." "-" }}
namespace: {{ $.Release.Namespace }}
labels:
app.kubernetes.io/name: adguardhome-replica-{{ $i }}
app.kubernetes.io/name: adguardhome-replica-{{ $version | toString | replace "." "-" }}
bakito.net/adguardhome-sync: replica
spec:
containers:

View File

@@ -15,7 +15,7 @@ spec:
{{- .Files.Get "bin/wait-for-agh-pods.sh" | nindent 10}}
containers:
- name: adguardhome-sync
image: ghcr.io/bakito/adguardhome-sync:main
image: localhost:5001/adguardhome-sync:e2e
command:
- /opt/go/adguardhome-sync
- run

View File

@@ -1,11 +1,11 @@
{{ range $i ,$_ := .Values.replica.versions }}
{{ range $i ,$version := .Values.replica.versions }}
apiVersion: v1
kind: Service
metadata:
name: service-replica-{{ $i }}
name: service-replica-{{ $version | toString | replace "." "-" }}
spec:
selector:
app.kubernetes.io/name: adguardhome-replica-{{ $i }}
app.kubernetes.io/name: adguardhome-replica-{{ $version | toString | replace "." "-" }}
ports:
- protocol: TCP
port: 3000