2016-08-01 22:39:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
env
|
2016-08-01 20:46:37 +00:00
|
|
|
|
2016-08-23 17:49:46 +00:00
|
|
|
container="${PLATFORM}"
|
2016-08-01 20:46:37 +00:00
|
|
|
build_dir="${HOME}/ansible"
|
|
|
|
|
|
|
|
test_target="${TARGET:-}"
|
|
|
|
test_flags="${TEST_FLAGS:-}"
|
|
|
|
|
|
|
|
# Force ansible color output by default.
|
|
|
|
# To disable color force mode use FORCE_COLOR=0
|
|
|
|
force_color="${FORCE_COLOR:-1}"
|
|
|
|
|
|
|
|
# FIXME: these tests fail
|
2016-09-28 04:37:24 +00:00
|
|
|
skip_tags='test_service,test_postgresql,test_mysql_db,test_mysql_user,test_mysql_variables,test_uri,test_get_url'
|
2016-08-01 20:46:37 +00:00
|
|
|
|
|
|
|
cd ~/
|
|
|
|
|
2016-08-23 17:49:46 +00:00
|
|
|
make="make"
|
2016-08-01 20:46:37 +00:00
|
|
|
|
2016-08-23 17:49:46 +00:00
|
|
|
if [ "${container}" = "freebsd" ]; then
|
|
|
|
make="gmake"
|
|
|
|
|
|
|
|
pkg install -y curl
|
2016-08-01 20:46:37 +00:00
|
|
|
|
2016-08-23 17:49:46 +00:00
|
|
|
if [ ! -f bootstrap.sh ]; then
|
|
|
|
curl "https://raw.githubusercontent.com/mattclay/ansible-hacking/master/bootstrap.sh" -o bootstrap.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
chmod +x bootstrap.sh
|
|
|
|
./bootstrap.sh pip -y -q
|
|
|
|
|
|
|
|
# tests require these packages
|
|
|
|
# TODO: bootstrap.sh should be capable of installing these
|
|
|
|
pkg install -y \
|
|
|
|
bash \
|
|
|
|
devel/ruby-gems \
|
2016-09-28 04:37:24 +00:00
|
|
|
gtar \
|
2016-08-23 17:49:46 +00:00
|
|
|
mercurial \
|
|
|
|
rsync \
|
|
|
|
ruby \
|
|
|
|
subversion \
|
|
|
|
sudo \
|
|
|
|
zip
|
|
|
|
fi
|
2016-08-01 20:46:37 +00:00
|
|
|
|
|
|
|
# TODO: bootstrap.sh should install these
|
|
|
|
pip install \
|
|
|
|
junit-xml \
|
2016-08-08 15:55:59 +00:00
|
|
|
virtualenv \
|
|
|
|
jmespath
|
2016-08-01 20:46:37 +00:00
|
|
|
|
|
|
|
# Tests assume loopback addresses other than 127.0.0.1 will work.
|
|
|
|
# Add aliases for loopback addresses used by tests.
|
|
|
|
|
|
|
|
for i in 3 4 254; do
|
|
|
|
ifconfig lo0 alias "127.0.0.${i}" up
|
|
|
|
done
|
|
|
|
|
|
|
|
ifconfig lo0
|
|
|
|
|
|
|
|
# Since tests run as root, we also need to be able to ssh to localhost as root.
|
|
|
|
sed -i '' 's/^# *PermitRootLogin.*$/PermitRootLogin yes/;' /etc/ssh/sshd_config
|
|
|
|
|
2016-08-23 17:49:46 +00:00
|
|
|
if [ "${container}" = "freebsd" ]; then
|
|
|
|
# Restart sshd for configuration changes and loopback aliases to work.
|
|
|
|
service sshd restart
|
|
|
|
fi
|
2016-08-01 20:46:37 +00:00
|
|
|
|
|
|
|
# Generate our ssh key and add it to our authorized_keys file.
|
|
|
|
# We also need to add localhost's server keys to known_hosts.
|
|
|
|
|
|
|
|
if [ ! -f "${HOME}/.ssh/id_rsa.pub" ]; then
|
|
|
|
ssh-keygen -q -t rsa -N '' -f "${HOME}/.ssh/id_rsa"
|
|
|
|
cp "${HOME}/.ssh/id_rsa.pub" "${HOME}/.ssh/authorized_keys"
|
|
|
|
for key in /etc/ssh/ssh_host_*_key.pub; do
|
|
|
|
pk=$(cat "${key}")
|
|
|
|
echo "localhost ${pk}" >> "${HOME}/.ssh/known_hosts"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2016-08-01 22:39:17 +00:00
|
|
|
repo_name="${REPO_NAME:-ansible}"
|
|
|
|
|
2016-08-01 20:46:37 +00:00
|
|
|
if [ -d "${build_dir}" ]; then
|
|
|
|
cd "${build_dir}"
|
2016-08-01 22:39:17 +00:00
|
|
|
elif [ "${repo_name}" = "ansible" ]; then
|
2016-08-01 20:46:37 +00:00
|
|
|
git clone "${REPOSITORY_URL:-https://github.com/ansible/ansible.git}" "${build_dir}"
|
|
|
|
cd "${build_dir}"
|
|
|
|
|
|
|
|
if [ "${PULL_REQUEST:-false}" = "false" ]; then
|
|
|
|
git checkout -f "${BRANCH:-devel}" --
|
|
|
|
git reset --hard "${COMMIT:-HEAD}"
|
|
|
|
else
|
|
|
|
git fetch origin "pull/${PULL_REQUEST}/head"
|
|
|
|
git checkout -f FETCH_HEAD
|
|
|
|
git merge "origin/${BRANCH}"
|
|
|
|
fi
|
|
|
|
|
2016-08-01 22:39:17 +00:00
|
|
|
git submodule init
|
|
|
|
git submodule sync
|
|
|
|
git submodule update
|
|
|
|
else
|
|
|
|
case "${repo_name}" in
|
|
|
|
"ansible-modules-core")
|
|
|
|
this_module_group="core"
|
|
|
|
;;
|
|
|
|
"ansible-modules-extras")
|
|
|
|
this_module_group="extras"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported repo name: ${repo_name}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
git clone "https://github.com/ansible/ansible.git" "${build_dir}"
|
|
|
|
|
|
|
|
cd "${build_dir}"
|
|
|
|
|
|
|
|
git submodule init
|
|
|
|
git submodule sync
|
|
|
|
git submodule update
|
|
|
|
|
|
|
|
cd "${build_dir}/lib/ansible/modules/${this_module_group}"
|
|
|
|
|
|
|
|
if [ "${PULL_REQUEST:-false}" = "false" ]; then
|
|
|
|
echo "Only pull requests are supported for module repositories."
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
git fetch origin "pull/${PULL_REQUEST}/head"
|
|
|
|
git checkout -f FETCH_HEAD
|
|
|
|
git merge "origin/${BRANCH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "${build_dir}"
|
|
|
|
fi
|
2016-08-01 20:46:37 +00:00
|
|
|
|
2016-08-01 22:39:17 +00:00
|
|
|
set +u
|
2016-08-01 20:46:37 +00:00
|
|
|
. hacking/env-setup
|
2016-08-01 22:39:17 +00:00
|
|
|
set -u
|
2016-08-01 20:46:37 +00:00
|
|
|
|
|
|
|
cd test/integration
|
|
|
|
|
2016-08-23 17:49:46 +00:00
|
|
|
if [ "${container}" = "osx" ]; then
|
|
|
|
# FIXME: these test targets fail
|
|
|
|
sed -i '' 's/ test_gathering_facts / /;' Makefile
|
|
|
|
|
|
|
|
# FIXME: these tests fail
|
2016-09-28 06:30:58 +00:00
|
|
|
skip_tags="${skip_tags},test_iterators,test_git"
|
|
|
|
|
|
|
|
# test_template assumes the group 'root' exists if this variable is not set
|
|
|
|
export GROUP=wheel
|
2016-08-23 17:49:46 +00:00
|
|
|
fi
|
|
|
|
|
2016-08-01 20:46:37 +00:00
|
|
|
# TODO: support httptester via reverse ssh tunnel
|
|
|
|
|
|
|
|
rm -rf "/tmp/shippable"
|
|
|
|
mkdir -p "/tmp/shippable/testresults"
|
|
|
|
|
|
|
|
# TODO: enable jail test
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
JUNIT_OUTPUT_DIR="/tmp/shippable/testresults" \
|
|
|
|
ANSIBLE_FORCE_COLOR="${force_color}" \
|
|
|
|
ANSIBLE_CALLBACK_WHITELIST=junit \
|
|
|
|
TEST_FLAGS="-e ansible_python_interpreter=/usr/local/bin/python2 --skip-tags '${skip_tags}' ${test_flags}" \
|
|
|
|
container="${container}" \
|
2016-08-23 17:49:46 +00:00
|
|
|
${make} ${test_target}
|