2018-08-12 13:01:04 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Run tests/ansible/all.yml under Ansible and Ansible-Mitogen
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import ci_lib
|
|
|
|
from ci_lib import run
|
|
|
|
|
|
|
|
|
|
|
|
TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible')
|
|
|
|
HOSTS_DIR = os.path.join(ci_lib.TMP, 'hosts')
|
|
|
|
|
|
|
|
|
2018-11-06 13:47:09 +00:00
|
|
|
with ci_lib.Fold('unit_tests'):
|
|
|
|
os.environ['SKIP_MITOGEN'] = '1'
|
|
|
|
ci_lib.run('./run_tests -v')
|
|
|
|
|
|
|
|
|
2018-08-12 13:01:04 +00:00
|
|
|
with ci_lib.Fold('docker_setup'):
|
2018-11-06 13:47:09 +00:00
|
|
|
containers = ci_lib.make_containers()
|
|
|
|
ci_lib.start_containers(containers)
|
2018-08-12 13:01:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
with ci_lib.Fold('job_setup'):
|
|
|
|
# Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version.
|
|
|
|
run("pip install -q ansible==%s", ci_lib.ANSIBLE_VERSION)
|
|
|
|
|
2018-11-06 13:47:09 +00:00
|
|
|
os.chdir(TESTS_DIR)
|
|
|
|
os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7))
|
|
|
|
|
2018-08-12 13:01:04 +00:00
|
|
|
run("mkdir %s", HOSTS_DIR)
|
2018-09-11 05:14:30 +00:00
|
|
|
run("ln -s %s/hosts/common-hosts %s", TESTS_DIR, HOSTS_DIR)
|
2018-08-12 13:01:04 +00:00
|
|
|
|
|
|
|
with open(os.path.join(HOSTS_DIR, 'target'), 'w') as fp:
|
|
|
|
fp.write('[test-targets]\n')
|
2018-11-06 13:47:09 +00:00
|
|
|
fp.writelines(
|
|
|
|
"%(name)s "
|
|
|
|
"ansible_host=%(hostname)s "
|
|
|
|
"ansible_port=%(port)s "
|
|
|
|
"ansible_user=mitogen__has_sudo_nopw "
|
|
|
|
"ansible_password=has_sudo_nopw_password"
|
|
|
|
"\n"
|
|
|
|
% container
|
|
|
|
for container in containers
|
|
|
|
)
|
2018-08-12 13:01:04 +00:00
|
|
|
|
|
|
|
# Build the binaries.
|
2018-09-11 05:40:56 +00:00
|
|
|
# run("make -C %s", TESTS_DIR)
|
2018-08-12 13:01:04 +00:00
|
|
|
if not ci_lib.exists_in_path('sshpass'):
|
|
|
|
run("sudo apt-get update")
|
|
|
|
run("sudo apt-get install -y sshpass")
|
|
|
|
|
|
|
|
|
|
|
|
with ci_lib.Fold('ansible'):
|
2018-11-05 19:04:09 +00:00
|
|
|
playbook = os.environ.get('PLAYBOOK', 'all.yml')
|
|
|
|
run('/usr/bin/time ./run_ansible_playbook.py %s -i "%s" %s',
|
|
|
|
playbook, HOSTS_DIR, ' '.join(sys.argv[1:]))
|