97
97
ret, out, err = subprocesses.run(
98
98
['byovm', 'shell', self.monitor_name, test_cmd])
99
99
assertions.assertShellSuccess(self, test_cmd, ret, out, err)
102
class TestMonitorRunJob(unittest.TestCase):
106
fixtures.isolate_from_disk_for_host(self)
107
fixtures.setup_byoci_conf(self)
108
self.out = io.StringIO()
109
self.err = io.StringIO()
110
fixtures.override_logging(self)
112
def test_succeeds(self):
113
fixtures.setup_master(self)
114
fixtures.setup_monitor(self)
116
test_cmd = 'cd /byoci && jenkins-jobs update jobs/'
117
ret, out, err = subprocesses.run(
118
['byovm', 'shell', self.monitor_name, test_cmd])
119
assertions.assertShellSuccess(self, test_cmd, ret, out, err)
120
# Now run a known one
121
test_cmd = ('cd /byoci &&'
122
' ./byo-ci-monitor run-job byoci/info-brz-slave-selftest')
123
ret, out, err = subprocesses.run(
124
['byovm', 'shell', self.monitor_name, test_cmd])
125
assertions.assertShellSuccess(self, test_cmd, ret, out, err)
126
# The job is waiting for a slave (not provisioned here)
127
# FIXME: If/when jenkins handling is rewritten as requests-based
128
# module, more assertions could be made. -- vila 2018-11-23
130
def test_fails(self):
131
fixtures.setup_master(self)
132
fixtures.setup_monitor(self)
133
with self.assertRaises(subprocesses.errors.CommandError) as cm:
134
test_cmd = ('cd /byoci &&'
135
' ./byo-ci-monitor run-job I-dont-exist')
136
subprocesses.run(['byovm', 'shell', self.monitor_name, test_cmd])
138
cm.exception.err.endswith('No job matches I-dont-exist\n'))