Skip to content

Commit 0759438

Browse files
committed
adding integration test for cross-host service dependencies during an update when the dependent host has no updates
1 parent dee545c commit 0759438

4 files changed

+103
-1
lines changed

Diff for: src/integrationtest/python/update_should_call_yadtyum_upgrade_on_remote_host_tests.py renamed to src/integrationtest/python/update_should_call_upgrade_on_remote_host_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
__author__ = 'Michael Gruber, Udo Juettner'
17+
__author__ = 'Marcel Wolf'
1818

1919
import unittest
2020
import integrationtest_support
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import unittest
2+
import integrationtest_support
3+
4+
host_with_updates_json = '''{
5+
"hostname": "host_with_updates",
6+
"fqdn": "host_with_updates",
7+
"current_artefacts": [
8+
"yit/0:0.0.1",
9+
"yat/0:0.0.7"
10+
],
11+
"next_artefacts": {
12+
"foo/0:0.0.0": "yit/0:0.0.1",
13+
"yat/0:0.0.8": "yat/0:0.0.7"
14+
},
15+
"services": [
16+
"foo_service":{
17+
"needs_artefacts": ["yat"],
18+
"state": 0
19+
}
20+
]
21+
}'''
22+
23+
host_with_dependent_service_json = '''{
24+
"hostname": "host_with_dependent_service",
25+
"fqdn": "host_with_dependent_service",
26+
"current_artefacts": [
27+
"yit/0:0.0.1",
28+
"yat/0:0.0.7"
29+
],
30+
"next_artefacts": {},
31+
"services": [
32+
"dependent_service":{
33+
"needs_services": ["service://host_with_updates/foo_service"],
34+
"state": 0
35+
}
36+
]
37+
}'''
38+
39+
40+
class Test (integrationtest_support.IntegrationTestSupport):
41+
42+
def test(self):
43+
self.write_target_file(
44+
'host_with_updates', 'host_with_dependent_service')
45+
46+
with self.fixture() as when:
47+
when.calling('ssh').at_least_with_arguments('host_with_updates').and_input('/usr/bin/yadt-status') \
48+
.then_write(host_with_updates_json)
49+
when.calling('ssh').at_least_with_arguments('host_with_dependent_service').and_input('/usr/bin/yadt-status') \
50+
.then_write(host_with_dependent_service_json)
51+
52+
when.calling('ssh').at_least_with_arguments('host_with_dependent_service', 'yadt-command yadt-service-status dependent_service')\
53+
.then_return(3).then_return(0)
54+
when.calling('ssh').at_least_with_arguments('host_with_dependent_service') \
55+
.then_return(0)
56+
57+
when.calling('ssh').at_least_with_arguments('host_with_updates', 'yadt-command yadt-service-status foo_service')\
58+
.then_return(3).then_return(0)
59+
when.calling('ssh').at_least_with_arguments('host_with_updates') \
60+
.then_return(0)
61+
62+
update_return_code = self.execute_command('yadtshell update --no-final-status')
63+
64+
self.assertEqual(0, update_return_code)
65+
66+
with self.verify() as verify:
67+
# yadt status before update
68+
verify.called('ssh').at_least_with_arguments('-o').and_input('/usr/bin/yadt-status')
69+
verify.called('ssh').at_least_with_arguments('-o').and_input('/usr/bin/yadt-status')
70+
71+
# ssh multiplexing
72+
verify.called('ssh').at_least_with_arguments(
73+
'host_with_dependent_service', '-O', 'check')
74+
verify.called('ssh').at_least_with_arguments(
75+
'host_with_updates', '-O', 'check')
76+
77+
# stop services in correct order
78+
verify.called('ssh').at_least_with_arguments(
79+
'host_with_dependent_service', 'yadt-command yadt-service-stop dependent_service')
80+
verify.called('ssh').at_least_with_arguments(
81+
'host_with_dependent_service', 'yadt-command yadt-service-status dependent_service')
82+
verify.called('ssh').at_least_with_arguments(
83+
'host_with_updates', 'yadt-command yadt-service-stop foo_service')
84+
verify.called('ssh').at_least_with_arguments(
85+
'host_with_updates', 'yadt-command yadt-service-status foo_service')
86+
87+
# upgrade host
88+
verify.called('ssh').at_least_with_arguments(
89+
'host_with_updates', 'yadt-command yadt-host-update yat-0:0.0.8 foo-0:0.0.0')
90+
91+
# start services in correct order
92+
verify.called('ssh').at_least_with_arguments(
93+
'host_with_updates', 'yadt-command yadt-service-start foo_service')
94+
verify.called('ssh').at_least_with_arguments(
95+
'host_with_updates', 'yadt-command yadt-service-status foo_service')
96+
verify.called('ssh').at_least_with_arguments(
97+
'host_with_dependent_service', 'yadt-command yadt-service-start dependent_service')
98+
verify.called('ssh').at_least_with_arguments(
99+
'host_with_dependent_service', 'yadt-command yadt-service-status dependent_service')
100+
101+
if __name__ == '__main__':
102+
unittest.main()

0 commit comments

Comments
 (0)