|
| 1 | +name: Integration Test for NodePort Service Type |
| 2 | + |
| 3 | +on: workflow_call |
| 4 | + |
| 5 | +jobs: |
| 6 | + test: |
| 7 | + name: Test |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + permissions: |
| 11 | + contents: 'read' |
| 12 | + id-token: 'write' |
| 13 | + packages: 'read' |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Set env and tools |
| 17 | + run: | |
| 18 | + echo "TESTNAMESPACE=op-test-nodeport-$(date +%s)" >> $GITHUB_ENV |
| 19 | +
|
| 20 | + - name: Check out code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + ref: ${{ github.head_ref }} |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - id: 'auth' |
| 27 | + name: 'Authenticate to Google Cloud' |
| 28 | + uses: 'google-github-actions/[email protected]' |
| 29 | + with: |
| 30 | + service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} |
| 31 | + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} |
| 32 | + access_token_lifetime: 600s |
| 33 | + |
| 34 | + - name: Use the GKE Autopilot test cluster |
| 35 | + uses: 'google-github-actions/[email protected]' |
| 36 | + with: |
| 37 | + cluster_name: 'dev-integrationtesting' |
| 38 | + location: 'us-central1' |
| 39 | + |
| 40 | + - name: Login to Github Packages |
| 41 | + uses: docker/login-action@v2 |
| 42 | + with: |
| 43 | + registry: ghcr.io |
| 44 | + username: ${{ github.actor }} |
| 45 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Deploy Operator |
| 48 | + run: | |
| 49 | + sleep 20; |
| 50 | + for i in {1..3}; do |
| 51 | + kubectl cluster-info |
| 52 | + kubectl get pods -n kube-system |
| 53 | + echo "current-context:" $(kubectl config current-context) |
| 54 | + echo "environment-kubeconfig:" ${KUBECONFIG} |
| 55 | + kubectl get ns pubsubplus-operator-system || kubectl create ns pubsubplus-operator-system |
| 56 | + if kubectl get deployment pubsubplus-eventbroker-operator -n pubsubplus-operator-system; then |
| 57 | + echo "pubsubplus-eventbroker-operator is already deployed" |
| 58 | + break |
| 59 | + else |
| 60 | + kubectl apply -f <(kubectl create secret generic regcred --from-file=.dockerconfigjson=${HOME}/.docker/config.json --type=kubernetes.io/dockerconfigjson -n pubsubplus-operator-system --dry-run=client -o yaml) |
| 61 | + make deploy | grep 'created \| configured' |
| 62 | + kubectl rollout status deployment pubsubplus-eventbroker-operator -n pubsubplus-operator-system --timeout=240s |
| 63 | + if [ $? -eq 0 ]; then |
| 64 | + break |
| 65 | + else |
| 66 | + echo "Rollout status check failed, retrying in 20 seconds..." |
| 67 | + sleep 20 |
| 68 | + fi |
| 69 | + fi |
| 70 | + done |
| 71 | +
|
| 72 | + - name: Testing NodePort with Fixed Port Assignment |
| 73 | + run: | |
| 74 | + kubectl create ns $TESTNAMESPACE && kubectl config set-context --current --namespace=$TESTNAMESPACE |
| 75 | + kubectl apply -f ci/manifests/eventbroker-nonha-nodeport.yaml | grep "test-nonha-nodeport created" |
| 76 | + sleep 25 ; kubectl get all |
| 77 | + for i in {1..3}; do |
| 78 | + if kubectl wait pods --selector app.kubernetes.io/instance=test-nonha-nodeport --for condition=Ready --timeout=120s; then |
| 79 | + echo "Pods are ready." |
| 80 | + break |
| 81 | + else |
| 82 | + echo "Waiting for pods failed, retrying in 10 seconds..." |
| 83 | + kubectl describe pods --selector app.kubernetes.io/instance=test-nonha-nodeport |
| 84 | + sleep 10 |
| 85 | + fi |
| 86 | + done |
| 87 | + |
| 88 | + # Verify service type is NodePort |
| 89 | + kubectl get service test-nonha-nodeport-pubsubplus -o jsonpath='{.spec.type}' | grep "NodePort" |
| 90 | + |
| 91 | + # Verify nodePort values are set correctly |
| 92 | + SEMP_NODEPORT=$(kubectl get service test-nonha-nodeport-pubsubplus -o jsonpath='{.spec.ports[?(@.name=="tcp-semp")].nodePort}') |
| 93 | + SMF_NODEPORT=$(kubectl get service test-nonha-nodeport-pubsubplus -o jsonpath='{.spec.ports[?(@.name=="tcp-smf")].nodePort}') |
| 94 | + WEB_NODEPORT=$(kubectl get service test-nonha-nodeport-pubsubplus -o jsonpath='{.spec.ports[?(@.name=="tcp-web")].nodePort}') |
| 95 | + |
| 96 | + echo "SEMP NodePort: $SEMP_NODEPORT, Expected: 30080" |
| 97 | + echo "SMF NodePort: $SMF_NODEPORT, Expected: 30555" |
| 98 | + echo "WEB NodePort: $WEB_NODEPORT, Expected: 30008" |
| 99 | + |
| 100 | + [ "$SEMP_NODEPORT" = "30080" ] && echo "SEMP NodePort test passed" || echo "SEMP NodePort test failed" |
| 101 | + [ "$SMF_NODEPORT" = "30555" ] && echo "SMF NodePort test passed" || echo "SMF NodePort test failed" |
| 102 | + [ "$WEB_NODEPORT" = "30008" ] && echo "WEB NodePort test passed" || echo "WEB NodePort test failed" |
| 103 | + |
| 104 | + # Test connectivity through NodePort |
| 105 | + NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="ExternalIP")].address}') |
| 106 | + echo "Using node IP: $NODE_IP" |
| 107 | + |
| 108 | + # Test SMF connectivity directly through NodePort |
| 109 | + echo "Testing direct NodePort connection to $NODE_IP:$SMF_NODEPORT" |
| 110 | + curl -O https://sftp.solace.com/download/SDKPERF_C_LINUX64 |
| 111 | + tar -xvf SDKPERF_C_LINUX64 |
| 112 | + pubSubTools/sdkperf_c -cip=tcp://$NODE_IP:$SMF_NODEPORT -mn=1000 -mr=0 -ptl=t1 -stl=t1 | grep "Total Messages" |
| 113 | + |
| 114 | + kubectl delete eventbroker test-nonha-nodeport | grep deleted |
| 115 | +
|
| 116 | + - name: Delete broker deployment |
| 117 | + run: | |
| 118 | + kubectl delete ns $TESTNAMESPACE --ignore-not-found |
0 commit comments