Ejemplo n.º 1
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)
Ejemplo n.º 2
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))
Ejemplo n.º 3
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))
Ejemplo n.º 4
0
    def test_more_than_one_same_soft_node(self):
        '''Test error when multiple software nodes with same name
        '''
        soft_node2 = Software("SVR4Transfer")
        self.doc.insert_children([soft_node2])
        tr_node2 = SVR4Spec()
        soft_node2.insert_children([tr_node2])
        self.doc.insert_children([soft_node2])

        self.assertRaises(Exception, TransferSVR4, "SVR4Transfer")
Ejemplo n.º 5
0
 def setUp(self):
     InstallEngine._instance = None
     InstallEngine()
     self.engine = InstallEngine.get_instance()
     self.doc = self.engine.data_object_cache.volatile
     self.soft_node = Software("SVR4Transfer", "SVR4")
     self.tr_node = SVR4Spec()
     self.soft_node.insert_children([self.tr_node])
     self.doc.insert_children([self.soft_node])
     self.tr_svr4 = TransferSVR4("SVR4Transfer")
     self.make_dummy_pkg(self.TEST_SRC_DIR + "/SUNWpkg1")
     self.make_dummy_pkg(self.TEST_SRC_DIR + "/SUNWpkg2")
     self.make_dummy_pkg(self.TEST_SRC_DIR + "/SUNWpkg3")
     if not os.path.isdir(AbstractSVR4.ADMIN_FILE_DIR):
         os.makedirs(AbstractSVR4.ADMIN_FILE_DIR, 0755)
Ejemplo n.º 6
0
    def test_info(self):
        '''Test that all the arguments get into the node correctly'''
        soft_node = Software("SVR4 transfer test 1")
        svr4_node = SVR4Spec()

        dst = Destination()
        path = Dir("/a")
        dst.insert_children([path])

        src = Source()
        path = Dir("/bin")
        src.insert_children([path])

        # first check src and dst
        soft_node.insert_children([dst, src, svr4_node])
        self.doc.insert_children([soft_node])
        soft_list = self.doc.get_children("SVR4 transfer test 1", Software)

        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                try:
                    args = tr.get_children("args", Args)[0]
                except:
                    self.assertTrue(True)
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(tr.action, None)
                self.assertEqual(tr.contents, None)

        # set cpio args
        args = Args({"svr4_args": "-n -d"})
        svr4_node.insert_children([args])

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["svr4_args"], "-n -d")
                self.assertEqual(tr.action, None)
                self.assertEqual(tr.contents, None)

        # set install package content
        svr4_node.action = "install"
        svr4_node.contents = ["SUNWcsr", "SUNWcsu"]

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["svr4_args"], "-n -d")
                self.assertEqual(tr.action, "install")
                self.assertEqual(tr.contents, ["SUNWcsr", "SUNWcsu"])

        # set uninstall package content
        svr4_node.action = "uninstall"
        svr4_node.contents = ["SUNWlxml", "SUNWzfs"]

        # Check that we can read the attributes out correctly
        for soft in soft_list:
            src_list = soft.get_children("source", Source)
            self.assertEqual(len(src_list), 1)

            src_path = src_list[0].get_children("dir", Dir)
            self.assertEqual(len(src_path), 1)
            src = src_path[0].dir_path

            dst_list = soft.get_children("destination", Destination)
            self.assertEqual(len(dst_list), 1)

            dst_path = dst_list[0].get_children("dir", Dir)
            self.assertEqual(len(dst_path), 1)
            dst = dst_path[0].dir_path

            tr_list = soft.get_children("transfer", SVR4Spec)
            for tr in tr_list:
                args = tr.get_children("args", Args)[0]
                self.assertEqual(dst, "/a")
                self.assertEqual(src, "/bin")
                self.assertEqual(args.arg_dict["svr4_args"], "-n -d")
                self.assertEqual(tr.action, "uninstall")
                self.assertEqual(tr.contents, ["SUNWlxml", "SUNWzfs"])