Skip to content

Commit

Permalink
chore: remove gateway test from BATS (#686)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Tang <[email protected]>
  • Loading branch information
JeffreyDallas authored Jan 29, 2024
1 parent 0599dd1 commit cb38dc5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 99 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/zxc-helm-chart-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ jobs:
# nmt-install.sh uses ubi8-init-dind image
scriptName: [ direct-install.sh, nmt-install.sh ]
steps:
- name: Setup Make
run: |
if ! command -v make >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y make
fi
- name: Get changed files related to charts
id: changed-files
uses: tj-actions/changed-files@90a06d6ba9543371ab4df8eeca0be07ca6054959 #v42.0.2
with:
files: |
files_yaml: |
chart:
- charts/**
scripts:
Expand All @@ -72,7 +78,7 @@ jobs:
echo ""
echo "Modified script files"
echo "-------------------------------------------------------------------"
for file in ${{ steps.changed-files.outputs.script_all_changed_files }}; do
for file in ${{ steps.changed-files.outputs.scripts_all_changed_files }}; do
echo " - ${file} was changed"
done
echo ""
Expand Down
17 changes: 11 additions & 6 deletions charts/fullstack-deployment/tests/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Helm Chart Tests
## Pre-requisites

Install `yq` from this link: [yq](https://github.com/mikefarah/yq/#install)

## Helm Chart Tests
This directory contains the BATS tests for helm chart.

`run.sh` is the entrypoint to execute the tests locally assuming
you have the network deployed already.

## Development
## How to create and debug test
- Use the `test_basic_deployment.bats` file as the template while creating new tests.
- In order to run and debug the tests inside the helm test container, do the following:

Expand All @@ -26,11 +30,12 @@ you have the network deployed already.
- Once debug is done, you can exit and use Ctrl+C to terminate the helm-test process (you will need to delete the `network-test` container using `kubectl delete network-test`).
- If it looks all good, revert changes in `charts/fullstack-deployment/template/tests/test-deployment.yaml`

## Run
## How to run the tests
- Goto folder `full-stack-testing/charts/fullstack-deployment/tests`
- Run `git submodule update --init` in order to install [bats](https://github.com/bats-core) for tests.
- Create a .env file in this directory from the `env.template` file
- From `dev` folder run `make deploy-network`
- Once network is deployed, you can run `./run.sh` to run the tests.
- Create a .env file in this directory by copying from the `env.template` file
- From `full-stack-testing/dev` folder run the follow command `make setup setup-cluster deploy-network` to create cluster and deploy network.
- Once network is deployed, you can run `./run.sh` from `tests` directory to run the tests. It will create a log file under `logs` directory.
- When tests are working, then redeploy and run the helm tests: `make destroy-network deploy-network helm-test`

## Notes
Expand Down
78 changes: 0 additions & 78 deletions charts/fullstack-deployment/tests/test_gateway_api_deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,84 +4,6 @@ setup() {
source "${TESTS_DIR}/load.sh"
}

@test "Check Envoy Proxy GRPC-Web routes" {
log_debug "----------------------------------------------------------------------------"
log_debug "TEST: Checking Envoy Proxy GRPC-Web Route"
log_debug "----------------------------------------------------------------------------"

local resp="$(get_pod_list network-node)"
local pods=(${resp}) # convert into an array
log_debug "Network nodes: ${pods[*]}"

local test_status="${FAIL}"
local status_val="${EX_ERR}"
if [[ "${#pods[@]}" -gt 0 ]]; then
test_status="${PASS}"
for pod in "${pods[@]}"; do
log_debug ""
local node_name=$(get_pod_label "${pod}" "fullstack.hedera.com/node-name")
[[ -z "${node_name}" ]] && test_status="${FAIL}" && break

local route_name="envoy-grpc-web-route-${node_name}"
local is_enabled=$(is_enabled_for_node "${node_name}" ".envoyProxy.enabled")
if [ "${is_enabled}" = "TRUE" ]; then
log_debug "EnvoyProxy enabled for node '${node_name}'"
log_debug "Checking Envoy proxy httproute '${route_name}'"
is_route_accepted "httproute" "${route_name}" || test_status="${FAIL}"
[ "${test_status}" = "FAIL" ] && break
else
log_debug "EnvoyProxy is not enabled for node '${node_name}'. Skipped route check for '${route_name}'."
fi
done
fi

log_debug ""
log_debug "[${test_status}] Envoy Proxy GRPC-Web Route Check"
log_debug ""

# assert success
[[ "${test_status}" = "${PASS}" ]]
}

@test "Check HAProxy GRPC routes" {
log_debug "----------------------------------------------------------------------------"
log_debug "TEST: Checking HAProxy GRPC Route"
log_debug "----------------------------------------------------------------------------"

local resp="$(get_pod_list network-node)"
local pods=(${resp}) # convert into an array
log_debug "Network nodes: ${pods[*]}"

local test_status="${FAIL}"
local status_val="${EX_ERR}"
if [[ "${#pods[@]}" -gt 0 ]]; then
test_status="${PASS}"
for pod in "${pods[@]}"; do
log_debug ""
local node_name=$(get_pod_label "${pod}" "fullstack.hedera.com/node-name")
[[ -z "${node_name}" ]] && test_status="${FAIL}" && break

local route_name="haproxy-grpc-route-${node_name}"
local is_enabled=$(is_enabled_for_node "${node_name}" ".haproxy.enabled")
if [ "${is_enabled}" = "TRUE" ]; then
log_debug "HAProxy enabled for node '${node_name}'"
log_debug "Checking HAProxy GRPC route '${route_name}'"
is_route_accepted "tcproute" "${route_name}" || test_status="${FAIL}"
[ "${test_status}" = "FAIL" ] && break
else
log_debug "HAProxy is not enabled for node '${node_name}'. Skipped route check for '${route_name}'."
fi
done
fi

log_debug ""
log_debug "[${test_status}] HAProxy GRPC Route Check"
log_debug ""

# assert success
[[ "${test_status}" = "${PASS}" ]]
}

@test "Check Network Node GRPC routes" {
log_debug "----------------------------------------------------------------------------"
log_debug "TEST: Checking Network Node GRPC Route"
Expand Down
11 changes: 2 additions & 9 deletions dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ init-shared:
echo "cloud:" > ${CLUSTER_SETUP_VALUES_FILE}

.PHONY: deploy-shared
deploy-shared: init-shared update-helm-dependencies enable-gateway-api enable-prometheus-stack-if-required enable-minio-operator-if-required
deploy-shared: init-shared update-helm-dependencies enable-prometheus-stack-if-required enable-minio-operator-if-required
source "${SCRIPTS_DIR}/main.sh" && deploy_shared # run only after gateway-api CRDs are available

.PHONY: destroy-shared
Expand Down Expand Up @@ -152,13 +152,6 @@ restart: stop-nodes start-nodes
.PHONY: reset
reset: destroy-network start

######################################### Gateway API #################################
.PHONY: enable-gateway-api
enable-gateway-api:
@echo ">> Enabling envoy gateway..."; \
echo " envoyGateway:" >> ${CLUSTER_SETUP_VALUES_FILE}; \
echo " enabled: true" >> ${CLUSTER_SETUP_VALUES_FILE};

######################################### Telemetry #################################
.PHONY: enable-prometheus-stack-if-required
enable-prometheus-stack-if-required:
Expand All @@ -185,7 +178,7 @@ destroy-grafana-tempo:
source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && unexpose_grafana && destroy_grafana_tempo

.PHONY: deploy-prometheus
deploy-prometheus: init-shared enable-gateway-api enable-prometheus-stack
deploy-prometheus: init-shared enable-prometheus-stack
source "${SCRIPTS_DIR}/main.sh" && deploy_shared # run only after gateway-api CRDs are available
-$(MAKE) wait-for-prometheus-operator
source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && deploy-prometheus && expose_prometheus
Expand Down
2 changes: 0 additions & 2 deletions dev/scripts/gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ function get_gateway_status() {
helm list --all-namespaces | grep envoy-gateway
echo "-----------------------Gateway CRDs------------------------------------------------------------------------------"
kubectl get crd
echo "-----------------------Gateway Class------------------------------------------------------------------------------"
kubectl get gatewayclass
echo "-----------------------Gateway------------------------------------------------------------------------------"
kubectl get gateway
echo "-----------------------HTTPRoute------------------------------------------------------------------------------"
Expand Down
2 changes: 0 additions & 2 deletions dev/scripts/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function deploy_fullstack_cluster_setup_chart() {

echo "-----------------------Shared Resources------------------------------------------------------------------------------"
kubectl get clusterrole "${POD_MONITOR_ROLE}" -o wide
kubectl get gatewayclass
echo ""

log_time "deploy_fullstack_cluster_setup_chart"
Expand All @@ -74,7 +73,6 @@ function destroy_fullstack_cluster_setup_chart() {

echo "-----------------------Shared Resources------------------------------------------------------------------------------"
kubectl get clusterrole "${POD_MONITOR_ROLE}" -o wide
kubectl get gatewayclass
echo ""

log_time "destroy_fullstack_cluster_setup_chart"
Expand Down

0 comments on commit cb38dc5

Please sign in to comment.