← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~andreserl/maas/trunk-fpi-tests into lp:maas

 

Andres Rodriguez has proposed merging lp:~andreserl/maas/trunk-fpi-tests into lp:maas with lp:~andreserl/maas/trunk-fpi as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~andreserl/maas/trunk-fpi-tests/+merge/163052
-- 
https://code.launchpad.net/~andreserl/maas/trunk-fpi-tests/+merge/163052
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andreserl/maas/trunk-fpi-tests into lp:maas.
=== modified file 'src/maasserver/tests/test_preseed.py'
--- src/maasserver/tests/test_preseed.py	2013-02-21 23:32:20 +0000
+++ src/maasserver/tests/test_preseed.py	2013-05-08 20:43:38 +0000
@@ -368,7 +368,7 @@
             nodegroup.get_managed_interface().ip,
             context["cluster_host"])
 
-    def test_preseed_context_null_cluster_host_if_unmanaged(self):
+    def test_preseed_context_not_null_cluster_host_if_unmanaged(self):
         # If the nodegroup has no managed interface recorded, which is
         # possible in the data model but would be a bit weird, the
         # cluster_host context variable is present, but None.
@@ -378,7 +378,7 @@
             interface.management = NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED
             interface.save()
         context = get_preseed_context(release, nodegroup)
-        self.assertIsNone(context["cluster_host"])
+        self.assertIsNotNone(context["cluster_host"])
 
     def test_preseed_context_null_cluster_host_if_does_not_exist(self):
         # If there's no nodegroup, the cluster_host context variable is
@@ -525,6 +525,12 @@
         preseed = get_preseed(node)
         self.assertIn('preseed/late_command', preseed)
 
+    def test_get_preseed_returns_xinstall_preseed(self):
+        node = factory.make_node()
+        node.use_fastpath_installer()
+        preseed = get_preseed(node)
+        self.assertIn('# Disabled by default', preseed)
+
     def test_get_enlist_preseed_returns_enlist_preseed(self):
         preseed = get_enlist_preseed()
         self.assertTrue(preseed.startswith('#cloud-config'))

=== modified file 'src/provisioningserver/pxe/tests/test_config.py'
--- src/provisioningserver/pxe/tests/test_config.py	2012-09-19 13:51:15 +0000
+++ src/provisioningserver/pxe/tests/test_config.py	2013-05-08 20:43:38 +0000
@@ -257,3 +257,38 @@
             self.assertThat(section["KERNEL"], contains_arch_path)
             self.assertThat(section["INITRD"], contains_arch_path)
             self.assertIn("APPEND", section)
+
+    def test_render_pxe_config_for_xinstall(self):
+        # The xinstall config uses an extra PXELINUX module to auto
+        # select between i386 and amd64.
+        get_ephemeral_name = self.patch(kernel_opts, "get_ephemeral_name")
+        get_ephemeral_name.return_value = factory.make_name("ephemeral")
+        options = {
+            "kernel_params":
+                make_kernel_parameters(purpose="xinstall"),
+            }
+        output = render_pxe_config(**options)
+        config = parse_pxe_config(output)
+        # The default section is defined.
+        default_section_label = config.header["DEFAULT"]
+        self.assertThat(config, Contains(default_section_label))
+        default_section = config[default_section_label]
+        # The default section uses the ifcpu64 module, branching to the "i386"
+        # or "amd64" labels accordingly.
+        self.assertEqual("ifcpu64.c32", default_section["KERNEL"])
+        self.assertEqual(
+            ["amd64", "--", "i386"],
+            default_section["APPEND"].split())
+        # Both "i386" and "amd64" sections exist.
+        self.assertThat(config, ContainsAll(("i386", "amd64")))
+        # Each section defines KERNEL, INITRD, and APPEND settings.  The
+        # KERNEL and INITRD ones contain paths referring to their
+        # architectures.
+        for section_label in ("i386", "amd64"):
+            section = config[section_label]
+            self.assertThat(
+                section, ContainsAll(("KERNEL", "INITRD", "APPEND")))
+            contains_arch_path = StartsWith("%s/" % section_label)
+            self.assertThat(section["KERNEL"], contains_arch_path)
+            self.assertThat(section["INITRD"], contains_arch_path)
+            self.assertIn("APPEND", section)

=== modified file 'src/provisioningserver/pxe/tests/test_install_image.py'
--- src/provisioningserver/pxe/tests/test_install_image.py	2012-08-31 15:41:18 +0000
+++ src/provisioningserver/pxe/tests/test_install_image.py	2013-05-08 20:43:38 +0000
@@ -209,3 +209,38 @@
         self.assertEqual(
             "rw-r--r--",
             target_dir.child("image").getPermissions().shorthand())
+
+    def test_install_dir_moves_dir_into_place_with_symlink(self):
+        download_image = os.path.join(self.make_dir(), 'download-image')
+        published_image = os.path.join(self.make_dir(), 'published-image')
+        base_path = os.path.dirname(published_image)
+        symlink_dest = 'xinstall'
+        contents = factory.getRandomString()
+        os.makedirs(download_image)
+        sample_file = factory.make_file(download_image, contents=contents)
+        install_dir(download_image, published_image, symlink_dest)
+        self.assertThat(
+            os.path.join(published_image, os.path.basename(sample_file)),
+            FileContains(contents))
+        self.assertThat(
+            os.path.join(base_path, symlink_dest, os.path.basename(sample_file)),
+            FileContains(contents))
+
+    def test_install_dir_replaces_existing_dir_with_symlink(self):
+        download_image = os.path.join(self.make_dir(), 'download-image')
+        published_image = os.path.join(self.make_dir(), 'published-image')
+        base_path = os.path.dirname(published_image)
+        symlink_dest = 'xinstall'
+        os.makedirs(download_image)
+        sample_file = factory.make_file(download_image)
+        os.makedirs(published_image)
+        os.symlink(published_image, os.path.join(base_path, symlink_dest))
+        obsolete_file = factory.make_file(published_image)
+        install_dir(download_image, published_image, symlink_dest)
+        self.assertThat(
+            os.path.join(published_image, os.path.basename(sample_file)),
+            FileExists())
+        self.assertThat(obsolete_file, Not(FileExists()))
+        self.assertThat(
+            os.path.join(base_path, symlink_dest, os.path.basename(sample_file)),
+            FileExists())

=== modified file 'src/provisioningserver/tests/test_kernel_opts.py'
--- src/provisioningserver/tests/test_kernel_opts.py	2013-02-01 01:07:25 +0000
+++ src/provisioningserver/tests/test_kernel_opts.py	2013-05-08 20:43:38 +0000
@@ -118,6 +118,21 @@
             "netcfg/choose_interface=auto",
             compose_kernel_command_line(params))
 
+    def test_xinstall_compose_kernel_command_line_inc_purpose_opts(self):
+        # The result of compose_kernel_command_line includes the purpose
+        # options for a non "commissioning" node.
+        get_ephemeral_name = self.patch(kernel_opts, "get_ephemeral_name")
+        get_ephemeral_name.return_value = "RELEASE-ARCH"
+        params = make_kernel_parameters(purpose="xinstall")
+        cmdline = compose_kernel_command_line(params)
+        self.assertThat(
+            cmdline,
+            ContainsAll([
+                "root=/dev/disk/by-path/ip-",
+                "iscsi_initiator=",
+                "overlayroot=tmpfs",
+                "ip=::::%s:BOOTIF" % params.hostname]))
+
     def test_commissioning_compose_kernel_command_line_inc_purpose_opts(self):
         # The result of compose_kernel_command_line includes the purpose
         # options for a non "commissioning" node.
@@ -147,8 +162,8 @@
         self.assertNotIn(cmdline, "None")
 
     def test_compose_kernel_command_line_inc_common_opts(self):
-        # Test that some kernel arguments appear on both commissioning
-        # and install command lines.
+        # Test that some kernel arguments appear on commissioning, install
+        # and xinstall command lines.
         get_ephemeral_name = self.patch(kernel_opts, "get_ephemeral_name")
         get_ephemeral_name.return_value = "RELEASE-ARCH"
         expected = ["nomodeset"]
@@ -159,6 +174,11 @@
         self.assertThat(cmdline, ContainsAll(expected))
 
         params = make_kernel_parameters(
+            purpose="xinstall", arch="i386")
+        cmdline = compose_kernel_command_line(params)
+        self.assertThat(cmdline, ContainsAll(expected))
+
+        params = make_kernel_parameters(
             purpose="install", arch="i386")
         cmdline = compose_kernel_command_line(params)
         self.assertThat(cmdline, ContainsAll(expected))
@@ -184,6 +204,22 @@
 
     def test_compose_kernel_command_line_inc_purpose_opts_comm_node(self):
         # The result of compose_kernel_command_line includes the purpose
+        # options for a "xinstall" node.
+        ephemeral_name = factory.make_name("ephemeral")
+        params = make_kernel_parameters(purpose="xinstall")
+        self.create_ephemeral_info(
+            ephemeral_name, params.arch, params.release)
+        self.assertThat(
+            compose_kernel_command_line(params),
+            ContainsAll([
+                "iscsi_target_name=%s:%s" % (
+                    ISCSI_TARGET_NAME_PREFIX, ephemeral_name),
+                "iscsi_target_port=3260",
+                "iscsi_target_ip=%s" % params.fs_host,
+                ]))
+
+    def test_compose_kernel_command_line_inc_purpose_opts_comm_node(self):
+        # The result of compose_kernel_command_line includes the purpose
         # options for a "commissioning" node.
         ephemeral_name = factory.make_name("ephemeral")
         params = make_kernel_parameters(purpose="commissioning")