Add amphora failover API test

This patch adds the amphora failover API test.

This patch also improves the load balancer failover API test to validate
that the amphora IDs have changed. This was a TODO in the code waiting
for the amphora show service client to be completed.

Change-Id: Ibffeb959d88b36be26355ff1b6a96dde8cfcd8c8
Story: 2004852
Task: 29077
This commit is contained in:
Michael Johnson 2019-01-28 12:16:06 -08:00
parent ab3e86198a
commit 9e7cad2054
2 changed files with 51 additions and 2 deletions

View File

@ -87,3 +87,41 @@ class AmphoraAPITest(test_base.LoadBalancerBaseTest):
amp = self.lb_admin_amphora_client.show_amphora(amphora_1[const.ID])
self.assertEqual(const.STATUS_ALLOCATED, amp[const.STATUS])
@decorators.idempotent_id('fb772680-b2ba-4fc3-989b-95ad8492ccaf')
def test_amphora_failover(self):
"""Tests the amphora failover API.
* Validates that non-admin accounts cannot failover amphora
* Fails over an amphora
* Validates that a new amphora is built
"""
amphorae = self.lb_admin_amphora_client.list_amphorae(
query_params='{loadbalancer_id}={lb_id}'.format(
loadbalancer_id=const.LOADBALANCER_ID, lb_id=self.lb_id))
amphora_1 = amphorae[0]
# Test RBAC not authorized for non-admin role
if not CONF.load_balancer.RBAC_test_type == const.NONE:
self.assertRaises(exceptions.Forbidden,
self.os_primary.amphora_client.amphora_failover,
amphora_1[const.ID])
self.assertRaises(
exceptions.Forbidden,
self.os_roles_lb_member.amphora_client.amphora_failover,
amphora_1[const.ID])
self.lb_admin_amphora_client.amphora_failover(amphora_1[const.ID])
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer,
self.lb_id, const.PROVISIONING_STATUS,
const.ACTIVE,
CONF.load_balancer.lb_build_interval,
CONF.load_balancer.lb_build_timeout)
after_amphorae = self.lb_admin_amphora_client.list_amphorae(
query_params='{loadbalancer_id}={lb_id}'.format(
loadbalancer_id=const.LOADBALANCER_ID, lb_id=self.lb_id))
for new_amp in after_amphorae:
self.assertNotEqual(amphora_1[const.ID], new_amp[const.ID])

View File

@ -818,6 +818,10 @@ class LoadBalancerAPITest(test_base.LoadBalancerBaseTest):
lb = self.mem_lb_client.show_loadbalancer(lb[const.ID])
self.assertEqual(const.ACTIVE, lb[const.PROVISIONING_STATUS])
before_amphorae = self.lb_admin_amphora_client.list_amphorae(
query_params='{loadbalancer_id}={lb_id}'.format(
loadbalancer_id=const.LOADBALANCER_ID, lb_id=lb[const.ID]))
self.os_roles_lb_admin.loadbalancer_client.failover_loadbalancer(
lb[const.ID])
@ -826,8 +830,15 @@ class LoadBalancerAPITest(test_base.LoadBalancerBaseTest):
const.ACTIVE,
CONF.load_balancer.lb_build_interval,
CONF.load_balancer.lb_build_timeout)
# TODO(johnsom) Assert the amphora ID has changed when amp client
# is available.
after_amphorae = self.lb_admin_amphora_client.list_amphorae(
query_params='{loadbalancer_id}={lb_id}'.format(
loadbalancer_id=const.LOADBALANCER_ID, lb_id=lb[const.ID]))
# Make sure all of the amphora on the load balancer have failed over
for amphora in before_amphorae:
for new_amp in after_amphorae:
self.assertNotEqual(amphora[const.ID], new_amp[const.ID])
# Attempt to clean up so that one full test run doesn't start 10+
# amps before the cleanup phase fires