Skip to content

Commit b0f1d9c

Browse files
authored
Merge branch 'master' into functype-detection
2 parents 142dd91 + 2b4422c commit b0f1d9c

File tree

4 files changed

+61
-34
lines changed

4 files changed

+61
-34
lines changed

.circleci/config.yml

+16-24
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,10 @@ commands:
5959
command: |
6060
. venv/bin/activate
6161
mkdir test-reports
62-
circleci tests glob synapse/tests/test_*.py synapse/vendor/**/test_*.py | circleci tests run --split-by=timings --command "xargs python3 -m pytest -v -s -rs --durations 6 --maxfail 6 -p no:logging --junitxml=test-reports/junit.xml -o junit_family=xunit1 ${COVERAGE_ARGS}"
63-
64-
check_runner_has_work:
65-
description: Check that this runner has work to do
66-
steps:
67-
- run:
68-
name: Check workload
69-
command: |
70-
mkdir -p ./tmp && \
71-
>./tmp/tests.txt && \
72-
circleci tests glob synapse/tests/test_*.py synapse/vendor/**/test_*.py | circleci tests run --split-by=timings --command ">./tmp/tests.txt xargs echo"
73-
[ -s tmp/tests.txt ] || circleci-agent step halt #if there are no tests, terminate execution after this step
62+
circleci tests glob synapse/tests/test_*.py synapse/vendor/**/test_*.py | \
63+
circleci tests run \
64+
--timings-type=name \
65+
--command="xargs python3 -m pytest -n 8 --dist worksteal -v -rs --durations 6 -p no:logging --junitxml=test-reports/junit.xml -o junit_family=xunit1 ${COVERAGE_ARGS}"
7466
7567
test_steps_doc:
7668
description: "Documentation test steps"
@@ -121,7 +113,15 @@ commands:
121113
steps:
122114
- checkout
123115

124-
- check_runner_has_work
116+
- run:
117+
# Run this first so we fail on syntax errors before installing a bunch
118+
# of stuff and doing a bunch of work. It's easier now that we're only
119+
# a single runner using xdist.
120+
name: syntax
121+
command: |
122+
pip install "pycodestyle>=2.10.0,<3.0.0"
123+
if [ -n "${RUN_SYNTAX}" ]; then pycodestyle synapse; fi;
124+
if [ -n "${RUN_SYNTAX}" ]; then pycodestyle scripts; fi;
125125
126126
- run:
127127
name: checkout regression repo
@@ -144,15 +144,8 @@ commands:
144144
- ./venv
145145
key: v5-venv-{{ .Environment.CIRCLE_JOB }}-{{ .Branch }}-{{ checksum "pyproject.toml" }}-{{ checksum "/tmp/python.version" }}
146146

147-
- run:
148-
name: syntax
149-
command: |
150-
. venv/bin/activate
151-
if [ -n "${RUN_SYNTAX}" ]; then pycodestyle synapse; fi;
152-
if [ -n "${RUN_SYNTAX}" ]; then pycodestyle scripts; fi;
153-
154-
155147
- do_test_execution
148+
156149
- do_report_coverage
157150

158151
- store_test_results:
@@ -439,7 +432,7 @@ commands:
439432
jobs:
440433

441434
python311:
442-
parallelism: 8
435+
resource_class: xlarge
443436
docker:
444437
- image: cimg/python:3.11
445438
environment:
@@ -456,7 +449,7 @@ jobs:
456449
- test_steps_python
457450

458451
python311_replay:
459-
parallelism: 6
452+
resource_class: xlarge
460453
docker:
461454
- image: cimg/python:3.11
462455
environment:
@@ -473,7 +466,6 @@ jobs:
473466
- test_steps_python
474467

475468
doctests:
476-
parallelism: 1
477469
docker:
478470
- image: cimg/python:3.11
479471
environment:

conftest.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import sys
3+
import warnings
4+
5+
import synapse.common as s_common
6+
7+
THROW = False
8+
9+
def audithook(event, args):
10+
if event == 'socket.bind':
11+
_, addr = args
12+
if isinstance(addr, tuple) and (port := addr[1]) != 0:
13+
14+
testname = os.environ.get('PYTEST_CURRENT_TEST', '<unknown>').split(' ')[0]
15+
16+
mesg = f'Synapse tests should not bind to fixed ports: {testname=} {port=}'
17+
warnings.warn(mesg)
18+
19+
if THROW:
20+
raise RuntimeError(mesg)
21+
22+
def pytest_sessionstart(session):
23+
if s_common.envbool('SYNDEV_AUDIT_PORT_BINDS'):
24+
sys.addaudithook(audithook)
25+
26+
if s_common.envbool('SYNDEV_AUDIT_PORT_BINDS_RAISE'):
27+
global THROW
28+
THROW = True

synapse/tests/test_lib_aha.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def test_lib_aha_clone(self):
5959
self.len(ahacount, await proxy0.getAhaUrls())
6060
self.len(ahacount, await proxy0.getAhaServers())
6161

62-
purl = await proxy0.addAhaClone(zoinks)
62+
purl = await proxy0.addAhaClone(zoinks, port=0)
6363

6464
conf1 = {'clone': purl}
6565
async with self.getTestAha(conf=conf1, dirn=dir1) as aha1:
@@ -574,7 +574,7 @@ async def test_lib_aha_provision(self):
574574
}
575575
s_common.yamlsave(axonconf, axonpath, 'cell.yaml')
576576

577-
argv = (axonpath, '--auth-passwd', 'rootbeer')
577+
argv = (axonpath, '--auth-passwd', 'rootbeer', '--https', '0')
578578
async with await s_axon.Axon.initFromArgv(argv) as axon:
579579

580580
# opts were copied through successfully
@@ -1161,7 +1161,8 @@ async def test_aha_provision_longname(self):
11611161
aconf = {
11621162
'aha:name': 'aha',
11631163
'aha:network': networkname,
1164-
'provision:listen': f'ssl://aha.{networkname}:0'
1164+
'dmon:listen': f'ssl://aha.{networkname}:0',
1165+
'provision:listen': f'ssl://aha.{networkname}:0',
11651166
}
11661167
name = aconf.get('aha:name')
11671168
netw = aconf.get('aha:network')
@@ -1300,11 +1301,17 @@ async def test_aha_provision_listen_dns_name(self):
13001301
conf = {
13011302
'aha:network': 'synapse',
13021303
'dns:name': 'here.loop.vertex.link',
1304+
'dmon:listen': 'ssl://0.0.0.0:0?hostname=here.loop.vertex.link&ca=synapse',
13031305
}
1304-
mesg = 'provision listening: ssl://0.0.0.0:27272?hostname=here.loop.vertex.link'
1305-
with self.getAsyncLoggerStream('synapse.lib.aha', mesg) as stream:
1306+
1307+
orig = s_aha.AhaCell._getProvListen
1308+
def _getProvListen(_self):
1309+
ret = orig(_self)
1310+
self.eq(ret, 'ssl://0.0.0.0:27272?hostname=here.loop.vertex.link')
1311+
return 'ssl://0.0.0.0:0?hostname=here.loop.vertex.link'
1312+
1313+
with mock.patch('synapse.lib.aha.AhaCell._getProvListen', _getProvListen):
13061314
async with self.getTestCell(s_aha.AhaCell, conf=conf) as aha:
1307-
self.true(await stream.wait(timeout=6))
13081315
# And the URL works with our listener :)
13091316
provurl = await aha.addAhaUserEnroll('bob.grey')
13101317
async with await s_telepath.openurl(provurl) as prox:

synapse/tests/test_tools_healthcheck.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def sleep(*args, **kwargs):
4545
await asyncio.sleep(0.6)
4646
core.addHealthFunc(sleep)
4747
outp.clear()
48-
retn = await s_t_healthcheck.main(['-c', curl, '-t', '0.2'], outp)
48+
retn = await s_t_healthcheck.main(['-c', curl, '-t', '0.4'], outp)
4949
self.eq(retn, 1)
5050
resp = json.loads(str(outp))
5151
self.eq(resp.get('components')[0].get('name'), 'error')
@@ -58,7 +58,7 @@ async def sleep(*args, **kwargs):
5858
_, port = await core.dmon.listen('tcp://127.0.0.1:0')
5959
root = await core.auth.getUserByName('root')
6060
await root.setPasswd('secret')
61-
retn = await s_t_healthcheck.main(['-c', f'tcp://root:[email protected]:{port}/cortex', '-t', '0.2'], outp)
61+
retn = await s_t_healthcheck.main(['-c', f'tcp://root:[email protected]:{port}/cortex', '-t', '0.4'], outp)
6262
self.eq(retn, 1)
6363
resp = json.loads(str(outp))
6464
self.eq(resp.get('components')[0].get('name'), 'error')
@@ -70,7 +70,7 @@ async def sleep(*args, **kwargs):
7070

7171
logger.info('Checking without perms')
7272
outp.clear()
73-
retn = await s_t_healthcheck.main(['-c', f'tcp://visi:[email protected]:{port}/cortex', '-t', '0.2'], outp)
73+
retn = await s_t_healthcheck.main(['-c', f'tcp://visi:[email protected]:{port}/cortex', '-t', '0.4'], outp)
7474
self.eq(retn, 1)
7575
resp = json.loads(str(outp))
7676
self.eq(resp.get('components')[0].get('name'), 'error')
@@ -83,7 +83,7 @@ async def sleep(*args, **kwargs):
8383
await core.fini()
8484
await asyncio.sleep(0)
8585
outp.clear()
86-
retn = await s_t_healthcheck.main(['-c', curl, '-t', '0.2'], outp)
86+
retn = await s_t_healthcheck.main(['-c', curl, '-t', '0.4'], outp)
8787
self.eq(retn, 1)
8888
resp = json.loads(str(outp))
8989
self.eq(resp.get('components')[0].get('name'), 'error')

0 commit comments

Comments
 (0)