Skip to content

Commit

Permalink
ci: update upgrade check
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Z committed Aug 3, 2022
1 parent 50f7b8d commit 7a66aef
Showing 1 changed file with 29 additions and 48 deletions.
77 changes: 29 additions & 48 deletions .github/workflows/upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ jobs:
with:
go-version: '1.18.3'
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install storage operator
if: matrix.install == 'static'
run: |
kubectl apply -f "https://github.com/emqx/emqx-operator/releases/download/$(git describe --abbrev=0 --tags)/emqx-operator-controller.yaml" --server-side --force-conflicts
browser_download_url="$(curl --silent --show-error \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ github.token }}" \
https://api.github.com/repos/emqx/emqx-operator/releases/latest \
| jq '.assets[0].browser_download_url')"
kubectl apply -f "$browser_download_url" --server-side --force-conflicts
- name: Install storage operator
if: matrix.install == 'helm'
run: |
Expand All @@ -54,7 +57,7 @@ jobs:
--namespace emqx-operator-system \
--create-namespace
- name: Check operator
timeout-minutes: 10
timeout-minutes: 5
run: |
set -euo pipefail
while [ "$(kubectl get pods -l "control-plane=controller-manager" -n emqx-operator-system -o json | jq '.items[0].status.containerStatuses[] | select(.ready==true) | .containerID')" = "" ]; do
Expand All @@ -71,30 +74,26 @@ jobs:
labels:
cluster: emqx
spec:
replicas: 3
persistent:
storageClassName: standard
resources:
requests:
storage: 20Mi
accessModes:
- ReadWriteOnce
emqxTemplate:
image: ${{ matrix.emqx[1] }}
EOF
- name: Check emqx pods status
run: |
set -euo pipefail
while ! kubectl describe sts emqx | grep -qE '^Pods[ \t]+Status:[ \t]+3 Running.*'; do
echo "waiting ${{ matrix.emqx[1] }} pod running"
sleep 1
done
echo "==========================="
echo "${{ matrix.emqx[1] }} pod run successfully"
- name: Check emqx cluster status
- name: Check emqx status
timeout-minutes: 5
run: |
set -euo pipefail
while
nodes="$(kubectl exec -i emqx-0 -c emqx -- curl --silent --basic -u admin:public -X GET http://localhost:8081/api/v4/brokers | jq '.data|length')";
[ "$nodes" != "3" ];
[ -z "$(kubectl get ${{ matrix.emqx[0] }} emqx -o json | jq '.status.conditions[] | select((.type == "Running") and (.status == "True"))')" ];
do
echo "waiting ${{ matrix.emqx[1] }} cluster scale"
echo "waiting ${{ matrix.emqx[0] }}"
sleep 1
done
echo "==========================="
echo "${{ matrix.emqx[1] }} cluster successfully"
- name: Build image
env:
IMG: "emqx/emqx-operator-controller:${{ github.sha }}"
Expand All @@ -115,42 +114,24 @@ jobs:
- name: Check operator
env:
IMG: "emqx/emqx-operator-controller:${{ github.sha }}"
timeout-minutes: 10
timeout-minutes: 5
run: |
set -euo pipefail
while [ "$(kubectl get pods -l "control-plane=controller-manager" -n emqx-operator-system -o json | jq '.items[0].status.containerStatuses[] | select(.ready==true) | .image' | tr -d '"')" != "$IMG" ]; do
echo "waiting operator controller pod running"
sleep 1
done
- run: kubectl exec -i emqx-0 -- curl --silent --basic -u admin:public -X GET http://localhost:8081/api/v4/brokers | jq '.data'
- name: Check emqx pods status
timeout-minutes: 10
- name: Check emqx status
timeout-minutes: 5
run: |
set -euo pipefail
while ! kubectl describe sts emqx | grep -qE '^Pods[ \t]+Status:[ \t]+3 Running.*'; do
echo "waiting ${{ matrix.emqx[1] }} pod running"
sleep 1
done
echo "==========================="
echo "${{ matrix.emqx[1] }} pod run successfully"
- name: Check emqx cluster status
timeout-minutes: 10
run: |
set -euo pipefail
sleep 30
while
nodes="$(kubectl exec -i emqx-0 -c emqx -- curl --silent --basic -u admin:public -X GET http://localhost:8081/api/v4/brokers | jq '.data|length')";
[ "$nodes" != "3" ];
[ -z "$(kubectl get ${{ matrix.emqx[0] }} emqx -o json | jq '.status.conditions[] | select((.type == "Running") and (.status == "True"))')" ];
do
kubectl exec -i emqx-0 -c emqx -- curl --silent --basic -u admin:public -X GET http://localhost:8081/api/v4/brokers | jq
echo "waiting ${{ matrix.emqx[1] }} cluster scale"
echo "waiting ${{ matrix.emqx[0] }}"
sleep 1
done
echo "==========================="
echo "${{ matrix.emqx[1] }} cluster successfully"
- name: Check emqx restarts
run: |
restart=$(kubectl get pods -l "cluster=emqx" -o json | jq '.items[].status.containerStatuses[] | select(.restartCount != 0)')
if [ -n "$restart" ]; then
echo $restart
exit 1
fi
- if: failure()
run: kubectl logs -l "control-plane=controller-manager" -n emqx-operator-system -c manager --tail=1000
- if: failure()
run: kubectl get ${{ matrix.emqx[0] }} emqx -o json

0 comments on commit 7a66aef

Please sign in to comment.