class ForestInheritance(TestCase):
    def setUp(self):
        self.dummy_vm   = DummyVm(boxname='test_1_vm',vms=[], force_new_builders = True)
        self.dummy_1    = Dummy(directory='test_1',vms=[self.dummy_vm])
        self.dummy_2    = Dummy(directory='test_2',vms=[self.dummy_vm])
        

    def test_compile_base(self):
        self.assertEquals("test_1@name", self.dummy_1.name)
        self.assertEquals(False, self.dummy_1.is_vm)
        self.assertEquals(True, self.dummy_1.run_on_vm)
        self.assertEquals("test_2@name", self.dummy_2.name)
        self.assertEquals(False, self.dummy_2.is_vm)
        self.assertEquals(True, self.dummy_2.run_on_vm)
        self.assertEquals("test_1_vm", self.dummy_vm.name)
        self.assertEquals(True, self.dummy_vm.is_vm)

    def test_commands_base(self):
        self.assertRaises(MyCommandError, self.dummy_vm.commands.simple)
        
    def test_start_base(self):
        self.builders = self.dummy_1.start()
        self.assertRaises(MyFactoryError, self.dummy_2.start)
        self.assertEquals(set([self.dummy_1, self.dummy_2]), self.builders.roots())
        self.assertEquals(2, len(self.builders.roots()))
        self.assertEquals(['dummyvm','ssh',' bash -c "source test_1/dummy ; onetest"'],
                          self.dummy_1.commands.simple(['onetest']))
        self.assertEquals(['dummyvm','ssh',' bash -c "source test_2/dummy ; twotest"'],
                          self.dummy_2.commands.simple(['twotest']))
        self.assertItemsEqual(
            ['test_2@name@test_1_vm',       'test_1@name@test_1_vm',
             'test_2@name@test_1_vm_quick', 'test_1@name@test_1_vm_quick', ],
            self.builders.get_builders_name())
        self.assertEquals({'nbr_of_elements': 8, 'nbr_of_steps': 12, 'nbr_of_chains': 4},
                          self.dummy_1.stats)
class SimpleInheritance(TestCase):
    def setUp(self):
        self.dummy_vm  = DummyVm(boxname='test_s_vm',vms=[], force_new_builders = True)
        self.dummy    = Dummy(directory='test_s',vms=[self.dummy_vm])
        
    def test_compile_base(self):
        self.assertEquals("test_s@name", self.dummy.name)
        self.assertEquals(False, self.dummy.is_vm)
        self.assertEquals("test_s_vm", self.dummy_vm.name)
        self.assertEquals(True, self.dummy_vm.is_vm)
        self.assertEquals(True, self.dummy.run_on_vm)

    def test_commands_base(self):
        self.assertRaises(MyCommandError, self.dummy.commands.simple)
        
    def test_start_base(self):
        self.builders = self.dummy.start()
        self.assertEquals(set([self.dummy]), self.builders.roots())
        self.assertEquals(1, len(self.builders.roots()))
        self.assertEquals(True, self.dummy.commands.run_on_vm)
#        self.assertEquals('toto', self.dummy.commands.vm.command_prefix(['tutu']))
        self.assertEquals(['dummyvm','ssh',' bash -c "source test_s/dummy ; onetest"'],
                          self.dummy.commands.simple(['onetest']))
        self.assertEquals(['test_s@name@test_s_vm', 'test_s@name@test_s_vm_quick'],
                          self.builders.get_builders_name())
        self.assertEquals({'nbr_of_elements': 4, 'nbr_of_steps': 6, 'nbr_of_chains': 2},
                          self.dummy.stats)

    def test_check_steps(self):
        self.builders = self.dummy.start()
        all_steps_expected = {'test_s@name@test_s_vm': 
                              [['bash',
                                '-c',
                                ' bash -c "exit 0  && echo TRUE" || echo FALSE'],
                               ['test1_vm', 'snap', 'take'],
                               ['dummyvm',
                                'ssh',
                                ' bash -c "sudo dummy completeinstall"'],
                               ['test1_vm', 'snap', 'go'],
                               ['test1_vm', 'snap', 'take']],
                              'test_s@name@test_s_vm_quick': [['test1_vm', 'snap', 'go']]}
        self.assertEquals(all_steps_expected, self.dummy.builderfactory.get_all_steps_command())
class ForestInheritance(TestCase):
    def setUp(self):
        self.dummy_vm_1   = DummyVm(boxname='test_1_vm_mh',vms=[], force_new_builders = True)
        self.dummy_vm_2   = DummyVm(boxname='test_2_vm_mh',vms=[])
        self.dummy_1    = Dummy(directory='test_mh',vms=[self.dummy_vm_1, self.dummy_vm_2])

    def test_start_base(self):
        self.builders = self.dummy_1.start()
        self.assertEquals(set([self.dummy_1]), self.builders.roots())
        self.assertEquals(1, len(self.builders.roots()))
        self.assertItemsEqual(['test_mh@name@test_2_vm_mh',
                           'test_mh@name@test_1_vm_mh',
                           'test_mh@name@test_2_vm_mh_quick',
                           'test_mh@name@test_1_vm_mh_quick'],
                          self.builders.get_builders_name())
        self.assertEquals({'nbr_of_elements': 8, 'nbr_of_steps': 7, 'nbr_of_chains': 4},
                          self.dummy_1.stats)
예제 #4
0
class BaseTest(TestCase):
    def setUp(self):
        self.factory = []
        self.dummy = Dummy(directory="test", vms=[], force_new_builders=True)

    def test_compile_base(self):
        self.assertEquals("test@name", self.dummy.name)
        self.assertEquals(False, self.dummy.is_vm)

    def test_commands_base(self):
        self.assertRaises(MyCommandError, self.dummy.commands.simple)

    def test_start_base(self):
        self.builders = self.dummy.start()
        self.assertEquals(set([self.dummy]), self.builders.roots())
        self.assertEquals(1, len(self.builders.roots()))
        self.assertEquals(["bash", "-c", "source test/dummy ; onetest"], self.dummy.commands.simple(["onetest"]))
        self.assertItemsEqual(["test@name", "test@name_quick"], self.builders.get_builders_name())
        self.assertEquals({"nbr_of_elements": 2, "nbr_of_steps": 1, "nbr_of_chains": 2}, self.dummy.stats)
 def setUp(self):
     self.dummy_vm  = DummyVm(boxname='test_s_vm',vms=[], force_new_builders = True)
     self.dummy    = Dummy(directory='test_s',vms=[self.dummy_vm])
 def setUp(self):
     self.dummy_vm_1   = DummyVm(boxname='test_1_vm_mh',vms=[], force_new_builders = True)
     self.dummy_vm_2   = DummyVm(boxname='test_2_vm_mh',vms=[])
     self.dummy_1    = Dummy(directory='test_mh',vms=[self.dummy_vm_1, self.dummy_vm_2])
예제 #7
0
 def setUp(self):
     self.factory = []
     self.dummy = Dummy(directory="test", vms=[], force_new_builders=True)