Skip to content

Commit 501cfca

Browse files
committed
issue #543: make localhost_ansible_tests run locally
1 parent 57203ae commit 501cfca

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

.ci/localhost_ansible_tests.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@
2727
os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7))
2828

2929
if not ci_lib.exists_in_path('sshpass'):
30-
run("brew install sshpass")
30+
run("brew install http://git.io/sshpass.rb")
3131

3232

3333
with ci_lib.Fold('machine_prep'):
34-
if os.path.expanduser('~mitogen__user1') == '~mitogen_user1':
34+
key_path = os.path.expanduser('~/.ssh/id_rsa')
35+
if not os.path.exists(key_path):
36+
run("ssh-keygen -N '' -f %s", key_path)
37+
38+
auth_path = os.path.expanduser('~/.ssh/authorized_keys')
39+
with open(auth_path, 'a') as fp:
40+
fp.write(open(key_path + '.pub').read())
41+
os.chmod(auth_path, int('0600', 8))
42+
43+
if os.path.expanduser('~mitogen__user1') == '~mitogen__user1':
3544
os.chdir(IMAGE_PREP_DIR)
3645
run("ansible-playbook -i localhost, _user_accounts.yml")
3746

@@ -40,4 +49,4 @@
4049
os.chdir(TESTS_DIR)
4150
playbook = os.environ.get('PLAYBOOK', 'all.yml')
4251
run('./run_ansible_playbook.py %s -l target %s',
43-
playbook, HOSTS_DIR, ' '.join(sys.argv[1:]))
52+
playbook, ' '.join(sys.argv[1:]))

tests/ansible/tests/affinity_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import multiprocessing
33
import os
4+
import sys
45
import tempfile
56

67
import mock
@@ -221,6 +222,11 @@ def test_high_cpus(self):
221222
for x in range(1, 4096, 32):
222223
policy.assign_subprocess()
223224

225+
MockLinuxPolicyTest = unittest2.skipIf(
226+
condition=(not sys.platform.startswith('linuxPolicy')),
227+
reason='select.select() not supported'
228+
)(MockLinuxPolicyTest)
229+
224230

225231
if __name__ == '__main__':
226232
unittest2.main()

tests/image_prep/_container_setup.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
- hosts: all
3+
vars_files:
4+
- shared_vars.yml
35
strategy: linear
46
gather_facts: false
57
tasks:
@@ -13,6 +15,8 @@
1315
fi
1416
1517
- hosts: all
18+
vars_files:
19+
- shared_vars.yml
1620
strategy: mitogen_free
1721
# Can't gather facts before here.
1822
gather_facts: true

tests/image_prep/_user_accounts.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66

77
- hosts: all
8+
vars_files:
9+
- shared_vars.yml
810
gather_facts: true
911
strategy: mitogen_free
1012
become: true

tests/image_prep/setup.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11

2-
- hosts: all
3-
gather_facts: false
4-
tasks:
5-
- set_fact:
6-
# Hacktacular.. but easiest place for it with current structure.
7-
sudo_group:
8-
MacOSX: admin
9-
Debian: sudo
10-
Ubuntu: sudo
11-
CentOS: wheel
12-
132
- include: _container_setup.yml
143
- include: _user_accounts.yml

tests/image_prep/shared_vars.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sudo_group:
2+
MacOSX: admin
3+
Debian: sudo
4+
Ubuntu: sudo
5+
CentOS: wheel

0 commit comments

Comments
 (0)