diff --git a/vitrage_tempest_plugin/tests/base.py b/vitrage_tempest_plugin/tests/base.py index e920902..740a45c 100644 --- a/vitrage_tempest_plugin/tests/base.py +++ b/vitrage_tempest_plugin/tests/base.py @@ -33,7 +33,6 @@ from vitrage.datasources import NOVA_HOST_DATASOURCE from vitrage.datasources import NOVA_INSTANCE_DATASOURCE from vitrage.datasources import NOVA_ZONE_DATASOURCE from vitrage.datasources import OPENSTACK_CLUSTER -from vitrage.datasources.static_physical import SWITCH from vitrage.graph.driver.networkx_graph import NXGraph from vitrage.graph import Edge from vitrage.graph import Vertex @@ -235,7 +234,7 @@ class BaseVitrageTempest(base.BaseTestCase): # switch props = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE, - VProps.VITRAGE_TYPE: SWITCH, + VProps.VITRAGE_TYPE: 'switch', self.NUM_VERTICES_PER_TYPE: kwargs.get( 'switch_entities', 0), self.NUM_EDGES_PER_TYPE: kwargs.get( @@ -303,6 +302,8 @@ class BaseVitrageTempest(base.BaseTestCase): '%s%s' % ('Num vertices is incorrect for: ', entity[VProps.VITRAGE_TYPE])) + # TODO(iafek): bug - edges between entities of the same type are + # counted twice entity_num_edges = sum([len(graph.get_edges(vertex.vertex_id)) for vertex in vertices]) self.assertEqual(entity[self.NUM_EDGES_PER_TYPE], diff --git a/vitrage_tempest_plugin/tests/datasources/test_static_physical.py b/vitrage_tempest_plugin/tests/datasources/test_static.py similarity index 76% rename from vitrage_tempest_plugin/tests/datasources/test_static_physical.py rename to vitrage_tempest_plugin/tests/datasources/test_static.py index ce5aef1..12a0d66 100644 --- a/vitrage_tempest_plugin/tests/datasources/test_static_physical.py +++ b/vitrage_tempest_plugin/tests/datasources/test_static.py @@ -25,18 +25,19 @@ from vitrage_tempest_plugin.tests import utils LOG = logging.getLogger(__name__) -class TestStaticPhysical(BaseVitrageTempest): - NUM_SWITCH = 2 +class TestStatic(BaseVitrageTempest): + NUM_SWITCH = 1 + NUM_NIC = 1 def setUp(self): - super(TestStaticPhysical, self).setUp() + super(TestStatic, self).setUp() def tearDown(self): - super(TestStaticPhysical, self).tearDown() + super(TestStatic, self).tearDown() @classmethod def setUpClass(cls): - super(TestStaticPhysical, cls).setUpClass() + super(TestStatic, cls).setUpClass() @utils.tempest_logger def test_switches(self): @@ -49,11 +50,14 @@ class TestStaticPhysical(BaseVitrageTempest): graph = self._create_graph_from_graph_dictionary(api_graph) entities = self._entities_validation_data( host_entities=1, - host_edges=1 + self.NUM_SWITCH, + host_edges=1, switch_entities=self.NUM_SWITCH, - switch_edges=self.NUM_SWITCH) + switch_edges=1, + nic_entities=self.NUM_NIC, + nic_edges=1) num_entities = self.num_default_entities + self.NUM_SWITCH + \ - self.num_default_networks + self.num_default_ports + self.NUM_NIC + self.num_default_networks + \ + self.num_default_ports num_edges = self.num_default_edges + self.NUM_SWITCH + \ self.num_default_ports @@ -73,26 +77,24 @@ class TestStaticPhysical(BaseVitrageTempest): hostname = socket.gethostname() # template file - resources_path = tempest_resources_dir() + '/static_physical/' - file_path = resources_path + '/static_physical_configuration.yaml' + file_path = \ + tempest_resources_dir() + '/static/static_configuration.yaml' with open(file_path, 'r') as f: template_data = f.read() template_data = template_data.replace('tmp-devstack', hostname) # new file new_file = open( - '/etc/vitrage/static_datasources/' - 'static_physical_configuration.yaml', 'w') + '/etc/vitrage/static_datasources/static_configuration.yaml', 'w') new_file.write(template_data) new_file.close() - time.sleep(25) + time.sleep(35) @staticmethod def _delete_switches(): - path = '/etc/vitrage/static_datasources/' \ - 'static_physical_configuration.yaml' + path = '/etc/vitrage/static_datasources/static_configuration.yaml' if os.path.exists(path): os.remove(path) - time.sleep(25) + time.sleep(35) diff --git a/vitrage_tempest_plugin/tests/resources/static/static_configuration.yaml b/vitrage_tempest_plugin/tests/resources/static/static_configuration.yaml new file mode 100644 index 0000000..50a8e1b --- /dev/null +++ b/vitrage_tempest_plugin/tests/resources/static/static_configuration.yaml @@ -0,0 +1,19 @@ +metadata: + description: 'static configuration with switches' + name: test_static +definitions: + entities: + - id: 12345 + name: nic-1 + static_id: nic-1 + type: nic + state: available + - id: 23456 + name: switch-2 + static_id: switch-2 + type: switch + state: available + relationships: + - relationship_type: attached + source: nic-1 + target: switch-2 diff --git a/vitrage_tempest_plugin/tests/resources/static_physical/static_physical_configuration.yaml b/vitrage_tempest_plugin/tests/resources/static_physical/static_physical_configuration.yaml deleted file mode 100644 index 800dc2f..0000000 --- a/vitrage_tempest_plugin/tests/resources/static_physical/static_physical_configuration.yaml +++ /dev/null @@ -1,19 +0,0 @@ -entities: - - type: switch - name: switch-1 - id: 12345 - state: available - relationships: - - type: nova.host - name: tmp-devstack - id: tmp-devstack - relation_type: attached - - type: switch - name: switch-2 - id: 23456 - state: available - relationships: - - type: nova.host - name: tmp-devstack - id: tmp-devstack - relation_type: attached \ No newline at end of file