diff --git a/tests/end2end_tests/contexts/sshnpd/test.sh b/tests/end2end_tests/contexts/sshnpd/test.sh old mode 100644 new mode 100755 diff --git a/tests/end2end_tests/entrypoints/sshnp_entrypoint.sh b/tests/end2end_tests/entrypoints/sshnp_entrypoint.sh index 4ca29872e..0bf8feaca 100644 --- a/tests/end2end_tests/entrypoints/sshnp_entrypoint.sh +++ b/tests/end2end_tests/entrypoints/sshnp_entrypoint.sh @@ -1,25 +1,37 @@ #!/bin/bash echo "SSHNP START ENTRY" SSHNP_COMMAND="$HOME/.local/bin/sshnp -f @sshnpatsign -t @sshnpdatsign -d deviceName -h @sshrvdatsign -s id_ed25519.pub -v > sshnp.log" -echo "Running: $SSHNP_COMMAND" -eval "$SSHNP_COMMAND" -cat sshnp.log -tail -n 5 sshnp.log | grep "ssh -p" > sshcommand.txt -if [ ! -s sshcommand.txt ]; then - # try again +run_test() +{ echo "Running: $SSHNP_COMMAND" eval "$SSHNP_COMMAND" cat sshnp.log - tail -n 5 sshnp.log | grep "ssh -p" > sshcommand.txt + tail -n 20 sshnp.log | grep "ssh -p" > sshcommand.txt + + # if sshcommand is empty, exit code 1 if [ ! -s sshcommand.txt ]; then - echo "could not find 'ssh -p' command in sshnp.log" - echo "last 5 lines of sshnp.log:" - tail -n 5 sshnp.log || echo - exit 1 + echo "sshcommand.txt is empty" + return 1 fi -fi -echo "$(sed '1!d' sshcommand.txt) -o StrictHostKeyChecking=no " > sshcommand.txt ; -echo "ssh -p command: $(cat sshcommand.txt)" -echo "sh test.sh " | eval "$(cat sshcommand.txt)" -sleep 2 # time for ssh connection to properly exit + + sed '1!d' sshcommand.txt + echo "ssh -p command: $(cat sshcommand.txt)" + echo "./test.sh " | eval "$(cat sshcommand.txt)" + sleep 2 # time for ssh connection to properly exit +} + +main() +{ + # run test 3 times, while run_test is not successful + for i in {1..3} + do + run_test + if [ $? -eq 0 ]; then + exit 0 + fi + sleep 5 + done +} + +main