-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Neutron gateway actions #611
Merged
lourot
merged 12 commits into
openstack-charmers:master
from
mkalcok:neutron_gateway_actions
Sep 13, 2021
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
988efd6
Tests for new "status" actions in neutron-gateway
mkalcok 5f0c43d
Skip loadbalancer cleanup on releases that don't support them
mkalcok 6fb2f3c
Merge remote-tracking branch 'upstream/master' into neutron_gateway_a…
mkalcok 74959de
fix linting errors
mkalcok cbc9c84
Move common functionality into helper method
mkalcok 837bfad
Skip LBaas tests on releases below mitaka.
mkalcok 12afecc
move loadbalancer cleanup logic to specific test.
mkalcok a5e5d9e
add more info to output of juju action fails
mkalcok 15ed2ab
Flip test logic for better readability & remove unnecessary `except` …
mkalcok b6f6db3
Fix after change of get-status-* actions output
mkalcok 00742d5
remove unused import
mkalcok 728c9fc
Rename actions from "get-status-*" to "show-*"
mkalcok File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,18 +274,9 @@ def setUpClass(cls, application_name='neutron-gateway', model_alias=None): | |
current_release = openstack_utils.get_os_release() | ||
bionic_train = openstack_utils.get_os_release('bionic_train') | ||
xenial_mitaka = openstack_utils.get_os_release('xenial_mitaka') | ||
cls.SKIP_LBAAS_TESTS = (xenial_mitaka <= current_release or | ||
cls.SKIP_LBAAS_TESTS = (current_release <= xenial_mitaka or | ||
current_release >= bionic_train) | ||
|
||
def tearDown(self): | ||
"""Cleanup loadbalancers if there are any left over.""" | ||
super(NeutronGatewayStatusActionsTest, self).tearDown() | ||
if not self.SKIP_LBAAS_TESTS: | ||
load_balancers = self.neutron_client.list_loadbalancers().get( | ||
'loadbalancers', []) | ||
for lbaas in load_balancers: | ||
self.neutron_client.delete_loadbalancer(lbaas['id']) | ||
|
||
def _assert_result_match(self, action_result, resource_list, | ||
resource_name): | ||
"""Assert that action_result contains same data as resource_list.""" | ||
|
@@ -352,33 +343,45 @@ def test_get_status_load_balancers(self): | |
if self.SKIP_LBAAS_TESTS: | ||
self.skipTest('LBaasV2 is not supported in this version.') | ||
|
||
# create LBaasV2 for the purpose of this test | ||
lbaas_name = 'test_lbaas' | ||
|
||
subnet_list = self.neutron_client.list_subnets( | ||
name='private_subnet').get('subnets', []) | ||
|
||
if not subnet_list: | ||
raise RuntimeError('Expected subnet "private_subnet" is not ' | ||
'configured.') | ||
loadbalancer_id = None | ||
|
||
subnet = subnet_list[0] | ||
loadbalancer_data = {'loadbalancer': {'name': lbaas_name, | ||
'vip_subnet_id': subnet['id']}} | ||
self.neutron_client.create_loadbalancer(body=loadbalancer_data) | ||
|
||
# test that client and action report same data | ||
ngw_unit = zaza.model.get_units(self.application_name, | ||
model_name=self.model_name)[0] | ||
lbaas_from_client = self.neutron_client.list_loadbalancers().get( | ||
'loadbalancers', []) | ||
|
||
result = zaza.model.run_action(ngw_unit.entity_id, | ||
'get-status-lb', | ||
model_name=self.model_name, | ||
action_params={"format": "json"}) | ||
try: | ||
# create LBaasV2 for the purpose of this test | ||
lbaas_name = 'test_lbaas' | ||
subnet_list = self.neutron_client.list_subnets( | ||
name='private_subnet').get('subnets', []) | ||
|
||
if not subnet_list: | ||
raise RuntimeError('Expected subnet "private_subnet" is not ' | ||
'configured.') | ||
|
||
subnet = subnet_list[0] | ||
loadbalancer_data = {'loadbalancer': {'name': lbaas_name, | ||
'vip_subnet_id': subnet['id'] | ||
} | ||
} | ||
loadbalancer = self.neutron_client.create_loadbalancer( | ||
body=loadbalancer_data) | ||
loadbalancer_id = loadbalancer['loadbalancer']['id'] | ||
|
||
# test that client and action report same data | ||
ngw_unit = zaza.model.get_units(self.application_name, | ||
model_name=self.model_name)[0] | ||
lbaas_from_client = self.neutron_client.list_loadbalancers().get( | ||
'loadbalancers', []) | ||
|
||
self._assert_result_match(result, lbaas_from_client, 'load-balancers') | ||
result = zaza.model.run_action(ngw_unit.entity_id, | ||
'get-status-lb', | ||
model_name=self.model_name, | ||
action_params={"format": "json"}) | ||
|
||
self._assert_result_match(result, lbaas_from_client, | ||
'load-balancers') | ||
except Exception as exc: | ||
raise exc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't needed; the exception with happen if no exceptions are caught which is essentially the same thing. |
||
finally: | ||
if loadbalancer_id: | ||
self.neutron_client.delete_loadbalancer(loadbalancer_id) | ||
|
||
|
||
class NeutronCreateNetworkTest(test_utils.OpenStackBaseTest): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative option/syntax:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, that does look better.