tests_multipublik: add assertions and comments (#60846)
This commit is contained in:
parent
453389ca40
commit
026cfba744
|
@ -28,15 +28,38 @@ def test_multipublik(tenants, mocker):
|
|||
hobo1 = tenants[0]
|
||||
hobo1.base_url = 'http://tenant1.example.net/'
|
||||
with tenant_context(hobo1):
|
||||
hobo2 = Hobo(title='title', slug='slug', base_url='http://hobo2.example.net')
|
||||
hobo2 = Hobo(title='Coll2', slug='hobo-coll2', base_url='http://hobo2.example.net')
|
||||
hobo2.save()
|
||||
hobo3 = Hobo(title='title', slug='slug', base_url='http://hobo3.example.net')
|
||||
hobo3 = Hobo(title='Coll3', slug='hobo-coll3', base_url='http://hobo3.example.net')
|
||||
hobo3.save()
|
||||
combo = Combo(title='xxx', slug='xxx', base_url='http://combo1.example.net')
|
||||
combo = Combo(title='Portail', slug='portal', base_url='http://combo1.example.net')
|
||||
combo.save()
|
||||
|
||||
# inform coll2 about interco environment
|
||||
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo1))
|
||||
|
||||
hobo2 = TenantMiddleware.get_tenant_by_hostname('hobo2.example.net')
|
||||
with tenant_context(hobo2):
|
||||
# interco combo created
|
||||
assert Combo.objects.count() == 1
|
||||
combo = Combo.objects.first()
|
||||
assert combo.slug == '_interco_portal'
|
||||
assert combo.base_url == 'http://combo1.example.net/'
|
||||
assert combo.secondary is True
|
||||
|
||||
assert Hobo.objects.count() == 2
|
||||
# interco hobo
|
||||
hobo = Hobo.objects.get(slug='_interco_hobo')
|
||||
assert hobo.title == 'Hobo'
|
||||
assert hobo.base_url == 'http://tenant1.example.net/'
|
||||
assert hobo.secondary is True
|
||||
|
||||
# coll3 Hobo
|
||||
hobo = Hobo.objects.get(slug='_interco_hobo-coll3')
|
||||
assert hobo.title == 'Coll3'
|
||||
assert hobo.base_url == 'http://hobo3.example.net/'
|
||||
assert hobo.secondary is True
|
||||
|
||||
# notify_agents will be called for secondary services: as celery
|
||||
# is not running we just block it
|
||||
mocker.patch('hobo.agent.hobo.management.commands.hobo_deploy.notify_agents')
|
||||
|
@ -44,38 +67,88 @@ def test_multipublik(tenants, mocker):
|
|||
hobo2 = TenantMiddleware.get_tenant_by_hostname('hobo2.example.net')
|
||||
hobo2.base_url = 'http://hobo2.example.net/'
|
||||
with tenant_context(hobo2):
|
||||
combo = Combo(title='xxx2', slug='xxx2', base_url='http://combo2.example.net')
|
||||
combo = Combo(title='Portail', slug='portal', base_url='http://combo2.example.net')
|
||||
combo.save()
|
||||
|
||||
# inform interco about coll2 environment
|
||||
HoboDeployCommand().handle(hobo1.base_url, get_hobo_json_filename(hobo2))
|
||||
|
||||
with tenant_context(hobo1):
|
||||
assert Combo.objects.filter(secondary=True).count() == 1
|
||||
assert Combo.objects.filter(secondary=False).count() == 1
|
||||
|
||||
# coll2 hobo
|
||||
combo = Combo.objects.get(secondary=True)
|
||||
assert combo.slug == '_hobo-coll2_portal'
|
||||
assert combo.title == 'Portail'
|
||||
assert combo.base_url == 'http://combo2.example.net/'
|
||||
|
||||
# interco environment has changed (secondary Combo coming from coll2)
|
||||
# inform coll2 about interco environment and check that nothing changes
|
||||
# (no service creation recursion)
|
||||
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo1))
|
||||
with tenant_context(hobo2):
|
||||
assert Hobo.objects.filter().count() == 2
|
||||
assert Hobo.objects.filter(secondary=True).count() == 2
|
||||
assert Combo.objects.filter().count() == 2
|
||||
assert Combo.objects.filter(secondary=True).count() == 1
|
||||
|
||||
# what are we checking here ?
|
||||
with tenant_context(hobo1):
|
||||
assert Hobo.objects.filter(secondary=True).count() == 0
|
||||
assert Combo.objects.filter(secondary=False).count() == 1
|
||||
assert Combo.objects.filter(secondary=False).count() == 1
|
||||
|
||||
# another secondary hobo
|
||||
# inform coll3 about interco environment
|
||||
HoboDeployCommand().handle(hobo3.base_url, get_hobo_json_filename(hobo1))
|
||||
hobo3 = TenantMiddleware.get_tenant_by_hostname('hobo3.example.net')
|
||||
hobo3.base_url = 'http://hobo3.example.net/'
|
||||
with tenant_context(hobo3):
|
||||
combo = Combo(title='xxx3', slug='xxx3', base_url='http://combo3.example.net')
|
||||
# interco combo created
|
||||
assert Combo.objects.count() == 1
|
||||
combo = Combo.objects.first()
|
||||
assert combo.slug == '_interco_portal'
|
||||
assert combo.base_url == 'http://combo1.example.net/'
|
||||
assert combo.secondary is True
|
||||
|
||||
assert Hobo.objects.count() == 2
|
||||
# interco hobo
|
||||
hobo = Hobo.objects.get(slug='_interco_hobo')
|
||||
assert hobo.title == 'Hobo'
|
||||
assert hobo.base_url == 'http://tenant1.example.net/'
|
||||
assert hobo.secondary is True
|
||||
|
||||
# coll2 Hobo
|
||||
hobo = Hobo.objects.get(slug='_interco_hobo-coll2')
|
||||
assert hobo.title == 'Coll2'
|
||||
assert hobo.base_url == 'http://hobo2.example.net/'
|
||||
assert hobo.secondary is True
|
||||
|
||||
# Add a portal in coll3
|
||||
combo = Combo(title='Portail', slug='portal', base_url='http://combo3.example.net')
|
||||
combo.save()
|
||||
|
||||
# inform interco about coll3 environment
|
||||
HoboDeployCommand().handle(hobo1.base_url, get_hobo_json_filename(hobo3))
|
||||
|
||||
with tenant_context(hobo1):
|
||||
assert Combo.objects.filter(secondary=True).count() == 2
|
||||
assert Combo.objects.filter(secondary=False).count() == 1
|
||||
# coll3 Combo
|
||||
combo = Combo.objects.get(slug='_hobo-coll3_portal')
|
||||
assert combo.title == 'Portail'
|
||||
assert combo.base_url == 'http://combo3.example.net/'
|
||||
assert combo.secondary is True
|
||||
|
||||
# inform coll2 about interco environment
|
||||
# nothing changed, coll2 does not care about secondary services in interco
|
||||
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo1))
|
||||
with tenant_context(hobo2):
|
||||
assert Combo.objects.filter(secondary=True).count() == 1
|
||||
assert Combo.objects.filter(secondary=False).count() == 1
|
||||
|
||||
# inform coll2 about coll3 environment
|
||||
# nothing changed, coll2 does not have to know anything about coll3
|
||||
# (except its hobo, which is a primary service in interco)
|
||||
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo3))
|
||||
with tenant_context(hobo2):
|
||||
assert Combo.objects.filter(secondary=True).count() == 1
|
||||
|
|
Loading…
Reference in New Issue