Exemplo n.º 1
0
 def test_get_memory_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('cat', '/proc/meminfo', run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._get_memory)
Exemplo n.º 2
0
 def test_make_directory_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'mkdir', '-p', '/tmp/foo').AndReturn(
         ('',''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._make_directory('/tmp/foo')
Exemplo n.º 3
0
 def test_attach_volumes_success(self):
     conn = openvz_conn.OpenVzConnection(False)
     self.mox.StubOutWithMock(conn, '_container_script_modify')
     conn._container_script_modify(test_instance, None, mox.IgnoreArg(),
                                   mox.IgnoreArg(), 'add')
     self.mox.ReplayAll()
     conn._attach_volumes(test_instance)
Exemplo n.º 4
0
 def test_set_perms_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'chmod', 755, '/tmp/foo').AndRaise(
         exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._set_perms('/tmp/foo', 755))
Exemplo n.º 5
0
 def test_make_directory_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'mkdir', '-p', '/tmp/foo').AndRaise(
         exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._make_directory, '/tmp/foo')
Exemplo n.º 6
0
 def before_tests(self):
     """Sets up the reboot tests."""
     self.init('VERIFY_REBOOT_VZ_')
     print("instance info local_id %s" % instance_info.local_id)
     self.local_id = instance_info.local_id
     self.name = "instance-00000001"
     self.conn = openvz_conn.OpenVzConnection(False)
Exemplo n.º 7
0
 def test_get_cpuunits_usage_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzcpucheck', '-v', run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._get_cpuunits_usage)
Exemplo n.º 8
0
 def test_attach_volumes_success(self):
     conn = openvz_conn.OpenVzConnection(False)
     self.mox.StubOutWithMock(conn, 'attach_volume')
     conn.attach_volume(INSTANCE['name'], None,
                                   mox.IgnoreArg())
     self.mox.ReplayAll()
     conn._attach_volumes(INSTANCE)
Exemplo n.º 9
0
 def test_write_to_file_failure(self):
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'w').AndRaise(Exception)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._write_to_file,
                       '/tmp/foo', file_contents)
Exemplo n.º 10
0
 def test_write_to_file_success(self):
     filehandle = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'w').AndReturn(filehandle)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._write_to_file('/tmp/foo', file_contents)
Exemplo n.º 11
0
 def test_get_cpuunits_usage_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzcpucheck', '-v', run_as_root=True)\
                               .AndReturn((CPUCHECKCONT, ''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._get_cpuunits_usage()
Exemplo n.º 12
0
 def test_set_diskspace_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'vzctl', 'set', test_instance['id'],
                               '--save', '--diskspace',
                               mox.IgnoreArg()).AndReturn(('',None))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._set_diskspace(test_instance)
Exemplo n.º 13
0
 def test_get_cpuunits_capability_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo',
                               'vzcpucheck').AndRaise(
         exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error,conn._get_cpuunits_capability)
Exemplo n.º 14
0
 def test_get_cpuunits_capability_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo',
                               'vzcpucheck').AndReturn(
             (vzcpucheck_return_nocontainers,''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._get_cpuunits_capability()
Exemplo n.º 15
0
 def test_set_diskspace_soft_and_hard_manual_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'],
                               '--save', '--diskspace', '40G:50G',
                               run_as_root=True).AndReturn(('', None))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._set_diskspace(INSTANCE, 40, 50)
Exemplo n.º 16
0
 def test_set_diskspace_soft_and_hard_manual_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'vzctl', 'set', test_instance['id'],
                               '--save', '--diskspace',
                               '40G:50G').AndReturn(('',None))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._set_diskspace(test_instance, (40,50))
Exemplo n.º 17
0
 def test_set_cpus_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'], '--save',
                               '--cpus', mox.IgnoreArg(), run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._set_cpus, INSTANCE)
Exemplo n.º 18
0
 def test_stop_failure_on_exec(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'stop', INSTANCE['id'],
                               run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._stop, INSTANCE)
Exemplo n.º 19
0
 def test_configure_vz_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'], '--save',
                               '--applyconfig', 'basic', run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._configure_vz, INSTANCE)
Exemplo n.º 20
0
 def test_configure_vz_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'], '--save',
                               '--applyconfig', 'basic', run_as_root=True)\
                               .AndReturn(('', ''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._configure_vz(INSTANCE)
Exemplo n.º 21
0
 def test_set_diskspace_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'], '--save',
                               '--diskspace', mox.IgnoreArg(),
                               run_as_root=True).AndReturn(('', None))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._set_diskspace(INSTANCE)
Exemplo n.º 22
0
 def test_set_vz_os_hint_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'], '--save',
                               '--ostemplate', 'ubuntu', run_as_root=True)\
                               .AndReturn(('', ''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._set_vz_os_hint(INSTANCE)
Exemplo n.º 23
0
 def test_create_vz_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'create', INSTANCE['id'],
                               '--ostemplate', INSTANCE['image_ref'],
                               run_as_root=True).AndReturn(('', ''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._create_vz(INSTANCE)
Exemplo n.º 24
0
 def test_set_perms_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'chmod', 755, '/tmp/foo').AndReturn(
         ('','')
     )
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._set_perms('/tmp/foo', 755)
Exemplo n.º 25
0
 def test_read_file_success(self):
     file_contents = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'r').AndReturn(file_contents)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     resp = conn._read_file('/tmp/foo')
     self.assertTrue(isinstance(resp, list))
Exemplo n.º 26
0
 def test_gratuitous_arp_all_addresses(self):
     conn = openvz_conn.OpenVzConnection(False)
     self.mox.StubOutWithMock(conn, '_send_garp')
     conn._send_garp(INSTANCE['id'],
                     mox.IgnoreArg(),
                     mox.IgnoreArg(),
                     mox.IgnoreArg()).MultipleTimes()
     self.mox.ReplayAll()
     conn._gratuitous_arp_all_addresses(INSTANCE, NETWORKINFO)
Exemplo n.º 27
0
 def test_set_vz_os_hint_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'set', INSTANCE['id'],
                               '--save', '--ostemplate', 'ubuntu',
                               run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._set_vz_os_hint, INSTANCE)
Exemplo n.º 28
0
 def test_get_memory_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('cat', '/proc/meminfo', run_as_root=True)\
                               .AndReturn((MEMINFO, ''))
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._get_memory()
     self.assertEquals(int, type(conn.utility['MEMORY_MB']))
     self.assertTrue(conn.utility['MEMORY_MB'] > 0)
Exemplo n.º 29
0
 def test_create_vz_fail(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('vzctl', 'create', INSTANCE['id'],
                               '--ostemplate', INSTANCE['image_ref'],
                               run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._create_vz, INSTANCE)
Exemplo n.º 30
0
 def test_set_diskspace_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('sudo', 'vzctl', 'set', test_instance['id'],
                               '--save', '--diskspace',
                               mox.IgnoreArg()).AndRaise(
         exception.ProcessExecutionError)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._set_diskspace, test_instance)