Added additional checks for floating ranges.

We need to create additional checks in
test_cli.py for floating ranges.
We need to check that floating ranges has been
successfully added to /etc/astute.yaml file
on controller node after deploying.

Change-Id: I2f340e30f5ff778ee359e7da1556b0d4a7bb63ef
Closes-Bug: 1517370
This commit is contained in:
Mikhail Samoylov 2015-12-08 18:12:59 +03:00
parent d10b382915
commit 271118a60a
3 changed files with 124 additions and 15 deletions

View File

@ -23,6 +23,7 @@ import os
import posixpath
import re
import signal
import ipaddr
from proboscis import asserts
@ -599,6 +600,37 @@ def node_freemem(remote, unit='MB'):
return ret
def hiera_json_out(node_ip, parameter):
hiera_cmd = "ruby -rhiera -rjson -e \"h = Hiera.new(); " \
"Hiera.logger = 'noop'; " \
"puts JSON.dump(h.lookup(\'{0}\', " \
"[], {{}}, nil, nil))\"".format(parameter)
ssh_manager = SSHManager()
config = ssh_manager.execute_on_remote(
ip=node_ip,
cmd=hiera_cmd,
jsonify=True,
err_msg='Cannot get floating ranges')['stdout_json']
return config
def generate_floating_ranges(start_ip, end_ip, step):
"""Generating floating range by first and last ip with any step
:param start_ip: first ip address in floating range
:param end_ip: last ip address in floating range
:param step: count of ip addresses in floating range
:return:
"""
ranges = []
ip_start = ipaddr.IPAddress(start_ip)
ip_end = ipaddr.IPAddress(end_ip)
while ip_end - step > ip_start:
ranges.append([str(ip_start), str(ip_start + step)])
ip_start += (step + 1)
return ranges
def get_node_hiera_roles(remote):
"""Get hiera roles assigned to host

View File

@ -23,6 +23,7 @@ from fuelweb_test.helpers.checkers import check_cluster_presence
from fuelweb_test.helpers.checkers import check_cobbler_node_exists
from fuelweb_test.helpers.decorators import log_snapshot_after_test
from fuelweb_test.helpers.utils import run_on_remote
from fuelweb_test.helpers.utils import generate_floating_ranges
from fuelweb_test.settings import DEPLOYMENT_MODE
from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE
from fuelweb_test.settings import OPENSTACK_RELEASE
@ -98,12 +99,14 @@ class CommandLineTest(test_cli_base.CommandLine):
Scenario:
1. Revert snapshot "ready_with_3_slaves"
2. Create a cluster using Fuel CLI
3. Provision a controller node using Fuel CLI
4. Provision two compute+cinder nodes using Fuel CLI
5. Deploy the controller node using Fuel CLI
6. Deploy the compute+cinder nodes using Fuel CLI
7. Run OSTF
8. Make snapshot "cli_selected_nodes_deploy"
3. Add floating ranges for public network
4. Provision a controller node using Fuel CLI
5. Provision two compute+cinder nodes using Fuel CLI
6. Deploy the controller node using Fuel CLI
7. Deploy the compute+cinder nodes using Fuel CLI
8. Compare floating ranges
9. Run OSTF
10. Make snapshot "cli_selected_nodes_deploy"
Duration 50m
"""
@ -129,7 +132,25 @@ class CommandLineTest(test_cli_base.CommandLine):
# Update network parameters
self.update_cli_network_configuration(cluster_id, remote)
# Change floating ranges
current_floating_range =\
self.get_floating_ranges(cluster_id, remote)
logger.info(
"Current floating ranges: {0}".format(
current_floating_range))
first_floating_address = current_floating_range[0][0]
logger.info(
"First floating address: {0}".format(
first_floating_address))
last_floating_address = current_floating_range[0][1]
logger.info(
"Last floating address: {0}".format(
last_floating_address))
new_floating_range = generate_floating_ranges(
first_floating_address,
last_floating_address, 10)
logger.info("New floating range: {0}".format(new_floating_range))
self.change_floating_ranges(cluster_id, remote, new_floating_range)
# Update SSL configuration
self.update_ssl_configuration(cluster_id, remote)
@ -162,18 +183,28 @@ class CommandLineTest(test_cli_base.CommandLine):
.format(cluster_id, node_ids[0]))
task = run_on_remote(remote, cmd, jsonify=True)
self.assert_cli_task_success(task, remote, timeout=60 * 60)
# Deploy the compute nodes
cmd = ('fuel --env-id={0} node --deploy --node {1},{2} --json'
.format(cluster_id, node_ids[1], node_ids[2]))
task = run_on_remote(remote, cmd, jsonify=True)
self.assert_cli_task_success(task, remote, timeout=30 * 60)
self.fuel_web.run_ostf(
cluster_id=cluster_id,
test_sets=['ha', 'smoke', 'sanity'])
self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)
# Verify networks
self.fuel_web.verify_network(cluster_id)
# Get hiera floating ranges after deploying cluster
controller_nodes = \
self.fuel_web.get_nailgun_cluster_nodes_by_roles(
cluster_id, ['controller'])
controller_node = controller_nodes[0]['ip']
actual_floating_ranges = self.hiera_floating_ranges(controller_node)
logger.info(
"Current floating ranges: {0}".format(actual_floating_ranges))
assert_equal(actual_floating_ranges, new_floating_range,
message="Floating ranges are not equal")
# Run OSTF
self.fuel_web.run_ostf(
cluster_id=cluster_id,
test_sets=['ha', 'smoke', 'sanity'])
self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)
@test(depends_on_groups=['cli_selected_nodes_deploy'],
groups=["cli_node_deletion_check"])

View File

@ -14,7 +14,6 @@
import time
import json
from proboscis.asserts import assert_equal
from devops.error import TimeoutError
@ -24,6 +23,7 @@ from fuelweb_test.helpers.ssl import change_cluster_ssl_config
from fuelweb_test.tests.base_test_case import TestBasic
from fuelweb_test import logwrap
from fuelweb_test import logger
from fuelweb_test.helpers.utils import hiera_json_out
class CommandLine(TestBasic):
@ -86,6 +86,52 @@ class CommandLine(TestBasic):
)
)
@logwrap
def hiera_floating_ranges(self, node_ip):
"""
1. SSH to controller node
2. Get network settings from controller node
3. Convert to json network settings in variable config_json
4. Get new list of floating ranges in variable floating ranges
5. Convert to sublist floating ranges in variable floating_ranges_json
"""
config_json = hiera_json_out(node_ip, 'quantum_settings')
floating_ranges = \
config_json[
"predefined_networks"][
"admin_floating_net"][
"L3"]["floating"]
floating_ranges_json = [
[float_address[0], float_address[1]] for float_address in (
float_address.split(':') for float_address in floating_ranges)]
return floating_ranges_json
@logwrap
def get_floating_ranges(self, cluster_id, remote):
"""
This method using for get floating ranges from master node before
cluster will be deployed.
1. SSH to master node
2. Get networks from master node
3. Save floating ranges from master node
"""
net_config = self.get_networks(cluster_id, remote)
floating_ranges =\
net_config[u'networking_parameters'][u'floating_ranges']
return floating_ranges
@logwrap
def change_floating_ranges(self, cluster_id, remote, floating_range):
net_config = self.get_networks(cluster_id, remote)
net_config[u'networking_parameters'][u'floating_ranges'] = \
floating_range
new_settings = net_config
self.update_network(cluster_id, remote, new_settings)
@logwrap
def update_cli_network_configuration(self, cluster_id, remote):
"""Update cluster network settings with custom configuration.