Files
rally/tests/benchmark/context/cleanup/test_utils.py
Alexander Maretskiy af3239d5d4 Add Neutron benchmarks scenario for creating and listing ports
Scenario NeutronNetworks.create_and_list_ports is added, which does the following:
  - creates network
  - creates a given number of ports
  - lists ports

blueprint benchmark-scenarios-for-neutron

Change-Id: I029f220dd70beb0c248877bd4bd718dfa63aba40
2014-06-24 17:48:00 +03:00

52 lines
2.0 KiB
Python

# Copyright 2014: Mirantis Inc.
# All Rights Reserved.
#
# 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.
from rally.benchmark.context.cleanup import utils
from rally.benchmark import scenarios
from tests import fakes
from tests import test
class CleanupUtilsTestCase(test.TestCase):
def test_delete_neutron_resources(self):
neutron = fakes.FakeClients().neutron()
scenario = scenarios.neutron.utils.NeutronScenario()
scenario.clients = lambda ins: neutron
network1 = scenario._create_network({})
subnet1 = scenario._create_subnet(network1, {})
router1 = scenario._create_router({})
# This also creates a port
neutron.add_interface_router(router1["router"]["id"],
{"subnet_id": subnet1["subnet"]["id"]})
network2 = scenario._create_network({})
scenario._create_subnet(network2, {})
scenario._create_router({})
scenario._create_port(network2, {})
total = lambda neutron: (len(neutron.list_networks()["networks"])
+ len(neutron.list_subnets()["subnets"])
+ len(neutron.list_routers()["routers"])
+ len(neutron.list_ports()["ports"]))
self.assertEqual(total(neutron), 8)
utils.delete_neutron_resources(neutron,
network1["network"]["tenant_id"])
self.assertEqual(total(neutron), 0)