Add test for scalability of configured environment

Change-Id: I0b52757948ee4d18fab38c7ae74cfeb8c58001d4
Implements: blueprint test-openstack-config-change
This commit is contained in:
Sergey Novikov 2015-12-21 14:42:44 +03:00
parent 39ae529491
commit d6daea1cc5
2 changed files with 168 additions and 25 deletions

View File

@ -0,0 +1,4 @@
---
keystone_config:
token/expiration:
value: 300

View File

@ -12,6 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import time
import random
from devops.helpers import helpers
from proboscis import asserts
from proboscis import test
@ -100,12 +103,13 @@ class ServicesReconfiguration(TestBasic):
with self.env.d_env.get_ssh_to_remote(node) as remote:
uptime = utils.get_process_uptime(remote, service_name)
asserts.assert_true(uptime <= uptime_before[node],
'Service "neutron-servers" was not '
'restarted on {0}'.format(node))
'Service "{0}" was not '
'restarted on {1}'.format(service_name,
node))
def check_overcommit_ratio(self, os_conn, cluster_id):
"""
:param os_conn: a object of connection to openstack services
:param os_conn: an object of connection to openstack services
:param cluster_id: an integer number of cluster id
:return:
"""
@ -124,23 +128,30 @@ class ServicesReconfiguration(TestBasic):
os_conn.delete_instance(excessive_server)
os_conn.delete_instance(server)
def check_nova_ephemral_disk(self, os_conn, cluster_id):
def check_nova_ephemeral_disk(self, os_conn, cluster_id,
hypervisor_name=None, fs_type='ext4'):
"""
:param os_conn: a object of connection to openstack services
:param os_conn: an object of connection to openstack services
:param cluster_id: an integer number of cluster id
:param hypervisor_name: a string of hypervisor name
:param fs_type: a string of fs type name
:return:
"""
net_name = self.fuel_web.get_cluster_predefined_networks_name(
cluster_id)['private_net']
os_conn.create_flavor(name='ephemeral',
flavor_id = random.randint(10, 10000)
os_conn.create_flavor(name='ephemeral{0}'.format(flavor_id),
ram=64,
vcpus=1,
disk=1,
flavorid=6,
flavorid=flavor_id,
ephemeral=1)
kwargs = {}
if hypervisor_name:
kwargs['availability_zone'] = "nova:{0}".format(hypervisor_name)
instance = os_conn.create_server_for_migration(
neutron=True, label=net_name, flavor=6)
neutron=True, label=net_name, flavor=flavor_id, **kwargs)
floating_ip = os_conn.assign_floating_ip(instance)
@ -154,16 +165,17 @@ class ServicesReconfiguration(TestBasic):
cluster_id, ['controller'])[0]['ip']
with self.env.d_env.get_ssh_to_remote(controller) as remote:
res = os_conn.execute_through_host(
remote, floating_ip.ip,
"mount | grep 'type ext4' "
" && echo 'OK' || echo 'FAIL'", creds)
asserts.assert_true('OK' in res['stdout'],
remote, floating_ip.ip, "mount", creds)
asserts.assert_true('/mnt type {0}'.format(fs_type)
in res['stdout'],
"Ephemeral disk format was not "
"changed on instance")
"changed on instance. "
"Please, see details: {0}".format(res))
os_conn.delete_instance(instance)
def check_ml2_vlan_range(self, os_conn):
"""
:param os_conn: a object of connection to openstack services
:param os_conn: an object of connection to openstack services
:return:
"""
tenant = os_conn.get_tenant('admin')
@ -180,7 +192,7 @@ class ServicesReconfiguration(TestBasic):
def check_nova_quota(self, os_conn, cluster_id):
"""
:param os_conn: a object of connection to openstack services
:param os_conn: an object of connection to openstack services
:param cluster_id: an integer number of cluster id
:return:
"""
@ -190,7 +202,6 @@ class ServicesReconfiguration(TestBasic):
label=net_name,
server_name="Test_reconfig")
os_conn.verify_instance_status(server, 'ACTIVE')
self.show_step(9)
try:
os_conn.create_instance(neutron_network=True,
label=net_name,
@ -203,6 +214,25 @@ class ServicesReconfiguration(TestBasic):
else:
raise Exception("New configuration was not applied")
def check_token_expiration(self, os_conn, time_expiration):
"""
:param os_conn: an object of connection to openstack services
:param time_expiration: an integer value of token time expiration
in seconds
:return:
"""
token = os_conn.keystone.tokens.authenticate(username='admin',
password='admin')
time.sleep(time_expiration)
try:
os_conn.keystone.tokens.validate(token.id)
except Exception as e:
if e.http_status != 404:
raise e
pass
else:
raise Exception("New configuration was not applied")
@test(depends_on=[SetupEnvironment.prepare_slaves_5],
groups=["services_reconfiguration", "basic_env_for_reconfiguration"])
@log_snapshot_after_test
@ -445,8 +475,7 @@ class ServicesReconfiguration(TestBasic):
cmd = "grep \"Can't contact LDAP server\" {0}".format(log_path)
utils.run_on_remote_get_results(remote, cmd)
self.env.make_snapshot("reconfigure_keystone_to_use_ldap",
is_make=True)
self.env.make_snapshot("reconfigure_keystone_to_use_ldap")
@test(depends_on_groups=['basic_env_for_reconfiguration'],
groups=["services_reconfiguration", "reconfigure_nova_quota"])
@ -498,11 +527,11 @@ class ServicesReconfiguration(TestBasic):
self.fuel_web.assert_task_success(task, timeout=300, interval=5)
self.show_step(7)
self.check_service_was_restarted(computes, uptimes_comp,
'nova-compute')
self.check_service_was_restarted(controllers, uptimes, 'nova-api')
self.show_step(8)
self.check_service_was_restarted(controllers, uptimes, 'nova-api')
self.check_service_was_restarted(computes, uptimes_comp,
'nova-compute')
self.show_step(9)
self.check_config_on_remote(controllers, structured_config)
@ -514,14 +543,13 @@ class ServicesReconfiguration(TestBasic):
self.check_nova_quota(os_conn, cluster_id)
self.env.make_snapshot("reconfigure_nova_quota",
is_make=True)
self.env.make_snapshot("reconfigure_nova_quota")
@test(depends_on_groups=['reconfigure_overcommit_ratio'],
groups=["services_reconfiguration",
"reconfigure_nova_ephemeral_disk"])
@log_snapshot_after_test
def reconfigure_nova_ephemral_disk(self):
def reconfigure_nova_ephemeral_disk(self):
"""Reconfigure nova ephemeral disk format
Scenario:
@ -586,7 +614,7 @@ class ServicesReconfiguration(TestBasic):
self.show_step(10)
self.show_step(11)
self.show_step(12)
self.check_nova_ephemral_disk(os_conn, cluster_id)
self.check_nova_ephemeral_disk(os_conn, cluster_id)
self.env.make_snapshot("reconfigure_nova_ephemeral_disk",
is_make=True)
@ -660,3 +688,114 @@ class ServicesReconfiguration(TestBasic):
snapshot = "preservation_config_after_reset_and_preconfigured_deploy"
self.env.make_snapshot(snapshot, is_make=True)
@test(depends_on_groups=['reconfigure_nova_ephemeral_disk'],
groups=["services_reconfiguration",
"reconfiguration_scalability"])
@log_snapshot_after_test
def reconfiguration_scalability(self):
"""Check scalability of configured environment
Scenario:
1. Revert snapshot "reconfigure_nova_ephemeral_disk"
2. Upload a new openstack configuration for keystone
3. Wait for configuration applying
4. Verify keystone settings
5. Keystone actions
6. Add 1 compute and 1 controller to cluster
7. Run network verification
8. Deploy changes
9. Run OSTF tests
10. Verify keystone settings
11. Verify nova settings
12. Create flavor with ephemral disk
13. Boot instance on updated compute with ephemral disk
14. Assign floating ip
15. Check ping to the instance
16. SSH to VM and check ephemeral disk format
17. Keystone actions
Snapshot "reconfiguration_scalability"
"""
self.show_step(1)
self.env.revert_snapshot("reconfigure_nova_ephemeral_disk")
self.show_step(2)
cluster_id = self.fuel_web.get_last_created_cluster()
config = utils.get_config_template('nova_disk')
structured_config_nova = get_structured_config_dict(config)
config = utils.get_config_template('keystone')
structured_config_keystone = get_structured_config_dict(config)
self.fuel_web.client.upload_configuration(config,
cluster_id,
role='controller')
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
cluster_id, ['controller'])
self.show_step(3)
task = self.fuel_web.client.apply_configuration(cluster_id,
role='controller')
self.fuel_web.assert_task_success(task, timeout=300, interval=5)
self.show_step(4)
self.check_config_on_remote(controllers, structured_config_keystone)
self.show_step(5)
os_conn = os_actions.OpenStackActions(
self.fuel_web.get_public_vip(cluster_id))
time_expiration = config[
'keystone_config']['token/expiration']['value']
self.check_token_expiration(os_conn, time_expiration)
self.show_step(6)
bs_nodes = [x for x in self.env.d_env.get_nodes()
if x.name == 'slave-05' or x.name == 'slave-06']
self.env.bootstrap_nodes(bs_nodes)
self.fuel_web.update_nodes(
cluster_id,
{'slave-05': ['compute']})
self.fuel_web.update_nodes(
cluster_id,
{'slave-06': ['controller']})
self.show_step(7)
self.fuel_web.verify_network(cluster_id)
self.show_step(8)
self.fuel_web.deploy_cluster_wait(cluster_id)
self.show_step(9)
self.fuel_web.run_ostf(cluster_id=cluster_id)
self.show_step(10)
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
cluster_id, ['controller'])
computes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
cluster_id, ['compute'])
target_controller = [x for x in controllers
if 'slave-06' in x['name']]
target_compute = [x for x in computes
if 'slave-05' in x['name']]
self.check_config_on_remote(target_controller,
structured_config_keystone)
self.show_step(11)
self.check_config_on_remote(target_compute, structured_config_nova)
self.show_step(12)
self.show_step(13)
self.show_step(14)
self.show_step(15)
self.show_step(16)
os_conn = os_actions.OpenStackActions(
self.fuel_web.get_public_vip(cluster_id))
hypervisor_name = target_compute[0]['fqdn']
self.check_nova_ephemeral_disk(os_conn, cluster_id,
hypervisor_name=hypervisor_name)
self.show_step(17)
self.check_token_expiration(os_conn, time_expiration)
self.env.make_snapshot("reconfiguration_scalability", is_make=True)