From d662d3fbae176d6bd31860b96697688353b540af Mon Sep 17 00:00:00 2001 From: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:06:40 -0600 Subject: [PATCH] fix: use "double fork" to invoke port forward within Taskfile (#1148) Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 25 ++++++++++----------- Taskfile.helper.yml | 11 +++++---- src/commands/mirror_node.ts | 2 +- src/commands/relay.ts | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 199d714a4..401e39e60 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -11,14 +11,6 @@ set -eo pipefail source .github/workflows/script/helper.sh -function enable_port_forward () -{ - kubectl port-forward -n solo-e2e svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 & - kubectl port-forward -n solo-e2e svc/hedera-explorer 8080:80 > /dev/null 2>&1 & - kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 & - kubectl port-forward -n solo-e2e svc/mirror-grpc 5600:5600 > /dev/null 2>&1 & -} - function clone_smart_contract_repo () { echo "Clone hedera-smart-contracts" @@ -50,6 +42,17 @@ function setup_smart_contract_test () cd - } +function check_port_forward () +{ + # run background task for few minutes + for i in {1..20} + do + echo "Check port forward" + ps -ef |grep port-forward + sleep 5 + done & +} + function start_background_transactions () { echo "Start background transaction" @@ -83,17 +86,13 @@ function start_sdk_test () return $result } -echo "Restart port-forward" -task clean:port-forward -enable_port_forward - - echo "Change to parent directory" cd ../ create_test_account clone_smart_contract_repo setup_smart_contract_test start_background_transactions +check_port_forward start_contract_test start_sdk_test echo "Sleep a while to wait background transactions to finish" diff --git a/Taskfile.helper.yml b/Taskfile.helper.yml index 8ad6dee20..8b7dcdccd 100644 --- a/Taskfile.helper.yml +++ b/Taskfile.helper.yml @@ -221,9 +221,8 @@ tasks: SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node start --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} ${DEBUG_NODE_FLAG} -q {{ .CLI_ARGS }} --dev - | if [[ "{{ .use_port_forwards }}" == "true" ]];then - echo "Enable port forwarding for Hedera Network Node" echo "Port forwarding for Hedera Network Node: grpc:50211" - nohup kubectl port-forward -n "${SOLO_NAMESPACE}" pod/network-node1-0 50211:50211 < /dev/null > {{.temp_prefix}}-50211-nohup.out 2>&1 & + /bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 &" sleep 4 fi @@ -245,7 +244,7 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera JSON RPC Relay" - nohup kubectl port-forward -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 & + /bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 &" sleep 4 fi @@ -426,10 +425,10 @@ tasks: if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera Explorer & Mirror Node Network" echo "Port forwarding for Hedera Explorer: http://localhost:6789" - nohup kubectl port-forward -n "${SOLO_NAMESPACE}" svc/hedera-explorer 6789:80 < /dev/null > {{.temp_prefix}}-6789-nohup.out 2>&1 & + /bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/hedera-explorer 8080:80 > /dev/null 2>&1 &" echo "Port forwarding for Mirror Node Network: grpc:5600, rest:5551" - nohup kubectl port-forward svc/mirror-grpc -n "${SOLO_NAMESPACE}" 5600:5600 < /dev/null > {{.temp_prefix}}-5600-nohup.out 2>&1 & - nohup kubectl port-forward svc/mirror-rest -n "${SOLO_NAMESPACE}" 5551:80 < /dev/null > {{.temp_prefix}}-5551-nohup.out 2>&1 & + /bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/mirror-grpc 5600:5600 > /dev/null 2>&1 &" + /bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/mirror-rest 5551:80 > /dev/null 2>&1 &" sleep 4 fi diff --git a/src/commands/mirror_node.ts b/src/commands/mirror_node.ts index c27789c8a..51dbf9a87 100644 --- a/src/commands/mirror_node.ts +++ b/src/commands/mirror_node.ts @@ -675,7 +675,7 @@ export class MirrorNodeCommand extends BaseCommand { .command({ command: 'destroy', desc: 'Destroy mirror-node components and database', - builder: y => flags.setCommandFlags(y, flags.chartDirectory, flags.force, flags.namespace), + builder: y => flags.setCommandFlags(y, flags.chartDirectory, flags.force, flags.quiet, flags.namespace), handler: argv => { self.logger.info("==== Running 'mirror-node destroy' ==="); self.logger.info(argv); diff --git a/src/commands/relay.ts b/src/commands/relay.ts index ede47a104..5754984f4 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -418,7 +418,7 @@ export class RelayCommand extends BaseCommand { command: 'destroy', desc: 'Destroy JSON RPC relay', builder: (y: any) => - flags.setCommandFlags(y, flags.chartDirectory, flags.namespace, flags.nodeAliasesUnparsed), + flags.setCommandFlags(y, flags.chartDirectory, flags.namespace, flags.quiet, flags.nodeAliasesUnparsed), handler: (argv: any) => { self.logger.info("==== Running 'relay destroy' ===", {argv}); self.logger.debug(argv);