194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
1 |
from testtools import TestCase |
2 |
from testtools.matchers import Contains |
|
194.2.65
by Diogo Matsubara
use addDetail() correctly |
3 |
from testtools.content import text_content |
194.2.76
by Diogo Matsubara
review comments |
4 |
import unittest |
194.2.82
by Diogo Matsubara
use zmq to signal to the CC that the RC tests have finished |
5 |
import zmq |
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
6 |
|
219.2.5
by Diogo Matsubara
add assertion function checking for command return code and output |
7 |
from utils import ( |
8 |
assertCommandReturnCode, run_command, update_pxe_config, |
|
9 |
CLUSTER_CONTROLLER_IP
|
|
10 |
)
|
|
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
11 |
|
194.2.76
by Diogo Matsubara
review comments |
12 |
|
13 |
tests_order = [ |
|
14 |
'test_preseed_updated_cluster_config', |
|
15 |
'test_update_pxe_config', |
|
16 |
'test_import_pxe_files', |
|
17 |
'test_wait_for_region_controller', |
|
18 |
]
|
|
19 |
||
20 |
||
21 |
def sorting_method(ignored, first_test, second_test): |
|
22 |
return tests_order.index(first_test) - tests_order.index(second_test) |
|
23 |
||
24 |
||
25 |
unittest.TestLoader.sortTestMethodsUsing = sorting_method |
|
26 |
||
27 |
||
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
28 |
class ClusterControllerIntegration(TestCase): |
29 |
||
194.2.76
by Diogo Matsubara
review comments |
30 |
def test_preseed_updated_cluster_config(self): |
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
31 |
# Make sure the cluster config was updated by the seed file.
|
32 |
maas_fd = open("/etc/maas/maas_cluster.conf" , "r+") |
|
33 |
maas_file = maas_fd.read() |
|
34 |
self.assertThat(maas_file, Contains( |
|
209.2.1
by Diogo Matsubara
fix cc match |
35 |
'MAAS_URL="http://192.168.21.5/MAAS"')) |
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
36 |
|
194.2.76
by Diogo Matsubara
review comments |
37 |
def test_update_pxe_config(self): |
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
38 |
update_pxe_config() |
39 |
||
194.2.76
by Diogo Matsubara
review comments |
40 |
def test_import_pxe_files(self): |
219.2.5
by Diogo Matsubara
add assertion function checking for command return code and output |
41 |
cmd = ['maas-import-pxe-files'] |
42 |
expected_output = 'Downloading to temporary location' |
|
43 |
assertCommandReturnCode(self, cmd, expected_output) |
|
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
44 |
|
194.2.76
by Diogo Matsubara
review comments |
45 |
def test_wait_for_region_controller(self): |
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
46 |
"""Wait for the region controller to run the integration tests.
|
47 |
||
194.2.84
by Diogo Matsubara
update docstring and remove unnecessary wait |
48 |
The region controller will send a message to the cluster controller
|
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
49 |
once all tests finish.
|
50 |
"""
|
|
194.2.82
by Diogo Matsubara
use zmq to signal to the CC that the RC tests have finished |
51 |
context = zmq.Context() |
194.2.83
by Diogo Matsubara
change the server to zmq.REP |
52 |
socket = context.socket(zmq.REP) |
194.2.82
by Diogo Matsubara
use zmq to signal to the CC that the RC tests have finished |
53 |
socket.bind('tcp://%s:5555' % CLUSTER_CONTROLLER_IP) |
54 |
msg = '' |
|
55 |
while msg != "Region controller tests finished.": |
|
56 |
msg = socket.recv() |
|
194.2.63
by Diogo Matsubara
addDetail() to tests that might timeout |
57 |
self.addDetail( |
58 |
"Waiting for region controller to signal end of tests", |
|
194.2.82
by Diogo Matsubara
use zmq to signal to the CC that the RC tests have finished |
59 |
text_content( |
60 |
"Waiting signal from region controller: '%s'" % msg)) |
|
194.2.51
by Diogo Matsubara
review comments from rvba, move cluster test to its own file and utilities to utils.py |
61 |
|
62 |
@classmethod
|
|
63 |
def tearDownClass(cls): |
|
64 |
"""Power off the cluster controller VM after the test run."""
|
|
65 |
run_command(["sudo", "poweroff"]) |