def test_get_state(self): fake_ctx = self.generate_node_context() with mock.patch('server_plugin.server.ctx', fake_ctx): with mock.patch('vcloud_plugin_common.ctx', fake_ctx): # connected network_name fake_client = self.generate_client([{ 'is_connected': True, 'network_name': 'network_name', 'ip': '1.1.1.1' }]) self.assertFalse(server._get_state(fake_client)) # not connected network_name fake_client = self.generate_client([{ 'is_connected': False, 'network_name': 'network_name', 'ip': '1.1.1.1' }]) self.assertTrue(server._get_state(fake_client)) # not ip in connected network_name fake_client = self.generate_client([{ 'is_connected': True, 'network_name': 'network_name', 'ip': None }]) self.assertFalse(server._get_state(fake_client)) # with managment_network fake_client = self.generate_client([{ 'is_connected': True, 'network_name': '_management_network', 'ip': '1.1.1.1' }]) self.assertTrue(server._get_state(fake_client))
def test_get_state(self): num_tries = 5 verified = False server.create() self._run_with_retry(server.start, self.ctx) for _ in range(num_tries): result = server._get_state(self.vca_client) if result is True: self.assertTrue('ip' in self.ctx.instance.runtime_properties) self.assertTrue('networks' in self.ctx.instance.runtime_properties) self.assertEqual(1, len(self.ctx.instance. runtime_properties['networks'].keys())) self.assertEqual(self.network_name, self.ctx.instance. runtime_properties['networks'].keys()[0]) ip_valid = True try: socket.inet_aton( self.ctx.instance.runtime_properties['ip']) except socket.error: ip_valid = False self.assertTrue(ip_valid) verified = True break time.sleep(2) self.assertTrue(verified)
def test_get_state(self): num_tries = 5 verified = False server.create() self._run_with_retry(server.start, self.ctx) for _ in range(num_tries): result = server._get_state(self.vca_client) if result is True: self.assertTrue('ip' in self.ctx.instance.runtime_properties) self.assertTrue( 'networks' in self.ctx.instance.runtime_properties) self.assertEqual( 1, len(self.ctx.instance.runtime_properties['networks'].keys( ))) self.assertEqual( self.network_name, self.ctx.instance.runtime_properties['networks'].keys()[0]) ip_valid = True try: socket.inet_aton( self.ctx.instance.runtime_properties['ip']) except socket.error: ip_valid = False self.assertTrue(ip_valid) verified = True break time.sleep(2) self.assertTrue(verified)
def _wait_for_server_configured(self): with contextlib.nested( mock.patch('server_plugin.server.ctx', self.server_ctx), mock.patch('vcloud_plugin_common.ctx', self.server_ctx)): num_tries = 10 verified = False for _ in range(num_tries): result = server._get_state(self.vca_client) if result is True: verified = True break time.sleep(10) self.assertTrue(verified, "Server configuration wasn't verified")