Add tests on manual vip allocation
- Add scenario when public vip is manually allocated from public ranges - Add scenario when public vip is allocated from floating ip ranges Change-Id: I82b321fb191980b6205bb8ffb430476636f1dbe8 Closes-Bug: #1554954
This commit is contained in:
parent
6e9e285006
commit
723a20a0fc
@ -2593,3 +2593,19 @@ class FuelWebClient(object):
|
|||||||
latest_task = sorted(tasks, key=lambda k: k['id'])[-1]
|
latest_task = sorted(tasks, key=lambda k: k['id'])[-1]
|
||||||
self.assert_task_success(latest_task, interval=interval,
|
self.assert_task_success(latest_task, interval=interval,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
|
|
||||||
|
@logwrap
|
||||||
|
def get_vip_info(self, cluster_id, vip_name='public'):
|
||||||
|
vip_data = self.client.get_vip_info_by_name(cluster_id, vip_name)
|
||||||
|
assert_true(vip_data, "Vip with name {} wasn't found".format(vip_name))
|
||||||
|
logger.debug("vip data is {}".format(vip_data[0]))
|
||||||
|
return vip_data[0]
|
||||||
|
|
||||||
|
@logwrap
|
||||||
|
def update_vip_ip(self, cluster_id, ip, vip_name='public'):
|
||||||
|
vip_data = self.get_vip_info(cluster_id, vip_name=vip_name)
|
||||||
|
vip_data['ip_addr'] = ip
|
||||||
|
vip_data['is_user_defined'] = True
|
||||||
|
vip_id = vip_data['id']
|
||||||
|
logger.debug("data to send {}".format(vip_data))
|
||||||
|
self.client.update_vip_ip(cluster_id, vip_id, vip_data)
|
||||||
|
@ -630,3 +630,33 @@ class NailgunClient(object):
|
|||||||
data['node_id'] = node_id
|
data['node_id'] = node_id
|
||||||
url = '/api/openstack-config/execute/'
|
url = '/api/openstack-config/execute/'
|
||||||
return self.client.put(url, data=data)
|
return self.client.put(url, data=data)
|
||||||
|
|
||||||
|
@logwrap
|
||||||
|
@json_parse
|
||||||
|
def get_vip_info(self, cluster_id):
|
||||||
|
"""Get all available vips.
|
||||||
|
|
||||||
|
:param cluster_id: Id of cluster.
|
||||||
|
:return: a decoded JSON response.
|
||||||
|
"""
|
||||||
|
return self.client.get("/api/clusters/{}/network_configuration/"
|
||||||
|
"ips/vips".format(cluster_id))
|
||||||
|
|
||||||
|
@logwrap
|
||||||
|
def get_vip_info_by_name(self, cluster_id, name):
|
||||||
|
"""Get vip data by its name.
|
||||||
|
|
||||||
|
:param cluster_id: Id of cluster.
|
||||||
|
:param name: Name of vip.
|
||||||
|
:return: vip info with specified name.
|
||||||
|
"""
|
||||||
|
vips_data = self.get_vip_info(cluster_id)
|
||||||
|
logger.debug("available vips are {}".format(vips_data))
|
||||||
|
vip_data = [vip for vip in vips_data if vip['vip_name'] == name]
|
||||||
|
return vip_data
|
||||||
|
|
||||||
|
@logwrap
|
||||||
|
@json_parse
|
||||||
|
def update_vip_ip(self, cluster_id, vip_id, data):
|
||||||
|
return self.client.put("/api/clusters/{0}/network_configuration/ips/"
|
||||||
|
"{1}/vips".format(cluster_id, vip_id), data)
|
||||||
|
182
fuelweb_test/tests/test_manual_vip_allocation.py
Normal file
182
fuelweb_test/tests/test_manual_vip_allocation.py
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
# Copyright 2016 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import netaddr
|
||||||
|
from proboscis import test
|
||||||
|
from proboscis.asserts import assert_equal
|
||||||
|
|
||||||
|
from fuelweb_test import logger
|
||||||
|
from fuelweb_test.helpers.decorators import log_snapshot_after_test
|
||||||
|
from fuelweb_test.tests.base_test_case import SetupEnvironment
|
||||||
|
from fuelweb_test.tests.base_test_case import TestBasic
|
||||||
|
|
||||||
|
|
||||||
|
@test(groups=["change_vip_manually"])
|
||||||
|
class ChangeVipManually(TestBasic):
|
||||||
|
"""ChangeVipManually
|
||||||
|
Contains tests on manual vip allocation
|
||||||
|
"""
|
||||||
|
|
||||||
|
@test(depends_on=[SetupEnvironment.prepare_slaves_9],
|
||||||
|
groups=["change_public_vip"])
|
||||||
|
@log_snapshot_after_test
|
||||||
|
def change_public_vip(self):
|
||||||
|
"""Deploy cluster with public vip manually set
|
||||||
|
|
||||||
|
Scenario:
|
||||||
|
1. Create cluster
|
||||||
|
2. Add 3 node with controller role
|
||||||
|
3. Add 2 node with compute role and 1 cinder node
|
||||||
|
4. Change public vip value to the next ip address
|
||||||
|
5. Verify networks
|
||||||
|
6. Deploy the cluster
|
||||||
|
7. Check that cluster public vip is the same we set manually
|
||||||
|
8. Verify networks
|
||||||
|
9. Run OSTF
|
||||||
|
|
||||||
|
Duration 180m
|
||||||
|
Snapshot change_public_vip
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.env.revert_snapshot("ready_with_9_slaves")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'tenant': 'manualvip',
|
||||||
|
'user': 'manualvip',
|
||||||
|
'password': 'manualvip'
|
||||||
|
}
|
||||||
|
self.show_step(1, initialize=True)
|
||||||
|
cluster_id = self.fuel_web.create_cluster(
|
||||||
|
name=self.__class__.__name__,
|
||||||
|
settings=data
|
||||||
|
)
|
||||||
|
self.show_step(2)
|
||||||
|
self.show_step(3)
|
||||||
|
self.fuel_web.update_nodes(
|
||||||
|
cluster_id,
|
||||||
|
{
|
||||||
|
'slave-01': ['controller'],
|
||||||
|
'slave-02': ['controller'],
|
||||||
|
'slave-03': ['controller'],
|
||||||
|
'slave-04': ['compute'],
|
||||||
|
'slave-05': ['compute'],
|
||||||
|
'slave-06': ['cinder'],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.show_step(4)
|
||||||
|
ip = netaddr.IPAddress(
|
||||||
|
self.fuel_web.get_vip_info(cluster_id)['ip_addr'])
|
||||||
|
ip_to_set = str(ip + 1)
|
||||||
|
logger.debug('ip to be set is {}'.format(ip_to_set))
|
||||||
|
self.fuel_web.update_vip_ip(cluster_id, ip_to_set)
|
||||||
|
self.show_step(5)
|
||||||
|
self.fuel_web.verify_network(cluster_id)
|
||||||
|
self.show_step(6)
|
||||||
|
self.fuel_web.deploy_cluster_wait(cluster_id)
|
||||||
|
public_vip = self.fuel_web.get_public_vip(cluster_id)
|
||||||
|
self.show_step(7)
|
||||||
|
assert_equal(public_vip, ip_to_set,
|
||||||
|
"Public vip doesn't match, actual - {0},"
|
||||||
|
" expected - {1}".format(public_vip, ip_to_set))
|
||||||
|
self.show_step(8)
|
||||||
|
self.fuel_web.verify_network(cluster_id)
|
||||||
|
self.show_step(9)
|
||||||
|
self.fuel_web.run_ostf(cluster_id=cluster_id)
|
||||||
|
|
||||||
|
self.env.make_snapshot("change_public_vip")
|
||||||
|
|
||||||
|
@test(depends_on=[SetupEnvironment.prepare_slaves_9],
|
||||||
|
groups=["change_public_vip_outside_range"])
|
||||||
|
@log_snapshot_after_test
|
||||||
|
def change_public_vip_outside_range(self):
|
||||||
|
"""Deploy cluster with public vip manually set
|
||||||
|
and picked from floating ips range
|
||||||
|
|
||||||
|
Scenario:
|
||||||
|
1. Create cluster
|
||||||
|
2. Add 3 node with controller role
|
||||||
|
3. Add 2 node with compute role and 3 ceph nodes
|
||||||
|
4. Reduce floating ip upper bound on
|
||||||
|
10 addresses
|
||||||
|
5. Change public vip to first not used public address
|
||||||
|
6. Verify networks
|
||||||
|
7. Deploy the cluster
|
||||||
|
8. Check that cluster public vip is the same we set manually
|
||||||
|
9. Run OSTF
|
||||||
|
|
||||||
|
Duration 180m
|
||||||
|
Snapshot change_public_vip_outside_range
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.env.revert_snapshot("ready_with_9_slaves")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'tenant': 'outsiderangevip',
|
||||||
|
'user': 'outsiderangevip',
|
||||||
|
'password': 'outsiderangevip',
|
||||||
|
'volumes_lvm': False,
|
||||||
|
'volumes_ceph': True,
|
||||||
|
'images_ceph': True,
|
||||||
|
'objects_ceph': True,
|
||||||
|
'ephemeral_ceph': True,
|
||||||
|
}
|
||||||
|
self.show_step(1, initialize=True)
|
||||||
|
cluster_id = self.fuel_web.create_cluster(
|
||||||
|
name=self.__class__.__name__,
|
||||||
|
settings=data
|
||||||
|
)
|
||||||
|
self.show_step(2)
|
||||||
|
self.show_step(3)
|
||||||
|
self.fuel_web.update_nodes(
|
||||||
|
cluster_id,
|
||||||
|
{
|
||||||
|
'slave-01': ['controller'],
|
||||||
|
'slave-02': ['controller'],
|
||||||
|
'slave-03': ['controller'],
|
||||||
|
'slave-04': ['compute'],
|
||||||
|
'slave-05': ['compute'],
|
||||||
|
'slave-06': ['ceph-osd'],
|
||||||
|
'slave-07': ['ceph-osd'],
|
||||||
|
'slave-08': ['ceph-osd'],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.show_step(4)
|
||||||
|
ranges = self.fuel_web.get_range(
|
||||||
|
self.env.d_env.get_network(name='public').ip, 1)
|
||||||
|
floating_upper_range = netaddr.IPAddress(ranges[0][-1]) - 10
|
||||||
|
ranges[0][-1] = str(floating_upper_range)
|
||||||
|
params = self.fuel_web.client.get_networks(
|
||||||
|
cluster_id)['networking_parameters']
|
||||||
|
params['floating_ranges'] = ranges
|
||||||
|
self.fuel_web.client.update_network(
|
||||||
|
cluster_id=cluster_id,
|
||||||
|
networking_parameters=params
|
||||||
|
)
|
||||||
|
self.show_step(5)
|
||||||
|
ip_to_set = str(floating_upper_range + 1)
|
||||||
|
logger.debug('ip to be set is {}'.format(ip_to_set))
|
||||||
|
self.fuel_web.update_vip_ip(cluster_id, ip_to_set)
|
||||||
|
self.show_step(6)
|
||||||
|
self.fuel_web.verify_network(cluster_id)
|
||||||
|
self.show_step(7)
|
||||||
|
self.fuel_web.deploy_cluster_wait(cluster_id)
|
||||||
|
public_vip = self.fuel_web.get_public_vip(cluster_id)
|
||||||
|
self.show_step(8)
|
||||||
|
assert_equal(public_vip, ip_to_set,
|
||||||
|
"Public vip doesn't match, actual - {0},"
|
||||||
|
" expected - {1}".format(public_vip, ip_to_set))
|
||||||
|
self.show_step(9)
|
||||||
|
self.fuel_web.run_ostf(cluster_id=cluster_id)
|
||||||
|
|
||||||
|
self.env.make_snapshot("change_public_vip_outside_range")
|
Loading…
Reference in New Issue
Block a user