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
1=== modified file 'maastest/main.py'
2--- maastest/main.py 2013-11-19 08:49:07 +0000
3+++ maastest/main.py 2013-11-19 11:29:13 +0000
4@@ -14,7 +14,9 @@
5 "main",
6 ]
7
8+import httplib
9 import inspect
10+import json
11 import logging
12 import sys
13 import unittest
14@@ -81,23 +83,63 @@
15 super(TestMAAS, self).setUp()
16 self.addCleanup(self.unify_details)
17
18- def test_dummy(self):
19- # TODO: Placeholder test. Replace with actual tests.
20- # For now, just hold so you can log into the VM and play with it.
21+ def print_connection_details(self):
22 print(
23- "\n****** VM RUNNING ON %s. PRESS ENTER TO SHUT DOWN. ******\n"
24+ "\n"
25 "URL: http://%s/MAAS/\n"
26 "Username: %s\n"
27 "Password: %s\n"
28 "SSH login: ssh -i ~/.maas-test/vm_ssh_id_rsa %s\n"
29 % (
30 self.machine.ip_address(),
31- self.machine.ip_address(),
32 self.maas.admin_user,
33 self.maas.admin_password,
34 self.machine.identity(),
35 ))
36+
37+ def get_node_list(self, status):
38+ """Return the list of nodes with the given status."""
39+ uri = utils.get_uri('nodes/')
40+ response = self.maas.admin_maas_client.get(uri, op="list")
41+ self.assertEqual(
42+ httplib.OK, response.code, "Failed to get the node list.")
43+ nodes = json.loads(response.read())
44+ relevant_nodes = [node for node in nodes if node['status'] == status]
45+ return relevant_nodes
46+
47+
48+class TestInteractiveOneNode(TestMAAS):
49+ """Test if a node is compatible with MAAS.
50+
51+ This is an interactive test: after MAAS is set up inside a virtual
52+ machine, it waits for the user to power up the node under test before
53+ trying to enlist and commission it."""
54+
55+ def test_enlist_node(self):
56+ """Enlist node."""
57+ # TODO: only print this in debug/verbose mode.
58+ self.print_connection_details()
59+ print(
60+ "Power up the node under test and press enter to proceed "
61+ "with the testing.")
62 sys.stdin.readline()
63+ for retry in utils.retries(delay=10, timeout=10 * 60):
64+ nb_enlisted_nodes = len(self.get_node_list(0)) # 0 = 'Declared'.
65+ if nb_enlisted_nodes == 1:
66+ return
67+ self.fail("Failed to enlist node.")
68+
69+ def test_commission_node(self):
70+ """Commission node."""
71+ uri = utils.get_uri('nodes/')
72+ response = self.maas.admin_maas_client.post(uri, op="accept_all")
73+ self.assertEqual(
74+ httplib.OK, response.code, "Failed to get accept the node.")
75+ for retry in utils.retries(delay=10, timeout=10 * 60):
76+ nb_enlisted_nodes = len(self.get_node_list(4)) # 4 = 'Ready'.
77+ if nb_enlisted_nodes == 1:
78+ return
79+ self.fail("Failed to commission node.")
80
81
82 def check_kvm_ok():
83@@ -126,8 +168,8 @@
84 logging.error("Unable to continue without KVM extensions.")
85 return 1
86
87- class ConfiguredTestMAAS(TestMAAS):
88- """A configured version of TestMAAS.
89+ class ConfiguredTestMAAS(TestInteractiveOneNode):
90+ """A configured version of TestInteractiveOneNode.
91
92 ConfiguredTestMAAS is a TestMAAS use to configure it by calling
93 cls.configure. We need to configure the class itself and not

Subscribers

People subscribed via source and target branches