mirror of
https://github.com/ivanilves/xiringuito.git
synced 2025-05-21 01:30:27 -07:00
Integration testing: Skeleton
This commit is contained in:
parent
3c2c161017
commit
4b37926db9
26
.travis.yml
Normal file
26
.travis.yml
Normal file
@ -0,0 +1,26 @@
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
env:
|
||||
global:
|
||||
- DOCKER_REPO=ivanilves
|
||||
|
||||
install:
|
||||
- docker pull ${DOCKER_REPO}/xiri-ubuntu
|
||||
- docker pull ${DOCKER_REPO}/xiri-centos
|
||||
|
||||
before_script:
|
||||
- chmod -R go-rwx testing/integration/ssh-keys
|
||||
|
||||
script:
|
||||
- testing/integration.sh zero
|
||||
- testing/integration.sh basic_connectivity_with_ssh
|
||||
|
||||
branches:
|
||||
except:
|
||||
- /^skip-ci/
|
63
testing/integration.sh
Executable file
63
testing/integration.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run integration testing suite for Xiringuito
|
||||
#
|
||||
cd $(dirname ${0})/integration
|
||||
|
||||
declare -r DISTS=$(find . -type f -name "Dockerfile.*" | sed 's/.*\.//')
|
||||
declare -r CASES=$(ls -1 cases | sed 's/\.sh$//')
|
||||
|
||||
function setup(){
|
||||
echo
|
||||
echo "[ SETUP ]"
|
||||
for DIST in ${DISTS}; do
|
||||
make docker-start DIST=${DIST}
|
||||
done
|
||||
}
|
||||
|
||||
function run_case(){
|
||||
declare -r CASE=${1}
|
||||
|
||||
declare -r XIRI_EXE=../../xiringuito
|
||||
declare -r SSH_USER=root
|
||||
|
||||
for DIST in ${DISTS}; do
|
||||
echo
|
||||
echo "[ RUN: ${1} / ${DIST} ]"
|
||||
|
||||
REMOTE_IP=$(make docker-ip DIST=${DIST})
|
||||
|
||||
SSH_EXTRA_OPTS="\
|
||||
-oUserKnownHostsFile=/dev/null \
|
||||
-oStrictHostKeyChecking=no \
|
||||
"
|
||||
|
||||
set -e
|
||||
source cases/${1}.sh
|
||||
set +e
|
||||
done
|
||||
}
|
||||
|
||||
function teardown(){
|
||||
echo
|
||||
echo "[ TEARDOWN ]"
|
||||
for DIST in ${DISTS}; do
|
||||
make docker-stop DIST=${DIST}
|
||||
make docker-rm DIST=${DIST}
|
||||
done
|
||||
}
|
||||
|
||||
if [[ ${#} != 1 ]]; then
|
||||
echo "Usage: $(basename ${0}) CASE"
|
||||
echo
|
||||
echo "Available integration testing cases:"
|
||||
echo "${CASES}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '*'
|
||||
echo "* Case: ${1}"
|
||||
echo '*'
|
||||
setup
|
||||
run_case ${1}
|
||||
teardown
|
9
testing/integration/Dockerfile.centos
Normal file
9
testing/integration/Dockerfile.centos
Normal file
@ -0,0 +1,9 @@
|
||||
FROM centos:7
|
||||
|
||||
LABEL maintainer "ivan.ilves@gmail.com"
|
||||
|
||||
RUN yum -y install openssh-server && ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa && yum clean all
|
||||
|
||||
ADD ./ssh-keys /root/.ssh
|
||||
|
||||
CMD ["/usr/sbin/sshd", "-De"]
|
9
testing/integration/Dockerfile.ubuntu
Normal file
9
testing/integration/Dockerfile.ubuntu
Normal file
@ -0,0 +1,9 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
LABEL maintainer "ivan.ilves@gmail.com"
|
||||
|
||||
RUN apt-get update && apt-get --yes install openssh-server && mkdir /var/run/sshd && apt-get clean
|
||||
|
||||
ADD ./ssh-keys /root/.ssh
|
||||
|
||||
CMD ["/usr/sbin/sshd", "-De"]
|
33
testing/integration/Makefile
Normal file
33
testing/integration/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
REPO = ivanilves
|
||||
DIST = ubuntu
|
||||
TAG = latest
|
||||
|
||||
NAME = xiri-$(DIST)
|
||||
IMAGE = $(REPO)/$(NAME):$(TAG)
|
||||
|
||||
docker-build:
|
||||
docker build -f Dockerfile.$(DIST) --no-cache -t $(IMAGE) .
|
||||
|
||||
docker-pull:
|
||||
docker pull $(IMAGE)
|
||||
|
||||
docker-push:
|
||||
docker push $(IMAGE)
|
||||
|
||||
docker-start:
|
||||
docker run -d --name $(NAME) $(IMAGE)
|
||||
|
||||
docker-bash:
|
||||
docker run -ti --name $(NAME) --rm $(IMAGE) bash
|
||||
|
||||
docker-logs:
|
||||
docker logs $(NAME)
|
||||
|
||||
docker-stop:
|
||||
docker kill $(NAME)
|
||||
|
||||
docker-rm:
|
||||
docker rm $(NAME)
|
||||
|
||||
docker-ip:
|
||||
@docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(NAME)
|
14
testing/integration/README.md
Normal file
14
testing/integration/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
#### Integration testing in Xiringuito
|
||||
|
||||
We do integration testing with Docker against two platforms:
|
||||
* Ubuntu 16.04
|
||||
* CentOS 7
|
||||
|
||||
Next cases (and even more) are covered:
|
||||
* Running with SSH agent
|
||||
* Running with SSH private key loaded directly from FS
|
||||
* With invalid SSH keys or w/o ones (predictable failure)
|
||||
* With and without route discovery
|
||||
* With and without reconnection
|
||||
* With and without propagation of server DNS configuration
|
||||
* Tearing down both client and server with no garbage left
|
1
testing/integration/cases/basic_connectivity_with_ssh.sh
Normal file
1
testing/integration/cases/basic_connectivity_with_ssh.sh
Normal file
@ -0,0 +1 @@
|
||||
ssh -i ssh-keys/id_rsa ${SSH_EXTRA_OPTS} ${SSH_USER}@${REMOTE_IP} true
|
0
testing/integration/cases/zero.sh
Normal file
0
testing/integration/cases/zero.sh
Normal file
1
testing/integration/ssh-keys/authorized_keys
Normal file
1
testing/integration/ssh-keys/authorized_keys
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+p+sO50YEcVXxkcDvZIO/2/HIUTlwmGNLOB0KNs8wpyPtJDvE3npoJSQljwhaiqGphadvMP1O6EV6nxnyNSHE0vEAYtiIqmll4gdkCnmxEcwotX+0AhZERg58TlFsF2ALOcaLKg0Ax+hag9JOV1b2C85NHT3A+2yiVSWtVx+rx8vetwOdmsQaW+z7MssY3dEh97VMQJ7c8Iyog/zXXqk8Ow+yuYNjoNHQPuwHvpmCAGkJMQlyxp/Mx6/Qf7Q0sHM5kotVajiV5s2rrp/jAHd2GOq812g19dlI7DcGhnL3MhR0nrtiuw8ezmeK+Ib7qQp6ZTouQfRlfCzbU/oz687z dummy-xiringuito-OpenSSH-key
|
27
testing/integration/ssh-keys/id_rsa
Normal file
27
testing/integration/ssh-keys/id_rsa
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAvqfrDudGBHFV8ZHA72SDv9vxyFE5cJhjSzgdCjbPMKcj7SQ7
|
||||
xN56aCUkJY8IWoqhqYWnbzD9TuhFep8Z8jUhxNLxAGLYiKppZeIHZAp5sRHMKLV/
|
||||
tAIWREYOfE5RbBdgCznGiyoNAMfoWoPSTldW9gvOTR09wPtsolUlrVcfq8fL3rcD
|
||||
nZrEGlvs+zLLGN3RIfe1TECe3PCMqIP8116pPDsPsrmDY6DR0D7sB76ZggBpCTEJ
|
||||
csafzMev0H+0NLBzOZKLVWo4lebNq66f4wB3dhjqvNdoNfXZSOw3BoZy9zIUdJ67
|
||||
YrsPHs5niviG+6kKemU6LkH0ZXws21P6M+vO8wIDAQABAoIBAQCwPzqkxFeNs9fn
|
||||
QP5CT4Eb049nxu56j+T6nBz8XD6ck2Y6yswV6jTuIaeQsPDgAlgABnYJ7Be+4imY
|
||||
eYvaxBM7iGUSHk5dyGs2rAR5DtYAQpug5mfvWB6NbtXlQ+ExM0quFfLcozryBdte
|
||||
EY5QrZzOR4um7ekwhTyftGboHyo/+RELurIK3nM2y68uwlMoF5/XtCr3fZOnyVvD
|
||||
BrYypBh32jbyjOx234566Gt8oFboYXloej5sMrWDcH+OVQ6d4Xdi7thC28zCJ/oB
|
||||
Gse17B0l0RQ96Wwnl6pe9/v9xSR30D70suir5zY7MZfOoN7V7XK6Cg4q+b4gfvA/
|
||||
rkLucOiBAoGBAPE1kC/zrDB36t2S9bFt8BCYRSsTQYGxIDuA2dkhbp2h3DnRIwIh
|
||||
KGjNGWQM93hXSRvON8IuFPwjY+lAwfB8EmSGGBDHdIgx/yAUXvruF5ntxZ6v9CZB
|
||||
1KfnjSVgvYBnBOQf+oBgRnFnprgVIJXJB9cOP8rU81NsmkSEeRR0qLoJAoGBAMpY
|
||||
yHRhN4AsxgTZlADHCspPZt/mrkZJz47uQSNd73UflPYTmhejkrica4NLFKllKXwt
|
||||
IeHLXY+OUiajZVhp9FZqTLG3SQSsSzbU+9cNO4mn5/WvQnnCn793MvEagaUQEnRs
|
||||
57cK6DfAYmQKv6XJExW167rp/W0bYA/lagOK6rAbAoGBAJl88xaAYVaqSCrcxDk2
|
||||
cuesbX8+jpWfh5o1oOpZKtFl2QR1f2hwfw1JTdnromHScTQfYj3PIw1a283mpkKI
|
||||
QQ/0gEXVFeNApU7dh573eM87jWAwKRVbGJ4LazaYu52EcIlVjAq6uLibM2y6DPUj
|
||||
aji/2XoRThEM75GgFogcv+05AoGAXrQY9ac+g6Xw8/oldAu0eCWbf3WG4WzQURQf
|
||||
tn7TgRzL6jQYbbHoDLFg/G0aeYHYXb792aEF5Bd3SZA18aB9dCiCRrcC3MYK2dnr
|
||||
GKaf0/ia7vkdAsHdZI5UcFW4kdmo2YbTGG9pahaHtkz1j5FBdmrTroKvUu56ElaM
|
||||
PKY62zsCgYEA0XOL4PHjXKlobpiLCgco6xL7NwWSbZz64zJdIcJSqYC2fPNCCTaV
|
||||
sXGAtgH6YQiXrprKgZGF6XKuOKdt7M6/gU6NcElCC8ms823nMcF7CWnAYuZs3jH/
|
||||
bup5Wn09j2P/8LK22aG6PTH+9mFV6ZgGNs41jMZxOcfmBd1RStMHaes=
|
||||
-----END RSA PRIVATE KEY-----
|
1
testing/integration/ssh-keys/id_rsa.pub
Normal file
1
testing/integration/ssh-keys/id_rsa.pub
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+p+sO50YEcVXxkcDvZIO/2/HIUTlwmGNLOB0KNs8wpyPtJDvE3npoJSQljwhaiqGphadvMP1O6EV6nxnyNSHE0vEAYtiIqmll4gdkCnmxEcwotX+0AhZERg58TlFsF2ALOcaLKg0Ax+hag9JOV1b2C85NHT3A+2yiVSWtVx+rx8vetwOdmsQaW+z7MssY3dEh97VMQJ7c8Iyog/zXXqk8Ow+yuYNjoNHQPuwHvpmCAGkJMQlyxp/Mx6/Qf7Q0sHM5kotVajiV5s2rrp/jAHd2GOq812g19dlI7DcGhnL3MhR0nrtiuw8ezmeK+Ib7qQp6ZTouQfRlfCzbU/oz687z dummy-xiringuito-OpenSSH-key
|
@ -110,7 +110,7 @@ fi
|
||||
declare -r TUNNEL_ID=$(cat ${TUNNEL_ID_FILE})
|
||||
declare -r REMOTE_PATH="/tmp/xiringuito.${TUNNEL_ID}"
|
||||
|
||||
declare -r SSH_OPTS="-oLogLevel=${SSH_LOG_LEVEL:-ERROR} -oConnectionAttempts=3 -oConnectTimeout=10"
|
||||
declare -r SSH_OPTS="-oLogLevel=${SSH_LOG_LEVEL:-ERROR} -oConnectionAttempts=3 -oConnectTimeout=10 ${SSH_EXTRA_OPTS}"
|
||||
|
||||
if [[ ${KERNEL} == linux ]]; then
|
||||
declare -r LOCAL_TUNNEL_ID=${TUNNEL_ID}
|
||||
|
Loading…
x
Reference in New Issue
Block a user