From 5237d6bbf6071b44658515dcdfd43cbe13bfd1a2 Mon Sep 17 00:00:00 2001 From: Starttoaster Date: Wed, 25 Sep 2024 07:48:20 -0700 Subject: [PATCH 1/2] Add chia-healthcheck and chia-exporter to smoke test fulL_node --- .github/workflows/smoke.yml | 42 +++++++++++++++++++++++++++++++++++++ tests/chianode.yaml | 6 ++++++ 2 files changed, 48 insertions(+) diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index e5105cd..8089edc 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -85,6 +85,30 @@ jobs: exit 1 fi + - name: Wait for Ready ChiaNode + run: | + found=0 + timeout=600 + endtime=$((SECONDS+timeout)) + while [ $SECONDS -lt $endtime ]; do + ready_status=$(kubectl get pod chianode-test-node-0 -o=jsonpath='{.status.containerStatuses[*].ready}') + statuses_grep_false=$(echo "$ready_status" | grep false) + if [ "$statuses_grep_false" = "" ]; then + echo "All containers in Pod are ready: $ready_status" + found=1 + break + else + echo "Container ready states: $ready_status. Waiting... ${SECONDS}/${endtime}" + fi + sleep 5 + done + if [ "$found" -eq 0 ]; then + echo "Timeout reached waiting for ChiaNode containers to enter Ready status." + echo "Getting Kubernetes Pods from the default namespace:" + kubectl get pods + exit 1 + fi + - name: Check to make sure ChiaNode peer Service has one endpoint run: | service_endpoints_number=$(kubectl get endpoints chianode-test-node -o json | jq '.subsets[].addresses | length') @@ -138,3 +162,21 @@ jobs: exit 1 fi echo "Expected 1 endpoint, found $service_endpoints_number" + + - name: Check to make sure ChiaNode exporter Service has one endpoint + run: | + service_endpoints_number=$(kubectl get endpoints chianode-test-node-metrics -o json | jq '.subsets[].addresses | length') + if [ "$service_endpoints_number" -ne 1 ]; then + echo "ChiaNode exporter Service was found to have $service_endpoints_number endpoints, expected 1" + exit 1 + fi + echo "Expected 1 endpoint, found $service_endpoints_number" + + - name: Check to make sure ChiaNode healthcheck Service has one endpoint + run: | + service_endpoints_number=$(kubectl get endpoints chianode-test-node-healthcheck -o json | jq '.subsets[].addresses | length') + if [ "$service_endpoints_number" -ne 1 ]; then + echo "ChiaNode healthcheck Service was found to have $service_endpoints_number endpoints, expected 1" + exit 1 + fi + echo "Expected 1 endpoint, found $service_endpoints_number" diff --git a/tests/chianode.yaml b/tests/chianode.yaml index 7273ff8..e0c9c7b 100644 --- a/tests/chianode.yaml +++ b/tests/chianode.yaml @@ -9,6 +9,12 @@ spec: testnet: true timezone: "UTC" logLevel: "INFO" + chiaExporter: + enabled: true + chiaHealthcheck: + enabled: true + service: + enabled: true storage: chiaRoot: persistentVolumeClaim: From d5c821c78636bcc5dee06b1c8e4d16e010f23a3c Mon Sep 17 00:00:00 2001 From: Starttoaster Date: Wed, 25 Sep 2024 07:57:13 -0700 Subject: [PATCH 2/2] Add check if kubectl command just failed --- .github/workflows/smoke.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 8089edc..24563de 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -91,15 +91,19 @@ jobs: timeout=600 endtime=$((SECONDS+timeout)) while [ $SECONDS -lt $endtime ]; do - ready_status=$(kubectl get pod chianode-test-node-0 -o=jsonpath='{.status.containerStatuses[*].ready}') - statuses_grep_false=$(echo "$ready_status" | grep false) - if [ "$statuses_grep_false" = "" ]; then - echo "All containers in Pod are ready: $ready_status" - found=1 - break + ready_status=$(kubectl get pod chianode-test-node-0 -o=jsonpath='{.status.containerStatuses[*].ready}' || true) + if [ "$ready_status" != "" ]; then + statuses_grep_false=$(echo "$ready_status" | grep false) + if [ "$statuses_grep_false" = "" ]; then + echo "All containers in Pod are ready: $ready_status" + found=1 + break + else + echo "Container ready states: $ready_status. Waiting... ${SECONDS}/${endtime}" + fi else - echo "Container ready states: $ready_status. Waiting... ${SECONDS}/${endtime}" - fi + echo "kubectl command failed this iteration, sleeping until next iteration... ${SECONDS}/${endtime}" + fi sleep 5 done if [ "$found" -eq 0 ]; then