tempest-api: Skip test if deployment has not enough agents

Neutron deployments can have various number of agents. For agentless
deployments there is no point in running agent API tests so that should
be reflected in tempest.conf available extension.

One of the tests require at least two agents - this patch skips such
test if environment doesn't contain enough agents for running the test.

Change-Id: I0f006258aa89c1f52fac73669352d725b109696c
Closes-bug: #1699199
This commit is contained in:
Jakub Libosvar 2017-06-22 12:15:12 +00:00
parent 3b93fad8d6
commit 4548ffd6b3
1 changed files with 11 additions and 6 deletions

View File

@ -28,7 +28,6 @@ class AgentManagementTestJSON(base.BaseAdminNetworkTest):
body = cls.admin_client.list_agents()
agents = body['agents']
cls.agent = agents[0] # don't modify this agent
cls.dyn_agent = agents[1]
@decorators.idempotent_id('9c80f04d-11f3-44a4-8738-ed2f879b0ff4')
def test_list_agent(self):
@ -66,20 +65,26 @@ class AgentManagementTestJSON(base.BaseAdminNetworkTest):
@decorators.idempotent_id('68a94a14-1243-46e6-83bf-157627e31556')
def test_update_agent_description(self):
agents = self.admin_client.list_agents()['agents']
try:
dyn_agent = agents[1]
except IndexError:
raise self.skipException("This test requires at least two agents.")
self.useFixture(tempest_fixtures.LockFixture('agent_description'))
description = 'description for update agent.'
agent_description = {'description': description}
body = self.admin_client.update_agent(agent_id=self.dyn_agent['id'],
body = self.admin_client.update_agent(agent_id=dyn_agent['id'],
agent_info=agent_description)
self.addCleanup(self._restore_agent)
self.addCleanup(self._restore_agent, dyn_agent)
updated_description = body['agent']['description']
self.assertEqual(updated_description, description)
def _restore_agent(self):
def _restore_agent(self, dyn_agent):
"""
Restore the agent description after update test.
"""
description = self.dyn_agent['description']
description = dyn_agent['description']
origin_agent = {'description': description}
self.admin_client.update_agent(agent_id=self.dyn_agent['id'],
self.admin_client.update_agent(agent_id=dyn_agent['id'],
agent_info=origin_agent)