Merge lp:~rvb/maas-test/bmc-params-4 into lp:maas-test

Proposed by Raphaël Badin
Status: Merged
Merged at revision: 49
Proposed branch: lp:~rvb/maas-test/bmc-params-4
Merge into: lp:maas-test
Prerequisite: lp:~rvb/maas-test/bmc-params-3
Diff against target: 207 lines (+85/-42)
2 files modified
maastest/main.py (+50/-38)
maastest/parser.py (+35/-4)
To merge this branch: bzr merge lp:~rvb/maas-test/bmc-params-4
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+196111@code.launchpad.net

Commit message

Add params to pass BMC information.

Description of the change

Still no testing for the parsing code because we're still unsure if this is going to stay exactly like that. Note that I finally the two existing test cases into one since they are really close; as a result, the code is a bit simpler.

To post a comment you must log in.
lp:~rvb/maas-test/bmc-params-4 updated
52. By Raphaël Badin

Merged bmc-params-3 into bmc-params-4.

Revision history for this message
Graham Binns (gmb) :
review: Approve
lp:~rvb/maas-test/bmc-params-4 updated
53. By Raphaël Badin

Merged bmc-params-3 into bmc-params-4.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'maastest/main.py'
--- maastest/main.py 2013-11-20 10:30:06 +0000
+++ maastest/main.py 2013-11-21 14:40:46 +0000
@@ -31,11 +31,9 @@
3131
32class TestMAAS(testtools.TestCase, testresources.ResourcedTestCase):32class TestMAAS(testtools.TestCase, testresources.ResourcedTestCase):
3333
34 direct_interface = None
35
36 @classmethod34 @classmethod
37 def configure(cls, interface):35 def configure(cls, args):
38 cls.direct_interface = interface36 cls.args = args
3937
40 @classmethod38 @classmethod
41 def setUpClass(cls):39 def setUpClass(cls):
@@ -44,7 +42,7 @@
44 architecture = utils.determine_vm_architecture()42 architecture = utils.determine_vm_architecture()
45 cls.machine = KVMFixture(43 cls.machine = KVMFixture(
46 series='saucy', architecture=architecture,44 series='saucy', architecture=architecture,
47 direct_interface=cls.direct_interface)45 direct_interface=cls.args.interface)
48 cls.machine.setUp()46 cls.machine.setUp()
49 try:47 try:
50 cls.maas = MAASFixture(cls.machine)48 cls.maas = MAASFixture(cls.machine)
@@ -108,21 +106,55 @@
108 return relevant_nodes106 return relevant_nodes
109107
110108
111class TestInteractiveOneNode(TestMAAS):109class TestOneNode(TestMAAS):
112 """Test if a node is compatible with MAAS.110 """Test if a node is compatible with MAAS."""
113111
114 This is an interactive test: after MAAS is set up inside a virtual112 def test_power_up_node(self):
115 machine, it waits for the user to power up the node under test before113 """Power up the node under test.
116 trying to enlist and commission it."""114
117115 If maas-test is running in interactive mode, this will ask the user
118 def test_enlist_node(self):116 to power up the node manually. Otherwise it will use the provided
119 """Enlist node."""117 power parameters to power up the node by running 'ipmipower' in the
118 virtual machine..
119 """
120 # TODO: only print this in debug/verbose mode.120 # TODO: only print this in debug/verbose mode.
121 self.print_connection_details()121 self.print_connection_details()
122 if self.args.interactive_enlistment:
123 self.power_up_node_interactive()
124 else:
125 self.power_up_node_noninteractive()
126
127 def power_up_node_interactive(self):
128 """Asks the user to power up the node manually."""
122 print(129 print(
123 "Power up the node under test and press enter to proceed "130 "Power up the node under test and press enter to proceed "
124 "with the testing.")131 "with the testing.")
125 sys.stdin.readline()132 sys.stdin.readline()
133
134 def power_up_node_noninteractive(self):
135 """Power up the node using the provided power parameters."""
136 # Scan the network to find the IP address of the node's BMC.
137 for retry in utils.retries(delay=20, timeout=5 * 60):
138 ip_scan = self.maas.kvm_fixture.get_ip_from_network_scan
139 power_address = ip_scan(self.args.bmc_mac)
140 if power_address is not None:
141 break
142 if power_address is None:
143 self.fail("Failed to get the IP address of the BMC.")
144 # Power-cycle the node.
145 self.maas.kvm_fixture.run_command([
146 'ipmipower', '-h', power_address,
147 '-u', self.args.bmc_username,
148 '-p', self.args.bmc_password, '--off'],
149 check_call=True)
150 self.maas.kvm_fixture.run_command([
151 'ipmipower', '-h', power_address,
152 '-u', self.args.bmc_username,
153 '-p', self.args.bmc_password, '--on'],
154 check_call=True)
155
156 def test_enlist_node(self):
157 """Enlist node."""
126 for retry in utils.retries(delay=10, timeout=10 * 60):158 for retry in utils.retries(delay=10, timeout=10 * 60):
127 nb_enlisted_nodes = len(self.get_node_list(0)) # 0 = 'Declared'.159 nb_enlisted_nodes = len(self.get_node_list(0)) # 0 = 'Declared'.
128 if nb_enlisted_nodes == 1:160 if nb_enlisted_nodes == 1:
@@ -134,7 +166,8 @@
134 uri = utils.get_uri('nodes/')166 uri = utils.get_uri('nodes/')
135 response = self.maas.admin_maas_client.post(uri, op="accept_all")167 response = self.maas.admin_maas_client.post(uri, op="accept_all")
136 self.assertEqual(168 self.assertEqual(
137 httplib.OK, response.code, "Failed to get accept the node.")169 httplib.OK, response.code, "Failed to accept node.")
170
138 for retry in utils.retries(delay=10, timeout=10 * 60):171 for retry in utils.retries(delay=10, timeout=10 * 60):
139 nb_enlisted_nodes = len(self.get_node_list(4)) # 4 = 'Ready'.172 nb_enlisted_nodes = len(self.get_node_list(4)) # 4 = 'Ready'.
140 if nb_enlisted_nodes == 1:173 if nb_enlisted_nodes == 1:
@@ -142,17 +175,6 @@
142 self.fail("Failed to commission node.")175 self.fail("Failed to commission node.")
143176
144177
145class TestOneNode(TestMAAS):
146 """Test if a node is compatible with MAAS.
147
148 This is a non-interactive test: after MAAS is set up inside a virtual
149 machine, it will enlist the node with the power parameters provided and
150 commission it."""
151
152 def test_to_do(self):
153 raise NotImplementedError("TODO!")
154
155
156def check_kvm_ok():178def check_kvm_ok():
157 """Check that this machine is capable of running KVM.179 """Check that this machine is capable of running KVM.
158180
@@ -179,17 +201,7 @@
179 logging.error("Unable to continue without KVM extensions.")201 logging.error("Unable to continue without KVM extensions.")
180 return 1202 return 1
181203
182 if args.interactive_enlistment:204 class ConfiguredTestMAAS(TestOneNode):
183 base_class = TestInteractiveOneNode
184 else:
185 # Blow up right now to avoid creating the VM before blowing up in
186 # TestOneNode.test_to_do.
187 raise NotImplementedError(
188 "Non-interactive mode not yet implemented, use "
189 "--interactive-enlistment for now")
190 base_class = TestOneNode
191
192 class ConfiguredTestMAAS(base_class):
193 """A configured version of TestInteractiveOneNode.205 """A configured version of TestInteractiveOneNode.
194206
195 ConfiguredTestMAAS is a TestMAAS use to configure it by calling207 ConfiguredTestMAAS is a TestMAAS use to configure it by calling
@@ -197,7 +209,7 @@
197 the instance because the KVMFixture TestMAAS instanciates and needs209 the instance because the KVMFixture TestMAAS instanciates and needs
198 to configure is created at the class level.210 to configure is created at the class level.
199 """211 """
200 ConfiguredTestMAAS.configure(args.interface)212 ConfiguredTestMAAS.configure(args)
201213
202 # Create a TestLoader which loads the tests in the order in which214 # Create a TestLoader which loads the tests in the order in which
203 # they are defined in the test case class.215 # they are defined in the test case class.
204216
=== modified file 'maastest/parser.py'
--- maastest/parser.py 2013-11-20 11:53:52 +0000
+++ maastest/parser.py 2013-11-21 14:40:46 +0000
@@ -19,11 +19,29 @@
19from six import text_type19from six import text_type
2020
2121
22class MAASTestArgumentParser(argparse.ArgumentParser):
23
24 def parse_args(self):
25 args = super(MAASTestArgumentParser, self).parse_args()
26 bmc_details = (args.bmc_mac, args.bmc_username, args.bmc_password)
27 if args.interactive_enlistment:
28 if bmc_details != (None, None, None):
29 self.error(
30 "None of the BMC details should be provided when using "
31 "--interactive-enlistment.")
32 else:
33 if None in bmc_details:
34 self.error(
35 "All the BMC details (MAC address, username "
36 "and password) must be provided.")
37 return args
38
39
22def prepare_parser():40def prepare_parser():
23 # TODO: This is not tested sinc how maas-test will interface with41 # TODO: This is not tested sinc how maas-test will interface with
24 # checkbox is still in flux. Right now, this is just to get the42 # checkbox is still in flux. Right now, this is just to get the
25 # testing going.43 # testing going.
26 parser = argparse.ArgumentParser(44 parser = MAASTestArgumentParser(
27 description="Test whether or not a node is compatible with MAAS.")45 description="Test whether or not a node is compatible with MAAS.")
2846
29 parser.add_argument(47 parser.add_argument(
@@ -39,8 +57,21 @@
39 "e.g. ppa:maas-maintainers/dailybuilds).")57 "e.g. ppa:maas-maintainers/dailybuilds).")
40 parser.add_argument(58 parser.add_argument(
41 '--interactive-enlistment', action='store_true',59 '--interactive-enlistment', action='store_true',
42 help="Perform an interactive enlistment. Instead of passing the "60 help="Perform an interactive enlistment. Instead of passing the "
43 "IPMI details on the command line, ask for the node to be "61 "BMC details on the command line, the node will have to be "
44 "powered up manually and enlist the node when it PXE boots.")62 "powered up manually.")
63 # BMC details.
64 parser.add_argument(
65 '--bmc-mac', type=text_type,
66 help="The MAC address of the node's BMC. This will be used to "
67 "power up the node to enlist it.")
68 parser.add_argument(
69 '--bmc-username', type=text_type,
70 help="The username to use when authenticating with the node's BMC. "
71 "This will be used to power up the node to enlist it.")
72 parser.add_argument(
73 '--bmc-password', type=text_type,
74 help="The password to use when authenticating with the node's BMC. "
75 "This will be used to power up the node to enlist it.")
4576
46 return parser77 return parser

Subscribers

People subscribed via source and target branches