Merge lp:~rvb/maas-test/real-tests into lp:maas-test

Proposed by Raphaël Badin
Status: Merged
Merged at revision: 41
Proposed branch: lp:~rvb/maas-test/real-tests
Merge into: lp:maas-test
Diff against target: 93 lines (+49/-7)
1 file modified
maastest/main.py (+49/-7)
To merge this branch: bzr merge lp:~rvb/maas-test/real-tests
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+195748@code.launchpad.net

Commit message

Add enlistment and commissioning tests.

Description of the change

I left TestMAAS as a mixin and added the two tests inside a separate class named TestInteractiveOneNode. This way, we can reuse the mixin (which takes care of all the set -up) if we want a fully automated (i.e. non interactive) test as well.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve

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-19 08:49:07 +0000
+++ maastest/main.py 2013-11-19 11:29:13 +0000
@@ -14,7 +14,9 @@
14 "main",14 "main",
15 ]15 ]
1616
17import httplib
17import inspect18import inspect
19import json
18import logging20import logging
19import sys21import sys
20import unittest22import unittest
@@ -81,23 +83,63 @@
81 super(TestMAAS, self).setUp()83 super(TestMAAS, self).setUp()
82 self.addCleanup(self.unify_details)84 self.addCleanup(self.unify_details)
8385
84 def test_dummy(self):86 def print_connection_details(self):
85 # TODO: Placeholder test. Replace with actual tests.
86 # For now, just hold so you can log into the VM and play with it.
87 print(87 print(
88 "\n****** VM RUNNING ON %s. PRESS ENTER TO SHUT DOWN. ******\n"88 "\n"
89 "URL: http://%s/MAAS/\n"89 "URL: http://%s/MAAS/\n"
90 "Username: %s\n"90 "Username: %s\n"
91 "Password: %s\n"91 "Password: %s\n"
92 "SSH login: ssh -i ~/.maas-test/vm_ssh_id_rsa %s\n"92 "SSH login: ssh -i ~/.maas-test/vm_ssh_id_rsa %s\n"
93 % (93 % (
94 self.machine.ip_address(),94 self.machine.ip_address(),
95 self.machine.ip_address(),
96 self.maas.admin_user,95 self.maas.admin_user,
97 self.maas.admin_password,96 self.maas.admin_password,
98 self.machine.identity(),97 self.machine.identity(),
99 ))98 ))
99
100 def get_node_list(self, status):
101 """Return the list of nodes with the given status."""
102 uri = utils.get_uri('nodes/')
103 response = self.maas.admin_maas_client.get(uri, op="list")
104 self.assertEqual(
105 httplib.OK, response.code, "Failed to get the node list.")
106 nodes = json.loads(response.read())
107 relevant_nodes = [node for node in nodes if node['status'] == status]
108 return relevant_nodes
109
110
111class TestInteractiveOneNode(TestMAAS):
112 """Test if a node is compatible with MAAS.
113
114 This is an interactive test: after MAAS is set up inside a virtual
115 machine, it waits for the user to power up the node under test before
116 trying to enlist and commission it."""
117
118 def test_enlist_node(self):
119 """Enlist node."""
120 # TODO: only print this in debug/verbose mode.
121 self.print_connection_details()
122 print(
123 "Power up the node under test and press enter to proceed "
124 "with the testing.")
100 sys.stdin.readline()125 sys.stdin.readline()
126 for retry in utils.retries(delay=10, timeout=10 * 60):
127 nb_enlisted_nodes = len(self.get_node_list(0)) # 0 = 'Declared'.
128 if nb_enlisted_nodes == 1:
129 return
130 self.fail("Failed to enlist node.")
131
132 def test_commission_node(self):
133 """Commission node."""
134 uri = utils.get_uri('nodes/')
135 response = self.maas.admin_maas_client.post(uri, op="accept_all")
136 self.assertEqual(
137 httplib.OK, response.code, "Failed to get accept the node.")
138 for retry in utils.retries(delay=10, timeout=10 * 60):
139 nb_enlisted_nodes = len(self.get_node_list(4)) # 4 = 'Ready'.
140 if nb_enlisted_nodes == 1:
141 return
142 self.fail("Failed to commission node.")
101143
102144
103def check_kvm_ok():145def check_kvm_ok():
@@ -126,8 +168,8 @@
126 logging.error("Unable to continue without KVM extensions.")168 logging.error("Unable to continue without KVM extensions.")
127 return 1169 return 1
128170
129 class ConfiguredTestMAAS(TestMAAS):171 class ConfiguredTestMAAS(TestInteractiveOneNode):
130 """A configured version of TestMAAS.172 """A configured version of TestInteractiveOneNode.
131173
132 ConfiguredTestMAAS is a TestMAAS use to configure it by calling174 ConfiguredTestMAAS is a TestMAAS use to configure it by calling
133 cls.configure. We need to configure the class itself and not175 cls.configure. We need to configure the class itself and not

Subscribers

People subscribed via source and target branches