Browse Source

Patch network_roles_metadata for 7.0 release where needed

The patching mostly done for tests for nailgun components adhering to
the release version. E.g. network serializers. Some tests are forced to
create environments of 8.0 version. The change is needed to resolve
possible issues with the tests when network roles metadata is changed
drastically and is not compatible with mentioned components.

Partial-Bug: #1517874
Change-Id: I55607157ae7767ffdfd1d855b872630832706e8e
changes/43/250743/11
Andrey Shestakov 7 years ago committed by Nikolay Starodubtsev
parent
commit
0dd45c2612
  1. 8
      nailgun/nailgun/extensions/cluster_upgrade/tests/base.py
  2. 2
      nailgun/nailgun/extensions/cluster_upgrade/tests/test_handlers.py
  3. 10
      nailgun/nailgun/extensions/cluster_upgrade/tests/test_validators.py
  4. 36
      nailgun/nailgun/test/integration/test_network_configuration.py
  5. 71
      nailgun/nailgun/test/integration/test_network_manager.py
  6. 4
      nailgun/nailgun/test/integration/test_orchestrator_serializer.py
  7. 237
      nailgun/nailgun/test/integration/test_orchestrator_serializer_70.py
  8. 2
      nailgun/nailgun/test/integration/test_verify_networks_task_manager.py
  9. 2
      nailgun/nailgun/test/unit/test_network_check.py
  10. 2
      nailgun/nailgun/test/unit/test_task.py

8
nailgun/nailgun/extensions/cluster_upgrade/tests/base.py

@ -31,10 +31,12 @@ class BaseCloneClusterTest(nailgun_test_base.BaseIntegrationTest):
version="2014.2.2-6.1",
state=consts.RELEASE_STATES.manageonly
)
self.release_70 = self.env.create_release(
self.release_80 = self.env.create_release(
operating_system=consts.RELEASE_OS.ubuntu,
version="2015.1.0-7.0",
version="2015.1.0-8.0",
)
self.cluster_61_db = self.env.create_cluster(
api=False,
release_id=self.release_61.id,
@ -45,5 +47,5 @@ class BaseCloneClusterTest(nailgun_test_base.BaseIntegrationTest):
self.cluster_61_db)
self.data = {
"name": "cluster-clone-{0}".format(self.cluster_61.id),
"release_id": self.release_70.id,
"release_id": self.release_80.id,
}

2
nailgun/nailgun/extensions/cluster_upgrade/tests/test_handlers.py

@ -36,7 +36,7 @@ class TestClusterUpgradeCloneHandler(tests_base.BaseCloneClusterTest):
self.assertEqual(resp.status_code, 200)
self.assertEqual(body["name"],
"cluster-clone-{0}".format(self.cluster_61.id))
self.assertEqual(body["release_id"], self.release_70.id)
self.assertEqual(body["release_id"], self.release_80.id)
def test_clone_cluster_not_found_error(self):
resp = self.app.post(

10
nailgun/nailgun/extensions/cluster_upgrade/tests/test_validators.py

@ -34,7 +34,7 @@ class TestClusterUpgradeValidator(tests_base.BaseCloneClusterTest):
def test_validate_release_upgrade(self):
self.validator.validate_release_upgrade(self.release_61,
self.release_70)
self.release_80)
@mock.patch.dict(settings.VERSION, {'feature_groups': ['mirantis']})
def test_validate_release_upgrade_deprecated_release(self):
@ -55,7 +55,7 @@ class TestClusterUpgradeValidator(tests_base.BaseCloneClusterTest):
"lower than the release of the original cluster\.$" \
.format(self.release_61.id)
with self.assertRaisesRegexp(errors.InvalidData, msg):
self.validator.validate_release_upgrade(self.release_70,
self.validator.validate_release_upgrade(self.release_80,
self.release_61)
def test_validate_cluster_name(self):
@ -71,12 +71,12 @@ class TestClusterUpgradeValidator(tests_base.BaseCloneClusterTest):
self.validator.validate_cluster_status(self.cluster_61)
def test_validate_cluster_status_invalid(self):
cluster_70 = self.env.create_cluster(
cluster_80 = self.env.create_cluster(
api=False,
release_id=self.release_70.id,
release_id=self.release_80.id,
)
relations.UpgradeRelationObject.create_relation(self.cluster_61.id,
cluster_70.id)
cluster_80.id)
msg = "^Upgrade is not possible because of the original cluster " \
"\({0}\) is already involved in the upgrade routine\.$" \
.format(self.cluster_61.id)

36
nailgun/nailgun/test/integration/test_network_configuration.py

@ -256,12 +256,15 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
def setUp(self):
super(TestNeutronNetworkConfigurationHandler, self).setUp()
cluster = self.env.create_cluster(api=True,
net_provider='neutron',
net_segment_type='gre',
mode='ha_compact'
)
self.cluster = self.db.query(models.Cluster).get(cluster['id'])
self.env.create(
release_kwargs={'version': '1111-8.0'},
cluster_kwargs={
'api': True,
'net_provider': 'neutron',
'net_segment_type': 'gre'
}
)
self.cluster = self.env.clusters[0]
def test_get_request_should_return_net_provider_segment_and_networks(self):
resp = self.env.neutron_networks_get(self.cluster.id)
@ -326,23 +329,6 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
"Change of 'segmentation_type' is prohibited"
)
def test_prohibit_setting_multiple_floating_ip_ranges(self):
resp = self.env.neutron_networks_get(self.cluster.id)
data = resp.json_body
data['networking_parameters']['floating_ranges'] = [
["172.16.0.130", "172.16.0.254"],
["172.16.1.1", "172.16.1.10"]
]
resp = self.env.neutron_networks_put(self.cluster.id, data,
expect_errors=True)
self.assertEqual(400, resp.status_code)
task = resp.json_body
self.assertEqual(
task['message'],
"Setting of multiple floating IP ranges is prohibited. "
"We support it since 8.0 version of environment."
)
@patch('nailgun.db.sqlalchemy.models.Release.environment_version', "8.0")
def test_setting_multiple_floating_ip_ranges_8_0(self):
initial_data = self.env.neutron_networks_get(self.cluster.id).json_body
@ -548,7 +534,7 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
}]
}
})
self.cluster.release.version = '2015.1-7.0'
self.cluster.release.version = '2015.1-8.0'
self.db.flush()
resp = self.env.neutron_networks_get(self.cluster.id)
@ -584,7 +570,6 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
]
}
})
self.cluster.release.version = '2015.1-7.0'
self.db.flush()
# check that we return 400 Bad Request
@ -644,7 +629,6 @@ class TestNeutronNetworkConfigurationHandler(BaseIntegrationTest):
'node_roles': ['compute'],
}]
}})
self.cluster.release.version = '2015.1-7.0'
self.db.flush()
resp = self.env.neutron_networks_get(self.cluster.id)

71
nailgun/nailgun/test/integration/test_network_manager.py

@ -38,7 +38,7 @@ from nailgun.db.sqlalchemy.models import IPAddrRange
from nailgun.db.sqlalchemy.models import NetworkGroup
from nailgun.db.sqlalchemy.models import Node
from nailgun.db.sqlalchemy.models import NodeNICInterface
from nailgun.logger import logger
from nailgun.db.sqlalchemy.models import Release
from nailgun.network.neutron import NeutronManager
from nailgun.network.neutron import NeutronManager70
from nailgun.network.neutron import NeutronManager80
@ -1019,14 +1019,68 @@ class TestNeutronManager70(BaseNetworkManagerTest):
self.net_manager = objects.Cluster.get_network_manager(self.cluster)
def _create_env(self):
release = self._prepare_release()
return self.env.create(
release_kwargs={'version': '1111-7.0'},
cluster_kwargs={
'api': False,
'release_id': release.id,
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron
}
)
def _prepare_release(self):
rel_id = self.env.create_release(version='1111-7.0').id
rel_db = self.db.query(Release).filter_by(id=rel_id).one()
to_patch = [
{
'id': "mgmt/vip",
'default_mapping': "management",
'properties': {
'subnet': True,
'gateway': False,
'vip': [
{
'name': "vrouter",
'namespace': "vrouter",
'alias': "management_vrouter_vip",
},
{
'name': "management",
'namespace': "haproxy",
'alias': "management_vip",
},
]
}
},
{
'id': "public/vip",
'default_mapping': "public",
'properties': {
'subnet': True,
'gateway': True,
'vip': [
{
'name': "vrouter_pub",
'namespace': "vrouter",
'alias': "public_vrouter_vip",
},
{
'name': "public",
'namespace': "haproxy",
'alias': "public_vip",
}
]
}
}
]
rel_db.network_roles_metadata = to_patch
self.db.flush()
return rel_db
def _check_vip_configuration(self, expected_vips, real_vips):
for vip in expected_vips:
name = vip['name']
@ -1176,9 +1230,11 @@ class TestNeutronManager70(BaseNetworkManagerTest):
class TestNovaNetworkManager70(TestNeutronManager70):
def _create_env(self):
release = self._prepare_release()
return self.env.create(
release_kwargs={'version': '1111-7.0'},
cluster_kwargs={
'release_id': release.id,
'api': False,
'net_provider': consts.CLUSTER_NET_PROVIDERS.nova_network
}
@ -1418,8 +1474,9 @@ class TestNeutronManager80(BaseNetworkManagerTest):
namespace: "haproxy"
""")
self.env._add_plugin_network_roles(self.cluster, unmapped_roles)
with patch.object(logger, 'warning') as mock_warn:
assigned_vips = self.net_manager.assign_vips_for_net_groups(
self.cluster)
mock_warn.assert_called_once_with(mock.ANY)
assigned_vips = self.net_manager.assign_vips_for_net_groups(
self.cluster)
self.assertNotIn('unmapped_vip', assigned_vips)
self._check_vip_configuration(expected_vips, assigned_vips)

4
nailgun/nailgun/test/integration/test_orchestrator_serializer.py

@ -1853,7 +1853,7 @@ class TestNeutronOrchestratorSerializer(OrchestratorSerializerTestBase):
@mock.patch('nailgun.rpc.cast')
def test_neutron_l3_floating_w_multiple_node_groups(self, _):
self.new_env_release_version = '1111-7.0'
self.new_env_release_version = '1111-8.0'
ng2_networks = {
'public': {'cidr': '199.10.0.0/24',
@ -1917,7 +1917,7 @@ class TestNeutronOrchestratorSerializer(OrchestratorSerializerTestBase):
'private' in (fact['network_scheme']['roles']), False)
def test_tun_segmentation(self):
self.new_env_release_version = '2015.1.0-7.0'
self.new_env_release_version = '2015.1.0-8.0'
cluster = self.create_env(consts.CLUSTER_MODES.ha_compact, 'tun')
facts = self.serializer.serialize(cluster, cluster.nodes)

237
nailgun/nailgun/test/integration/test_orchestrator_serializer_70.py

@ -48,7 +48,189 @@ from nailgun.test.integration.test_orchestrator_serializer import \
TestSerializeInterfaceDriversData
class BaseTestDeploymentAttributesSerialization70(BaseDeploymentSerializer):
class PrepareDataMixin(object):
def patch_net_roles_for_release(self):
rel_id = self.env.create_release(version=self.env_version).id
rel_db = self.db.query(models.Release).filter_by(id=rel_id).one()
to_patch = yaml.safe_load("""
-
id: "keystone/api"
default_mapping: "management"
properties: &default_network_roles_metadata_properties
subnet: true
gateway: false
vip: []
-
id: "admin/pxe"
default_mapping: "fuelweb_admin"
properties:
subnet: true
gateway: true
vip: []
-
id: "swift/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "neutron/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "sahara/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "ceilometer/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "cinder/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "glance/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "heat/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "nova/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "murano/api"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "horizon"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "mgmt/memcache"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "mgmt/database"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "mgmt/messaging"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "mgmt/corosync"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "mgmt/vip"
default_mapping: "management"
properties:
subnet: true
gateway: false
vip:
-
name: "vrouter"
namespace: "vrouter"
alias: "management_vrouter_vip"
-
name: "management"
namespace: "haproxy"
alias: "management_vip"
-
id: "public/vip"
default_mapping: "public"
properties:
subnet: true
gateway: true
vip:
-
name: "vrouter_pub"
namespace: "vrouter"
alias: "public_vrouter_vip"
-
name: "public"
namespace: "haproxy"
alias: "public_vip"
-
id: "neutron/private"
default_mapping: "private"
properties:
subnet: false
gateway: false
vip: []
-
id: "neutron/mesh"
default_mapping: "private"
properties: *default_network_roles_metadata_properties
-
id: "neutron/floating"
default_mapping: "public"
properties:
subnet: false
gateway: false
vip: []
-
id: "swift/replication"
default_mapping: "storage"
properties: *default_network_roles_metadata_properties
-
id: "ceph/public"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "ceph/radosgw"
default_mapping: "public"
properties: *default_network_roles_metadata_properties
-
id: "ceph/replication"
default_mapping: "storage"
properties: *default_network_roles_metadata_properties
-
id: "cinder/iscsi"
default_mapping: "storage"
properties: *default_network_roles_metadata_properties
-
id: "mongo/db"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "fw-admin"
default_mapping: "fuelweb_admin"
properties:
subnet: true
gateway: true
vip: []
-
id: "management"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
-
id: "ex"
default_mapping: "public"
properties:
subnet: true
gateway: true
vip: []
-
id: "storage"
default_mapping: "storage"
properties: *default_network_roles_metadata_properties
-
id: "nova/migration"
default_mapping: "management"
properties: *default_network_roles_metadata_properties
""")
rel_db.network_roles_metadata = to_patch
self.db.flush()
return rel_db
class BaseTestDeploymentAttributesSerialization70(BaseDeploymentSerializer,
PrepareDataMixin):
management = ['keystone/api', 'neutron/api', 'swift/api', 'sahara/api',
'ceilometer/api', 'cinder/api', 'glance/api', 'heat/api',
'nova/api', 'murano/api', 'horizon', 'management',
@ -81,9 +263,11 @@ class BaseTestDeploymentAttributesSerialization70(BaseDeploymentSerializer):
self.vm_data = self.env.read_fixtures(['vmware_attributes'])
def create_env(self, mode):
release = self.patch_net_roles_for_release()
return self.env.create(
release_kwargs={'version': self.env_version},
cluster_kwargs={
'release_id': release.id,
'mode': mode,
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
'net_segment_type': self.segmentation_type},
@ -364,9 +548,10 @@ class TestDeploymentSerializationForNovaNetwork70(
):
def create_env(self, mode):
release = self.patch_net_roles_for_release()
return self.env.create(
release_kwargs={'version': self.env_version},
cluster_kwargs={
'release_id': release.id,
'mode': mode,
'net_provider': consts.CLUSTER_NET_PROVIDERS.nova_network},
nodes_kwargs=[
@ -555,10 +740,7 @@ class TestPluginDeploymentTasksInjection(base.BaseIntegrationTest):
super(TestPluginDeploymentTasksInjection, self).setUp()
self.env.create(
release_kwargs={
'version': '2015.1.0-7.0',
'deployment_tasks': self.release_deployment_tasks,
},
release_kwargs={'deployment_tasks': self.release_deployment_tasks},
cluster_kwargs={
'mode': consts.CLUSTER_MODES.ha_compact,
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
@ -837,7 +1019,8 @@ class TestPluginDeploymentTasksInjection(base.BaseIntegrationTest):
self.assertItemsEqual(release_depl_tasks_ids, serialized_tasks_ids)
class TestRolesSerializationWithPlugins(BaseDeploymentSerializer):
class TestRolesSerializationWithPlugins(BaseDeploymentSerializer,
PrepareDataMixin):
env_version = '2015.1.0-7.0'
@ -881,11 +1064,10 @@ class TestRolesSerializationWithPlugins(BaseDeploymentSerializer):
def setUp(self):
super(TestRolesSerializationWithPlugins, self).setUp()
release = self.patch_net_roles_for_release()
self.env.create(
release_kwargs={
'version': self.env_version,
},
cluster_kwargs={
'release_id': release.id,
'mode': consts.CLUSTER_MODES.ha_compact,
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.vlan,
@ -972,7 +1154,8 @@ class TestRolesSerializationWithPlugins(BaseDeploymentSerializer):
}])
class TestNetworkTemplateSerializer70(BaseDeploymentSerializer):
class TestNetworkTemplateSerializer70(BaseDeploymentSerializer,
PrepareDataMixin):
env_version = '2015.1.0-7.0'
@ -993,10 +1176,11 @@ class TestNetworkTemplateSerializer70(BaseDeploymentSerializer):
AstuteGraph(cluster_db)).serialize(self.cluster, cluster_db.nodes)
def create_env(self, segment_type):
release = self.patch_net_roles_for_release()
cluster = self.env.create(
release_kwargs={'version': self.env_version},
cluster_kwargs={
'api': False,
'release_id': release.id,
'mode': consts.CLUSTER_MODES.ha_compact,
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
'net_segment_type': segment_type},
@ -1621,8 +1805,31 @@ class TestSerializer70Mixin(object):
class TestNovaOrchestratorSerializer70(TestSerializer70Mixin,
TestNovaOrchestratorSerializer):
pass
TestNovaOrchestratorSerializer,
PrepareDataMixin):
def create_env(self, mode, network_manager='FlatDHCPManager'):
node_args = [
{'roles': ['controller', 'cinder'], 'pending_addition': True},
{'roles': ['compute', 'cinder'], 'pending_addition': True},
{'roles': ['compute'], 'pending_addition': True},
{'roles': ['mongo'], 'pending_addition': True},
{'roles': [], 'pending_roles': ['cinder'],
'pending_addition': True}]
release = self.patch_net_roles_for_release()
cluster = self.env.create(
cluster_kwargs={
'release_id': release.id,
'mode': mode,
'net_manager': network_manager,
'net_provider': consts.CLUSTER_NET_PROVIDERS.nova_network},
nodes_kwargs=node_args)
cluster_db = self.db.query(models.Cluster).get(cluster['id'])
objects.Cluster.prepare_for_deployment(cluster_db)
self.db.flush()
return cluster_db
class TestSerializeInterfaceDriversData70(TestSerializer70Mixin,

2
nailgun/nailgun/test/integration/test_verify_networks_task_manager.py

@ -474,7 +474,7 @@ class TestNetworkVerificationWithTemplates(BaseIntegrationTest):
{"name": "eth3", "mac": "00:00:00:00:22:99"}]
)
self.cluster = self.env.create(
release_kwargs={'version': '2015.1.0-7.0'},
release_kwargs={'version': '2015.1.0-8.0'},
cluster_kwargs={
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
'net_segment_type': net_type,

2
nailgun/nailgun/test/unit/test_network_check.py

@ -668,7 +668,7 @@ class TestCheckVIPsNames(BaseIntegrationTest):
super(TestCheckVIPsNames, self).setUp()
self.env.create(
release_kwargs={'version': '2015.1.0-7.0'},
release_kwargs={'version': '2015.1.0-8.0'},
cluster_kwargs={
'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.gre,

2
nailgun/nailgun/test/unit/test_task.py

@ -269,7 +269,7 @@ class TestCheckBeforeDeploymentTask(BaseTestCase):
def setUp(self):
super(TestCheckBeforeDeploymentTask, self).setUp()
self.env.create(
release_kwargs={'version': '1111-7.0'},
release_kwargs={'version': '1111-8.0'},
cluster_kwargs={
'net_provider': 'neutron',
'net_segment_type': 'gre'

Loading…
Cancel
Save