Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
add restart test
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
  • Loading branch information
vieux committed Sep 8, 2017
1 parent 94afd32 commit 6c308a5
Showing 1 changed file with 40 additions and 43 deletions.
83 changes: 40 additions & 43 deletions tests/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,62 @@ set -x

TAG=test

# before_install
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
#sudo apt-get update
#sudo apt-get -y install docker-ce

# install
sudo docker pull rastasheep/ubuntu-sshd
sudo docker pull busybox
docker pull rastasheep/ubuntu-sshd
docker pull busybox

docker build -t sshd tests/testdata
#script

# make the plugin
sudo PLUGIN_TAG=$TAG make
PLUGIN_TAG=$TAG make
# enable the plugin
sudo docker plugin enable vieux/sshfs:$TAG
docker plugin enable vieux/sshfs:$TAG
# list plugins
sudo docker plugin ls
docker plugin ls
# start sshd
sudo docker run -d -p 2222:22 sshd
docker run --name sshd -d -p 2222:22 sshd

# test1: simple
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
docker volume rm sshvolume

# test2: allow_other
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write -u nobody busybox sh -c "echo hello > /write/world"
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write -u nobody busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read -u nobody busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume
docker volume rm sshvolume

# test3: compression
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
docker volume rm sshvolume

# test4: source
sudo docker plugin disable vieux/sshfs:$TAG
sudo docker plugin set vieux/sshfs:$TAG state.source=/tmp
sudo docker plugin enable vieux/sshfs:$TAG
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /tmp/sshfs-state.json
sudo docker volume rm sshvolume
# test4: restart
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
(sleep 2; docker restart sshd) &
docker run --rm -v sshvolume:/read busybox sh -c "sleep 4 ; grep -Fxq hello /read/world"
docker volume rm sshvolume

# test5: ssh key
sudo docker plugin disable vieux/sshfs:$TAG
sudo docker plugin set vieux/sshfs:$TAG sshkey.source=`pwd`/test/testdata/
sudo docker plugin enable vieux/sshfs:$TAG
sudo docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 sshvolume
sudo docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
sudo docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
#sudo cat /var/lib/docker/plugins/sshfs-state.json
sudo docker volume rm sshvolume
# test5: source
docker plugin disable vieux/sshfs:$TAG
docker plugin set vieux/sshfs:$TAG state.source=/tmp
docker plugin enable vieux/sshfs:$TAG
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
docker volume rm sshvolume

# test6: ssh key
docker plugin disable vieux/sshfs:$TAG
docker plugin set vieux/sshfs:$TAG sshkey.source=`pwd`/tests/testdata/
docker plugin enable vieux/sshfs:$TAG
docker volume create -d vieux/sshfs:$TAG -o sshcmd=root@localhost:/ -o port=2222 sshvolume
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
docker volume rm sshvolume

0 comments on commit 6c308a5

Please sign in to comment.