1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add support for OS X CI on Shippable. (#17160)

This commit is contained in:
Matt Clay 2016-08-23 10:49:46 -07:00 committed by GitHub
parent 92c6283e93
commit a695e18615
5 changed files with 79 additions and 33 deletions

View file

@ -8,6 +8,8 @@ matrix:
exclude:
- env: TEST=none
include:
- env: TEST=remote TARGET=all PLATFORM=osx VERSION=10.11
- env: TEST=remote TARGET=all PLATFORM=freebsd VERSION=10.3-STABLE
- env: TEST=remote TARGET=ci_win1 PLATFORM=windows VERSION=2012-R2_RTM

View file

@ -4,5 +4,6 @@ remote
[posix:vars]
ansible_connection=ssh
ansible_host=@ansible_host
ansible_port=@ansible_port
ansible_user=@ansible_user
ansible_python_interpreter=/usr/local/bin/python2

View file

@ -285,6 +285,7 @@ def make_inventory(inventory_template, connection, instance_id):
inventory = template\
.replace('@instance_id', instance_id)\
.replace('@ansible_host', connection['hostname'])\
.replace('@ansible_port', str(connection.get('port', 22)))\
.replace('@ansible_user', connection['username'])\
.replace('@ansible_password', connection.get('password', ''))
@ -331,7 +332,7 @@ class HttpRequest:
return self.request('PUT', url, data, headers)
def request(self, method, url, data=None, headers=None):
args = ['/usr/bin/curl', '-s', '-i', '-X', method]
args = ['/usr/bin/curl', '-s', '-S', '-i', '-X', method]
if headers is not None:
for header in headers:

View file

@ -3,8 +3,7 @@
set -eux
env
# TODO: add support for other posix environments
container=freebsd
container="${PLATFORM}"
build_dir="${HOME}/ansible"
test_target="${TARGET:-}"
@ -19,7 +18,11 @@ skip_tags='test_unarchive,test_service,test_postgresql,test_mysql_db,test_mysql_
cd ~/
# ssl certificate errors using fetch, so install curl
make="make"
if [ "${container}" = "freebsd" ]; then
make="gmake"
pkg install -y curl
if [ ! -f bootstrap.sh ]; then
@ -40,6 +43,7 @@ pkg install -y \
subversion \
sudo \
zip
fi
# TODO: bootstrap.sh should install these
pip install \
@ -59,8 +63,10 @@ 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
if [ "${container}" = "freebsd" ]; then
# Restart sshd for configuration changes and loopback aliases to work.
service sshd restart
fi
# Generate our ssh key and add it to our authorized_keys file.
# We also need to add localhost's server keys to known_hosts.
@ -136,6 +142,14 @@ set -u
cd test/integration
if [ "${container}" = "osx" ]; then
# FIXME: these test targets fail
sed -i '' 's/ test_gathering_facts / /;' Makefile
# FIXME: these tests fail
skip_tags="${skip_tags},test_iterators,test_template,test_git"
fi
# TODO: support httptester via reverse ssh tunnel
rm -rf "/tmp/shippable"
@ -148,4 +162,4 @@ JUNIT_OUTPUT_DIR="/tmp/shippable/testresults" \
ANSIBLE_CALLBACK_WHITELIST=junit \
TEST_FLAGS="-e ansible_python_interpreter=/usr/local/bin/python2 --skip-tags '${skip_tags}' ${test_flags}" \
container="${container}" \
gmake ${test_target}
${make} ${test_target}

View file

@ -32,6 +32,22 @@ else
test_auth="remote"
fi
case "${test_platform}" in
"windows")
ci_endpoint="https://14blg63h2i.execute-api.us-east-1.amazonaws.com"
;;
"freebsd")
ci_endpoint="https://14blg63h2i.execute-api.us-east-1.amazonaws.com"
;;
"osx")
ci_endpoint="https://osx.testing.ansible.com"
;;
*)
echo "unsupported platform: ${test_platform}"
exit 1
;;
esac
env
case "${test_platform}" in
@ -56,7 +72,7 @@ function cleanup
fi
if [ "${keep_instance}" = '' ]; then
"${source_root}/test/utils/shippable/ansible-core-ci" -v stop "${instance_id}"
"${source_root}/test/utils/shippable/ansible-core-ci" --endpoint "${ci_endpoint}" -v stop "${instance_id}"
fi
echo "instance_id: ${instance_id}"
@ -66,7 +82,7 @@ trap cleanup EXIT INT TERM
if [ ${start_instance} ]; then
# shellcheck disable=SC2086
"${source_root}/test/utils/shippable/ansible-core-ci" -v \
"${source_root}/test/utils/shippable/ansible-core-ci" --endpoint "${ci_endpoint}" -v \
start --id "${instance_id}" "${test_auth}" "${test_platform}" "${test_version}" ${args}
fi
@ -94,7 +110,7 @@ case "${test_platform}" in
;;
esac
"${source_root}/test/utils/shippable/ansible-core-ci" -v \
"${source_root}/test/utils/shippable/ansible-core-ci" --endpoint "${ci_endpoint}" -v \
get "${instance_id}" \
--template "${inventory_template}" \
> "${inventory_file}" \
@ -123,13 +139,17 @@ test_windows() {
}
test_remote() {
endpoint=$("${source_root}/test/utils/shippable/ansible-core-ci" get \
endpoint=$("${source_root}/test/utils/shippable/ansible-core-ci" --endpoint "${ci_endpoint}" get \
"${instance_id}" \
--template <(echo "@ansible_user@@ansible_host"))
ssh_port=$("${source_root}/test/utils/shippable/ansible-core-ci" --endpoint "${ci_endpoint}" get \
"${instance_id}" \
--template <(echo "@ansible_port"))
(
cat <<EOF
env \
PLATFORM='${test_platform}' \
REPOSITORY_URL='${REPOSITORY_URL:-}' \
REPO_NAME='${REPO_NAME:-}' \
PULL_REQUEST='${PULL_REQUEST:-}' \
@ -147,16 +167,24 @@ cat <<EOF
put "${source_root}/test/utils/shippable/remote-integration.sh" "/tmp/remote-integration.sh"
put "/tmp/remote-script.sh" "/tmp/remote-script.sh"
EOF
) | sftp -b - -o StrictHostKeyChecking=no "${endpoint}"
) | sftp -b - -o StrictHostKeyChecking=no -P "${ssh_port}" "${endpoint}"
pre_cleanup=test_remote_cleanup
ssh "${endpoint}" \
"su -l root -c 'chmod +x /tmp/remote-script.sh; /tmp/remote-script.sh'"
case "${test_platform}" in
"osx")
become="sudo -i PATH=/usr/local/bin:\$PATH"
;;
*)
become="su -l root -c"
;;
esac
ssh -p "${ssh_port}" "${endpoint}" "${become}" "'chmod +x /tmp/remote-script.sh; /tmp/remote-script.sh'"
}
test_remote_cleanup() {
scp -r "${endpoint}:/tmp/shippable" "${source_root}"
scp -r -P "${ssh_port}" "${endpoint}:/tmp/shippable" "${source_root}"
}
"${test_function}"