Skip to content

Commit afafdca

Browse files
committed
add ansible tests, use common docker image
1 parent 51505a5 commit afafdca

20 files changed

+369
-48
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ before_install:
1212
- sudo apt-get install -y xmlstarlet jq
1313
- sudo chsh --shell $(which bash)
1414
script:
15-
- './gradlew clean build && groovy testbuild.groovy -gradle && make TAG=SNAPSHOT BUILD_NUM=$TRAVIS_BUILD_NUMBER rpm deb && bash run-api-tests.sh && bash run-docker-tests.sh && bash run-docker-ssl-tests.sh && DOCKER_COMPOSE_SPEC=docker-compose-api-mysql.yaml bash run-docker-api-tests.sh'
15+
- './gradlew clean build && groovy testbuild.groovy -gradle && make TAG=SNAPSHOT BUILD_NUM=$TRAVIS_BUILD_NUMBER rpm deb && bash run-api-tests.sh && DOCKER_COMPOSE_SPEC=docker-compose-api-mysql.yaml bash run-docker-api-tests.sh && bash run-docker-tests.sh && bash run-docker-ssl-tests.sh && bash run-docker-ansible-tests.sh'
1616
addons:
1717
hostname: rdbuild
1818
apt:

run-docker-ansible-tests.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
#/ trigger local ci test run
3+
4+
5+
. rd_versions.sh
6+
7+
8+
set -euo pipefail
9+
IFS=$'\n\t'
10+
readonly ARGS=("$@")
11+
DOCKER_DIR=$PWD/test/docker
12+
13+
usage() {
14+
grep '^#/' <"$0" | cut -c4- # prints the #/ lines above as usage info
15+
}
16+
die(){
17+
echo >&2 "$@" ; exit 2
18+
}
19+
20+
check_args(){
21+
if [ ${#ARGS[@]} -gt 0 ] ; then
22+
DOCKER_DIR=$1
23+
fi
24+
}
25+
copy_jar(){
26+
local FARGS=("$@")
27+
local DIR=${FARGS[0]}
28+
local -a VERS=( $( rd_get_version ) )
29+
local JAR=rundeck-launcher-${VERS[0]}-${VERS[2]}.jar
30+
local buildJar=$PWD/rundeck-launcher/launcher/build/libs/$JAR
31+
test -f $buildJar || die "Jar file not found $buildJar"
32+
mkdir -p $DIR
33+
cp $buildJar $DIR/rundeck-launcher.jar
34+
echo $DIR/$JAR
35+
}
36+
run_tests(){
37+
local FARGS=("$@")
38+
local DIR=${FARGS[0]}
39+
40+
cd $DIR
41+
bash $DIR/test-ansible.sh
42+
}
43+
run_docker_test(){
44+
local FARGS=("$@")
45+
local DIR=${FARGS[0]}
46+
local launcherJar=$( copy_jar $DIR ) || die "Failed to copy jar"
47+
run_tests $DIR
48+
}
49+
50+
51+
main() {
52+
check_args
53+
run_docker_test $DOCKER_DIR
54+
}
55+
main
56+

test/docker/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
export RUNDECK_VERSION=${RUNDECK_VERSION:-2.7.0}
3+
export RUNDECK_VERSION=${RUNDECK_VERSION:-2.9.2}
44
export LAUNCHER_URL=${LAUNCHER_URL:-http://dl.bintray.com/rundeck/rundeck-maven/rundeck-launcher-${RUNDECK_VERSION}.jar}
55
export CLI_DEB_URL=${CLI_DEB_URL:-https://dl.bintray.com/rundeck/rundeck-deb}
6-
export CLI_VERS=${CLI_VERS:-1.0.0-1}
6+
export CLI_VERS=${CLI_VERS:-1.0.15-1}

test/docker/docker-compose-ansible-test.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
version: '3'
1+
version: '2'
22

33
services:
44
rundeck1:
55
hostname: rundeck1
66
build:
77
context: dockers/rundeckansible/
8-
args:
9-
CLI_DEB_URL: ${CLI_DEB_URL}
10-
CLI_VERS: ${CLI_VERS}
11-
LAUNCHER_URL: ${LAUNCHER_URL}
128
links:
139
- hostnode
1410
environment:
@@ -22,6 +18,7 @@ services:
2218
- CONFIG_SCRIPT_PRESTART=scripts/config-ansible.sh
2319
- SETUP_TEST_PROJECT=atest
2420
- CONFIG_TEST_PROJECT_FILE=atest/atest-project.properties
21+
- NODE_CACHE_FIRST_LOAD_SYNCH=1
2522
volumes:
2623
- logs:/home/rundeck/logs:rw
2724
- resources:/home/rundeck/resources:rw

test/docker/docker-compose-api-mysql.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ services:
1717
- ./dockers/mysql/conf:/etc/mysql/conf.d
1818
rundeck1:
1919
hostname: rundeck1
20-
build:
21-
context: dockers/rundeck/
22-
args:
23-
CLI_DEB_URL: ${CLI_DEB_URL}
24-
CLI_VERS: ${CLI_VERS}
25-
LAUNCHER_URL: ${LAUNCHER_URL}
20+
image: rdtest:latest
2621
# entrypoint: bash /home/rundeck/run.sh
2722
links:
2823
- mysql

test/docker/docker-compose-api-test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ version: '2'
33
services:
44
rundeck1:
55
hostname: rundeck1
6-
build:
7-
context: dockers/rundeck/
8-
args:
9-
CLI_DEB_URL: ${CLI_DEB_URL}
10-
CLI_VERS: ${CLI_VERS}
11-
LAUNCHER_URL: ${LAUNCHER_URL}
6+
image: rdtest:latest
127
# entrypoint: bash /home/rundeck/run.sh
138
environment:
149
- RUNDECK_NODE=rundeck1

test/docker/docker-compose-multinode-test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ version: '2'
33
services:
44
rundeck1:
55
hostname: rundeck1
6-
build:
7-
context: dockers/rundeck/
8-
args:
9-
CLI_DEB_URL: ${CLI_DEB_URL}
10-
CLI_VERS: ${CLI_VERS}
11-
LAUNCHER_URL: ${LAUNCHER_URL}
6+
image: rdtest:latest
127
links:
138
- hostnode
149
# entrypoint: bash /home/rundeck/run.sh

test/docker/docker-compose-ssl-test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ version: '2'
33
services:
44
rundeck1:
55
hostname: rundeck1
6-
build:
7-
context: dockers/rundeck/
8-
args:
9-
CLI_DEB_URL: ${CLI_DEB_URL}
10-
CLI_VERS: ${CLI_VERS}
11-
LAUNCHER_URL: ${LAUNCHER_URL}
6+
image: rdtest:latest
127
# entrypoint: bash /home/rundeck/run.sh
138
environment:
149
- RUNDECK_NODE=rundeck1

test/docker/dockers/rundeck/scripts/config-ansible.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
#/ does something ...
33
#/ usage: [..]
44

5-
set -euo pipefail
5+
#set -euo pipefail
66
IFS=$'\n\t'
7-
readonly ARGS=("$@")
87
# <http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/>
98
# <http://redsymbol.net/articles/unofficial-bash-strict-mode/>
109

@@ -31,10 +30,9 @@ check_args(){
3130
# # set -x
3231
#}
3332
setup_ansible(){
34-
cat >/etc/ansible/hosts <<END
33+
sudo cat >/home/rundeck/resources/ansibleinv.ini <<END
3534
[ansible-nodes]
36-
$NODE1 ansible_host=$NODE1 ansible_port=22
37-
test-ansible-node ansible_connection=local ansible_host=127.0.0.1
35+
test-ansible-node ansible_connection=local
3836
$RUNDECK_NODE ansible_connection=local
3937
END
4038

test/docker/dockers/rundeck/scripts/run_tests.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ set -e
44

55
TEST_DIR=$1
66
TEST_SCRIPT=${2:-/tests/run-tests.sh}
7+
TEST_PROJECT=${3:-testproj1}
78

8-
: ${TEST_DIR?"Argument required"}
9-
echo "run_tests with $TEST_DIR"
9+
: ${TEST_DIR?"Dir required"}
10+
: ${TEST_SCRIPT?"Script required"}
11+
: ${TEST_PROJECT?"Project required"}
12+
echo "run_tests with $TEST_DIR and $TEST_SCRIPT for project $TEST_PROJECT"
1013

1114
export API_KEY=letmein99
1215
# define env vars used by rd tool
@@ -69,11 +72,12 @@ echo "starting tests"
6972

7073
set +e
7174
chmod -w $TEST_SCRIPT
75+
chmod +x $TEST_SCRIPT
7276
sync
7377

7478
$TEST_SCRIPT \
7579
--rdeck-base $HOME \
76-
--rundeck-project testproj1 \
80+
--rundeck-project $TEST_PROJECT \
7781
--rundeck-user $USERNAME \
7882
--test-dir $TEST_DIR
7983
EC=$?

0 commit comments

Comments
 (0)