Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OS X CI on Shippable. #17160

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/integration/inventory.remote.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion test/utils/shippable/ansible-core-ci
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''))

Expand Down Expand Up @@ -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:
Expand Down
62 changes: 38 additions & 24 deletions test/utils/shippable/remote-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-}"
Expand All @@ -19,27 +18,32 @@ skip_tags='test_unarchive,test_service,test_postgresql,test_mysql_db,test_mysql_

cd ~/

# ssl certificate errors using fetch, so install curl
pkg install -y curl
make="make"

if [ ! -f bootstrap.sh ]; then
curl "https://raw.githubusercontent.com/mattclay/ansible-hacking/master/bootstrap.sh" -o bootstrap.sh
fi
if [ "${container}" = "freebsd" ]; then
make="gmake"

pkg install -y curl

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 \
mercurial \
rsync \
ruby \
subversion \
sudo \
zip
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 \
mercurial \
rsync \
ruby \
subversion \
sudo \
zip
fi

# TODO: bootstrap.sh should install these
pip install \
Expand All @@ -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

# Restart sshd for configuration changes and loopback aliases to work.
service sshd restart
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.
Expand Down Expand Up @@ -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"
Expand All @@ -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}
44 changes: 36 additions & 8 deletions test/utils/shippable/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand All @@ -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

Expand Down Expand Up @@ -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}" \
Expand Down Expand Up @@ -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:-}' \
Expand All @@ -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}"