Change admin IP ranges in tests for node groups

Change default IP addresses range for admin/pxe network
in system test for multiple cluster networks feature.
Check that DHCP range is configured properly and Nailgun
doesn't allocate excluded from range IPs to nodes.

Change-Id: I64069e287a6970b93931d93212efb0c1712af40a
Closes-bug: #1513154
This commit is contained in:
Artem Panchenko 2015-11-22 18:22:13 +02:00 committed by tatyana-leontovich
parent 1e1d740012
commit 6e855eead1
1 changed files with 86 additions and 14 deletions

View File

@ -13,7 +13,9 @@
# under the License.
from ipaddr import IPAddress
from ipaddr import summarize_address_range
from devops.helpers.helpers import wait
from proboscis import SkipTest
from proboscis import test
from proboscis.asserts import assert_true
@ -33,6 +35,41 @@ from fuelweb_test import logger
class TestMultipleClusterNets(TestBasic):
"""TestMultipleClusterNets.""" # TODO documentation
@staticmethod
def change_default_admin_range(networks, number_excluded_ips):
"""Change IP range for admin network by excluding N of first addresses
from default range
:param networks: list, environment networks configuration
:param number_excluded_ips: int, number of IPs to remove from range
"""
default_admin_network = [n for n in networks
if (n['name'] == "fuelweb_admin" and
n['group_id'] is None)]
assert_true(len(default_admin_network) == 1,
"Default 'admin/pxe' network not found "
"in cluster network configuration!")
default_admin_range = [IPAddress(ip) for ip
in default_admin_network[0]["ip_ranges"][0]]
new_admin_range = [default_admin_range[0] + number_excluded_ips,
default_admin_range[1]]
default_admin_network[0]["ip_ranges"][0] = [str(ip)
for ip in new_admin_range]
return default_admin_network[0]["ip_ranges"][0]
@staticmethod
def is_ip_in_range(ip_addr, ip_range_start, ip_range_end):
ip_addr_ranges = summarize_address_range(IPAddress(ip_range_start),
IPAddress(ip_range_end))
return any(IPAddress(ip_addr) in iprange for iprange in ip_addr_ranges)
@staticmethod
def is_update_dnsmasq_running(tasks):
for task in tasks:
if task['name'] == "update_dnsmasq" and \
task["status"] == "running":
return True
return False
@test(depends_on=[SetupEnvironment.prepare_release],
groups=["multiple_cluster_networks",
"deploy_neutron_tun_ha_nodegroups", "thread_7"])
@ -117,14 +154,16 @@ class TestMultipleClusterNets(TestBasic):
Scenario:
1. Revert snapshot with ready master node
2. Bootstrap slaves from default nodegroup
3. Create cluster with Neutron VXLAN, Ceph and custom nodegroup
4. Bootstrap slave nodes from custom nodegroup
5. Add 3 controller + ceph nodes from default nodegroup
6. Add 2 compute + ceph nodes from custom nodegroup
7. Deploy cluster
8. Run network verification
9. Run health checks (OSTF)
2. Create cluster with Neutron VXLAN, Ceph and custom nodegroup
3. Exclude 10 first IPs from range for default admin/pxe network
4. Bootstrap slave nodes from both default and custom nodegroups
5. Check that excluded IPs aren't allocated to discovered nodes
6. Add 3 controller + ceph nodes from default nodegroup
7. Add 2 compute + ceph nodes from custom nodegroup
8. Deploy cluster
9. Run network verification
10. Run health checks (OSTF)
11. Check that excluded IPs aren't allocated to deployed nodes
Duration 110m
Snapshot deploy_ceph_ha_nodegroups
@ -138,9 +177,7 @@ class TestMultipleClusterNets(TestBasic):
self.env.revert_snapshot("ready")
self.show_step(2)
self.env.bootstrap_nodes(self.env.d_env.nodes().slaves[0:5:2])
self.show_step(3)
cluster_id = self.fuel_web.create_cluster(
name=self.__class__.__name__,
mode=DEPLOYMENT_MODE_HA,
@ -156,11 +193,33 @@ class TestMultipleClusterNets(TestBasic):
}
)
self.show_step(3)
networks = self.fuel_web.client.get_networks(cluster_id)["networks"]
new_admin_range = self.change_default_admin_range(
networks, number_excluded_ips=10)
wait(lambda: not self.is_update_dnsmasq_running(
self.fuel_web.client.get_tasks()), timeout=60,
timeout_msg="Timeout exceeded while waiting for task "
"'update_dnsmasq' is finished!")
self.fuel_web.client.update_network(cluster_id, networks=networks)
logger.info("New addresses range for default admin network:"
" {0}".format(new_admin_range))
self.show_step(4)
self.env.bootstrap_nodes(self.env.d_env.nodes().slaves[1:5:2])
self.env.bootstrap_nodes(self.env.d_env.nodes().slaves[0:5])
self.show_step(5)
default_ng_nodes = [self.fuel_web.get_nailgun_node_by_devops_node(node)
for node in self.env.d_env.nodes().slaves[0:5:2]]
for node in default_ng_nodes:
assert_true(self.is_ip_in_range(node['ip'], *new_admin_range),
"Node '{0}' has IP address '{1}' which "
"is not from defined IP addresses range:"
" {2}!".format(node['fqdn'], node['ip'],
new_admin_range))
self.show_step(6)
self.show_step(7)
nodegroup_default = NODEGROUPS[0]['name']
nodegroup_custom = NODEGROUPS[1]['name']
self.fuel_web.update_nodes(
@ -174,12 +233,25 @@ class TestMultipleClusterNets(TestBasic):
}
)
self.show_step(7)
self.fuel_web.deploy_cluster_wait(cluster_id, timeout=150 * 60)
self.show_step(8)
self.fuel_web.verify_network(cluster_id)
self.fuel_web.deploy_cluster_wait(cluster_id, timeout=150 * 60)
self.show_step(9)
self.fuel_web.verify_network(cluster_id)
self.show_step(10)
self.fuel_web.run_ostf(cluster_id=cluster_id)
self.show_step(11)
group_id = self.fuel_web.get_nodegroup(cluster_id,
name=nodegroup_default)['id']
default_ng_nodes = [node for node in
self.fuel_web.client.list_cluster_nodes(cluster_id)
if node['group_id'] == group_id]
for node in default_ng_nodes:
assert_true(self.is_ip_in_range(node['ip'], *new_admin_range),
"Node '{0}' has IP address '{1}' which "
"is not from defined IP addresses range:"
" {2}!".format(node['fqdn'], node['ip'],
new_admin_range))
self.env.make_snapshot("deploy_ceph_ha_nodegroups")
@test(depends_on=[SetupEnvironment.prepare_release],