28 |
28 |
hobo1 = tenants[0]
|
29 |
29 |
hobo1.base_url = 'http://tenant1.example.net/'
|
30 |
30 |
with tenant_context(hobo1):
|
31 |
|
hobo2 = Hobo(title='title', slug='slug', base_url='http://hobo2.example.net')
|
|
31 |
hobo2 = Hobo(title='Coll2', slug='hobo-coll2', base_url='http://hobo2.example.net')
|
32 |
32 |
hobo2.save()
|
33 |
|
hobo3 = Hobo(title='title', slug='slug', base_url='http://hobo3.example.net')
|
|
33 |
hobo3 = Hobo(title='Coll3', slug='hobo-coll3', base_url='http://hobo3.example.net')
|
34 |
34 |
hobo3.save()
|
35 |
|
combo = Combo(title='xxx', slug='xxx', base_url='http://combo1.example.net')
|
|
35 |
combo = Combo(title='Portail', slug='portal', base_url='http://combo1.example.net')
|
36 |
36 |
combo.save()
|
37 |
37 |
|
|
38 |
# inform coll2 about interco environment
|
38 |
39 |
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo1))
|
39 |
40 |
|
|
41 |
hobo2 = TenantMiddleware.get_tenant_by_hostname('hobo2.example.net')
|
|
42 |
with tenant_context(hobo2):
|
|
43 |
# interco combo created
|
|
44 |
assert Combo.objects.count() == 1
|
|
45 |
combo = Combo.objects.first()
|
|
46 |
assert combo.slug == '_interco_portal'
|
|
47 |
assert combo.base_url == 'http://combo1.example.net/'
|
|
48 |
assert combo.secondary is True
|
|
49 |
|
|
50 |
assert Hobo.objects.count() == 2
|
|
51 |
# interco hobo
|
|
52 |
hobo = Hobo.objects.get(slug='_interco_hobo')
|
|
53 |
assert hobo.title == 'Hobo'
|
|
54 |
assert hobo.base_url == 'http://tenant1.example.net/'
|
|
55 |
assert hobo.secondary is True
|
|
56 |
|
|
57 |
# coll3 Hobo
|
|
58 |
hobo = Hobo.objects.get(slug='_interco_hobo-coll3')
|
|
59 |
assert hobo.title == 'Coll3'
|
|
60 |
assert hobo.base_url == 'http://hobo3.example.net/'
|
|
61 |
assert hobo.secondary is True
|
|
62 |
|
40 |
63 |
# notify_agents will be called for secondary services: as celery
|
41 |
64 |
# is not running we just block it
|
42 |
65 |
mocker.patch('hobo.agent.hobo.management.commands.hobo_deploy.notify_agents')
|
... | ... | |
44 |
67 |
hobo2 = TenantMiddleware.get_tenant_by_hostname('hobo2.example.net')
|
45 |
68 |
hobo2.base_url = 'http://hobo2.example.net/'
|
46 |
69 |
with tenant_context(hobo2):
|
47 |
|
combo = Combo(title='xxx2', slug='xxx2', base_url='http://combo2.example.net')
|
|
70 |
combo = Combo(title='Portail', slug='portal', base_url='http://combo2.example.net')
|
48 |
71 |
combo.save()
|
|
72 |
|
|
73 |
# inform interco about coll2 environment
|
49 |
74 |
HoboDeployCommand().handle(hobo1.base_url, get_hobo_json_filename(hobo2))
|
50 |
75 |
|
51 |
76 |
with tenant_context(hobo1):
|
52 |
77 |
assert Combo.objects.filter(secondary=True).count() == 1
|
53 |
78 |
assert Combo.objects.filter(secondary=False).count() == 1
|
54 |
79 |
|
|
80 |
# coll2 hobo
|
|
81 |
combo = Combo.objects.get(secondary=True)
|
|
82 |
assert combo.slug == '_hobo-coll2_portal'
|
|
83 |
assert combo.title == 'Portail'
|
|
84 |
assert combo.base_url == 'http://combo2.example.net/'
|
|
85 |
|
|
86 |
# interco environment has changed (secondary Combo coming from coll2)
|
|
87 |
# inform coll2 about interco environment and check that nothing changes
|
|
88 |
# (no service creation recursion)
|
55 |
89 |
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo1))
|
|
90 |
with tenant_context(hobo2):
|
|
91 |
assert Hobo.objects.filter().count() == 2
|
|
92 |
assert Hobo.objects.filter(secondary=True).count() == 2
|
|
93 |
assert Combo.objects.filter().count() == 2
|
|
94 |
assert Combo.objects.filter(secondary=True).count() == 1
|
|
95 |
|
|
96 |
# what are we checking here ?
|
56 |
97 |
with tenant_context(hobo1):
|
57 |
98 |
assert Hobo.objects.filter(secondary=True).count() == 0
|
58 |
99 |
assert Combo.objects.filter(secondary=False).count() == 1
|
59 |
|
assert Combo.objects.filter(secondary=False).count() == 1
|
60 |
100 |
|
61 |
|
# another secondary hobo
|
|
101 |
# inform coll3 about interco environment
|
62 |
102 |
HoboDeployCommand().handle(hobo3.base_url, get_hobo_json_filename(hobo1))
|
63 |
103 |
hobo3 = TenantMiddleware.get_tenant_by_hostname('hobo3.example.net')
|
64 |
104 |
hobo3.base_url = 'http://hobo3.example.net/'
|
65 |
105 |
with tenant_context(hobo3):
|
66 |
|
combo = Combo(title='xxx3', slug='xxx3', base_url='http://combo3.example.net')
|
|
106 |
# interco combo created
|
|
107 |
assert Combo.objects.count() == 1
|
|
108 |
combo = Combo.objects.first()
|
|
109 |
assert combo.slug == '_interco_portal'
|
|
110 |
assert combo.base_url == 'http://combo1.example.net/'
|
|
111 |
assert combo.secondary is True
|
|
112 |
|
|
113 |
assert Hobo.objects.count() == 2
|
|
114 |
# interco hobo
|
|
115 |
hobo = Hobo.objects.get(slug='_interco_hobo')
|
|
116 |
assert hobo.title == 'Hobo'
|
|
117 |
assert hobo.base_url == 'http://tenant1.example.net/'
|
|
118 |
assert hobo.secondary is True
|
|
119 |
|
|
120 |
# coll2 Hobo
|
|
121 |
hobo = Hobo.objects.get(slug='_interco_hobo-coll2')
|
|
122 |
assert hobo.title == 'Coll2'
|
|
123 |
assert hobo.base_url == 'http://hobo2.example.net/'
|
|
124 |
assert hobo.secondary is True
|
|
125 |
|
|
126 |
# Add a portal in coll3
|
|
127 |
combo = Combo(title='Portail', slug='portal', base_url='http://combo3.example.net')
|
67 |
128 |
combo.save()
|
|
129 |
|
|
130 |
# inform interco about coll3 environment
|
68 |
131 |
HoboDeployCommand().handle(hobo1.base_url, get_hobo_json_filename(hobo3))
|
69 |
132 |
|
70 |
133 |
with tenant_context(hobo1):
|
71 |
134 |
assert Combo.objects.filter(secondary=True).count() == 2
|
72 |
135 |
assert Combo.objects.filter(secondary=False).count() == 1
|
|
136 |
# coll3 Combo
|
|
137 |
combo = Combo.objects.get(slug='_hobo-coll3_portal')
|
|
138 |
assert combo.title == 'Portail'
|
|
139 |
assert combo.base_url == 'http://combo3.example.net/'
|
|
140 |
assert combo.secondary is True
|
73 |
141 |
|
|
142 |
# inform coll2 about interco environment
|
|
143 |
# nothing changed, coll2 does not care about secondary services in interco
|
74 |
144 |
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo1))
|
75 |
145 |
with tenant_context(hobo2):
|
76 |
146 |
assert Combo.objects.filter(secondary=True).count() == 1
|
77 |
147 |
assert Combo.objects.filter(secondary=False).count() == 1
|
78 |
148 |
|
|
149 |
# inform coll2 about coll3 environment
|
|
150 |
# nothing changed, coll2 does not have to know anything about coll3
|
|
151 |
# (except its hobo, which is a primary service in interco)
|
79 |
152 |
HoboDeployCommand().handle(hobo2.base_url, get_hobo_json_filename(hobo3))
|
80 |
153 |
with tenant_context(hobo2):
|
81 |
154 |
assert Combo.objects.filter(secondary=True).count() == 1
|
82 |
|
-
|