← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~matsubara/maas/packaging-tests into lp:~maas-maintainers/maas/packaging

 

Diogo Matsubara has proposed merging lp:~matsubara/maas/packaging-tests into lp:~maas-maintainers/maas/packaging.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~matsubara/maas/packaging-tests/+merge/123630

This branch adds the XS-Testsuite header to the package and some initial tests to be run by autopkgtest.

-- 
https://code.launchpad.net/~matsubara/maas/packaging-tests/+merge/123630
Your team MAAS Maintainers is requested to review the proposed merge of lp:~matsubara/maas/packaging-tests into lp:~maas-maintainers/maas/packaging.
=== modified file 'debian/control'
--- debian/control	2012-08-29 02:56:47 +0000
+++ debian/control	2012-09-10 19:54:18 +0000
@@ -6,6 +6,7 @@
  python-django
 Standards-Version: 3.9.3
 X-Python-Version: >= 2.7
+XS-Testsuite: autopkgtest
 Homepage: https://launchpad.net/maas
 
 Package: maas

=== added directory 'debian/tests'
=== added file 'debian/tests/control'
--- debian/tests/control	1970-01-01 00:00:00 +0000
+++ debian/tests/control	2012-09-10 19:54:18 +0000
@@ -0,0 +1,2 @@
+Tests: maas-package-test
+Depends: @, python-nose, xvfb, python-pip

=== added file 'debian/tests/maas-package-test'
--- debian/tests/maas-package-test	1970-01-01 00:00:00 +0000
+++ debian/tests/maas-package-test	2012-09-10 19:54:18 +0000
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e -u
+exec 2>&1
+pip install sst
+nosetests tests/maas-integration.py

=== added directory 'tests'
=== added file 'tests/maas-integration.py'
--- tests/maas-integration.py	1970-01-01 00:00:00 +0000
+++ tests/maas-integration.py	2012-09-10 19:54:18 +0000
@@ -0,0 +1,72 @@
+# TODO
+#  - send ipmi commands to turn on/off nodes
+#  - run import pxe files
+#  - check node states once they're on/off
+#  - check node state changes (declared -> commissionig -> ready)
+import os
+from subprocess import check_output
+import sys
+from unittest import TestCase
+
+from pyvirtualdisplay import Display
+from sst.actions import (
+    assert_url, assert_text_contains, assert_title_contains, click_button,
+    get_element, go_to, write_textfield)
+
+
+sys.path.insert(0, "/usr/share/maas")
+os.environ['DJANGO_SETTINGS_MODULE'] = 'maas.settings'
+from maasserver.models import User
+
+MAAS_URL = "http://10.98.0.13/MAAS";
+ADMIN_USER = "admin"
+PASSWORD = "test"
+
+
+class TestMAASIntegration(TestCase):
+
+    def setUp(self):
+        self.display = Display(visible=0, size=(1280, 1024))
+        self.display.start()
+
+    def tearDown(self):
+        self.display.stop()
+
+    def createadmin(self):
+        """Run sudo maas createsuperuser."""
+        cmd_output = check_output(
+            ["sudo", "maas", "createsuperuser", "--username=%s" % ADMIN_USER,
+            "--email=example@xxxxxxxxxxxxx", "--noinput"])
+        ## Set password for admin user.
+        try:
+            admin = User.objects.get(username=ADMIN_USER)
+        except User.DoesNotExist:
+            admin = User(username=ADMIN_USER)
+        admin.set_password(PASSWORD)
+        admin.save()
+        return cmd_output
+
+    def installation(self):
+        # Check the installation worked.
+        go_to(MAAS_URL)
+        assert_text_contains(
+            get_element(tag="body"), "No admin user has been created yet")
+
+    def createadmin_and_login(self):
+        ## Creates the admin user.
+        output = self.createadmin()
+        self.assertEqual(output, 'Superuser created successfully.')
+        ## Login with the newly created admin user
+        go_to(MAAS_URL)
+        assert_text_contains(
+            get_element(tag="body"), "Login to lenovo-RD230-01 MAAS")
+        write_textfield("id_username", ADMIN_USER)
+        write_textfield("id_password", PASSWORD)
+        click_button("Login")
+        assert_url("MAAS/")
+        assert_title_contains("Dashboard")
+
+    def test_integration(self):
+        # Run the integration tests in order.
+        self.installation()
+        self.createadmin_and_login()


Follow ups