diff --git a/sshpiperd/e2e/docker-compose.yml b/sshpiperd/e2e/docker-compose.yml index bbcab316..06011c6c 100644 --- a/sshpiperd/e2e/docker-compose.yml +++ b/sshpiperd/e2e/docker-compose.yml @@ -1,23 +1,6 @@ version: '3' services: - client: - image: rsalian/centos-sshpass - volumes: - - workingdir:/workingdir - - localkey:/local - - host1ssh:/host1 - - names:/names - - ./test.sh:/test.sh - links: - - "piper:piper" - - "piper_mysql:piper_mysql" - command: - - "/bin/bash" - - "/test.sh" - depends_on: - - piper - - piper_mysql host1: image: rastasheep/ubuntu-sshd volumes: @@ -27,6 +10,27 @@ services: image: rastasheep/ubuntu-sshd volumes: - names:/names + client: + image: valudio/docker-sshpass + volumes: + - workingdir:/workingdir + - localkey:/local + - host1ssh:/host1 + - names:/names + - ./test.sh:/test.sh + - ./wait.sh:/wait.sh + links: + - "piper:piper" + - "piper_sqlite:piper_sqlite" + - "piper_mysql:piper_mysql" + - "piper_pg:piper_pg" + command: + - "/bin/sh" + - "/test.sh" + depends_on: + - piper + - piper_mysql + - piper_pg piper: environment: - "SSHPIPERD_UPSTREAM_WORKINGDIR_NOCHECKPERM=true" @@ -39,6 +43,26 @@ services: volumes: - workingdir:/var/sshpiper - ./piper.sh:/piper.sh + - ./wait.sh:/wait.sh + command: + - "/bin/sh" + - "/piper.sh" + depends_on: + - host1 + - host2 + piper_sqlite: + environment: + - "SSHPIPERD_UPSTREAM_DRIVER=sqlite" + - "SSHPIPERD_AUDITOR=typescript-logger" + - "SSHPIPERD_BANNERTEXT=hellopiper" + build: ../.. + links: + - "host1:host1" + - "host2:host2" + volumes: + - workingdir:/var/sshpiper + - ./piper.sh:/piper.sh + - ./wait.sh:/wait.sh command: - "/bin/sh" - "/piper.sh" @@ -47,6 +71,8 @@ services: - host2 piper_mysql: environment: + - "WAIT_HOST=mysql" + - "WAIT_PORT=3306" - "SSHPIPERD_UPSTREAM_DRIVER=mysql" - "SSHPIPERD_UPSTREAM_MYSQL_HOST=mysql" - "SSHPIPERD_AUDITOR=typescript-logger" @@ -59,6 +85,7 @@ services: volumes: - ./piper.sh:/piper.sh - workingdir:/var/sshpiper + - ./wait.sh:/wait.sh command: - "/bin/sh" - "/piper.sh" @@ -73,6 +100,37 @@ services: - "MYSQL_DATABASE=sshpiper" tmpfs: - /var/lib/mysql + piper_pg: + environment: + - "WAIT_HOST=postgres" + - "WAIT_PORT=5432" + - "SSHPIPERD_UPSTREAM_DRIVER=postgres" + - "SSHPIPERD_UPSTREAM_POSTGRES_HOST=postgres" + - "SSHPIPERD_UPSTREAM_POSTGRES_SSLMODE=disable" + - "SSHPIPERD_AUDITOR=typescript-logger" + - "SSHPIPERD_BANNERTEXT=hellopiper" + build: ../.. + links: + - "host1:host1" + - "host2:host2" + - "postgres:postgres" + volumes: + - ./piper.sh:/piper.sh + - workingdir:/var/sshpiper + - ./wait.sh:/wait.sh + command: + - "/bin/sh" + - "/piper.sh" + depends_on: + - postgres + - host1 + - host2 + postgres: + image: postgres + environment: + - "POSTGRES_DB=sshpiper" + tmpfs: + - /var/lib/postgresql/data volumes: diff --git a/sshpiperd/e2e/piper.sh b/sshpiperd/e2e/piper.sh old mode 100644 new mode 100755 index 90ebc25f..726f4c44 --- a/sshpiperd/e2e/piper.sh +++ b/sshpiperd/e2e/piper.sh @@ -1,6 +1,8 @@ #!/bin/sh -sleep 10 # TODO remove ulgy workaround +if [ ! -z $WAIT_HOST ]; then + /wait.sh $WAIT_HOST $WAIT_PORT +fi /sshpiperd pipe add -n host1 -u host1 --upstream-username root /sshpiperd pipe add -n host2 -u host2 --upstream-username root diff --git a/sshpiperd/e2e/test.sh b/sshpiperd/e2e/test.sh old mode 100644 new mode 100755 index fff60619..e9dbd17d --- a/sshpiperd/e2e/test.sh +++ b/sshpiperd/e2e/test.sh @@ -1,9 +1,12 @@ -#!/bin/bash +#!/bin/sh + +/wait.sh piper 2222 +/wait.sh piper_mysql 2222 +/wait.sh piper_pg 2222 + # TODO to python -sleep 12 # TODO remove ulgy workaround - mkdir -p /local mkdir -p /workingdir/host{1,2} @@ -50,5 +53,7 @@ runtest(){ runtest "host1 with public key:" "host1" "ssh host1@piper -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /local/id_rsa cat /names/host1" runtest "host2 with password:" "host2" "sshpass -p root ssh host2@piper -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null cat /names/host2" +runtest "sqlite host2 with password:" "host2" "sshpass -p root ssh host2@piper_sqlite -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null cat /names/host2" runtest "mysql host2 with password:" "host2" "sshpass -p root ssh host2@piper_mysql -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null cat /names/host2" +runtest "pg host2 with password:" "host2" "sshpass -p root ssh host2@piper_pg -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null cat /names/host2" diff --git a/sshpiperd/e2e/wait.sh b/sshpiperd/e2e/wait.sh new file mode 100755 index 00000000..e330379e --- /dev/null +++ b/sshpiperd/e2e/wait.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +for i in `seq 300`; do + nc -w 1 -z "$1" "$2" >/dev/null 2>&1 + nc -w 1 -z "$1" "$2" + if [ $? -eq 0 ]; then + break + fi + sleep 1 +done