Skip to content

Commit 9d404e0

Browse files
authored
Merge pull request #800 from moreati/0.2-backport
Prepare 0.2.10rc1
2 parents 27ad214 + f8062f2 commit 9d404e0

25 files changed

+278
-71
lines changed

.ci/ansible_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
]
1717

1818
batches.extend(
19-
['docker pull %s' % (ci_lib.image_for_distro(distro),)]
19+
['docker pull %s' % (ci_lib.image_for_distro(distro),), 'sleep 1']
2020
for distro in ci_lib.DISTROS
2121
)
2222

.ci/ansible_tests.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ def pause_if_interactive():
3737

3838

3939
with ci_lib.Fold('job_setup'):
40-
# Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version.
41-
run("pip install -q ansible==%s", ci_lib.ANSIBLE_VERSION)
42-
4340
os.chdir(TESTS_DIR)
4441
os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7))
4542

@@ -69,8 +66,6 @@ def pause_if_interactive():
6966
run("sudo apt-get update")
7067
run("sudo apt-get install -y sshpass")
7168

72-
run("bash -c 'sudo ln -vfs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py /usr/lib/python2.7 || true'")
73-
run("bash -c 'sudo ln -vfs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py $VIRTUAL_ENV/lib/python2.7 || true'")
7469

7570
with ci_lib.Fold('ansible'):
7671
playbook = os.environ.get('PLAYBOOK', 'all.yml')

.ci/azure-pipelines-steps.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ steps:
1414
# stuff into. The virtualenv can probably be removed again, but this was a
1515
# hard-fought battle and for now I am tired of this crap.
1616
- script: |
17-
# need wheel before building virtualenv because of bdist_wheel and setuptools deps
18-
# Mac's System Integrity Protection prevents symlinking /usr/bin
19-
# and Azure isn't allowing disabling it apparently: https://developercommunityapi.westus.cloudapp.azure.com/idea/558702/allow-disabling-sip-on-microsoft-hosted-macos-agen.html
20-
# the || will activate when running python3 tests
2117
# TODO: get python3 tests passing
22-
(sudo ln -fs /usr/bin/python$(python.version) /usr/bin/python &&
23-
/usr/bin/python -m pip install -U pip wheel setuptools &&
24-
/usr/bin/python -m pip install -U virtualenv &&
25-
/usr/bin/python -m virtualenv /tmp/venv -p /usr/bin/python$(python.version)) ||
26-
(sudo /usr/bin/python$(python.version) -m pip install -U pip wheel setuptools &&
27-
/usr/bin/python$(python.version) -m venv /tmp/venv)
18+
set -o errexit
19+
set -o nounset
20+
set -o pipefail
21+
set -x
22+
23+
# Ensure virtualenv is in system-wide $PATH on OSX, for Ansible test tasks
24+
# that use it, e.g. regression/issue_152__virtualenv_python_fails.yml
25+
if [[ -d /Library/Frameworks/Python.framework/Versions/2.7/bin ]]; then
26+
echo $PATH
27+
which python
28+
python -m pip install -U pip virtualenv
29+
ln -s /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenv /usr/local/bin/virtualenv
30+
virtualenv --version
31+
fi
32+
33+
# Create virtualenv using desired Python version, to run the testcases
34+
python$(python.version) -m pip install -U pip wheel setuptools virtualenv
35+
python$(python.version) -m virtualenv /tmp/venv -p python$(python.version)
2836
echo "##vso[task.prependpath]/tmp/venv/bin"
2937
3038
displayName: activate venv
@@ -37,3 +45,5 @@ steps:
3745

3846
- script: .ci/$(MODE)_tests.py
3947
displayName: "Run $(MODE)_tests.py"
48+
env:
49+
NOCOVERAGE: 1

.ci/azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
strategy:
1414
matrix:
1515
Mito27_27:
16-
python.version: '2.7.18'
16+
python.version: '2.7'
1717
MODE: mitogen
1818
Ans288_27:
19-
python.version: '2.7.18'
19+
python.version: '2.7'
2020
MODE: localhost_ansible
2121
VER: 2.8.8
2222

.ci/ci_lib.py

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,28 @@ def cleanup_travis_junk(stdout=sys.stdout, stderr=sys.stderr, proc=proc):
8080
# -----------------
8181

8282
def _argv(s, *args):
83+
"""Interpolate a command line using *args, return an argv style list.
84+
85+
>>> _argv('git commit -m "Use frobnicate 2.0 (fixes #%d)"', 1234)
86+
['git', commit', '-m', 'Use frobnicate 2.0 (fixes #1234)']
87+
"""
8388
if args:
8489
s %= args
8590
return shlex.split(s)
8691

8792

8893
def run(s, *args, **kwargs):
94+
""" Run a command, with arguments, and print timing information
95+
96+
>>> rc = run('echo "%s %s"', 'foo', 'bar')
97+
Running: ['/usr/bin/time', '--', 'echo', 'foo bar']
98+
foo bar
99+
0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 1964maxresident)k
100+
0inputs+0outputs (0major+71minor)pagefaults 0swaps
101+
Finished running: ['/usr/bin/time', '--', 'echo', 'foo bar']
102+
>>> rc
103+
0
104+
"""
89105
argv = ['/usr/bin/time', '--'] + _argv(s, *args)
90106
print('Running: %s' % (argv,))
91107
try:
@@ -98,12 +114,36 @@ def run(s, *args, **kwargs):
98114
return ret
99115

100116

101-
def run_batches(batches):
102-
combine = lambda batch: 'set -x; ' + (' && '.join(
117+
def combine(batch):
118+
"""
119+
>>> combine(['ls -l', 'echo foo'])
120+
'set -x; ( ls -l; ) && ( echo foo; )'
121+
"""
122+
return 'set -x; ' + (' && '.join(
103123
'( %s; )' % (cmd,)
104124
for cmd in batch
105125
))
106126

127+
128+
def run_batches(batches):
129+
""" Run shell commands grouped into batches, showing an execution trace.
130+
131+
Raise AssertionError if any command has exits with a non-zero status.
132+
133+
>>> run_batches([['echo foo', 'true']])
134+
+ echo foo
135+
foo
136+
+ true
137+
>>> run_batches([['true', 'echo foo'], ['false']])
138+
+ true
139+
+ echo foo
140+
foo
141+
+ false
142+
Traceback (most recent call last):
143+
File "...", line ..., in <module>
144+
File "...", line ..., in run_batches
145+
AssertionError
146+
"""
107147
procs = [
108148
subprocess.Popen(combine(batch), shell=True)
109149
for batch in batches
@@ -112,12 +152,28 @@ def run_batches(batches):
112152

113153

114154
def get_output(s, *args, **kwargs):
155+
"""
156+
Print and run command line s, %-interopolated using *args. Return stdout.
157+
158+
>>> s = get_output('echo "%s %s"', 'foo', 'bar')
159+
Running: ['echo', 'foo bar']
160+
>>> s
161+
'foo bar\n'
162+
"""
115163
argv = _argv(s, *args)
116164
print('Running: %s' % (argv,))
117165
return subprocess.check_output(argv, **kwargs)
118166

119167

120168
def exists_in_path(progname):
169+
"""
170+
Return True if proganme exists in $PATH.
171+
172+
>>> exists_in_path('echo')
173+
True
174+
>>> exists_in_path('kwyjibo') # Only found in North American cartoons
175+
False
176+
"""
121177
return any(os.path.exists(os.path.join(dirname, progname))
122178
for dirname in os.environ['PATH'].split(os.pathsep))
123179

@@ -132,6 +188,18 @@ def destroy(self, rmtree=shutil.rmtree):
132188

133189

134190
class Fold(object):
191+
"""
192+
Bracket a section of stdout with travis_fold markers.
193+
194+
This allows the section to be collapsed or expanded in Travis CI web UI.
195+
196+
>>> with Fold('stage 1'):
197+
... print('Frobnicate the frobnitz')
198+
...
199+
travis_fold:start:stage 1
200+
Frobnicate the frobnitz
201+
travis_fold:end:stage 1
202+
"""
135203
def __init__(self, name):
136204
self.name = name
137205

@@ -171,6 +239,8 @@ def __exit__(self, _1, _2, _3):
171239
)
172240

173241
def get_docker_hostname():
242+
"""Return the hostname where the docker daemon is running.
243+
"""
174244
url = os.environ.get('DOCKER_HOST')
175245
if url in (None, 'http+docker://localunixsocket'):
176246
return 'localhost'
@@ -180,10 +250,34 @@ def get_docker_hostname():
180250

181251

182252
def image_for_distro(distro):
183-
return 'mitogen/%s-test' % (distro.partition('-')[0],)
253+
"""Return the container image name or path for a test distro name.
254+
255+
The returned value is suitable for use with `docker pull`.
256+
257+
>>> image_for_distro('centos5')
258+
'public.ecr.aws/n5z0e8q9/centos5-test'
259+
>>> image_for_distro('centos5-something_custom')
260+
'public.ecr.aws/n5z0e8q9/centos5-test'
261+
"""
262+
return 'public.ecr.aws/n5z0e8q9/%s-test' % (distro.partition('-')[0],)
184263

185264

186265
def make_containers(name_prefix='', port_offset=0):
266+
"""
267+
>>> import pprint
268+
>>> BASE_PORT=2200; DISTROS=['debian', 'centos6']
269+
>>> pprint.pprint(make_containers())
270+
[{'distro': 'debian',
271+
'hostname': 'localhost',
272+
'name': 'target-debian-1',
273+
'port': 2201,
274+
'python_path': '/usr/bin/python'},
275+
{'distro': 'centos6',
276+
'hostname': 'localhost',
277+
'name': 'target-centos6-2',
278+
'port': 2202,
279+
'python_path': '/usr/bin/python'}]
280+
"""
187281
docker_hostname = get_docker_hostname()
188282
firstbit = lambda s: (s+'-').split('-')[0]
189283
secondbit = lambda s: (s+'-').split('-')[1]
@@ -256,6 +350,14 @@ def get_interesting_procs(container_name=None):
256350

257351

258352
def start_containers(containers):
353+
"""Run docker containers in the background, with sshd on specified ports.
354+
355+
>>> containers = start_containers([
356+
... {'distro': 'debian', 'hostname': 'localhost',
357+
... 'name': 'target-debian-1', 'port': 2201,
358+
... 'python_path': '/usr/bin/python'},
359+
... ])
360+
"""
259361
if os.environ.get('KEEP'):
260362
return
261363

.ci/localhost_ansible_tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020

2121

2222
with ci_lib.Fold('job_setup'):
23-
# Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version.
24-
run("pip install -q virtualenv ansible==%s", ci_lib.ANSIBLE_VERSION)
25-
2623
os.chmod(KEY_PATH, int('0600', 8))
24+
# NOTE: sshpass v1.06 causes errors so pegging to 1.05 -> "msg": "Error when changing password","out": "passwd: DS error: eDSAuthFailed\n",
25+
# there's a checksum error with "brew install http://git.io/sshpass.rb" though, so installing manually
2726
if not ci_lib.exists_in_path('sshpass'):
28-
run("brew install http://git.io/sshpass.rb")
27+
os.system("curl -O -L https://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz && \
28+
tar xvf sshpass-1.05.tar.gz && \
29+
cd sshpass-1.05 && \
30+
./configure && \
31+
sudo make install")
2932

3033

3134
with ci_lib.Fold('machine_prep'):

.ci/prep_azure.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,4 @@
4343
.format(pv=os.environ['PYTHONVERSION'])
4444
])
4545

46-
47-
if ci_lib.have_docker():
48-
batches.extend(
49-
['docker pull %s' % (ci_lib.image_for_distro(distro),)]
50-
for distro in ci_lib.DISTROS
51-
)
52-
53-
5446
ci_lib.run_batches(batches)

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ cache:
1616
- directories:
1717
- /home/travis/virtualenv
1818

19+
env:
20+
- NOCOVERAGE=1
21+
1922
install:
2023
- grep -Erl git-lfs\|couchdb /etc/apt | sudo xargs rm -v
2124
- .ci/${MODE}_install.py

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2019, David Wilson
1+
Copyright 2021, the Mitogen authors
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
![](https://i.imgur.com/eBM6LhJ.gif)
77

8-
[![Total alerts](https://img.shields.io/lgtm/alerts/g/dw/mitogen.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dw/mitogen/alerts/)
8+
[![Total alerts](https://img.shields.io/lgtm/alerts/g/mitogen-hq/mitogen.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/mitogen-hq/mitogen/alerts/)
99

10-
[![Build Status](https://travis-ci.org/dw/mitogen.svg?branch=master)](https://travis-ci.org/dw/mitogen)
10+
[![Build Status](https://api.travis-ci.com/mitogen-hq/mitogen.svg?branch=master)](https://api.travis-ci.com/mitogen-hq/mitogen)
1111

12-
[![Pipelines Status](https://dev.azure.com/dw-mitogen/Mitogen/_apis/build/status/dw.mitogen?branchName=master)](https://dev.azure.com/dw-mitogen/Mitogen/_build/latest?definitionId=1?branchName=master)
12+
[![Pipelines Status](https://dev.azure.com/mitogen-hq/mitogen/_apis/build/status/mitogen-hq.mitogen?branchName=master)](https://dev.azure.com/mitogen-hq/mitogen/_build/latest?definitionId=1&branchName=master)

0 commit comments

Comments
 (0)