Пример #1
0
    def test_progress_estimate_with_size(self):
        '''Test progress estimate value when size is pre-calculated  exists
        '''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = ["./"]
        size_to_transfer = dir_size(src_path)
        self.tr_node.size = str(size_to_transfer)

        progress_estimate = self.tr_cpio.get_progress_estimate()
        expect_estimate = \
            int((float(size_to_transfer / 1024) / self.tr_cpio.DEFAULT_SIZE) \
                * self.tr_cpio.DEFAULT_PROG_EST)

        self.assertEqual(progress_estimate, expect_estimate)
Пример #2
0
    def test_media_transform(self):
        '''Test media transform functionality'''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "transform"
        self.tr_node.contents = self.TEST_MEDIA_TRANSFORM
        with open(self.TEST_MEDIA_TRANSFORM, 'w') as filehandle:
            filehandle.write("#!/usr/bin/python\n")
            filehandle.write("import os\n")
            mkdir_cmd = "os.mkdir('" + self.TEST_DST_DIR + "')"
            filehandle.write(mkdir_cmd + "\n")
            mkdir_cmd = "os.mkdir('" + os.path.join(self.TEST_DST_DIR,
                                                    "media") + "')"
            filehandle.write(mkdir_cmd)
        os.chmod(self.TEST_MEDIA_TRANSFORM, 0777)
        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_progress_estimate_with_size(self):
        '''Test progress estimate value when size is pre-calculated  exists
        '''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = ["./"]
        size_to_transfer = dir_size(src_path)
        self.tr_node.size = str(size_to_transfer)

        progress_estimate = self.tr_cpio.get_progress_estimate()
        expect_estimate = \
            int((float(size_to_transfer/1024) / self.tr_cpio.DEFAULT_SIZE) * \
                self.tr_cpio.DEFAULT_PROG_EST)

        self.assertEqual(progress_estimate, expect_estimate)
Пример #4
0
    def test_dry_run_transfer(self):
        '''Test with accurate input dry run succeeds
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "install"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Пример #5
0
    def test_cpio_non_default_args_set(self):
        '''Test copying a list of directories and files succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a list for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        args = Args({"cpio_args": "-n -d -pdum"})
        self.tr_node.insert_children([args])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("etc/X11")
        self.TEST_CONTENTS_LIST.append("etc/zones")
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_cpio_w_dir_list_file(self):
        '''Test directory cpio copy succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a file for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_DIR_LIST_FILE
        with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle:
            filehandle.write("etc/X11" + "\n")
            filehandle.write("etc/zones" + "\n")

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_cpio_non_default_args_set(self):
        '''Test copying a list of directories and files succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a list for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        args = Args({"cpio_args": "-n -d -pdum"})
        self.tr_node.insert_children([args])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("etc/X11")
        self.TEST_CONTENTS_LIST.append("etc/zones")
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_cpio_w_file_list(self):
        '''Test copy from a list succeeds'''
        # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir
        # using a file list as the contents source

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_cpio_w_file_list_file(self):
        '''Test copy of a file list file succeeds'''
        # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir
        # using a file list file as the contents souce

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_FILE_LIST_FILE
        with open(self.TEST_FILE_LIST_FILE, 'w') as filehandle:
            filehandle.write("bin/xclock" + "\n")
            filehandle.write("bin/pv.sh" + "\n")

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_cleanup_temp_files(self):
        '''Test the cleanup of the temporary files'''
        # Set up the source
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = ["./"]

        self.tr_cpio._parse_input()
        try:
            self.tr_cpio._cleanup_tmp_files()
        except Exception as err:
            self.fail(str(err))
Пример #11
0
    def test_cpio_w_dir_list_file(self):
        '''Test directory cpio copy succeeds'''
        # Copy all the directories and files from /etc/X11 and /etc/zones
        # to /rpool/cpio_test_dir using a file for the contents

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_DIR_LIST_FILE
        with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle:
            filehandle.write("etc/X11" + "\n")
            filehandle.write("etc/zones" + "\n")

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Пример #12
0
    def test_cpio_w_file_list_file(self):
        '''Test copy of a file list file succeeds'''
        # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir
        # using a file list file as the contents souce

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_FILE_LIST_FILE
        with open(self.TEST_FILE_LIST_FILE, 'w') as filehandle:
            filehandle.write("bin/xclock" + "\n")
            filehandle.write("bin/pv.sh" + "\n")

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Пример #13
0
    def test_single_args_instance(self):
        '''Test pass when single instance of args provided
        '''
        mysrc = "srcdir"
        mydest = "destfile"
        args = Args({"svr4_args": "-n -d %s -R %s" % (mysrc, mydest)})
        self.tr_node.insert_children([args])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def create_misc_archive(self):
        """ class method to create the /mnt/misc file system archive
        """
        os.chdir(self.pkg_img_path)

        self.logger.info("Generating /mnt/misc file system archive")

        os.mkdir("miscdirs")
        shutil.move("opt", "miscdirs")
        shutil.move("etc", "miscdirs")
        shutil.move("var", "miscdirs")

        # add Software node to install items from /mnt/misc

        src_path = Dir("/mnt/misc")
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        tr_install_misc = CPIOSpec()
        tr_install_misc.action = CPIOSpec.INSTALL
        tr_install_misc.contents = ["."]
        tr_install_misc.size = str(dir_size(os.path.join(self.pkg_img_path,
                                                         "miscdirs")))

        misc_software_node = Software(TRANSFER_MISC, type="CPIO")
        misc_software_node.insert_children([src, dst, tr_install_misc])
        self.doc.persistent.insert_children(misc_software_node)

        cmd = [cli.MKISOFS, "-o", "solarismisc.zlib", "-N", "-l", "-R",
               "-U", "-allow-multidot", "-no-iso-translate", "-quiet",
               "-cache-inodes", "-d", "-D", "-V", "\"compress\"",
               "miscdirs"]
        run(cmd)

        self.logger.info("Compressing /mnt/misc file system archive " +
                         "using: " + self.compression_type)

        cmd = [cli.LOFIADM, "-C", self.compression_type,
               os.path.join(self.pkg_img_path, "solarismisc.zlib")]
        p = run(cmd, check_result=Popen.ANY)
        if p.returncode != 0:
            if "invalid algorithm name" in p.stderr:
                raise RuntimeError("Invalid compression algorithm " +
                    "specified for /mnt/misc archive: " +
                    self.compression_type)
            else:
                raise RuntimeError("Compression of /mnt/misc file system " +
                                   "failed:  " + os.strerror(p.returncode))

        # the removal of /usr must be deferred to until solarismisc.zlib has
        # been created because the contents of solarismisc.zlib actually come
        # from /usr
        shutil.rmtree(os.path.join(self.pkg_img_path, "miscdirs"),
                      ignore_errors=True)
        shutil.rmtree(os.path.join(self.pkg_img_path, "usr"),
                      ignore_errors=True)
Пример #15
0
    def test_cpio_w_file_list(self):
        '''Test copy from a list succeeds'''
        # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir
        # using a file list as the contents source

        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.TEST_CONTENTS_LIST.append("bin/xclock")
        self.TEST_CONTENTS_LIST.append("bin/pv.sh")

        self.tr_node.action = "install"
        self.tr_node.contents = self.TEST_CONTENTS_LIST

        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_valid_transfer_action(self):
        '''Test valid input with dry run.
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        self.tr_node3 = SVR4Spec()
        self.tr_node3.action = "transform"
        self.tr_node3.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node3])

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
    def test_single_args_instance(self):
        '''Test pass when single instance of args provided
        '''
        mysrc = "srcdir"
        mydest = "destfile"
        args = Args({"svr4_args": "-n -d %s -R %s" % (mysrc, mydest)})
        self.tr_node.insert_children([args])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def test_install_uninstall_dry_run(self):
        '''Test an install followed by an uninstall'''
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2", "SUNWpkg3"]
        args = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node.insert_children([args])
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Пример #19
0
    def test_valid_transfer_action(self):
        '''Test valid input with dry run.
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        self.tr_node3 = SVR4Spec()
        self.tr_node3.action = "transform"
        self.tr_node3.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node3])

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
Пример #20
0
    def test_cleanup_temp_files(self):
        '''Test the cleanup of the temporary files'''
        # Set up the source
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "install"
        self.tr_node.contents = ["./"]

        self.tr_cpio._parse_input()
        try:
            self.tr_cpio._cleanup_tmp_files()
        except Exception as err:
            self.fail(str(err))
    def test_media_transform(self):
        '''Test media transform functionality'''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "transform"
        self.tr_node.contents = self.TEST_MEDIA_TRANSFORM
        with open(self.TEST_MEDIA_TRANSFORM, 'w') as filehandle:
            filehandle.write("#!/usr/bin/python\n")
            filehandle.write("import os\n")
            mkdir_cmd = "os.mkdir('" + self.TEST_DST_DIR + "')"
            filehandle.write(mkdir_cmd + "\n")
            mkdir_cmd = "os.mkdir('" + os.path.join(self.TEST_DST_DIR,
                                                    "media") + "')"
            filehandle.write(mkdir_cmd)
        os.chmod(self.TEST_MEDIA_TRANSFORM, 0777)
        try:
            self.tr_cpio.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Пример #22
0
    def test_install_uninstall_dry_run(self):
        '''Test an install followed by an uninstall'''
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2", "SUNWpkg3"]
        args = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node.insert_children([args])
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "uninstall"
        self.tr_node2.contents = ["SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
    def add_content_list_to_doc(self, content_list):
        src_path = Dir(MEDIA_DIR_VAR)
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        media_install = CPIOSpec()
        media_install.action = CPIOSpec.INSTALL
        media_install.contents = content_list
        total_size_byte = 0
        for content in content_list:
            content_path = os.path.join(self.pkg_img_path, content)
            # only want to calculate the size of files, since directories
            # are traversed and it's files are included in the list.
            if not os.path.isdir(content_path):
                total_size_byte += file_size(content_path)
        media_install.size = str(total_size_byte)

        media_soft_node = Software(TRANSFER_MEDIA, type="CPIO")
        media_soft_node.insert_children([src, dst, media_install])

        # Add that into the software transfer list.
        self.doc.persistent.insert_children(media_soft_node)

        # call manifest writer to write out the content of
        # the transfer manifest
        manifest_out = os.path.join(self.pkg_img_path, TRANSFER_MANIFEST_NAME)
        xslt_name = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 "xslt", "doc2_media_transfer.xslt")
        manifest_writer = ManifestWriter("manifest-writer",
                                         manifest_out, xslt_file=xslt_name)
        manifest_writer.write(self.doc)
    def test_dry_run_transfer(self):
        '''Test with accurate input dry run succeeds
        '''
        self.tr_node2 = SVR4Spec()
        self.tr_node2.action = "install"
        self.tr_node2.contents = ["SUNWpkg1", "SUNWpkg2"]
        self.soft_node.insert_children([self.tr_node2])
        args2 = Args({"svr4_args": "-n -R %s" % (self.TEST_DST_DIR)})
        self.tr_node2.insert_children([args2])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])

        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1", "SUNWpkg2"]

        try:
            self.tr_svr4.execute(dry_run=True)
        except Exception as err:
            self.fail(str(err))
Пример #25
0
 def test_origin_not_specified(self):
     '''Test an errer is raised when the origin is not specified.
     '''
     src = Source()
     pub = Publisher()
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     tr_p5i = TransferP5I("P5I transfer")
     self.assertRaises(ObjectNotFoundError, tr_p5i.execute, DRY_RUN)
Пример #26
0
 def test_origin_not_specified(self):
     '''Test an errer is raised when the origin is not specified.
     '''
     src = Source()
     pub = Publisher()
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     tr_p5i = TransferP5I("P5I transfer")
     self.assertRaises(ObjectNotFoundError, tr_p5i.execute, DRY_RUN)
Пример #27
0
    def test_dst_not_specified(self):
        ''' Test that an error is raised when dst is not specified'''
        # Test that an error is raised.
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        self.soft_node.insert_children([src])
        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
    def test_dst_not_specified(self):
        ''' Test that an error is raised when dst is not specified'''
        # Test that an error is raised.
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        self.soft_node.insert_children([src])
        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
Пример #29
0
    def test_dst_not_specified(self):
        '''Test error when dst is not specified
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        self.soft_node.insert_children([src])
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
    def test_dst_not_specified(self):
        '''Test error when dst is not specified
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        self.soft_node.insert_children([src])
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
Пример #31
0
    def test_set_invalid_facets(self):
        '''Ensure an error is raised for an invalid facet'''
        src = Source()
        pub = Publisher("opensolaris.org")
        origin = Origin("http://ipkg.sfbay.sun.com/release/")
        pub.insert_children([origin])
        src.insert_children([pub])
        self.soft_node.insert_children([src])
        facet = Facet("doc", 'True')
        self.ips_image.insert_children([facet])

        self.assertRaises(Exception, self.tr_ips.execute)
Пример #32
0
    def test_set_invalid_facets(self):
        '''Ensure an error is raised for an invalid facet'''
        src = Source()
        pub = Publisher("opensolaris.org")
        origin = Origin("http://ipkg.sfbay.sun.com/release/")
        pub.insert_children([origin])
        src.insert_children([pub])
        self.soft_node.insert_children([src])
        facet = Facet("doc", 'True')
        self.ips_image.insert_children([facet])

        self.assertRaises(Exception, self.tr_ips.execute)
Пример #33
0
 def test_default_publisher(self):
     '''Test that using the default publisher succeeds'''
     src = Source()
     pub = Publisher()
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     pub.insert_children([origin])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #34
0
 def test_source_omit_name_first_success(self):
     '''Test that omitting name is allowed for first publisher'''
     src = Source()
     pub = Publisher("")
     origin = Origin("http://ipkg.sfbay.sun.com/dev/")
     pub.insert_children([origin])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #35
0
 def test_default_publisher(self):
     '''Test that using the default publisher succeeds'''
     src = Source()
     pub = Publisher()
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     pub.insert_children([origin])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #36
0
 def test_mirrors(self):
     '''Test creating mirrors succeeds'''
     src = Source()
     pub = Publisher("opensolaris.org")
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     mirror = Mirror("http://ipkg.central.sun.com:8000/")
     pub.insert_children([origin, mirror])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #37
0
 def test_mirrors(self):
     '''Test creating mirrors succeeds'''
     src = Source()
     pub = Publisher("opensolaris.org")
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     mirror = Mirror("http://ipkg.central.sun.com:8000/")
     pub.insert_children([origin, mirror])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #38
0
    def test_multiple_source_info(self):
        '''Test that specifying multiple sources succeeds.'''
        soft_node = Software("transfer test 2")
        src1 = Source()
        pub1 = Publisher("test1.org")
        origin1 = Origin("http://test1/dev")
        pub1.insert_children([origin1])
        src1.insert_children([pub1])

        src2 = Source()
        pub2 = Publisher("test2.org")
        origin2 = Origin("http://test2/dev")
        pub2.insert_children([origin2])
        src2.insert_children([pub2])

        tr_node = IPSSpec()
        soft_node.insert_children([src1, src2, tr_node])
        self.doc.insert_children([soft_node])
        soft_list = self.doc.get_children("transfer test 2", Software)
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            pub = src_list[0].get_children("publisher", Publisher)
            origin = pub[0].get_children("origin", Origin)
            self.assertEqual(pub[0].publisher, "test1.org")
            self.assertEqual(origin[0].origin, "http://test1/dev")
            pub = src_list[1].get_children("publisher", Publisher)
            origin = pub[0].get_children("origin", Origin)
            self.assertEqual(pub[0].publisher, "test2.org")
            self.assertEqual(origin[0].origin, "http://test2/dev")
    def test_src_not_exist(self):
        ''' Test that an error is raised when src doesn't exist.'''

        #Set up the source
        src = Source()
        path = Dir("/hello")
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])
        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
Пример #40
0
    def test_src_not_exist(self):
        ''' Test that an error is raised when src doesn't exist.'''

        #Set up the source
        src = Source()
        path = Dir("/hello")
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])
        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
Пример #41
0
 def test_set_create_facets(self):
     '''Test that creating facets succeeds'''
     src = Source()
     pub = Publisher("opensolaris.org")
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     pub.insert_children([origin])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     facet = Facet("facet.doc", 'True')
     self.ips_image.insert_children([facet])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #42
0
    def test_src_not_exist(self):
        '''Test that an error is raised when the source doesn't exist'''
        src = Source()
        pub = Publisher()
        origin = Origin("/doesnt_exist")
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
    def test_src_not_exist(self):
        '''Test that an error is raised when the source doesn't exist'''
        src = Source()
        pub = Publisher()
        origin = Origin("/doesnt_exist")
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
Пример #44
0
    def test_source_replacement(self):
        '''Test that replacing a source succeeds'''
        # Setup an IPS image
        src = Source()
        pub = Publisher("opensolaris.org")
        origin = Origin("http://ipkg.sfbay.sun.com/release/")
        pub2 = Publisher("extra")
        origin2 = Origin("http://ipkg.sfbay.sun.com/extra/")
        pub2.insert_children([origin2])
        pub.insert_children([origin])
        src.insert_children([pub, pub2])
        self.soft_node.insert_children([src])
        try:
            self.tr_ips.execute(dry_run=DRY_RUN)
        except Exception as err:
            self.fail(str(err))

        # Create a new transaction with a differnt publisher/origin.
        # Specify to update the image created above.
        self.soft_node = Software("IPS post install")
        self.doc.insert_children([self.soft_node])
        src = Source()
        pub = Publisher("opensolaris.org")
        origin = Origin("http://ipkg.sfbay.sun.com/dev/")
        pub.insert_children([origin])
        src.insert_children([pub])
        dst = Destination()
        self.ips_image = Image(self.IPS_IMG_DIR, "update")
        dst.insert_children([self.ips_image])
        self.soft_node.insert_children([dst, src])
        try:
            self.tr_ips.execute(dry_run=DRY_RUN)
        except Exception as err:
            self.fail(str(err))
Пример #45
0
 def test_set_create_facets(self):
     '''Test that creating facets succeeds'''
     src = Source()
     pub = Publisher("opensolaris.org")
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     pub.insert_children([origin])
     src.insert_children([pub])
     self.soft_node.insert_children([src])
     facet = Facet("facet.doc", 'True')
     self.ips_image.insert_children([facet])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #46
0
 def test_publisher_not_specified(self):
     '''Test an error is raised when the publisher is not specified.
     '''
     src = Source()
     self.soft_node.insert_children([src])
     tr_p5i = TransferP5I("P5I transfer")
     self.assertRaises(Exception, tr_p5i.execute, DRY_RUN)
Пример #47
0
    def test_dir_excl_list_not_valid(self):
        '''Test that an error is raised for invalid dir_excl_list'''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "uninstall"
        self.tr_node.contents = "/tmp/invalid_dir_file"
        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
Пример #48
0
    def test_file_name(self):
        '''Test that Origin is set correctly in the node'''
        p5i_node = Software("transfer 1")
        src = Source()
        pub = Publisher()
        origin = Origin(self.DEF_P5I_FILE)
        pub.insert_children([origin])
        src.insert_children([pub])
        p5i_node.insert_children([src])
        self.doc.insert_children([p5i_node])

        soft_list = self.doc.get_children("transfer 1", Software)
        for soft in soft_list:
            src = soft.get_children("source", Source)[0]
            pub = src.get_children("publisher", Publisher)[0]
            origin = pub.get_children("origin", Origin)[0]
            self.assertTrue(origin.origin == self.DEF_P5I_FILE)
    def test_dir_excl_list_not_valid(self):
        '''Test that an error is raised for invalid dir_excl_list'''
        src = Source()
        src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11")
        path = Dir(src_path)
        src.insert_children([path])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified
        self.tr_node.action = "uninstall"
        self.tr_node.contents = "/tmp/invalid_dir_file"
        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)
    def test_file_name(self):
        '''Test that Origin is set correctly in the node'''
        p5i_node = Software("transfer 1")
        src = Source()
        pub = Publisher()
        origin = Origin(self.DEF_P5I_FILE)
        pub.insert_children([origin])
        src.insert_children([pub])
        p5i_node.insert_children([src])
        self.doc.insert_children([p5i_node])

        soft_list = self.doc.get_children("transfer 1", Software)
        for soft in soft_list:
            src = soft.get_children("source", Source)[0]
            pub = src.get_children("publisher", Publisher)[0]
            origin = pub.get_children("origin", Origin)[0]
            self.assertTrue(origin.origin == self.DEF_P5I_FILE)
    def test_transfer_fail_uninstall(self):
        '''Test that the transfer mechanism to uninstall
           fails with a non-existent package
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = 'uninstall'
        self.tr_node.contents = ["SUNWpkg0"]

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=False)
    def test_uninstall_bad_args(self):
        '''Test transfer uninstall fails with bad args
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        args = Args({"svr4_args": "-q -r -s -t"})
        self.tr_node.insert_children([args])
        self.tr_node.action = "uninstall"
        self.tr_node.contents = ["SUNWpkg1"]
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=False)
Пример #53
0
 def test_multiple_sources(self):
     '''Test that setting multiple sources succeeds'''
     src = Source()
     pub = Publisher("opensolaris.org")
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     pub2 = Publisher("contrib.opensolaris.org")
     origin2 = Origin("http://ipkg.sfbay.sun.com/contrib/")
     pub3 = Publisher("extra")
     origin3 = Origin("http://ipkg.sfbay.sun.com/extra/")
     pub.insert_children([origin])
     pub2.insert_children([origin2])
     pub3.insert_children([origin3])
     src.insert_children([pub, pub2, pub3])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #54
0
    def test_transfer_fail_uninstall(self):
        '''Test that the transfer mechanism to uninstall
           fails with a non-existent package
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = 'uninstall'
        self.tr_node.contents = ["SUNWpkg0"]

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=False)
Пример #55
0
    def test_uninstall_bad_args(self):
        '''Test transfer uninstall fails with bad args
        '''
        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        args = Args({"svr4_args": "-q -r -s -t"})
        self.tr_node.insert_children([args])
        self.tr_node.action = "uninstall"
        self.tr_node.contents = ["SUNWpkg1"]
        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=False)
Пример #56
0
 def test_multiple_sources(self):
     '''Test that setting multiple sources succeeds'''
     src = Source()
     pub = Publisher("opensolaris.org")
     origin = Origin("http://ipkg.sfbay.sun.com/release/")
     pub2 = Publisher("contrib.opensolaris.org")
     origin2 = Origin("http://ipkg.sfbay.sun.com/contrib/")
     pub3 = Publisher("extra")
     origin3 = Origin("http://ipkg.sfbay.sun.com/extra/")
     pub.insert_children([origin])
     pub2.insert_children([origin2])
     pub3.insert_children([origin3])
     src.insert_children([pub, pub2, pub3])
     self.soft_node.insert_children([src])
     try:
         self.tr_ips.execute(dry_run=DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #57
0
 def test_install(self):
     '''Test that p5i install is successful'''
     src = Source()
     pub = Publisher("test")
     origin = Origin(PKG_FULL_P5I)
     pub.insert_children(origin)
     pub_prim = Publisher("test2")
     origin_prim = Origin(PKG_PUB_PATH)
     pub1 = Publisher(PKG_PUBLISHER)
     origin1 = Origin(PKG_PUB_PATH)
     pub_prim.insert_children(origin_prim)
     pub1.insert_children(origin1)
     src.insert_children([pub, pub_prim, pub1])
     self.soft_node.insert_children(src)
     tr_p5i = TransferP5I("P5I transfer")
     try:
         tr_p5i.execute(DRY_RUN)
     except Exception as err:
         self.fail(str(err))
Пример #58
0
 def test_install(self):
     '''Test that p5i install is successful'''
     src = Source()
     pub = Publisher("test")
     origin = Origin(PKG_FULL_P5I)
     pub.insert_children(origin)
     pub_prim = Publisher("test2")
     origin_prim = Origin(PKG_PUB_PATH)
     pub1 = Publisher(PKG_PUBLISHER)
     origin1 = Origin(PKG_PUB_PATH)
     pub_prim.insert_children(origin_prim)
     pub1.insert_children(origin1)
     src.insert_children([pub, pub_prim, pub1])
     self.soft_node.insert_children(src)
     tr_p5i = TransferP5I("P5I transfer")
     try:
         tr_p5i.execute(DRY_RUN)
     except Exception as err:
         self.fail(str(err))
    def test_bad_args_name(self):
        '''Test having invalid args key fails'''
        args = Args({"svr44444_args": "-n -d"})
        self.tr_node.insert_children([args])

        src = Source()
        pub = Publisher()
        origin = Origin(self.TEST_SRC_DIR)
        pub.insert_children([origin])
        src.insert_children([pub])

        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])
        self.soft_node.insert_children([src, dst])
        self.tr_node.action = "install"
        self.tr_node.contents = ["SUNWpkg1"]

        self.assertRaises(Exception, self.tr_svr4.execute, dry_run=True)
    def test_cpio_no_contents(self):
        ''' Test that an error is raised when no contents exist'''
        # Set up the source
        src = Source()
        path = Dir(self.TEST_SRC_DIR)
        src.insert_children([path])

        # Set up the destination
        dst = Destination()
        path = Dir(self.TEST_DST_DIR)
        dst.insert_children([path])

        # Insert the source and dest into the Software node
        self.soft_node.insert_children([src, dst])

        # The CPIO values that are specified - no contents
        self.tr_node.action = "install"

        self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True)