From 48fcd93a693c4860b03a43414a3dbc3a744fe3e5 Mon Sep 17 00:00:00 2001 From: morvencao Date: Fri, 28 Jun 2024 03:43:32 +0000 Subject: [PATCH] add e2e for maestro server broadcast subscription type. Signed-off-by: morvencao --- .github/workflows/e2e.yml | 28 +++++++++++++++++++++++++--- test/e2e/setup/e2e_setup.sh | 25 ++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index bcca5b04..b1b046a6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -23,10 +23,31 @@ jobs: uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - - name: Setup kind - uses: engineerd/setup-kind@v0.5.0 + # - name: Setup kind + # uses: engineerd/setup-kind@v0.5.0 + # with: + # version: v0.17.0 + - name: install ginkgo + run: go install github.com/onsi/ginkgo/v2/ginkgo@v2.15.0 + - name: Test E2E + run: | + make e2e-test + env: + container_tool: docker + + e2e-broadcast-subscription: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 with: - version: v0.17.0 + go-version: ${{ env.GO_VERSION }} + # - name: Setup kind + # uses: engineerd/setup-kind@v0.5.0 + # with: + # version: v0.17.0 - name: install ginkgo run: go install github.com/onsi/ginkgo/v2/ginkgo@v2.15.0 - name: Test E2E @@ -34,3 +55,4 @@ jobs: make e2e-test env: container_tool: docker + ENABLE_BROADCAST_SUBSCRIPTION: true diff --git a/test/e2e/setup/e2e_setup.sh b/test/e2e/setup/e2e_setup.sh index 7c1dbcda..3a18ce76 100755 --- a/test/e2e/setup/e2e_setup.sh +++ b/test/e2e/setup/e2e_setup.sh @@ -152,8 +152,26 @@ kubectl create secret generic maestro-mqtt-certs -n $namespace --from-file=ca.cr kubectl patch deploy/maestro-mqtt -n $namespace --type='json' -p='[{"op":"add","path":"/spec/template/spec/volumes/-","value":{"name":"mosquitto-certs","secret":{"secretName":"maestro-mqtt-certs"}}},{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts/-","value":{"name":"mosquitto-certs","mountPath":"/mosquitto/certs"}}]' kubectl wait deploy/maestro-mqtt -n $namespace --for condition=Available=True --timeout=200s -# apply the maestro-mqtt secret -cat << EOF | kubectl -n $namespace apply -f - +maestroServerPatch='[{"op":"add","path":"/spec/template/spec/volumes/-","value":{"name":"mqtt-certs","secret":{"secretName":"maestro-server-certs"}}},{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts/-","value":{"name":"mqtt-certs","mountPath":"/secrets/mqtt-certs"}},{"op":"replace","path":"/spec/template/spec/containers/0/livenessProbe/initialDelaySeconds","value":1},{"op":"replace","path":"/spec/template/spec/containers/0/readinessProbe/initialDelaySeconds","value":1}]' +if [ -n "${ENABLE_BROADCAST_SUBSCRIPTION}" ] && [ "${ENABLE_BROADCAST_SUBSCRIPTION}" = "true" ]; then + maestroServerPatch='[{"op":"add","path":"/spec/template/spec/containers/0/command/-","value":"--subscription-type=broadcast"},{"op":"add","path":"/spec/template/spec/volumes/-","value":{"name":"mqtt-certs","secret":{"secretName":"maestro-server-certs"}}},{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts/-","value":{"name":"mqtt-certs","mountPath":"/secrets/mqtt-certs"}},{"op":"replace","path":"/spec/template/spec/containers/0/livenessProbe/initialDelaySeconds","value":1},{"op":"replace","path":"/spec/template/spec/containers/0/readinessProbe/initialDelaySeconds","value":1}]' + cat << EOF | kubectl -n $namespace apply -f - +apiVersion: v1 +kind: Secret +metadata: + name: maestro-mqtt +stringData: + config.yaml: | + brokerHost: maestro-mqtt-server.maestro:1883 + caFile: /secrets/mqtt-certs/ca.crt + clientCertFile: /secrets/mqtt-certs/client.crt + clientKeyFile: /secrets/mqtt-certs/client.key + topics: + sourceEvents: sources/maestro/consumers/+/sourceevents + agentEvents: sources/maestro/consumers/+/agentevents +EOF +else + cat << EOF | kubectl -n $namespace apply -f - apiVersion: v1 kind: Secret metadata: @@ -168,10 +186,11 @@ stringData: sourceEvents: sources/maestro/consumers/+/sourceevents agentEvents: \$share/statussubscribers/sources/maestro/consumers/+/agentevents EOF +fi # create secret containing the client certs to mqtt broker and patch the maestro deployment kubectl create secret generic maestro-server-certs -n $namespace --from-file=ca.crt=${certDir}/ca.crt --from-file=client.crt=${certDir}/server-client.crt --from-file=client.key=${certDir}/server-client.key -kubectl patch deploy/maestro -n $namespace --type='json' -p='[{"op": "add","path":"/spec/template/spec/volumes/-","value":{"name":"mqtt-certs","secret":{"secretName":"maestro-server-certs"}}},{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts/-","value":{"name":"mqtt-certs","mountPath":"/secrets/mqtt-certs"}},{"op":"replace","path":"/spec/template/spec/containers/0/livenessProbe/initialDelaySeconds","value":1},{"op":"replace","path":"/spec/template/spec/containers/0/readinessProbe/initialDelaySeconds","value":1}]' +kubectl patch deploy/maestro -n $namespace --type='json' -p=${maestroServerPatch} kubectl wait deploy/maestro -n $namespace --for condition=Available=True --timeout=200s # 6. create a consumer