From 964955f740c2b61bc5907cddb7b339e559100038 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Tue, 21 Feb 2023 13:37:11 +0200 Subject: [PATCH 1/6] update calls to binaries --- tests/nym-gateway-binary-check.sh | 50 ++++++++++++++--- tests/nym-mixnode-binary-check.sh | 93 ++++++++++++++++++++++++------- 2 files changed, 117 insertions(+), 26 deletions(-) diff --git a/tests/nym-gateway-binary-check.sh b/tests/nym-gateway-binary-check.sh index 7489553617..de1b71e5c4 100755 --- a/tests/nym-gateway-binary-check.sh +++ b/tests/nym-gateway-binary-check.sh @@ -9,30 +9,66 @@ RELEASE_DIRECTORY="target/release" VERSION_NUMBER=$1 WALLET_ADDRESS_CONST=n1435n84se65tn7yv536am0sfvng4yyrwj7thhxr MOCK_HOST="1.2.3.4" -OUTPUT=$(for i in {1..8}; do echo -n $(( $RANDOM % 10 )); done) +OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${OUTPUT}" +BINARY_NAME="nym-gateway" -echo "the version number is ${VERSION_NUMBER}" +echo "the version number is ${VERSION_NUMBER} to be installed from github" cd ${PWD}${RELEASE_DIRECTORY} -if [ -f nym-gateway ]; then +# steps +# we curl the existing binary from the release page of github +# we init the binary to check successful init +# then in our testing branch, we build the binary locally +# re run the init based upon the configuration injected +# we validate that no errors are return from upgrading the binary against the test + +# install the current release binary +# so this is dependant on running on a linux machine for the time being + +curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +chmod u+x $BINARY_NAME + +#-------------------------------------- +# functions +#-------------------------------------- + +check_gateway_binary_build() if [ -f nym-gateway ]; then echo "running init tests" # we wont use config env files for now # unless we want to use a specific environment - OUTPUT=$(./nym-gateway --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST}) > /dev/null 2>&1 - + OUTPUT=$(./nym-gateway --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST}) >/dev/null 2>&1 + # get jq values for things we can assert against VALUE=$(echo ${OUTPUT} | jq .wallet_address) VALUE=${VALUE#\"} VALUE=${VALUE%\"} - + + echo $OUTPUT + sleep 2 + # do asserts here based upon the output on init - assert $(cat ${VALUE}) $(echo ${WALLET_ADDRESS_CONST}) + assert $(echo ${VALUE}) $(echo ${WALLET_ADDRESS_CONST}) assert_end nym-gateway-tests else echo "exting test no binary found" fi +# we run the release version first +check_gateway_binary_build +# lets remove the binary then navigate to the target/release directory for checking the latest version +# expect to have successful output and configuration +if [ -f $BINARY_NAME ]; then + echo "removing nym-mixnode" + rm -rf $BINARY_NAME +else + echo "no binary found exiting" + exit 1 +fi + +# we should expect it to pass because no errors should be presented when performing the upgrade of an init +# this should be caught at testing staage +check_gateway_binary_build diff --git a/tests/nym-mixnode-binary-check.sh b/tests/nym-mixnode-binary-check.sh index 1e62b21318..35c2a5b9a2 100755 --- a/tests/nym-mixnode-binary-check.sh +++ b/tests/nym-mixnode-binary-check.sh @@ -4,31 +4,86 @@ PWD="../" RELEASE_DIRECTORY="target/release" -VERSION_NUMBER=$1 +RELEASE_VERSION_NUMBER=$1 WALLET_ADDRESS_CONST=n1435n84se65tn7yv536am0sfvng4yyrwj7thhxr MOCK_HOST="1.2.3.4" -OUTPUT=$(for i in {1..8}; do echo -n $(( $RANDOM % 10 )); done) +OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${OUTPUT}" +BINARY_NAME="nym-mixnode" -echo "the version number is ${VERSION_NUMBER}" +echo "the version number is ${VERSION_NUMBER} to be installed from github" -cd $PWD/$RELEASE_DIRECTORY +# steps +# we curl the existing binary from the release page of github +# we init the binary to check successful init +# then in our testing branch, we build the binary locally +# re run the init based upon the configuration injected +# we validate that no errors are return from upgrading the binary against the test -if [ -f nym-mixnode ]; then - echo "running init tests" - # we wont use config env files for now - OUTPUT=$(./nym-mixnode --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST}) > /dev/null 2>&1 - - # get jq values for things we can assert against - # tidy this bit up - okay for first push - VALUE=$(echo ${OUTPUT} | jq .wallet_address) - VALUE=${VALUE#\"} - VALUE=${VALUE%\"} - - # do asserts here based upon the output on init +# install the current release binary +# so this is dependant on running on a linux machine for the time being +curl -L "https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/${BINARY_NAME}" -o nym-mixnode +chmod u+x "$BINARY_NAME" - assert $(cat ${VALUE}) $(echo ${WALLET_ADDRESS_CONST}) - assert_end nym-mixnode-tests +#-------------------------------------- +# functions +#-------------------------------------- +check_mixnode_binary_build() { + if [ -f "$BINARY_NAME" ]; then + echo "running init tests" + # we wont use config env files for now + OUTPUT=$(./${BINARY_NAME} --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST} > /dev/null) + # get jq values for things we can assert against + # tidy this bit up - okay for first push + + VALUE="$(echo ${OUTPUT} | jq .wallet_address | tr -d '"')" + + # do asserts here based upon the output on init + assert "echo ${VALUE}" $(echo ${WALLET_ADDRESS_CONST}) + assert_end nym-mixnode-tests + else + echo "exiting test no binary found" + fi +} + +#------------------------------- +# tests +#------------------------------- + +# we run the release version first +check_mixnode_binary_build +# whoami +# this is dependant on where it runs on ci potentially, will need to tweak this in the future +first_init=$(cat /root/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =") + +#lets remove the binary then navigate to the target/release directory for checking the latest version +if [ -f "$BINARY_NAME" ]; then + echo "removing nym-mixnode" + rm -rf "$BINARY_NAME" + echo "successfully removed nym-mixnode" else - echo "exting test no binary found" + echo "no binary found exiting" + exit 1 +fi +# we should expect it to pass because no errors should be presented when performing the upgrade of an init +# this should be caught at testing stage +# navigate to latest binary build +cd $PWD$RELEASE_DIRECTORY +#re run against the current binary built locally +check_mixnode_binary_build + +echo "diff the config files after each init" +echo "-------------------------------------" + +second_init=$(cat /root/.nym/mixnodes/${ID}/config/config.toml | grep -v "^\[mixnode\]$" | grep -v "^version =") + +diff -w <(echo "$first_init") <(echo "$second_init") + +# check the status of the diff +if [ $? -eq 0 ]; then + echo "no differences in config files, exiting script" + exit 0 +else + echo "there are differences in the config files, it may require a fresh init on the binary" + exit 1 fi From 6ce743fbd55e37db06a1aa69580ee8e8bfcde378 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Tue, 21 Feb 2023 17:11:20 +0200 Subject: [PATCH 2/6] add the nym-client and tidy up the mixnode next up gateway, socks-5, network-requester --- tests/nym-client-binary-check.sh | 114 ++++++++++++++++++++++++++++++ tests/nym-mixnode-binary-check.sh | 20 ++++-- 2 files changed, 127 insertions(+), 7 deletions(-) create mode 100755 tests/nym-client-binary-check.sh diff --git a/tests/nym-client-binary-check.sh b/tests/nym-client-binary-check.sh new file mode 100755 index 0000000000..c54f40948c --- /dev/null +++ b/tests/nym-client-binary-check.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +set -e + +. assert.sh -v -x + +PWD="../" +RELEASE_DIRECTORY="target/release" +VERSION_NUMBER=$1 +OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) +ID="test-${OUTPUT}" +BINARY_NAME="nym-client" + +echo "the version number is ${VERSION_NUMBER} to be installed from github" + +cd ${PWD}${RELEASE_DIRECTORY} + +# steps +# we curl the existing binary from the release page of github +# we init the binary to check successful init +# then in our testing branch, we build the binary locally +# re run the init based upon the configuration injected +# we validate that no errors are return from upgrading the binary against the test + +# install the current release binary +# so this is dependant on running on a linux machine for the time being + +curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +chmod u+x $BINARY_NAME + +#---------------------------------------------------------------------------------------------------------- +# functions +#---------------------------------------------------------------------------------------------------------- + +check_nym_client_binary_build() if [ -f $BINARY_NAME ]; then + echo "running init tests" + ./${BINARY_NAME} init --id ${ID} --output-json >/dev/null 2>&1 + + # currently this outputs to a file name name + # we currently store the output in a file in the same directory + + if [ -f client_init_results.json ]; then + OUTPUT=$(cat client_init_results.json) + + # get jq values for things we can assert against + # until the service provider is provided in the output we can validate the id is correct on init + VALUE=$(echo ${OUTPUT} | jq .id) + VALUE=${VALUE#\"} + VALUE=${VALUE%\"} + + echo "${OUTPUT}" + sleep 2 + + # do asserts here based upon the output on init + + assert $(echo ${VALUE}) $(echo ${ID}) + assert_end nym-client-tests + else + echo "exting test no binary found" + fi +else + echo "exting test no binary found" +fi + +#---------------------------------------------------------------------------------------------------------- +# tests +#---------------------------------------------------------------------------------------------------------- +# we run the release version first + +check_nym_client_binary_build + +first_init=$(cat /root/.nym/clients/${ID}/config/config.toml | grep -v "^version =") + +#---------------------------------------------------------------------------------------------------------- +# lets remove the binary then navigate to the target/release directory for checking the latest version +# expect to have successful output and configuration +#---------------------------------------------------------------------------------------------------------- + +if [ -f $BINARY_NAME ]; then + echo "removing client binary" + rm -rf $BINARY_NAME +else + echo "no binary found exiting" + exit 1 +fi + +#---------------------------------------------------------------------------------------------------------- +# we should expect it to pass because no errors should be presented when performing the upgrade of an init +# this should be caught at testing stage - navigate to latest binary build +#---------------------------------------------------------------------------------------------------------- + +cd ${PWD}${RELEASE_DIRECTORY} + +# re-run against the current binary built locally + +echo "diff the config files after each init" +echo "-------------------------------------" + +check_nym_client_binary_build + +second_init=$(cat /root/.nym/clients/${ID}/config/config.toml | grep -v "^version =") + +diff -w <(echo "$first_init") <(echo "$second_init") + +# check the status of the diff +if [ $? -eq 0 ]; then + echo "no differences in config files, exiting script" + exit 0 +else + echo "there are differences in the config files, it may require a fresh init on the binary" + exit 1 +fi + +# we should expect it to pass because no errors should be presented when performing the upgrade of an init diff --git a/tests/nym-mixnode-binary-check.sh b/tests/nym-mixnode-binary-check.sh index 35c2a5b9a2..89a4a604b6 100755 --- a/tests/nym-mixnode-binary-check.sh +++ b/tests/nym-mixnode-binary-check.sh @@ -25,14 +25,15 @@ echo "the version number is ${VERSION_NUMBER} to be installed from github" curl -L "https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/${BINARY_NAME}" -o nym-mixnode chmod u+x "$BINARY_NAME" -#-------------------------------------- +#---------------------------------------------------------------------------------------------------------- # functions -#-------------------------------------- +#---------------------------------------------------------------------------------------------------------- + check_mixnode_binary_build() { if [ -f "$BINARY_NAME" ]; then echo "running init tests" # we wont use config env files for now - OUTPUT=$(./${BINARY_NAME} --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST} > /dev/null) + OUTPUT=$(./${BINARY_NAME} --output json init --id ${ID} --host ${MOCK_HOST} --wallet-address ${WALLET_ADDRESS_CONST} >/dev/null) # get jq values for things we can assert against # tidy this bit up - okay for first push @@ -46,9 +47,9 @@ check_mixnode_binary_build() { fi } -#------------------------------- +#---------------------------------------------------------------------------------------------------------- # tests -#------------------------------- +#---------------------------------------------------------------------------------------------------------- # we run the release version first check_mixnode_binary_build @@ -65,11 +66,16 @@ else echo "no binary found exiting" exit 1 fi + +#---------------------------------------------------------------------------------------------------------- # we should expect it to pass because no errors should be presented when performing the upgrade of an init -# this should be caught at testing stage -# navigate to latest binary build +# this should be caught at testing stage - navigate to latest binary build +#---------------------------------------------------------------------------------------------------------- + cd $PWD$RELEASE_DIRECTORY + #re run against the current binary built locally + check_mixnode_binary_build echo "diff the config files after each init" From 5813e9212b66076f018eb662b25e3a78a2bd6ad4 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Tue, 21 Feb 2023 17:34:34 +0200 Subject: [PATCH 3/6] adding socks-5-test --- tests/nym-socks-5-binary-check.sh | 116 ++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 tests/nym-socks-5-binary-check.sh diff --git a/tests/nym-socks-5-binary-check.sh b/tests/nym-socks-5-binary-check.sh new file mode 100755 index 0000000000..9433ed932c --- /dev/null +++ b/tests/nym-socks-5-binary-check.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +set -e + +. assert.sh -v -x + +PWD="../" +RELEASE_DIRECTORY="target/release" +VERSION_NUMBER=$1 +MOCK_SERVICE_PROVIDER="36cUqdggtdXixZhmXfyZm3Dep3Q5QsKVPotMrVSmS4oY.ZCCAdFPwPNSTtUMYveA62ttEFe8FDiB3cdheWHtCytX@6Lnxj9vD2YMtSmfe8zp5RBtj1uZLYQAFRxY9q7ANwrZz" +RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) +ID="test-${RANDOM_ID}" +BINARY_NAME="nym-socks5-client" + +echo "the version number is ${VERSION_NUMBER} to be installed from github" + +cd ${PWD}${RELEASE_DIRECTORY} + +# steps +# we curl the existing binary from the release page of github +# we init the binary to check successful init +# then in our testing branch, we build the binary locally +# re run the init based upon the configuration injected +# we validate that no errors are return from upgrading the binary against the test + +# install the current release binary +# so this is dependant on running on a linux machine for the time being + +curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +chmod u+x $BINARY_NAME + + +#---------------------------------------------------------------------------------------------------------- +# functions +#---------------------------------------------------------------------------------------------------------- + +check_nym_socks5_client_binary_build() if [ -f $BINARY_NAME ]; then + echo "running init tests" + ./${BINARY_NAME} init --id ${ID} --provider ${MOCK_SERVICE_PROVIDER} --output-json >/dev/null 2>&1 + + # currently this outputs to a file name name + # we currently store the output in a file in the same directory + + if [ -f "socks5_client_init_results.json" ]; then + OUTPUT=$(cat socks5_client_init_results.json) + + # get jq values for things we can assert against + # until the service provider is provided in the output we can validate the id is correct on init + VALUE=$(echo ${OUTPUT} | jq .id) + VALUE=${VALUE#\"} + VALUE=${VALUE%\"} + + echo "${OUTPUT}" + sleep 2 + + # do asserts here based upon the output on init + + assert $(echo ${VALUE}) $(echo ${ID}) + assert_end nym-client-tests + else + echo "exting test no binary found" + fi +else + echo "exting test no binary found" +fi + +#---------------------------------------------------------------------------------------------------------- +# tests +#---------------------------------------------------------------------------------------------------------- +# we run the release version first + +check_nym_socks5_client_binary_build + +first_init=$(cat /root/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =") + +#---------------------------------------------------------------------------------------------------------- +# lets remove the binary then navigate to the target/release directory for checking the latest version +# expect to have successful output and configuration +#---------------------------------------------------------------------------------------------------------- + +if [ -f $BINARY_NAME ]; then + echo "removing client binary" + rm -rf $BINARY_NAME +else + echo "no binary found exiting" + exit 1 +fi + +#---------------------------------------------------------------------------------------------------------- +# we should expect it to pass because no errors should be presented when performing the upgrade of an init +# this should be caught at testing stage - navigate to latest binary build +#---------------------------------------------------------------------------------------------------------- + +cd ${PWD}${RELEASE_DIRECTORY} + +# re-run against the current binary built locally + +echo "diff the config files after each init" +echo "-------------------------------------" + +check_nym_socks5_client_binary_build + +second_init=$(cat /root/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^version =") + +diff -w <(echo "$first_init") <(echo "$second_init") + +# check the status of the diff +if [ $? -eq 0 ]; then + echo "no differences in config files, exiting script" + exit 0 +else + echo "there are differences in the config files, it may require a fresh init on the binary" + exit 1 +fi + +# we should expect it to pass because no errors should be presented when performing the upgrade of an init From cc1c9a75b492e3d6d020a35cd880d78cd6628331 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Tue, 21 Feb 2023 17:35:11 +0200 Subject: [PATCH 4/6] remove file --- tests/socks5-binary-check.sh | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 tests/socks5-binary-check.sh diff --git a/tests/socks5-binary-check.sh b/tests/socks5-binary-check.sh deleted file mode 100755 index 74c27dbf69..0000000000 --- a/tests/socks5-binary-check.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -# TODO \ No newline at end of file From 73f3f8cfab3d6dd95519c8c51a0c67770b8c6161 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Thu, 23 Feb 2023 09:34:51 +0200 Subject: [PATCH 5/6] pushing changes --- tests/build_and_run.sh | 21 +++- tests/nym-gateway-binary-check.sh | 46 +++++++-- tests/nym-mixnode-binary-check.sh | 2 +- tests/nym-network-requester-binary-check.sh | 106 ++++++++++++++++++++ tests/nym-socks-5-binary-check.sh | 9 +- 5 files changed, 168 insertions(+), 16 deletions(-) create mode 100755 tests/nym-network-requester-binary-check.sh diff --git a/tests/build_and_run.sh b/tests/build_and_run.sh index f6ff95f3cd..765e053bf7 100755 --- a/tests/build_and_run.sh +++ b/tests/build_and_run.sh @@ -19,10 +19,27 @@ echo "working directory ${PWD}" cargo build --release --all #here there should be the applicable binaries to test inits - +echo "running mixnode binary check" ./nym-mixnode-binary-check.sh "$VERSION_NUMBER" sleep 2 echo "running gateway binary check" -#./nym-gateway-binary-check.sh "$VERSION_NUMBER" \ No newline at end of file +./nym-gateway-binary-check.sh "$VERSION_NUMBER" + +sleep 2 + +echo "running socks-5 binary check" +./nym-socks-5-binary-check.sh "$VERSION_NUMBER" + +sleep 2 + +echo "running network-requester binary check" +./nym-network-requester-binary-check.sh "$VERSION_NUMBER" + +sleep 2 + +echo "running client binary check" +./nym-client-binary-check.sh "$VERSION_NUMBER" + + diff --git a/tests/nym-gateway-binary-check.sh b/tests/nym-gateway-binary-check.sh index de1b71e5c4..a13798a96a 100755 --- a/tests/nym-gateway-binary-check.sh +++ b/tests/nym-gateway-binary-check.sh @@ -9,8 +9,8 @@ RELEASE_DIRECTORY="target/release" VERSION_NUMBER=$1 WALLET_ADDRESS_CONST=n1435n84se65tn7yv536am0sfvng4yyrwj7thhxr MOCK_HOST="1.2.3.4" -OUTPUT=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) -ID="test-${OUTPUT}" +RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) +ID="test-${RANDOM_ID}" BINARY_NAME="nym-gateway" echo "the version number is ${VERSION_NUMBER} to be installed from github" @@ -56,19 +56,49 @@ else echo "exting test no binary found" fi +#---------------------------------------------------------------------------------------------------------- +# tests +#---------------------------------------------------------------------------------------------------------- + # we run the release version first check_gateway_binary_build -# lets remove the binary then navigate to the target/release directory for checking the latest version -# expect to have successful output and configuration +# whoami +# this is dependant on where it runs on ci potentially, will need to tweak this in the future +first_init=$(cat /root/.nym/gateways/${ID}/config/config.toml | grep -v "^\[gateway\]$" | grep -v "^version =") -if [ -f $BINARY_NAME ]; then - echo "removing nym-mixnode" - rm -rf $BINARY_NAME +#lets remove the binary then navigate to the target/release directory for checking the latest version +if [ -f "$BINARY_NAME" ]; then + echo "removing nym-gateway" + rm -rf "$BINARY_NAME" + echo "successfully removed nym-gateway" else echo "no binary found exiting" exit 1 fi +#---------------------------------------------------------------------------------------------------------- # we should expect it to pass because no errors should be presented when performing the upgrade of an init -# this should be caught at testing staage +# this should be caught at testing stage - navigate to latest binary build +#---------------------------------------------------------------------------------------------------------- + +cd ${PWD}${RELEASE_DIRECTORY} + +#re run against the current binary built locally + check_gateway_binary_build + +echo "diff the config files after each init" +echo "-------------------------------------" + +second_init=$(cat /root/.nym/gateways/${ID}/config/config.toml | grep -v "^\[gateway\]$" | grep -v "^version =") + +diff -w <(echo "$first_init") <(echo "$second_init") + +# check the status of the diff +if [ $? -eq 0 ]; then + echo "no differences in config files, exiting script" + exit 0 +else + echo "there are differences in the config files, it may require a fresh init on the binary" + exit 1 +fi diff --git a/tests/nym-mixnode-binary-check.sh b/tests/nym-mixnode-binary-check.sh index 89a4a604b6..4acd3f997d 100755 --- a/tests/nym-mixnode-binary-check.sh +++ b/tests/nym-mixnode-binary-check.sh @@ -72,7 +72,7 @@ fi # this should be caught at testing stage - navigate to latest binary build #---------------------------------------------------------------------------------------------------------- -cd $PWD$RELEASE_DIRECTORY +cd ${PWD}${RELEASE_DIRECTORY} #re run against the current binary built locally diff --git a/tests/nym-network-requester-binary-check.sh b/tests/nym-network-requester-binary-check.sh new file mode 100755 index 0000000000..a82fe1284e --- /dev/null +++ b/tests/nym-network-requester-binary-check.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +set -e + +. assert.sh -v -x + +PWD="../" +RELEASE_DIRECTORY="target/release" +VERSION_NUMBER=$1 +RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) +ID="test-${RANDOM_ID}" +BINARY_NAME="nym-network-requester" + +echo "the version number is ${VERSION_NUMBER} to be installed from github" + +cd ${PWD}${RELEASE_DIRECTORY} + +# we have now the bundled the client into the network requester, more a less the same output as the client + +curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME +chmod u+x $BINARY_NAME + +#---------------------------------------------------------------------------------------------------------- +# functions +#---------------------------------------------------------------------------------------------------------- + +check_nym_network_requester_binary_build() if [ -f $BINARY_NAME ]; then + echo "running init tests" + ./${BINARY_NAME} init --id ${ID} --output-json >/dev/null 2>&1 + + # currently this outputs to a file name name + # we currently store the output in a file in the same directory + + if [ -f "client_init_results.json" ]; then + OUTPUT=$(cat client_init_results.json) + + # get jq values for things we can assert against + # until the service provider is provided in the output we can validate the id is correct on init + VALUE=$(echo ${OUTPUT} | jq .id) + VALUE=${VALUE#\"} + VALUE=${VALUE%\"} + + echo "${OUTPUT}" + sleep 2 + + # do asserts here based upon the output on init + + assert $(echo ${VALUE}) $(echo ${ID}) + assert_end nym-network-requester-tests + else + echo "exting test no binary found" + fi +else + echo "exting test no binary found" +fi + +#---------------------------------------------------------------------------------------------------------- +# tests +#---------------------------------------------------------------------------------------------------------- +# we run the release version first + +check_nym_network_requester_binary_build + +first_init=$(cat /root/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =") + +#---------------------------------------------------------------------------------------------------------- +# lets remove the binary then navigate to the target/release directory for checking the latest version +# expect to have successful output and configuration +#---------------------------------------------------------------------------------------------------------- + +if [ -f $BINARY_NAME ]; then + echo "removing nym-network-requester binary" + rm -rf $BINARY_NAME +else + echo "no binary found exiting" + exit 1 +fi + +#---------------------------------------------------------------------------------------------------------- +# we should expect it to pass because no errors should be presented when performing the upgrade of an init +# this should be caught at testing stage - navigate to latest binary build +#---------------------------------------------------------------------------------------------------------- + +cd ${PWD}${RELEASE_DIRECTORY} + +# re-run against the current binary built locally + +echo "diff the config files after each init" +echo "-------------------------------------" + +check_nym_network_requester_binary_build + +second_init=$(cat /root/.nym/service-providers/network-requester/${ID}/config/config.toml | grep -v "^version =") + +diff -w <(echo "$first_init") <(echo "$second_init") + +# check the status of the diff +if [ $? -eq 0 ]; then + echo "no differences in config files, exiting script" + exit 0 +else + echo "there are differences in the config files, it may require a fresh init on the binary" + exit 1 +fi + +# we should expect it to pass because no errors should be presented when performing the upgrade of an init diff --git a/tests/nym-socks-5-binary-check.sh b/tests/nym-socks-5-binary-check.sh index 9433ed932c..f8ba7807ee 100755 --- a/tests/nym-socks-5-binary-check.sh +++ b/tests/nym-socks-5-binary-check.sh @@ -10,7 +10,7 @@ VERSION_NUMBER=$1 MOCK_SERVICE_PROVIDER="36cUqdggtdXixZhmXfyZm3Dep3Q5QsKVPotMrVSmS4oY.ZCCAdFPwPNSTtUMYveA62ttEFe8FDiB3cdheWHtCytX@6Lnxj9vD2YMtSmfe8zp5RBtj1uZLYQAFRxY9q7ANwrZz" RANDOM_ID=$(for i in {1..8}; do echo -n $(($RANDOM % 10)); done) ID="test-${RANDOM_ID}" -BINARY_NAME="nym-socks5-client" +BINARY_NAME="nym-socks5-client" echo "the version number is ${VERSION_NUMBER} to be installed from github" @@ -29,7 +29,6 @@ cd ${PWD}${RELEASE_DIRECTORY} curl -L https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/$BINARY_NAME -o $BINARY_NAME chmod u+x $BINARY_NAME - #---------------------------------------------------------------------------------------------------------- # functions #---------------------------------------------------------------------------------------------------------- @@ -40,7 +39,7 @@ check_nym_socks5_client_binary_build() if [ -f $BINARY_NAME ]; then # currently this outputs to a file name name # we currently store the output in a file in the same directory - + if [ -f "socks5_client_init_results.json" ]; then OUTPUT=$(cat socks5_client_init_results.json) @@ -56,7 +55,7 @@ check_nym_socks5_client_binary_build() if [ -f $BINARY_NAME ]; then # do asserts here based upon the output on init assert $(echo ${VALUE}) $(echo ${ID}) - assert_end nym-client-tests + assert_end nym-socks-5-client-tests else echo "exting test no binary found" fi @@ -79,7 +78,7 @@ first_init=$(cat /root/.nym/socks5-clients/${ID}/config/config.toml | grep -v "^ #---------------------------------------------------------------------------------------------------------- if [ -f $BINARY_NAME ]; then - echo "removing client binary" + echo "removing socks-5-client binary" rm -rf $BINARY_NAME else echo "no binary found exiting" From ab2a9f24c33050eaed87650d76f485620d31d513 Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Thu, 23 Feb 2023 09:37:09 +0200 Subject: [PATCH 6/6] remove text --- tests/nym-client-binary-check.sh | 9 +-------- tests/nym-gateway-binary-check.sh | 7 ------- tests/nym-mixnode-binary-check.sh | 7 ------- tests/nym-socks-5-binary-check.sh | 7 ------- 4 files changed, 1 insertion(+), 29 deletions(-) diff --git a/tests/nym-client-binary-check.sh b/tests/nym-client-binary-check.sh index c54f40948c..ef22d439cd 100755 --- a/tests/nym-client-binary-check.sh +++ b/tests/nym-client-binary-check.sh @@ -15,13 +15,6 @@ echo "the version number is ${VERSION_NUMBER} to be installed from github" cd ${PWD}${RELEASE_DIRECTORY} -# steps -# we curl the existing binary from the release page of github -# we init the binary to check successful init -# then in our testing branch, we build the binary locally -# re run the init based upon the configuration injected -# we validate that no errors are return from upgrading the binary against the test - # install the current release binary # so this is dependant on running on a linux machine for the time being @@ -38,7 +31,7 @@ check_nym_client_binary_build() if [ -f $BINARY_NAME ]; then # currently this outputs to a file name name # we currently store the output in a file in the same directory - + if [ -f client_init_results.json ]; then OUTPUT=$(cat client_init_results.json) diff --git a/tests/nym-gateway-binary-check.sh b/tests/nym-gateway-binary-check.sh index a13798a96a..5c8df30fb8 100755 --- a/tests/nym-gateway-binary-check.sh +++ b/tests/nym-gateway-binary-check.sh @@ -17,13 +17,6 @@ echo "the version number is ${VERSION_NUMBER} to be installed from github" cd ${PWD}${RELEASE_DIRECTORY} -# steps -# we curl the existing binary from the release page of github -# we init the binary to check successful init -# then in our testing branch, we build the binary locally -# re run the init based upon the configuration injected -# we validate that no errors are return from upgrading the binary against the test - # install the current release binary # so this is dependant on running on a linux machine for the time being diff --git a/tests/nym-mixnode-binary-check.sh b/tests/nym-mixnode-binary-check.sh index 4acd3f997d..b670113c0d 100755 --- a/tests/nym-mixnode-binary-check.sh +++ b/tests/nym-mixnode-binary-check.sh @@ -13,13 +13,6 @@ BINARY_NAME="nym-mixnode" echo "the version number is ${VERSION_NUMBER} to be installed from github" -# steps -# we curl the existing binary from the release page of github -# we init the binary to check successful init -# then in our testing branch, we build the binary locally -# re run the init based upon the configuration injected -# we validate that no errors are return from upgrading the binary against the test - # install the current release binary # so this is dependant on running on a linux machine for the time being curl -L "https://github.com/nymtech/nym/releases/download/nym-binaries-${RELEASE_VERSION_NUMBER}/${BINARY_NAME}" -o nym-mixnode diff --git a/tests/nym-socks-5-binary-check.sh b/tests/nym-socks-5-binary-check.sh index f8ba7807ee..b818db3b9a 100755 --- a/tests/nym-socks-5-binary-check.sh +++ b/tests/nym-socks-5-binary-check.sh @@ -16,13 +16,6 @@ echo "the version number is ${VERSION_NUMBER} to be installed from github" cd ${PWD}${RELEASE_DIRECTORY} -# steps -# we curl the existing binary from the release page of github -# we init the binary to check successful init -# then in our testing branch, we build the binary locally -# re run the init based upon the configuration injected -# we validate that no errors are return from upgrading the binary against the test - # install the current release binary # so this is dependant on running on a linux machine for the time being