def test_vm_livemigrate_persistent_API(self): patch_auth() inst = model.Model(libvirt_uri='qemu:///system', objstore_loc=self.tmp_store) host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') cherrypy_port = get_free_port('cherrypy_port') with RollbackContext() as rollback: test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=inst) rollback.prependDefer(test_server.stop) self.request = partial(request, host, ssl_port) self.create_vm_test() rollback.prependDefer(rollback_wrapper, self.inst.vm_delete, u'test_vm_migrate') # removing cdrom because it is not shared storage and will make # the migration fail dev_list = self.inst.vmstorages_get_list('test_vm_migrate') self.inst.vmstorage_delete('test_vm_migrate', dev_list[0]) try: self.inst.vm_start('test_vm_migrate') except Exception, e: self.fail('Failed to start the vm, reason: %s' % e.message) migrate_url = "/plugins/kimchi/vms/%s/migrate" % 'test_vm_migrate' req = json.dumps({ 'remote_host': KIMCHI_LIVE_MIGRATION_TEST, 'user': '******' }) resp = self.request(migrate_url, req, 'POST') self.assertEquals(202, resp.status) task = json.loads(resp.read()) wait_task(self._task_lookup, task['id']) task = json.loads( self.request('/plugins/kimchi/tasks/%s' % task['id'], '{}').read()) self.assertEquals('finished', task['status']) try: remote_conn = self.get_remote_conn() rollback.prependDefer(remote_conn.close) remote_vm = remote_conn.lookupByName('test_vm_migrate') self.assertTrue(remote_vm.isPersistent()) remote_vm.destroy() remote_vm.undefine() except Exception, e: self.fail('Migration test failed: %s' % e.message)
def setUpModule(): global test_server, model, host, port, ssl_port model = GingerModel() host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
def setUpModule(): global test_server, model, host, port, ssl_port patch_auth(sudo=False) model = mockmodel.MockModel('/tmp/obj-store-test') host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
def setUpModule(): global test_server, model, host, port, ssl_port patch_auth(sudo=False) model = mockmodel.MockModel("/tmp/obj-store-test") host = "127.0.0.1" port = get_free_port("http") ssl_port = get_free_port("https") test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
def test_vm_livemigrate_persistent_API(self): patch_auth() inst = model.Model(libvirt_uri='qemu:///system', objstore_loc=self.tmp_store) host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') cherrypy_port = get_free_port('cherrypy_port') with RollbackContext() as rollback: test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=inst) rollback.prependDefer(test_server.stop) self.request = partial(request, host, ssl_port) self.create_vm_test() rollback.prependDefer(rollback_wrapper, self.inst.vm_delete, u'test_vm_migrate') # removing cdrom because it is not shared storage and will make # the migration fail dev_list = self.inst.vmstorages_get_list('test_vm_migrate') self.inst.vmstorage_delete('test_vm_migrate', dev_list[0]) try: self.inst.vm_start('test_vm_migrate') except Exception, e: self.fail('Failed to start the vm, reason: %s' % e.message) migrate_url = "/plugins/kimchi/vms/%s/migrate" % 'test_vm_migrate' req = json.dumps({'remote_host': KIMCHI_LIVE_MIGRATION_TEST, 'user': '******'}) resp = self.request(migrate_url, req, 'POST') self.assertEquals(202, resp.status) task = json.loads(resp.read()) wait_task(self._task_lookup, task['id']) task = json.loads( self.request( '/plugins/kimchi/tasks/%s' % task['id'], '{}' ).read() ) self.assertEquals('finished', task['status']) try: remote_conn = self.get_remote_conn() rollback.prependDefer(remote_conn.close) remote_vm = remote_conn.lookupByName('test_vm_migrate') self.assertTrue(remote_vm.isPersistent()) remote_vm.destroy() remote_vm.undefine() except Exception, e: self.fail('Migration test failed: %s' % e.message)
def setUpModule(): global test_server, model, host, port, ssl_port, cherrypy_port patch_auth() model = Model(None, "/tmp/obj-store-test") host = "127.0.0.1" port = get_free_port("http") ssl_port = get_free_port("https") cherrypy_port = get_free_port("cherrypy_port") test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=model)
def setUpModule(): global test_server, model, host, port, ssl_port, cherrypy_port patch_auth() model = MockModel('/tmp/obj-store-test') host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') cherrypy_port = get_free_port('cherrypy_port') test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=model)
def setUpModule(): global host, port, ssl_port, model, test_server, fake_iso cherrypy.request.headers = {'Accept': 'application/json'} model = mockmodel.MockModel('/tmp/obj-store-test') patch_auth() port = get_free_port('http') ssl_port = get_free_port('https') host = '127.0.0.1' test_server = run_server(host, port, ssl_port, test_mode=True, model=model) fake_iso = '/tmp/fake.iso' iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
def setUpModule(): global test_server, model, host, port, ssl_port, cherrypy_port patch_auth() model = MockModel('/tmp/obj-store-test') host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') cherrypy_port = get_free_port('cherrypy_port') test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=model) iso_gen.construct_fake_iso(MOCK_ISO, True, '14.04', 'ubuntu')
def setUpModule(): global host, port, ssl_port, model, test_server, fake_iso cherrypy.request.headers = {'Accept': 'application/json'} model = mockmodel.MockModel('/tmp/obj-store-test') patch_auth() port = get_free_port('http') ssl_port = get_free_port('https') host = '127.0.0.1' test_server = run_server(host, port, ssl_port, test_mode=True, model=model) fake_iso = '/tmp/fake.iso' open(fake_iso, 'w').close()
def setUpModule(): global test_server, model, host, ssl_port, tmpfile patch_auth() tmpfile = tempfile.mktemp() model = MockModel(tmpfile) host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') cherrypy_port = get_free_port('cherrypy_port') test_server = run_server(host, port, ssl_port, test_mode=True, cherrypy_port=cherrypy_port, model=model)
def setUpModule(): global test_server, model, host, port, ssl_port patch_auth(sudo=False) model = mockmodel.MockModel('/tmp/obj-store-test') host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') test_server = run_server(host, port, ssl_port, test_mode=True, model=model) # Create fake ISO to do the tests construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
def setUpClass(cls): super(TestLdap, cls).setUpClass() logging.getLogger('ldap_test').setLevel(logging.ERROR) cls.mock_server_port = utils.get_free_port() cls.ldap_server = MockLdapServer() cls.ldap_server.start()
def setUpClass(cls): super(TestGithub, cls).setUpClass() # Configure mock server. cls.mock_server_port = utils.get_free_port() cls.mock_server = HTTPServer(('localhost', cls.mock_server_port), MockGithubRequestHandler) # Start running mock server in a separate thread. # Daemon threads automatically shut down when the main process exits. cls.mock_server_thread = Thread(target=cls.mock_server.serve_forever) cls.mock_server_thread.setDaemon(True) cls.mock_server_thread.start()
def __init__(self): self.server_port = get_free_port() self.ldap_server = LdapServer({ 'port': self.server_port, 'bind_dn': self.ldap_bind_dn, 'password': self.ldap_bind_password, 'base': { 'objectclass': ['domain'], 'dn': self.ldap_base_dn, 'attributes': {'dc': self.ldap_base_dc} }, 'entries': self.ldap_entries, })
def __init__(self): self.server_port = get_free_port() self.ldap_server = LdapServer({ 'port': self.server_port, 'bind_dn': self.ldap_bind_dn, 'password': self.ldap_bind_password, 'base': { 'objectclass': ['domain'], 'dn': self.ldap_base_dn, 'attributes': { 'dc': self.ldap_base_dc } }, 'entries': self.ldap_entries, })
def setUpClass(cls): # The mock LDAP server requires Java runtime if not distutils.spawn.find_executable('java'): raise SkipTest('The mock LDAP server requires Java runtime') try: super(TestLdap, cls).setUpClass() logging.getLogger('ldap_test').setLevel(logging.ERROR) cls.mock_server_port = utils.get_free_port() cls.ldap_server = MockLdapServer() cls.ldap_server.start() except Exception: # Ensure that Vault server is taken down if setUpClass fails super(TestLdap, cls).tearDownClass() raise
def setUpClass(cls): super(TestLdap, cls).setUpClass() logging.getLogger('ldap_test').setLevel(logging.ERROR) cls.mock_server_port = utils.get_free_port() cls.mock_ldap_url = 'ldap://localhost:{port}'.format(port=cls.mock_server_port) cls.ldap_server = LdapServer({ 'port': cls.mock_server_port, 'bind_dn': LDAP_BIND_DN, 'password': LDAP_BIND_PASSWORD, 'base': { 'objectclass': ['domain'], 'dn': LDAP_BASE_DN, 'attributes': {'dc': LDAP_BASE_DC} }, 'entries': LDAP_ENTRIES, }) cls.ldap_server.start()
def setUpClass(cls): try: super(TestGithub, cls).setUpClass() # Configure mock server. cls.mock_server_port = utils.get_free_port() cls.mock_server = HTTPServer(('localhost', cls.mock_server_port), MockGithubRequestHandler) # Start running mock server in a separate thread. # Daemon threads automatically shut down when the main process exits. cls.mock_server_thread = Thread( target=cls.mock_server.serve_forever) cls.mock_server_thread.setDaemon(True) cls.mock_server_thread.start() except Exception: # Ensure that Vault server is taken down if setUpClass fails super(TestGithub, cls).tearDownClass() raise
def __init__(self, app_config=None, address='localhost', port='80'): Thread.__init__(self) self.address = address self.server_port = get_free_port() if app_config is None: app_config = { 'SECRET_KEY': 'secret', 'SQLALCHEMY_DATABASE_URI': 'sqlite:///:memory:', 'SQLALCHEMY_TRACK_MODIFICATIONS': False, } app_config.update({ 'OAUTH2_JWT_ISS': 'http://{address}:{port}/oauth'.format(address=self.address, port=self.server_port), }) app = create_app(app_config) self.srv = make_server('127.0.0.1', self.server_port, app) self.ctx = app.app_context() self.ctx.push()