Ejemplo n.º 1
0
    def test_pickleing(self):
        """
        Test pickling for example save vm env.
        """
        m = factory(AA, system_version=0, qemu_version=0)()
        mm = factory(BB, qemu_version=3)()

        f = open("/tmp/pick", "w+")
        cPickle.dump(m, f, cPickle.HIGHEST_PROTOCOL)
        cPickle.dump(mm, f, cPickle.HIGHEST_PROTOCOL)
        f.close()

        # Delete classes for ensure that pickel works correctly.
        name = m.__class__.__name__
        del m
        del globals()[name]

        name = mm.__class__.__name__
        del mm
        del globals()[name]

        f = open("/tmp/pick", "r+")
        c = cPickle.load(f)
        cc = cPickle.load(f)
        f.close()
Ejemplo n.º 2
0
    def test_pickleing(self):
        """
        Test pickling for example save vm env.
        """
        m = factory(AA, system_version=0, qemu_version=0)()
        mm = factory(BB, qemu_version=3)()

        f = open("/tmp/pick", "w+")
        cPickle.dump(m, f, cPickle.HIGHEST_PROTOCOL)
        cPickle.dump(mm, f, cPickle.HIGHEST_PROTOCOL)
        f.close()

        # Delete classes for ensure that pickel works correctly.
        name = m.__class__.__name__
        del m
        del globals()[name]

        name = mm.__class__.__name__
        del mm
        del globals()[name]

        f = open("/tmp/pick", "r+")
        c = cPickle.load(f)
        cc = cPickle.load(f)
        f.close()
Ejemplo n.º 3
0
    def test_complicated_multiple_create_params(self):
        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM1.func3.expect_call()

        mm = factory(AA, qemu_version=0, system_version=2, q_version=0)()
        # check class name.
        self.assertEqual(str(mm), "managed_AA_Sys1_Q_VM_System1")
        mm.func3()   # call VM1.func1(m) -> VM.func1

        self.god.check_playback()
Ejemplo n.º 4
0
    def test_complicated_versioning(self):
        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM1.func3.expect_call()

        mm = factory(AA)()
        # check class name.
        self.assertEqual(str(mm), "managed_AA_Sys1_Q1_VM1_System1")
        mm.func3()   # call VM1.func1(m) -> VM.func1

        self.god.check_playback()
    def test_sharing_data_in_same_version(self):
        mm = factory(BB)()
        bb = factory(BB)()
        cc = factory(BB, qemu_version=0)()

        # Get corespond class in versionable class
        man[bb.__class__, VM].test_class_vm1 = 1
        man[bb.__class__, BB].test_class_bb = 2
        man[cc.__class__, BB].test_class_bb = 3
        # check class name.
        self.assertEqual(bb.__class__.test_class_vm1,
                         mm.__class__.test_class_vm1)
        self.assertEqual(bb.__class__.test_class_bb,
                         mm.__class__.test_class_bb)

        # In class hierarchy is class which don't have to be versioned
        # because that first value should be equal and second one shouldn't.
        self.assertEqual(bb.__class__.test_class_vm1,
                         cc.__class__.test_class_vm1)
        self.assertNotEqual(bb.__class__.test_class_bb,
                            cc.__class__.test_class_bb)
Ejemplo n.º 6
0
    def test_complicated_multiple_create_params(self):
        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM1.func3.expect_call()

        mm = factory(AA, qemu_version=0, system_version=2, q_version=0)()
        # check class name.
        self.assertEqual(str(mm), "managed_AA_Sys1_Q_VM_System1")
        mm.func3()  # call VM1.func1(m) -> VM.func1

        self.god.check_playback()
Ejemplo n.º 7
0
    def test_complicated_versioning(self):
        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM1.func3.expect_call()

        mm = factory(AA)()
        # check class name.
        self.assertEqual(str(mm), "managed_AA_Sys1_Q1_VM1_System1")
        mm.func3()  # call VM1.func1(m) -> VM.func1

        self.god.check_playback()
Ejemplo n.º 8
0
    def test_sharing_data_in_same_version(self):
        mm = factory(BB)()
        bb = factory(BB)()
        cc = factory(BB, qemu_version=0)()

        # Get corespond class in versionable class
        man[bb.__class__, VM].test_class_vm1 = 1
        man[bb.__class__, BB].test_class_bb = 2
        man[cc.__class__, BB].test_class_bb = 3
        # check class name.
        self.assertEqual(bb.__class__.test_class_vm1,
                         mm.__class__.test_class_vm1)
        self.assertEqual(bb.__class__.test_class_bb,
                         mm.__class__.test_class_bb)

        # In class hierarchy is class which don't have to be versioned
        # because that first value should be equal and second one shouldn't.
        self.assertEqual(bb.__class__.test_class_vm1,
                         cc.__class__.test_class_vm1)
        self.assertNotEqual(bb.__class__.test_class_bb,
                            cc.__class__.test_class_bb)
Ejemplo n.º 9
0
 def init_system(self):
     """
     Create new dbfile without any configuration.
     """
     sm = factory(ServiceManager)()
     try:
         if utils.load_module("openvswitch"):
             sm.restart("openvswitch")
     except error.CmdError:
         logging.error("Service OpenVSwitch is probably not"
                       " installed in system.")
         raise
     self.pid_files_path = "/var/run/openvswitch/"
Ejemplo n.º 10
0
    def test_simple_create_by_params_v1(self):
        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM1.func3.expect_call()

        mm = factory(BB, qemu_version=2)()
        # check class name.
        self.assertEqual(str(mm), "managed_BB_VM1")
        mm.func3()   # call VM1.func1(m) -> VM.func1
        self.assertEqual(mm.VM1_cls, "VM1")

        self.god.check_playback()
Ejemplo n.º 11
0
    def test_simple_create_by_params_v1(self):
        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM1.func3.expect_call()

        mm = factory(BB, qemu_version=2)()
        # check class name.
        self.assertEqual(str(mm), "managed_BB_VM1")
        mm.func3()  # call VM1.func1(m) -> VM.func1
        self.assertEqual(mm.VM1_cls, "VM1")

        self.god.check_playback()
Ejemplo n.º 12
0
    def test_simple_versioning(self):
        self.god.stub_function(VM, "func1")
        self.god.stub_function(VM1, "func2")

        VM1.func2.expect_call()
        VM.func1.expect_call()

        mm = factory(BB)()
        # check class name.
        self.assertEqual(str(mm), "managed_BB_VM1")
        mm.func2()   # call BB.func2(m) -> VM1.func2
        mm.func1()   # call VM1.func1(m) -> VM.func1

        self.god.check_playback()
Ejemplo n.º 13
0
    def test_simple_versioning(self):
        self.god.stub_function(VM, "func1")
        self.god.stub_function(VM1, "func2")

        VM1.func2.expect_call()
        VM.func1.expect_call()

        mm = factory(BB)()
        # check class name.
        self.assertEqual(str(mm), "managed_BB_VM1")
        mm.func2()  # call BB.func2(m) -> VM1.func2
        mm.func1()  # call VM1.func1(m) -> VM.func1

        self.god.check_playback()
Ejemplo n.º 14
0
    def test_simple_create_by_params_v0(self):
        def wrap(mm):
            mm.VM1_cls

        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM.func3.expect_call()

        mm = factory(BB, qemu_version=0)()
        # check class name.
        self.assertEqual(str(mm), "managed_BB_VM")
        mm.func3()   # call VM1.func1(m) -> VM.func1
        self.assertRaises(AttributeError, wrap, mm)

        self.god.check_playback()
Ejemplo n.º 15
0
    def test_simple_create_by_params_v0(self):
        def wrap(mm):
            mm.VM1_cls

        self.god.stub_function(VM, "func3")
        self.god.stub_function(VM1, "func3")

        VM.func3.expect_call()

        mm = factory(BB, qemu_version=0)()
        # check class name.
        self.assertEqual(str(mm), "managed_BB_VM")
        mm.func3()  # call VM1.func1(m) -> VM.func1
        self.assertRaises(AttributeError, wrap, mm)

        self.god.check_playback()