synapse 2.176.0__py311-none-any.whl → 2.178.0__py311-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of synapse might be problematic. Click here for more details.
- synapse/axon.py +24 -9
- synapse/cortex.py +337 -172
- synapse/cryotank.py +46 -37
- synapse/datamodel.py +17 -4
- synapse/exc.py +19 -0
- synapse/lib/agenda.py +7 -13
- synapse/lib/aha.py +361 -88
- synapse/lib/auth.py +1520 -0
- synapse/lib/base.py +27 -9
- synapse/lib/cell.py +422 -163
- synapse/lib/config.py +15 -11
- synapse/lib/coro.py +13 -0
- synapse/lib/grammar.py +5 -0
- synapse/lib/hive.py +24 -3
- synapse/lib/hiveauth.py +6 -32
- synapse/lib/layer.py +7 -9
- synapse/lib/link.py +22 -18
- synapse/lib/lmdbslab.py +152 -3
- synapse/lib/modelrev.py +1 -1
- synapse/lib/nexus.py +24 -12
- synapse/lib/schemas.py +136 -0
- synapse/lib/storm.py +61 -29
- synapse/lib/stormlib/aha.py +1 -1
- synapse/lib/stormlib/auth.py +185 -10
- synapse/lib/stormlib/cortex.py +16 -5
- synapse/lib/stormlib/gen.py +80 -0
- synapse/lib/stormlib/imap.py +6 -2
- synapse/lib/stormlib/model.py +55 -0
- synapse/lib/stormlib/modelext.py +60 -0
- synapse/lib/stormlib/smtp.py +12 -2
- synapse/lib/stormlib/tabular.py +212 -0
- synapse/lib/stormtypes.py +14 -1
- synapse/lib/trigger.py +1 -1
- synapse/lib/version.py +2 -2
- synapse/lib/view.py +55 -28
- synapse/models/base.py +7 -0
- synapse/models/biz.py +4 -0
- synapse/models/files.py +8 -1
- synapse/models/inet.py +8 -0
- synapse/telepath.py +32 -17
- synapse/tests/files/aha/certs/cas/synapse.crt +28 -0
- synapse/tests/files/aha/certs/cas/synapse.key +51 -0
- synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.crt +30 -0
- synapse/tests/files/aha/certs/hosts/00.aha.loop.vertex.link.key +51 -0
- synapse/tests/files/aha/certs/users/root@synapse.crt +29 -0
- synapse/tests/files/aha/certs/users/root@synapse.key +51 -0
- synapse/tests/files/changelog/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz +0 -0
- synapse/tests/files/changelog/model_2.176.0_2a25c58bbd344716cd7cbc3f4304d8925b0f4ef2.yaml.gz +0 -0
- synapse/tests/files/rstorm/testsvc.py +1 -1
- synapse/tests/test_axon.py +8 -5
- synapse/tests/test_cortex.py +149 -141
- synapse/tests/test_cryotank.py +4 -4
- synapse/tests/test_datamodel.py +7 -0
- synapse/tests/test_lib_agenda.py +10 -3
- synapse/tests/test_lib_aha.py +336 -490
- synapse/tests/{test_lib_hiveauth.py → test_lib_auth.py} +314 -11
- synapse/tests/test_lib_base.py +20 -0
- synapse/tests/test_lib_cell.py +210 -30
- synapse/tests/test_lib_config.py +4 -3
- synapse/tests/test_lib_httpapi.py +18 -14
- synapse/tests/test_lib_layer.py +33 -33
- synapse/tests/test_lib_link.py +42 -1
- synapse/tests/test_lib_lmdbslab.py +68 -0
- synapse/tests/test_lib_nexus.py +12 -4
- synapse/tests/test_lib_node.py +0 -7
- synapse/tests/test_lib_storm.py +45 -0
- synapse/tests/test_lib_stormlib_aha.py +35 -36
- synapse/tests/test_lib_stormlib_auth.py +21 -0
- synapse/tests/test_lib_stormlib_cell.py +4 -15
- synapse/tests/test_lib_stormlib_cortex.py +12 -12
- synapse/tests/test_lib_stormlib_gen.py +99 -0
- synapse/tests/test_lib_stormlib_imap.py +14 -3
- synapse/tests/test_lib_stormlib_model.py +108 -0
- synapse/tests/test_lib_stormlib_modelext.py +64 -0
- synapse/tests/test_lib_stormlib_smtp.py +51 -0
- synapse/tests/test_lib_stormlib_tabular.py +226 -0
- synapse/tests/test_lib_stormsvc.py +4 -1
- synapse/tests/test_lib_stormtypes.py +10 -0
- synapse/tests/test_model_base.py +3 -0
- synapse/tests/test_model_biz.py +3 -0
- synapse/tests/test_model_files.py +12 -2
- synapse/tests/test_model_inet.py +24 -0
- synapse/tests/test_tools_aha.py +78 -101
- synapse/tests/test_tools_changelog.py +196 -0
- synapse/tests/test_tools_healthcheck.py +4 -3
- synapse/tests/utils.py +87 -121
- synapse/tools/aha/clone.py +50 -0
- synapse/tools/aha/enroll.py +2 -1
- synapse/tools/backup.py +2 -2
- synapse/tools/changelog.py +776 -15
- {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/METADATA +48 -48
- {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/RECORD +95 -82
- {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/WHEEL +1 -1
- {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/LICENSE +0 -0
- {synapse-2.176.0.dist-info → synapse-2.178.0.dist-info}/top_level.txt +0 -0
synapse/tests/test_cortex.py
CHANGED
|
@@ -54,40 +54,21 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
54
54
|
async def test_cortex_handoff(self):
|
|
55
55
|
|
|
56
56
|
with self.getTestDir() as dirn:
|
|
57
|
-
|
|
58
|
-
coredir0 = s_common.genpath(dirn, 'core00')
|
|
59
|
-
coredir1 = s_common.genpath(dirn, 'core01')
|
|
60
|
-
coredir2 = s_common.genpath(dirn, 'core02',)
|
|
61
|
-
|
|
62
|
-
conf = {
|
|
63
|
-
'aha:name': 'aha',
|
|
64
|
-
'aha:network': 'newp',
|
|
65
|
-
'provision:listen': 'tcp://127.0.0.1:0',
|
|
66
|
-
}
|
|
67
|
-
async with self.getTestAha(dirn=ahadir, conf=conf) as aha:
|
|
68
|
-
|
|
69
|
-
provaddr, provport = aha.provdmon.addr
|
|
70
|
-
aha.conf['provision:listen'] = f'tcp://127.0.0.1:{provport}'
|
|
71
|
-
|
|
72
|
-
ahahost, ahaport = await aha.dmon.listen('ssl://127.0.0.1:0?hostname=aha.newp&ca=newp')
|
|
73
|
-
aha.conf['aha:urls'] = (f'ssl://127.0.0.1:{ahaport}?hostname=aha.newp',)
|
|
57
|
+
async with self.getTestAha() as aha:
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
coreconf = {'aha:provision': provurl, 'nexslog:en': False}
|
|
59
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('00.cortex')}
|
|
77
60
|
|
|
78
|
-
async with self.getTestCore(
|
|
61
|
+
async with self.getTestCore(conf=conf) as core00:
|
|
79
62
|
|
|
80
63
|
with self.raises(s_exc.BadArg):
|
|
81
64
|
await core00.handoff(core00.getLocalUrl())
|
|
82
65
|
|
|
83
66
|
self.false((await core00.getCellInfo())['cell']['uplink'])
|
|
84
67
|
|
|
85
|
-
provinfo = {'mirror': '00.cortex'}
|
|
86
|
-
provurl = await aha.addAhaSvcProv('01.cortex', provinfo=provinfo)
|
|
87
|
-
|
|
88
68
|
# provision with the new hostname and mirror config
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
provinfo = {'mirror': '00.cortex'}
|
|
70
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('01.cortex', provinfo=provinfo)}
|
|
71
|
+
async with self.getTestCore(conf=conf) as core01:
|
|
91
72
|
|
|
92
73
|
# test out connecting to the leader but having aha chose a mirror
|
|
93
74
|
async with s_telepath.loadTeleCell(core01.dirn):
|
|
@@ -117,9 +98,9 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
117
98
|
self.true((await core00.getCellInfo())['cell']['uplink'])
|
|
118
99
|
self.false((await core01.getCellInfo())['cell']['uplink'])
|
|
119
100
|
|
|
120
|
-
mods00 = s_common.yamlload(
|
|
121
|
-
mods01 = s_common.yamlload(
|
|
122
|
-
self.eq(mods00, {'mirror': 'aha://01.cortex.
|
|
101
|
+
mods00 = s_common.yamlload(core00.dirn, 'cell.mods.yaml')
|
|
102
|
+
mods01 = s_common.yamlload(core01.dirn, 'cell.mods.yaml')
|
|
103
|
+
self.eq(mods00, {'mirror': 'aha://01.cortex.synapse'})
|
|
123
104
|
self.eq(mods01, {'mirror': None})
|
|
124
105
|
|
|
125
106
|
await core00.nodes('[inet:ipv4=5.5.5.5]')
|
|
@@ -129,12 +110,11 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
129
110
|
# This pops the mirror config out of the mods file we copied
|
|
130
111
|
# from the backup.
|
|
131
112
|
provinfo = {'mirror': '01.cortex'}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
async with self.getTestCore(dirn=coredir2, conf=coreconf) as core02:
|
|
113
|
+
conf = {'aha:provision': await aha.addAhaSvcProv('02.cortex', provinfo=provinfo)}
|
|
114
|
+
async with self.getTestCore(conf=conf) as core02:
|
|
135
115
|
self.false(core02.isactive)
|
|
136
|
-
self.eq(core02.conf.get('mirror'), 'aha://root@01.cortex
|
|
137
|
-
mods02 = s_common.yamlload(
|
|
116
|
+
self.eq(core02.conf.get('mirror'), 'aha://root@01.cortex...')
|
|
117
|
+
mods02 = s_common.yamlload(core02.dirn, 'cell.mods.yaml')
|
|
138
118
|
self.eq(mods02, {})
|
|
139
119
|
# The mirror writeback and change distribution works
|
|
140
120
|
self.len(0, await core01.nodes('inet:ipv4=6.6.6.6'))
|
|
@@ -144,7 +124,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
144
124
|
self.len(1, await core01.nodes('inet:ipv4=6.6.6.6'))
|
|
145
125
|
self.len(1, await core00.nodes('inet:ipv4=6.6.6.6'))
|
|
146
126
|
# list mirrors
|
|
147
|
-
exp = ['aha://00.cortex.
|
|
127
|
+
exp = ['aha://00.cortex.synapse', 'aha://02.cortex.synapse']
|
|
148
128
|
self.sorteq(exp, await core00.getMirrorUrls())
|
|
149
129
|
self.sorteq(exp, await core01.getMirrorUrls())
|
|
150
130
|
self.sorteq(exp, await core02.getMirrorUrls())
|
|
@@ -396,7 +376,7 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
396
376
|
with self.getTestDir() as dirn:
|
|
397
377
|
|
|
398
378
|
async with self.getTestCore(dirn=dirn) as core:
|
|
399
|
-
self.nn(
|
|
379
|
+
self.nn(core.cellinfo.pop('cortex:version'))
|
|
400
380
|
|
|
401
381
|
with self.raises(s_exc.BadStorageVersion):
|
|
402
382
|
async with self.getTestCore(dirn=dirn) as core:
|
|
@@ -2693,6 +2673,8 @@ class CortexTest(s_t_utils.SynTest):
|
|
|
2693
2673
|
self.len(1, await core.nodes('.hehe [ -.hehe ]'))
|
|
2694
2674
|
self.len(0, await core.nodes('.hehe'))
|
|
2695
2675
|
|
|
2676
|
+
self.none(await core._addUnivProp('hehe', None, None))
|
|
2677
|
+
|
|
2696
2678
|
# ensure that we can delete univ props in a authenticated setting
|
|
2697
2679
|
async with self.getTestCoreAndProxy() as (realcore, core):
|
|
2698
2680
|
|
|
@@ -3145,6 +3127,8 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
3145
3127
|
self.len(0, pkgs)
|
|
3146
3128
|
await self.asyncraises(s_exc.NoSuchPkg, proxy.delStormPkg('foosball'))
|
|
3147
3129
|
|
|
3130
|
+
self.none(await core._delStormPkg('foosball'))
|
|
3131
|
+
|
|
3148
3132
|
# This segfaults in regex < 2022.9.11
|
|
3149
3133
|
query = '''test:str~="(?(?<=A)|(?(?![^B])C|D))"'''
|
|
3150
3134
|
msgs = await core.stormlist(query)
|
|
@@ -3886,16 +3870,15 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
3886
3870
|
await core.addStormPkg(otherpkg)
|
|
3887
3871
|
|
|
3888
3872
|
visi = await core.auth.addUser('visi')
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
opts['vars']['useriden'] = visi.iden
|
|
3873
|
+
uopts = dict(opts)
|
|
3874
|
+
uopts['user'] = visi.iden
|
|
3875
|
+
opts['vars']['useriden'] = visi.iden
|
|
3893
3876
|
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3877
|
+
await self.asyncraises(s_exc.AuthDeny, core.nodes('$lib.graph.del($iden2)', opts=uopts))
|
|
3878
|
+
await core.nodes('$lib.graph.grant($iden2, users, $useriden, 3)', opts=opts)
|
|
3879
|
+
await core.nodes('$lib.graph.del($iden2)', opts=uopts)
|
|
3897
3880
|
|
|
3898
|
-
|
|
3881
|
+
self.len(2, await core.callStorm('return($lib.graph.list())', opts=opts))
|
|
3899
3882
|
|
|
3900
3883
|
q = '$lib.graph.del($lib.guid(graph.powerup, testgraph))'
|
|
3901
3884
|
await self.asyncraises(s_exc.AuthDeny, core.nodes(q))
|
|
@@ -4430,10 +4413,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4430
4413
|
'''
|
|
4431
4414
|
Everything still works when no nexus log is kept
|
|
4432
4415
|
'''
|
|
4433
|
-
conf = {'
|
|
4434
|
-
'nexslog:en': False,
|
|
4435
|
-
'layers:logedits': True,
|
|
4436
|
-
}
|
|
4416
|
+
conf = {'nexslog:en': False, 'layers:logedits': True}
|
|
4437
4417
|
async with self.getTestCore(conf=conf) as core:
|
|
4438
4418
|
self.len(2, await core.nodes('[test:str=foo test:str=bar]'))
|
|
4439
4419
|
self.len(2, await core.nodes('test:str'))
|
|
@@ -4442,10 +4422,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4442
4422
|
'''
|
|
4443
4423
|
Everything still works when no layer log is kept
|
|
4444
4424
|
'''
|
|
4445
|
-
conf = {'
|
|
4446
|
-
'nexslog:en': True,
|
|
4447
|
-
'layers:logedits': False,
|
|
4448
|
-
}
|
|
4425
|
+
conf = {'nexslog:en': True, 'layers:logedits': False}
|
|
4449
4426
|
async with self.getTestCore(conf=conf) as core:
|
|
4450
4427
|
self.len(2, await core.nodes('[test:str=foo test:str=bar]'))
|
|
4451
4428
|
self.len(2, await core.nodes('test:str'))
|
|
@@ -4463,18 +4440,12 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
4463
4440
|
'''
|
|
4464
4441
|
Make sure settings make it down to the slab
|
|
4465
4442
|
'''
|
|
4466
|
-
conf = {
|
|
4467
|
-
'layer:lmdb:map_async': False,
|
|
4468
|
-
'layer:lmdb:max_replay_log': 500,
|
|
4469
|
-
'layers:lockmemory': True,
|
|
4470
|
-
}
|
|
4443
|
+
conf = {'layers:lockmemory': True}
|
|
4471
4444
|
async with self.getTestCore(conf=conf) as core:
|
|
4472
4445
|
layr = core.getLayer()
|
|
4473
4446
|
slab = layr.layrslab
|
|
4474
4447
|
|
|
4475
4448
|
self.true(slab.lockmemory)
|
|
4476
|
-
self.eq(500, slab.max_xactops_len)
|
|
4477
|
-
self.true(500, slab.mapasync)
|
|
4478
4449
|
|
|
4479
4450
|
async def test_feed_syn_nodes(self):
|
|
4480
4451
|
|
|
@@ -5373,11 +5344,6 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5373
5344
|
|
|
5374
5345
|
url = core00.getLocalUrl()
|
|
5375
5346
|
|
|
5376
|
-
core01conf = {'nexslog:en': False, 'mirror': url}
|
|
5377
|
-
with self.raises(s_exc.BadConfValu):
|
|
5378
|
-
async with self.getTestCore(dirn=path01, conf=core01conf) as core01:
|
|
5379
|
-
self.fail('Should never get here.')
|
|
5380
|
-
|
|
5381
5347
|
core01conf = {'mirror': url}
|
|
5382
5348
|
|
|
5383
5349
|
async with self.getTestCore(dirn=path01, conf=core01conf) as core01:
|
|
@@ -5905,7 +5871,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5905
5871
|
# nexus recover() previously failed on adding to the hive
|
|
5906
5872
|
# although the dmon would get successfully started
|
|
5907
5873
|
self.nn(await core.callStorm('return($lib.dmon.get($iden))', opts=asuser))
|
|
5908
|
-
self.nn(core.
|
|
5874
|
+
self.nn(core.stormdmondefs.get(iden))
|
|
5909
5875
|
|
|
5910
5876
|
async def test_cortex_storm_dmon_view(self):
|
|
5911
5877
|
|
|
@@ -5948,7 +5914,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
5948
5914
|
|
|
5949
5915
|
visi = await core.auth.addUser('visi')
|
|
5950
5916
|
await visi.setAdmin(True)
|
|
5951
|
-
await visi.
|
|
5917
|
+
await visi.setProfileValu('cortex:view', view2_iden)
|
|
5952
5918
|
|
|
5953
5919
|
await core.nodes('$q=$lib.queue.add(dmon2)')
|
|
5954
5920
|
q = '''
|
|
@@ -6000,6 +5966,8 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
6000
5966
|
with self.raises(s_exc.CantDelCmd):
|
|
6001
5967
|
await core.delStormCmd('sleep')
|
|
6002
5968
|
|
|
5969
|
+
self.none(await core._delStormCmd('newp'))
|
|
5970
|
+
|
|
6003
5971
|
async def test_cortex_storm_lib_dmon_cmds(self):
|
|
6004
5972
|
async with self.getTestCore() as core:
|
|
6005
5973
|
await core.nodes('''
|
|
@@ -6115,12 +6083,22 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
6115
6083
|
await core.addFormProp('_hehe:haha', 'visi', ('str', {}), {})
|
|
6116
6084
|
self.len(1, await core.nodes('_hehe:haha [ :visi=lolz ]'))
|
|
6117
6085
|
|
|
6118
|
-
|
|
6119
|
-
await core.
|
|
6086
|
+
await core.addEdge(('test:int', '_goes', None), {})
|
|
6087
|
+
await core._addEdge(('test:int', '_goes', None), {})
|
|
6088
|
+
|
|
6089
|
+
with self.raises(s_exc.DupEdgeType):
|
|
6090
|
+
await core.addEdge(('test:int', '_goes', None), {})
|
|
6091
|
+
|
|
6092
|
+
# manually edit in borked entries
|
|
6093
|
+
core.extforms.set('_hehe:bork', ('_hehe:bork', None, None, None))
|
|
6094
|
+
core.extedges.set(s_common.guid('newp'), ((None, '_does', 'newp'), {}))
|
|
6120
6095
|
|
|
6121
6096
|
async with self.getTestCore(dirn=dirn) as core:
|
|
6122
6097
|
|
|
6123
6098
|
self.none(core.model.form('_hehe:bork'))
|
|
6099
|
+
self.none(core.model.edge((None, '_does', 'newp')))
|
|
6100
|
+
|
|
6101
|
+
self.nn(core.model.edge(('test:int', '_goes', None)))
|
|
6124
6102
|
|
|
6125
6103
|
self.len(1, await core.nodes('_hehe:haha=10'))
|
|
6126
6104
|
self.len(1, await core.nodes('_hehe:haha:visi=lolz'))
|
|
@@ -6173,6 +6151,11 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
6173
6151
|
with self.raises(s_exc.BadFormDef):
|
|
6174
6152
|
await core.delForm('hehe:haha')
|
|
6175
6153
|
|
|
6154
|
+
with self.raises(s_exc.NoSuchEdge):
|
|
6155
|
+
await core.delEdge(('newp', 'newp', 'newp'))
|
|
6156
|
+
|
|
6157
|
+
await core._delEdge(('newp', 'newp', 'newp'))
|
|
6158
|
+
|
|
6176
6159
|
await core.nodes('_hehe:haha [ -:visi ]')
|
|
6177
6160
|
await core.delFormProp('_hehe:haha', 'visi')
|
|
6178
6161
|
|
|
@@ -6301,100 +6284,121 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
6301
6284
|
await core.axon.metrics())
|
|
6302
6285
|
|
|
6303
6286
|
async def test_cortex_delLayerView(self):
|
|
6304
|
-
async with self.getTestCore() as core:
|
|
6305
6287
|
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
await self.asyncraises(s_exc.SynErr, core._delViewWithLayer(core.view.iden, None, None))
|
|
6288
|
+
with self.getTestDir() as dirn:
|
|
6289
|
+
async with self.getTestCore(dirn=dirn) as core:
|
|
6309
6290
|
|
|
6310
|
-
|
|
6311
|
-
|
|
6291
|
+
# Can't delete the default view
|
|
6292
|
+
await self.asyncraises(s_exc.SynErr, core.delView(core.view.iden))
|
|
6293
|
+
await self.asyncraises(s_exc.SynErr, core._delViewWithLayer(core.view.iden, None, None))
|
|
6312
6294
|
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
await self.asyncraises(s_exc.NoSuchView, core.delViewWithLayer('XXX'))
|
|
6295
|
+
# Can't delete a layer in a view
|
|
6296
|
+
await self.asyncraises(s_exc.SynErr, core.delLayer(core.view.layers[0].iden))
|
|
6316
6297
|
|
|
6317
|
-
|
|
6318
|
-
|
|
6298
|
+
# Can't delete a nonexistent view
|
|
6299
|
+
await self.asyncraises(s_exc.NoSuchView, core.delView('XXX'))
|
|
6300
|
+
await self.asyncraises(s_exc.NoSuchView, core.delViewWithLayer('XXX'))
|
|
6319
6301
|
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
view2_iden = vdef2.get('iden')
|
|
6302
|
+
# Can't delete a nonexistent layer
|
|
6303
|
+
await self.asyncraises(s_exc.NoSuchLayer, core.delLayer('XXX'))
|
|
6323
6304
|
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6305
|
+
# Fork the main view
|
|
6306
|
+
vdef2 = await core.view.fork()
|
|
6307
|
+
view2_iden = vdef2.get('iden')
|
|
6327
6308
|
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
view3_iden = (await core.addView(vdef3)).get('iden')
|
|
6309
|
+
# Can't delete a view twice
|
|
6310
|
+
await core.delView(view2_iden)
|
|
6311
|
+
await self.asyncraises(s_exc.NoSuchView, core.delView(view2_iden))
|
|
6332
6312
|
|
|
6333
|
-
|
|
6334
|
-
|
|
6313
|
+
layr = await core.addLayer()
|
|
6314
|
+
layriden = layr['iden']
|
|
6315
|
+
vdef3 = {'layers': (layriden,)}
|
|
6316
|
+
view3_iden = (await core.addView(vdef3)).get('iden')
|
|
6335
6317
|
|
|
6336
|
-
|
|
6318
|
+
opts = {'view': view3_iden}
|
|
6319
|
+
await core.callStorm('$lib.view.get().set(protected, $lib.true)', opts=opts)
|
|
6337
6320
|
|
|
6338
|
-
|
|
6321
|
+
await self.asyncraises(s_exc.CantDelView, core.delViewWithLayer(view3_iden))
|
|
6339
6322
|
|
|
6340
|
-
|
|
6341
|
-
vdef4 = await view3.fork()
|
|
6323
|
+
await core.callStorm('$lib.view.get().set(protected, $lib.false)', opts=opts)
|
|
6342
6324
|
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
view4 = core.getView(view4_iden)
|
|
6325
|
+
view3 = core.getView(view3_iden)
|
|
6326
|
+
vdef4 = await view3.fork()
|
|
6346
6327
|
|
|
6347
|
-
|
|
6348
|
-
|
|
6328
|
+
deadlayr = view3.layers[0].iden
|
|
6329
|
+
view4_iden = vdef4.get('iden')
|
|
6330
|
+
view4 = core.getView(view4_iden)
|
|
6349
6331
|
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
layr2 = await core.callStorm('$layer=$lib.layer.add() return($layer)')
|
|
6353
|
-
varz = {'iden': layriden, 'tgt': layr2.get('iden'), 'port': port}
|
|
6354
|
-
opts = {'vars': varz, 'view': view3_iden}
|
|
6355
|
-
|
|
6356
|
-
pullq = '$layer=$lib.layer.get($iden).addPull(`tcp://root:secret@127.0.0.1:{$port}/*/layer/{$tgt}`)'
|
|
6357
|
-
pushq = '$layer=$lib.layer.get($iden).addPush(`tcp://root:secret@127.0.0.1:{$port}/*/layer/{$tgt}`)'
|
|
6358
|
-
msgs = await core.stormlist(pullq, opts=opts)
|
|
6359
|
-
self.stormHasNoWarnErr(msgs)
|
|
6332
|
+
self.eq(view4.parent, view3)
|
|
6333
|
+
self.len(2, view4.layers)
|
|
6360
6334
|
|
|
6361
|
-
|
|
6362
|
-
|
|
6335
|
+
await core.auth.rootuser.setPasswd('secret')
|
|
6336
|
+
host, port = await core.dmon.listen('tcp://127.0.0.1:0/')
|
|
6337
|
+
layr2 = await core.callStorm('$layer=$lib.layer.add() return($layer)')
|
|
6338
|
+
varz = {'iden': layriden, 'tgt': layr2.get('iden'), 'port': port}
|
|
6339
|
+
opts = {'vars': varz, 'view': view3_iden}
|
|
6363
6340
|
|
|
6364
|
-
|
|
6341
|
+
pullq = '$layer=$lib.layer.get($iden).addPull(`tcp://root:secret@127.0.0.1:{$port}/*/layer/{$tgt}`)'
|
|
6342
|
+
pushq = '$layer=$lib.layer.get($iden).addPush(`tcp://root:secret@127.0.0.1:{$port}/*/layer/{$tgt}`)'
|
|
6343
|
+
msgs = await core.stormlist(pullq, opts=opts)
|
|
6344
|
+
self.stormHasNoWarnErr(msgs)
|
|
6365
6345
|
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
{'event': 'view:setlayers', 'info': {'iden': view4.iden, 'layers': layridens}},
|
|
6369
|
-
{'event': 'view:set', 'info': {'iden': view4.iden, 'name': 'parent', 'valu': None}}
|
|
6370
|
-
]
|
|
6371
|
-
task = core.schedCoro(s_t_utils.waitForBehold(core, events))
|
|
6346
|
+
msgs = await core.stormlist(pushq, opts=opts)
|
|
6347
|
+
self.stormHasNoWarnErr(msgs)
|
|
6372
6348
|
|
|
6373
|
-
|
|
6349
|
+
coros = len(core.activecoros)
|
|
6374
6350
|
|
|
6375
|
-
|
|
6351
|
+
layridens = [lyr.iden for lyr in view4.layers if lyr.iden != view3.layers[0].iden]
|
|
6352
|
+
events = [
|
|
6353
|
+
{'event': 'view:setlayers', 'info': {'iden': view4.iden, 'layers': layridens}},
|
|
6354
|
+
{'event': 'view:set', 'info': {'iden': view4.iden, 'name': 'parent', 'valu': None}}
|
|
6355
|
+
]
|
|
6356
|
+
task = core.schedCoro(s_t_utils.waitForBehold(core, events))
|
|
6376
6357
|
|
|
6377
|
-
|
|
6378
|
-
self.len(coros - 2, core.activecoros)
|
|
6358
|
+
await core.delViewWithLayer(view3_iden)
|
|
6379
6359
|
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6360
|
+
await asyncio.wait_for(task, timeout=1)
|
|
6361
|
+
|
|
6362
|
+
# push/pull activecoros have been deleted
|
|
6363
|
+
self.len(coros - 2, core.activecoros)
|
|
6364
|
+
|
|
6365
|
+
self.none(view4.parent)
|
|
6366
|
+
self.len(1, view4.layers)
|
|
6367
|
+
self.none(core.getLayer(deadlayr))
|
|
6383
6368
|
|
|
6384
|
-
|
|
6385
|
-
|
|
6369
|
+
vdef5 = await view4.fork()
|
|
6370
|
+
view5 = core.getView(vdef5.get('iden'))
|
|
6386
6371
|
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6372
|
+
usedlayr = view4.layers[0].iden
|
|
6373
|
+
vdef6 = {'layers': (usedlayr,)}
|
|
6374
|
+
view6 = core.getView((await core.addView(vdef6)).get('iden'))
|
|
6390
6375
|
|
|
6391
|
-
|
|
6376
|
+
await core.delViewWithLayer(view4_iden)
|
|
6392
6377
|
|
|
6393
|
-
|
|
6394
|
-
|
|
6378
|
+
self.none(view5.parent)
|
|
6379
|
+
self.len(1, view5.layers)
|
|
6395
6380
|
|
|
6396
|
-
|
|
6397
|
-
|
|
6381
|
+
self.nn(core.getLayer(usedlayr))
|
|
6382
|
+
self.eq([usedlayr], [lyr.iden for lyr in view6.layers])
|
|
6383
|
+
|
|
6384
|
+
layrs = list(core.layers.keys())
|
|
6385
|
+
viewdefs = {}
|
|
6386
|
+
for vdef in await core.getViewDefs():
|
|
6387
|
+
vdef['layers'] = [layr['iden'] for layr in vdef['layers']]
|
|
6388
|
+
viewdefs[vdef['iden']] = vdef
|
|
6389
|
+
|
|
6390
|
+
async with self.getTestCore(dirn=dirn) as core:
|
|
6391
|
+
self.sorteq(layrs, list(core.layers.keys()))
|
|
6392
|
+
|
|
6393
|
+
viewdefs2 = {}
|
|
6394
|
+
for vdef in await core.getViewDefs():
|
|
6395
|
+
vdef['layers'] = [layr['iden'] for layr in vdef['layers']]
|
|
6396
|
+
viewdefs2[vdef['iden']] = vdef
|
|
6397
|
+
|
|
6398
|
+
self.eq(len(viewdefs), len(viewdefs2))
|
|
6399
|
+
|
|
6400
|
+
for iden, vdef in viewdefs.items():
|
|
6401
|
+
self.eq(vdef, viewdefs2.get(iden))
|
|
6398
6402
|
|
|
6399
6403
|
async def test_cortex_view_opts(self):
|
|
6400
6404
|
'''
|
|
@@ -6675,7 +6679,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
6675
6679
|
await proxy.popStormVar('hehe')
|
|
6676
6680
|
|
|
6677
6681
|
async with core.getLocalProxy() as proxy:
|
|
6678
|
-
self.
|
|
6682
|
+
self.eq('haha', await proxy.setStormVar('hehe', 'haha'))
|
|
6679
6683
|
self.eq('haha', await proxy.getStormVar('hehe'))
|
|
6680
6684
|
self.eq('hoho', await proxy.getStormVar('lolz', default='hoho'))
|
|
6681
6685
|
self.eq('haha', await proxy.popStormVar('hehe'))
|
|
@@ -7904,7 +7908,8 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
7904
7908
|
await core.delHttpExtApi('notAGuid')
|
|
7905
7909
|
|
|
7906
7910
|
async def test_cortex_query_offload(self):
|
|
7907
|
-
|
|
7911
|
+
|
|
7912
|
+
async with self.getTestAha() as aha:
|
|
7908
7913
|
|
|
7909
7914
|
async with await s_base.Base.anit() as base:
|
|
7910
7915
|
|
|
@@ -7927,11 +7932,11 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
7927
7932
|
|
|
7928
7933
|
msgs = await core00.stormlist('aha.pool.add pool00...')
|
|
7929
7934
|
self.stormHasNoWarnErr(msgs)
|
|
7930
|
-
self.stormIsInPrint('Created AHA service pool: pool00.
|
|
7935
|
+
self.stormIsInPrint('Created AHA service pool: pool00.synapse', msgs)
|
|
7931
7936
|
|
|
7932
7937
|
msgs = await core00.stormlist('aha.pool.svc.add pool00... 01.core...')
|
|
7933
7938
|
self.stormHasNoWarnErr(msgs)
|
|
7934
|
-
self.stormIsInPrint('AHA service (01.core...) added to service pool (pool00.
|
|
7939
|
+
self.stormIsInPrint('AHA service (01.core...) added to service pool (pool00.synapse)', msgs)
|
|
7935
7940
|
|
|
7936
7941
|
msgs = await core00.stormlist('cortex.storm.pool.set newp')
|
|
7937
7942
|
self.stormIsInErr(':// not found in [newp]', msgs)
|
|
@@ -8079,7 +8084,7 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
8079
8084
|
waiter = core01.stormpool.waiter(1, 'svc:del')
|
|
8080
8085
|
msgs = await core01.stormlist('aha.pool.svc.del pool00... 01.core...', opts={'mirror': False})
|
|
8081
8086
|
self.stormHasNoWarnErr(msgs)
|
|
8082
|
-
self.stormIsInPrint('AHA service (01.core.
|
|
8087
|
+
self.stormIsInPrint('AHA service (01.core.synapse) removed from service pool (pool00.synapse)', msgs)
|
|
8083
8088
|
|
|
8084
8089
|
# TODO: this wait should not return None
|
|
8085
8090
|
await waiter.wait(timeout=3)
|
|
@@ -8134,6 +8139,10 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
8134
8139
|
with self.raises(s_exc.AuthDeny) as cm:
|
|
8135
8140
|
await core.nodes('[test:str=hello]', opts=aslow)
|
|
8136
8141
|
|
|
8142
|
+
# Coverage for nonexistent users/roles
|
|
8143
|
+
core.auth.stor.set('gate:cortex:user:newp', {'iden': 'newp'})
|
|
8144
|
+
core.auth.stor.set('gate:cortex:role:newp', {'iden': 'newp'})
|
|
8145
|
+
|
|
8137
8146
|
with self.getAsyncLoggerStream('synapse.cortex') as stream:
|
|
8138
8147
|
async with self.getTestCore(dirn=dirn) as core: # type: s_cortex.Cortex
|
|
8139
8148
|
# The cortex authgate still does nothing
|
|
@@ -8165,7 +8174,6 @@ class CortexBasicTest(s_t_utils.SynTest):
|
|
|
8165
8174
|
return ret
|
|
8166
8175
|
|
|
8167
8176
|
conf = {
|
|
8168
|
-
'layer:lmdb:map_async': True,
|
|
8169
8177
|
'nexslog:en': True,
|
|
8170
8178
|
'layers:logedits': True,
|
|
8171
8179
|
}
|
synapse/tests/test_cryotank.py
CHANGED
|
@@ -119,14 +119,14 @@ class CryoTest(s_t_utils.SynTest):
|
|
|
119
119
|
# test passing conf data in through init directly
|
|
120
120
|
tank = await cryo.init('conftest', conf={'map_size': s_const.mebibyte * 64})
|
|
121
121
|
self.eq(tank.slab.mapsize, s_const.mebibyte * 64)
|
|
122
|
-
_, conf =
|
|
122
|
+
_, conf = cryo.names.get('conftest')
|
|
123
123
|
self.eq(conf, {'map_size': s_const.mebibyte * 64})
|
|
124
124
|
|
|
125
125
|
# And the data was persisted
|
|
126
126
|
async with self.getTestCryo(dirn) as cryo:
|
|
127
127
|
tank = cryo.tanks.get('conftest')
|
|
128
128
|
self.eq(tank.slab.mapsize, s_const.mebibyte * 64)
|
|
129
|
-
_, conf =
|
|
129
|
+
_, conf = cryo.names.get('conftest')
|
|
130
130
|
self.eq(conf, {'map_size': s_const.mebibyte * 64})
|
|
131
131
|
|
|
132
132
|
async def test_cryo_perms(self):
|
|
@@ -264,14 +264,14 @@ class CryoTest(s_t_utils.SynTest):
|
|
|
264
264
|
)
|
|
265
265
|
|
|
266
266
|
tank00 = await cryo.init('tank00')
|
|
267
|
-
self.true(tank00iden == cryo.names.get('tank00')
|
|
267
|
+
self.true(tank00iden == cryo.names.get('tank00')[0] == tank00.iden())
|
|
268
268
|
self.false(os.path.exists(os.path.join(tank00.dirn, 'guid')))
|
|
269
269
|
self.false(os.path.exists(os.path.join(tank00.dirn, 'cell.guid')))
|
|
270
270
|
self.false(os.path.exists(os.path.join(tank00.dirn, 'slabs', 'cell.lmdb')))
|
|
271
271
|
self.eq(0, s_slaboffs.SlabOffs(tank00.slab, 'offsets').get(seqniden))
|
|
272
272
|
|
|
273
273
|
tank01 = await cryo.init('tank01')
|
|
274
|
-
self.true(tank01iden == cryo.names.get('tank01')
|
|
274
|
+
self.true(tank01iden == cryo.names.get('tank01')[0] == tank01.iden())
|
|
275
275
|
self.false(os.path.exists(os.path.join(tank01.dirn, 'guid')))
|
|
276
276
|
self.false(os.path.exists(os.path.join(tank01.dirn, 'cell.guid')))
|
|
277
277
|
self.false(os.path.exists(os.path.join(tank01.dirn, 'slabs', 'cell.lmdb')))
|
synapse/tests/test_datamodel.py
CHANGED
|
@@ -321,3 +321,10 @@ class DataModelTest(s_t_utils.SynTest):
|
|
|
321
321
|
|
|
322
322
|
model = (await core.getModelDefs())[0][1]
|
|
323
323
|
self.isin(('meta:rule', 'matches', None), [e[0] for e in model['edges']])
|
|
324
|
+
|
|
325
|
+
self.nn(core.model.edge(('meta:rule', 'matches', None)))
|
|
326
|
+
|
|
327
|
+
core.model.delEdge(('meta:rule', 'matches', None))
|
|
328
|
+
self.none(core.model.edge(('meta:rule', 'matches', None)))
|
|
329
|
+
|
|
330
|
+
core.model.delEdge(('meta:rule', 'matches', None))
|
synapse/tests/test_lib_agenda.py
CHANGED
|
@@ -485,6 +485,13 @@ class AgendaTest(s_t_utils.SynTest):
|
|
|
485
485
|
|
|
486
486
|
await core.updateCronJob(guid3, '#bahhumbug')
|
|
487
487
|
|
|
488
|
+
# Add a job with invalid storage version
|
|
489
|
+
cdef = (await core.listCronJobs())[0]
|
|
490
|
+
guid = s_common.guid()
|
|
491
|
+
cdef['ver'] = 0
|
|
492
|
+
cdef['iden'] = guid
|
|
493
|
+
core.agenda.apptdefs.set(guid, cdef)
|
|
494
|
+
|
|
488
495
|
async with self.getTestCore(dirn=dirn) as core:
|
|
489
496
|
|
|
490
497
|
appts = await core.listCronJobs()
|
|
@@ -850,7 +857,7 @@ class AgendaTest(s_t_utils.SynTest):
|
|
|
850
857
|
|
|
851
858
|
async def test_cron_kill_pool(self):
|
|
852
859
|
|
|
853
|
-
async with self.
|
|
860
|
+
async with self.getTestAha() as aha:
|
|
854
861
|
|
|
855
862
|
import synapse.cortex as s_cortex
|
|
856
863
|
import synapse.lib.base as s_base
|
|
@@ -872,11 +879,11 @@ class AgendaTest(s_t_utils.SynTest):
|
|
|
872
879
|
|
|
873
880
|
msgs = await core00.stormlist('aha.pool.add pool00...')
|
|
874
881
|
self.stormHasNoWarnErr(msgs)
|
|
875
|
-
self.stormIsInPrint('Created AHA service pool: pool00.
|
|
882
|
+
self.stormIsInPrint('Created AHA service pool: pool00.synapse', msgs)
|
|
876
883
|
|
|
877
884
|
msgs = await core00.stormlist('aha.pool.svc.add pool00... 01.core...')
|
|
878
885
|
self.stormHasNoWarnErr(msgs)
|
|
879
|
-
self.stormIsInPrint('AHA service (01.core...) added to service pool (pool00.
|
|
886
|
+
self.stormIsInPrint('AHA service (01.core...) added to service pool (pool00.synapse)', msgs)
|
|
880
887
|
|
|
881
888
|
msgs = await core00.stormlist('cortex.storm.pool.set --connection-timeout 1 --sync-timeout 1 aha://pool00...')
|
|
882
889
|
self.stormHasNoWarnErr(msgs)
|