Add new Neutron API Tests
This commit is contained in:
105
zaza/openstack/charm_tests/neutron/tests.py
Normal file
105
zaza/openstack/charm_tests/neutron/tests.py
Normal file
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2018 Canonical Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Encapsulating `neutron-openvswitch` testing."""
|
||||
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
import zaza
|
||||
import zaza.openstack.charm_tests.test_utils as test_utils
|
||||
|
||||
|
||||
class NeutronApiTest(test_utils.OpenStackBaseTest):
|
||||
|
||||
def test_900_restart_on_config_change(self):
|
||||
"""Checking restart happens on config change.
|
||||
|
||||
Change disk format and assert then change propagates to the correct
|
||||
file and that services are restarted as a result
|
||||
"""
|
||||
# Expected default and alternate values
|
||||
current_value = zaza.model.get_application_config(
|
||||
'neutron-api')['debug']['value']
|
||||
new_value = str(not bool(current_value)).title()
|
||||
current_value = str(current_value).title()
|
||||
|
||||
set_default = {'debug': current_value}
|
||||
set_alternate = {'debug': new_value}
|
||||
default_entry = {'DEFAULT': {'debug': [current_value]}}
|
||||
alternate_entry = {'DEFAULT': {'debug': [new_value]}}
|
||||
|
||||
# Config file affected by juju set config change
|
||||
conf_file = '/etc/neutron/neutron.conf'
|
||||
|
||||
# Make config change, check for service restarts
|
||||
logging.info(
|
||||
'Setting verbose on neutron-api {}'.format(set_alternate))
|
||||
self.restart_on_changed(
|
||||
conf_file,
|
||||
set_default,
|
||||
set_alternate,
|
||||
default_entry,
|
||||
alternate_entry,
|
||||
['neutron-server'])
|
||||
|
||||
def test_901_pause_resume(self):
|
||||
"""Run pause and resume tests.
|
||||
|
||||
Pause service and check services are stopped then resume and check
|
||||
they are started
|
||||
"""
|
||||
with self.pause_resume(["neutron-server", "apache2", "haproxy"]):
|
||||
logging.info("Testing pause resume")
|
||||
|
||||
|
||||
class SecurityTest(test_utils.OpenStackBaseTest):
|
||||
"""Neutron APIsecurity tests tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Run class setup for running Neutron API SecurityTests."""
|
||||
super(SecurityTest, cls).setUpClass()
|
||||
|
||||
def test_security_checklist(self):
|
||||
"""Verify expected state with security-checklist."""
|
||||
# Changes fixing the below expected failures will be made following
|
||||
# this initial work to get validation in. There will be bugs targeted
|
||||
# to each one and resolved independently where possible.
|
||||
|
||||
expected_failures = [
|
||||
'validate-enables-tls',
|
||||
'validate-uses-tls-for-keystone',
|
||||
]
|
||||
expected_passes = [
|
||||
'validate-file-ownership',
|
||||
'validate-file-permissions',
|
||||
'validate-uses-keystone',
|
||||
]
|
||||
|
||||
for unit in zaza.model.get_units('neutron-api',
|
||||
model_name=self.model_name):
|
||||
logging.info('Running `security-checklist` action'
|
||||
' on unit {}'.format(unit.entity_id))
|
||||
test_utils.audit_assertions(
|
||||
zaza.model.run_action(
|
||||
unit.entity_id,
|
||||
'security-checklist',
|
||||
model_name=self.model_name,
|
||||
action_params={}),
|
||||
expected_passes,
|
||||
expected_failures,
|
||||
expected_to_pass=False)
|
||||
Reference in New Issue
Block a user