#!/usr/bin/env bash GIT_ROOT=$(git rev-parse --show-toplevel) # write path to repo echo "$GIT_ROOT" > "$GIT_ROOT/tests/resources/path_to_repo" # create or update a VM, start it and wait for successful ping start_vm () { if [ -d "/var/lib/microvms/abra-$1" ]; then make "vm-$1-update" else make "vm-$1-create" fi make "vm-$1-start" host_available=0 while [ $host_available == 0 ]; do if ping -c 1 "$2" &> /dev/null then host_available=1 else echo "could not ping $1, waiting for 5 seconds..." sleep 5 fi done } start_vm "client" "10.0.0.2" start_vm "server" "10.0.0.3" # revert dynamic content of file to prevent commiting changes git restore -- "$GIT_ROOT/tests/resources/path_to_repo" read -rp "Press enter to run all tests or specify test files: " TEST_INTEGRATION_FILES # -t option is needed for stdin output that is checked in integration tests # sleep is needed because adding ssh key sometimes does not find agent when adding without timeout ssh -t abra@10.0.0.2 -i "$GIT_ROOT/tests/resources/local_integration_ssh" "cd abra; sleep 5; chmod 600 ./tests/resources/local_integration_ssh; ssh-add ./tests/resources/local_integration_ssh; make test-integration TEST_INTEGRATION_FILES=$TEST_INTEGRATION_FILES"