Skip to content

Commit

Permalink
Pin test runner to ubuntu-20.04 (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
kke authored Nov 23, 2022
1 parent ef82f84 commit 026d077
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [pull_request]
jobs:

build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: install test dependencies
run: |
Expand Down
12 changes: 9 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@ $(footloose):
rm -f .ssh/identity
ssh-keygen -t $(KEY_TYPE) -b $(KEY_SIZE) -f .ssh/identity -N $(KEY_PASSPHRASE)

.PHONY: docker-network
docker-network:
docker network inspect footloose-cluster || docker network create footloose-cluster --subnet 172.16.86.0/24 --gateway 172.16.86.1 --attachable

footloose.yaml: .ssh/identity $(footloose)
$(footloose) config create \
--config footloose.yaml \
--image quay.io/footloose/ubuntu18.04 \
--name rigtest \
--key .ssh/identity \
--replicas $(REPLICAS) \
--override
--networks footloose-cluster \
--override \
--replicas $(REPLICAS)

.PHONY: create-host
create-host: footloose.yaml
create-host: footloose.yaml docker-network
$(footloose) create -c footloose.yaml

.PHONY: delete-host
Expand All @@ -58,6 +63,7 @@ delete-host: footloose.yaml
clean: delete-host
rm -f footloose.yaml identity rigtest
rm -rf .ssh
docker network rm footloose-cluster || true

.PHONY: sshport
sshport:
Expand Down
33 changes: 29 additions & 4 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@ ssh_port() {
footloose show $1 -o json|grep hostPort|grep -oE "[0-9]+"
}

sanity_check() {
color_echo "- Testing footloose machine connection"
make create-host
echo "* Footloose status"
footloose status
echo "* Docker ps"
docker ps
echo "* SSH port: $(ssh_port node0)"
echo "* Testing stock ssh"
ssh -vvv -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i .ssh/identity -p $(ssh_port node0) root@127.0.0.1 echo "test-conn"
set +e
echo "* Testing footloose ssh"
footloose ssh root@node0 echo test-conn | grep -q test-conn
local exit_code=$?
set -e
make clean
return $exit_code
}


rig_test_agent_with_public_key() {
color_echo "- Testing connection using agent and providing a path to public key"
make create-host
Expand All @@ -28,12 +48,12 @@ rig_test_agent_with_public_key() {

rig_test_agent_with_private_key() {
color_echo "- Testing connection using agent and providing a path to protected private key"
make create-host KEY_PASSPHRASE=foo
make create-host KEY_PASSPHRASE=testPhrase
eval $(ssh-agent -s)
expect -c '
spawn ssh-add .ssh/identity
expect "?:"
send "foo\n"
send "testPhrase\n"
expect eof"
'
set +e
Expand Down Expand Up @@ -90,7 +110,7 @@ rig_test_key_from_path() {

rig_test_protected_key_from_path() {
color_echo "- Testing regular keypath to encrypted key, two hosts"
make create-host KEY_PASSPHRASE=foo REPLICAS=2
make create-host KEY_PASSPHRASE=testPhrase REPLICAS=2
set +e
ssh_port node0 > .ssh/port_A
ssh_port node1 > .ssh/port_B
Expand All @@ -105,14 +125,19 @@ rig_test_protected_key_from_path() {
spawn ./rigtest -host 127.0.0.1:$PORTA,127.0.0.1:$PORTB -user root -keypath .ssh/identity -askpass true
expect "Password:"
send "foo\n"
send "testPhrase\n"
expect eof"
' $port1 $port2
local exit_code=$?
set -e
return $exit_code
}

if ! sanity_check; then
echo "Sanity check failed"
exit 1
fi

for test in $(declare -F|grep rig_test_|cut -d" " -f3); do
if [ "$FOCUS" != "" ] && [ "$FOCUS" != "$test" ]; then
continue
Expand Down

0 comments on commit 026d077

Please sign in to comment.