Skip to content

Commit cb6715c

Browse files
author
Gabriel Monroy
committed
refactor(tests): cleanup tests, move common logic into test-setup.sh
1 parent c2a90db commit cb6715c

5 files changed

Lines changed: 409 additions & 85 deletions

File tree

tests/bin/test-acceptance.sh

Lines changed: 109 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,123 @@
11
#!/bin/bash
22
#
3-
# Preps a test environment and runs `make test-integration` with single-node vagrant.
3+
# Preps a test environment and runs `make test-integration`
4+
# against artifacts produced from the current source tree
5+
#
6+
7+
# fail on any command exiting non-zero
8+
set -eo pipefail
49

5-
echo Testing ${DEIS_TEST_APP?}...
6-
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
10+
# absolute path to current directory
11+
export THIS_DIR=$(cd $(dirname $0); pwd)
712

8-
cd ${GOPATH?}/src/github.com/deis/deis
9-
echo HOST_IPADDR=${HOST_IPADDR?}
10-
echo DEISCTL_TUNNEL=${DEISCTL_TUNNEL?}
13+
# setup the test environment
14+
source $THIS_DIR/test-setup.sh
1115

12-
# Environment reset and configuration
13-
rm -rf ~/.deis
14-
ssh-add -D || eval $(ssh-agent) && ssh-add -D
15-
ssh-add ~/.vagrant.d/insecure_private_key
16-
ssh-add ~/.ssh/deis
17-
$THIS_DIR/halt-all-vagrants.sh
18-
vagrant destroy --force
19-
rm -rf tests/example-*
16+
# setup callbacks on process exit and error
17+
trap cleanup EXIT
18+
trap dump_logs ERR
2019

21-
set -e
20+
echo
21+
echo "Running test-acceptance..."
22+
echo
2223

24+
# test building documentation
2325
make -C docs/ test
26+
27+
echo
28+
echo "Building from current source tree..."
29+
echo
30+
31+
# build all docker images and client binaries
2432
make build
25-
make test-components
2633

27-
if ! [[ -x deisctl ]]; then
28-
curl -sSL http://deis.io/deisctl/install.sh | sudo sh
29-
fi
34+
# use the built client binaries
35+
export PATH=$DEIS_ROOT/deisctl:$DEIS_ROOT/client/dist:$PATH
36+
37+
echo
38+
echo "Running unit and functional tests..."
39+
echo
3040

31-
if [[ -z "$DEIS_REGISTRY" ]]; then
32-
docker ps | grep -q registry && curl -s http://$HOST_IPADDR:5000 2>&1 >/dev/null
33-
[[ $? -eq 0 ]] || make dev-registry
34-
export DEIS_REGISTRY=$HOST_IPADDR:5000
35-
fi
41+
make test-components
3642

43+
echo
44+
echo "Provisioning 3-node CoreOS..."
45+
echo
46+
47+
export DEIS_NUM_INSTANCES=3
48+
git checkout $DEIS_ROOT/contrib/coreos/user-data
49+
make discovery-url
3750
vagrant up --provider virtualbox
38-
make push
51+
52+
echo
53+
echo "Waiting for etcd/fleet..."
54+
55+
until deisctl list >/dev/null 2>&1; do
56+
sleep 1
57+
done
58+
59+
echo
60+
echo "Provisioning Deis on old release..."
61+
echo
62+
63+
function set_release {
64+
deisctl config $1 set image=deis/$1:$2
65+
}
66+
set_release logger ${OLD_TAG}
67+
set_release cache ${OLD_TAG}
68+
set_release router ${OLD_TAG}
69+
set_release database ${OLD_TAG}
70+
set_release controller ${OLD_TAG}
71+
set_release registry ${OLD_TAG}
72+
3973
deisctl install platform
40-
deisctl start platform
41-
make test-integration
42-
deisctl uninstall platform
43-
vagrant halt
74+
deisctl scale router=3
75+
deisctl start router@1 router@2 router@3
76+
time deisctl start platform
77+
78+
echo
79+
echo "Running smoke tests..."
80+
echo
81+
82+
time make test-smoke
83+
84+
echo
85+
echo "Publishing new release..."
86+
echo
87+
88+
time make release
89+
90+
echo
91+
echo "Updating channel with new release..."
92+
echo
93+
94+
updateservicectl channel update --app-id=${APP_ID} --channel=${CHANNEL} --version=${BUILD_TAG} --publish=true
95+
96+
echo
97+
echo "Waiting for upgrade to complete..."
98+
echo
99+
100+
deisctl config platform channel=${CHANNEL} autoupdate=true
101+
102+
function wait_for_update {
103+
set -x
104+
vagrant ssh $1 -c "journalctl -n 500 -u deis-updater.service -f" &
105+
pid_$1=$!
106+
vagrant ssh $1 -c "/bin/sh -c \"while [[ \"\$(cat /etc/deis-version)\" != \"${BUILD_TAG}\" ]]; do echo waiting for update to complete...; sleep 5; done\""
107+
kill $pid_$1
108+
set +x
109+
}
110+
111+
wait_for_update deis-1 &
112+
update1=$!
113+
wait_for_update deis-2 &
114+
update2=$!
115+
wait_for_update deis-3 &
116+
update3=$!
117+
wait update1 update2 update3
118+
119+
echo
120+
echo "Running end-to-end integration test..."
121+
echo
122+
123+
time make test-integration

tests/bin/test-integration.sh

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,78 @@
11
#!/bin/bash
22
#
3-
# Preps a test environment and runs `make test-integration` with single-node vagrant.
4-
5-
echo Testing ${DEIS_TEST_APP?}...
6-
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
7-
8-
# Environment reset and configuration
9-
rm -rf ~/.deis ~/.fleetctl ~/.ssh/known_hosts
10-
ssh-add -D || eval $(ssh-agent) && ssh-add -D
11-
ssh-add ~/.vagrant.d/insecure_private_key
12-
ssh-add ~/.ssh/deis
13-
cd ${GOPATH?}/src/github.com/deis/deis
14-
rm -rf tests/example-*
15-
16-
# Vagrant provisioning
17-
$THIS_DIR/halt-all-vagrants.sh
18-
vagrant destroy --force
19-
vagrant up --provider virtualbox --provision
20-
21-
# Trap exit signal to halt vagrant
22-
function cleanup {
23-
set +e
24-
make stop
25-
vagrant halt
26-
}
3+
# Preps a test environment and runs `make test-integration`
4+
# against artifacts produced from the current source tree
5+
#
6+
7+
# fail on any command exiting non-zero
8+
set -eo pipefail
9+
10+
# absolute path to current directory
11+
export THIS_DIR=$(cd $(dirname $0); pwd)
12+
13+
# setup the test environment
14+
source $THIS_DIR/test-setup.sh
15+
16+
# setup callbacks on process exit and error
2717
trap cleanup EXIT
18+
trap dump_logs ERR
2819

29-
set -e
20+
echo
21+
echo "Running test-integration..."
22+
echo
3023

31-
# Build updated Deis CLI and use it for testing
32-
virtualenv --system-site-packages venv
33-
. venv/bin/activate
34-
pip install docopt==0.6.2 python-dateutil==2.2 requests==2.3.0 pyinstaller==2.1 termcolor==1.1.0
35-
make -C client/ client
36-
chmod +x client/dist/deis
37-
export PATH=`pwd`/client/dist:$PATH
24+
# test building documentation
25+
make -C docs/ test
3826

39-
# Install Deis and run tests
27+
echo
28+
echo "Building from current source tree..."
29+
echo
30+
31+
# build all docker images and client binaries
4032
make build
41-
make run
42-
make test-integration
33+
34+
# use the built client binaries
35+
export PATH=$DEIS_ROOT/deisctl:$DEIS_ROOT/client/dist:$PATH
36+
37+
echo
38+
echo "Running unit and functional tests..."
39+
echo
40+
41+
make test-components
42+
43+
echo
44+
echo "Provisioning 3-node CoreOS..."
45+
echo
46+
47+
export DEIS_NUM_INSTANCES=3
48+
git checkout $DEIS_ROOT/contrib/coreos/user-data
49+
make discovery-url
50+
vagrant up --provider virtualbox
51+
52+
echo
53+
echo "Waiting for etcd/fleet..."
54+
55+
until deisctl list >/dev/null 2>&1; do
56+
sleep 1
57+
done
58+
59+
echo
60+
echo "Publishing release from source tree..."
61+
echo
62+
63+
make dev-release
64+
65+
echo
66+
echo "Provisioning Deis..."
67+
echo
68+
69+
deisctl install platform
70+
deisctl scale router=3
71+
deisctl start router@1 router@2 router@3
72+
time deisctl start platform
73+
74+
echo
75+
echo "Running integration suite..."
76+
echo
77+
78+
time make test-integration

tests/bin/test-nightly.sh

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,68 @@
11
#!/bin/bash
22
#
3-
# Preps a test environment and runs `make test-integration` with single-node vagrant.
3+
# Preps a test environment and runs `make test-integration`
4+
# using the latest published artifacts available on Docker Hub
5+
# and the deis.io website.
6+
#
7+
8+
# fail on any command exiting non-zero
9+
set -eo pipefail
10+
11+
# absolute path to current directory
12+
export THIS_DIR=$(cd $(dirname $0); pwd)
413

5-
echo Testing ${DEIS_TEST_APP?}...
6-
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
14+
# setup the test environment
15+
source $THIS_DIR/test-setup.sh
716

8-
cd ${GOPATH?}/src/github.com/deis/deis
9-
echo DEISCTL_TUNNEL=${DEISCTL_TUNNEL?}
17+
# setup callbacks on process exit and error
18+
trap cleanup EXIT
19+
trap dump_logs ERR
1020

11-
# Environment reset and configuration
12-
rm -rf ~/.deis
13-
ssh-add -D || eval $(ssh-agent) && ssh-add -D
14-
ssh-add ~/.vagrant.d/insecure_private_key
15-
ssh-add ~/.ssh/deis
16-
$THIS_DIR/halt-all-vagrants.sh
17-
vagrant destroy --force
18-
rm -rf tests/example-*
21+
echo
22+
echo "Running test-nightly on $DEIS_TEST_APP..."
23+
echo
1924

20-
set -e
25+
echo
26+
echo "Installing clients..."
27+
echo
2128

22-
if ! [[ -x deisctl ]]; then
23-
curl -sSL http://deis.io/deisctl/install.sh | sudo sh
24-
fi
29+
# FIXME: switch to deis CLI install from website
30+
cd $DEIS_ROOT/client
31+
sudo python setup.py install
32+
cd $THIS_DIR
2533

34+
# install latest deisctl from the website
35+
curl -sSL http://deis.io/deisctl/install.sh | sudo sh
36+
37+
echo
38+
echo "Provisioning 3-node CoreOS..."
39+
echo
40+
41+
export DEIS_NUM_INSTANCES=3
42+
git checkout contrib/coreos/user-data
43+
make discovery-url
2644
vagrant up --provider virtualbox
45+
46+
echo
47+
echo "Waiting for etcd/fleet..."
48+
49+
until deisctl list >/dev/null 2>&1; do
50+
sleep 1
51+
done
52+
53+
echo
54+
echo "Provisioning Deis..."
55+
echo
56+
57+
# provision deis from master using :latest
2758
deisctl install platform
28-
deisctl start platform
29-
make test-integration
30-
deisctl uninstall platform
31-
vagrant halt
59+
deisctl scale router=3
60+
deisctl start router@1 router@2 router@3
61+
time deisctl start platform
62+
63+
echo
64+
echo "Running integration tests..."
65+
echo
66+
67+
# run the full integration suite
68+
time make test-integration

0 commit comments

Comments
 (0)