Nova net functional tests round 1
* address scope * network agent * network flavor * network flavor profile * network meter * network meter rule Also create a new common network functional test class NetworkTests to house the setting of haz_network in a single place. The individual test skipping stays in the final classes to re-enforce the idea that some tests work with both Nova-net and Neutron. Change-Id: Ie3910231c6fc9e2031438c599afa904f43c874a7
This commit is contained in:
parent
7b609ebd55
commit
e0d1af94a1
openstackclient/tests/functional/network/v2
22
openstackclient/tests/functional/network/v2/common.py
Normal file
22
openstackclient/tests/functional/network/v2/common.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# 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 openstackclient.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkTests(base.TestCase):
|
||||||
|
"""Functional tests for Network commands"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
# super(NetworkTests, cls).setUp()
|
||||||
|
cls.haz_network = base.is_service_enabled('network')
|
@ -13,10 +13,10 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional.network.v2 import common
|
||||||
|
|
||||||
|
|
||||||
class AddressScopeTests(base.TestCase):
|
class AddressScopeTests(common.NetworkTests):
|
||||||
"""Functional tests for address scope. """
|
"""Functional tests for address scope. """
|
||||||
|
|
||||||
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
|
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
|
||||||
@ -24,6 +24,12 @@ class AddressScopeTests(base.TestCase):
|
|||||||
# has its own needs and there are collisions when running
|
# has its own needs and there are collisions when running
|
||||||
# tests in parallel.
|
# tests in parallel.
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(AddressScopeTests, self).setUp()
|
||||||
|
# Nothing in this class works with Nova Network
|
||||||
|
if not self.haz_network:
|
||||||
|
self.skipTest("No Network service present")
|
||||||
|
|
||||||
def test_address_scope_delete(self):
|
def test_address_scope_delete(self):
|
||||||
"""Test create, delete multiple"""
|
"""Test create, delete multiple"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
|
@ -13,39 +13,85 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional.network.v2 import common
|
||||||
|
|
||||||
|
|
||||||
class NetworkAgentTests(base.TestCase):
|
class NetworkAgentTests(common.NetworkTests):
|
||||||
"""Functional tests for network agent. """
|
"""Functional tests for network agent"""
|
||||||
IDs = None
|
|
||||||
HEADERS = ['ID']
|
|
||||||
FIELDS = ['id']
|
|
||||||
|
|
||||||
@classmethod
|
def setUp(self):
|
||||||
def test_network_agent_list(cls):
|
super(NetworkAgentTests, self).setUp()
|
||||||
opts = cls.get_opts(cls.HEADERS)
|
# Nothing in this class works with Nova Network
|
||||||
raw_output = cls.openstack('network agent list' + opts)
|
if not self.haz_network:
|
||||||
# get the list of network agent IDs.
|
self.skipTest("No Network service present")
|
||||||
cls.IDs = raw_output.split('\n')
|
|
||||||
|
|
||||||
def test_network_agent_show(self):
|
def test_network_agent_list_show_set(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
"""Test network agent list, set, show commands
|
||||||
raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
|
|
||||||
self.assertEqual(self.IDs[0] + "\n", raw_output)
|
|
||||||
|
|
||||||
def test_network_agent_set(self):
|
Do these serially because show and set rely on the existing agent IDs
|
||||||
opts = self.get_opts(['admin_state_up'])
|
from the list output and we had races when run in parallel.
|
||||||
self.openstack('network agent set --disable ' + self.IDs[0])
|
"""
|
||||||
raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
|
|
||||||
self.assertEqual("DOWN\n", raw_output)
|
# agent list
|
||||||
self.openstack('network agent set --enable ' + self.IDs[0])
|
agent_list = json.loads(self.openstack(
|
||||||
raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
|
'network agent list -f json'
|
||||||
self.assertEqual("UP\n", raw_output)
|
))
|
||||||
|
self.assertIsNotNone(agent_list[0])
|
||||||
|
|
||||||
|
agent_ids = list([row["ID"] for row in agent_list])
|
||||||
|
|
||||||
|
# agent show
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'network agent show -f json ' +
|
||||||
|
agent_ids[0]
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
agent_ids[0],
|
||||||
|
cmd_output['id'],
|
||||||
|
)
|
||||||
|
|
||||||
|
# agent set
|
||||||
|
raw_output = self.openstack(
|
||||||
|
'network agent set ' +
|
||||||
|
'--disable ' +
|
||||||
|
agent_ids[0]
|
||||||
|
)
|
||||||
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'network agent show -f json ' +
|
||||||
|
agent_ids[0]
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
"DOWN",
|
||||||
|
cmd_output['admin_state_up'],
|
||||||
|
)
|
||||||
|
|
||||||
|
raw_output = self.openstack(
|
||||||
|
'network agent set ' +
|
||||||
|
'--enable ' +
|
||||||
|
agent_ids[0]
|
||||||
|
)
|
||||||
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'network agent show -f json ' +
|
||||||
|
agent_ids[0]
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
"UP",
|
||||||
|
cmd_output['admin_state_up'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NetworkAgentListTests(base.TestCase):
|
class NetworkAgentListTests(common.NetworkTests):
|
||||||
"""Functional test for network agent list --network. """
|
"""Functional test for network agent"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(NetworkAgentListTests, self).setUp()
|
||||||
|
# Nothing in this class works with Nova Network
|
||||||
|
if not self.haz_network:
|
||||||
|
self.skipTest("No Network service present")
|
||||||
|
|
||||||
def test_network_dhcp_agent_list(self):
|
def test_network_dhcp_agent_list(self):
|
||||||
"""Test network agent list"""
|
"""Test network agent list"""
|
||||||
|
@ -14,15 +14,20 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional.network.v2 import common
|
||||||
|
|
||||||
|
|
||||||
class NetworkFlavorTests(base.TestCase):
|
class NetworkFlavorTests(common.NetworkTests):
|
||||||
"""Functional tests for network flavor."""
|
"""Functional tests for network flavor"""
|
||||||
|
|
||||||
def test_add_remove_network_flavor_profile(self):
|
def setUp(self):
|
||||||
|
super(NetworkFlavorTests, self).setUp()
|
||||||
|
# Nothing in this class works with Nova Network
|
||||||
|
if not self.haz_network:
|
||||||
|
self.skipTest("No Network service present")
|
||||||
|
|
||||||
|
def test_network_flavor_add_remove_profile(self):
|
||||||
"""Test add and remove network flavor to/from profile"""
|
"""Test add and remove network flavor to/from profile"""
|
||||||
|
|
||||||
# Create Flavor
|
# Create Flavor
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
cmd_output1 = json.loads(self.openstack(
|
cmd_output1 = json.loads(self.openstack(
|
||||||
|
@ -12,30 +12,40 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional.network.v2 import common
|
||||||
|
|
||||||
|
|
||||||
class NetworkFlavorProfileTests(base.TestCase):
|
class NetworkFlavorProfileTests(common.NetworkTests):
|
||||||
"""Functional tests for network flavor-profile."""
|
"""Functional tests for network flavor profile"""
|
||||||
|
|
||||||
DESCRIPTION = 'fakedescription'
|
DESCRIPTION = 'fakedescription'
|
||||||
METAINFO = 'Extrainfo'
|
METAINFO = 'Extrainfo'
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(NetworkFlavorProfileTests, self).setUp()
|
||||||
|
# Nothing in this class works with Nova Network
|
||||||
|
if not self.haz_network:
|
||||||
|
self.skipTest("No Network service present")
|
||||||
|
|
||||||
def test_network_flavor_profile_create(self):
|
def test_network_flavor_profile_create(self):
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
' network flavor profile create -f json --description '
|
'network flavor profile create -f json ' +
|
||||||
+ self.DESCRIPTION + ' --enable --metainfo ' + self.METAINFO))
|
'--description ' + self.DESCRIPTION + ' ' +
|
||||||
|
'--enable --metainfo ' + self.METAINFO
|
||||||
|
))
|
||||||
ID = json_output.get('id')
|
ID = json_output.get('id')
|
||||||
self.assertIsNotNone(ID)
|
self.assertIsNotNone(ID)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
True,
|
True,
|
||||||
json_output.get('enabled'))
|
json_output.get('enabled'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'))
|
json_output.get('description'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Extrainfo',
|
'Extrainfo',
|
||||||
json_output.get('meta_info')
|
json_output.get('meta_info'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
@ -44,40 +54,51 @@ class NetworkFlavorProfileTests(base.TestCase):
|
|||||||
|
|
||||||
def test_network_flavor_profile_list(self):
|
def test_network_flavor_profile_list(self):
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
' network flavor profile create -f json --description '
|
'network flavor profile create -f json ' +
|
||||||
+ self.DESCRIPTION + ' --enable --metainfo ' + self.METAINFO))
|
'--description ' + self.DESCRIPTION + ' ' +
|
||||||
|
'--enable ' +
|
||||||
|
'--metainfo ' + self.METAINFO
|
||||||
|
))
|
||||||
ID1 = json_output.get('id')
|
ID1 = json_output.get('id')
|
||||||
self.assertIsNotNone(ID1)
|
self.assertIsNotNone(ID1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
True,
|
True,
|
||||||
json_output.get('enabled'))
|
json_output.get('enabled'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'))
|
json_output.get('description'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Extrainfo',
|
'Extrainfo',
|
||||||
json_output.get('meta_info')
|
json_output.get('meta_info'),
|
||||||
)
|
)
|
||||||
|
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
' network flavor profile create -f json --description '
|
'network flavor profile create -f json ' +
|
||||||
+ self.DESCRIPTION + ' --disable --metainfo ' + self.METAINFO))
|
'--description ' + self.DESCRIPTION + ' ' +
|
||||||
|
'--disable ' +
|
||||||
|
'--metainfo ' + self.METAINFO
|
||||||
|
))
|
||||||
ID2 = json_output.get('id')
|
ID2 = json_output.get('id')
|
||||||
self.assertIsNotNone(ID2)
|
self.assertIsNotNone(ID2)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output.get('enabled'))
|
json_output.get('enabled'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'))
|
json_output.get('description'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Extrainfo',
|
'Extrainfo',
|
||||||
json_output.get('meta_info')
|
json_output.get('meta_info'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test list
|
# Test list
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network flavor profile list -f json'))
|
'network flavor profile list -f json'
|
||||||
|
))
|
||||||
self.assertIsNotNone(json_output)
|
self.assertIsNotNone(json_output)
|
||||||
|
|
||||||
id_list = [item.get('ID') for item in json_output]
|
id_list = [item.get('ID') for item in json_output]
|
||||||
@ -86,39 +107,48 @@ class NetworkFlavorProfileTests(base.TestCase):
|
|||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
'network flavor profile delete ' + ID1 + " " + ID2)
|
'network flavor profile delete ' + ID1 + ' ' + ID2
|
||||||
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
def test_network_flavor_profile_set(self):
|
def test_network_flavor_profile_set(self):
|
||||||
json_output_1 = json.loads(self.openstack(
|
json_output_1 = json.loads(self.openstack(
|
||||||
' network flavor profile create -f json --description '
|
'network flavor profile create -f json ' +
|
||||||
+ self.DESCRIPTION + ' --enable --metainfo ' + self.METAINFO))
|
'--description ' + self.DESCRIPTION + ' ' +
|
||||||
|
'--enable ' +
|
||||||
|
'--metainfo ' + self.METAINFO
|
||||||
|
))
|
||||||
ID = json_output_1.get('id')
|
ID = json_output_1.get('id')
|
||||||
self.assertIsNotNone(ID)
|
self.assertIsNotNone(ID)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
True,
|
True,
|
||||||
json_output_1.get('enabled'))
|
json_output_1.get('enabled'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output_1.get('description'))
|
json_output_1.get('description'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Extrainfo',
|
'Extrainfo',
|
||||||
json_output_1.get('meta_info')
|
json_output_1.get('meta_info'),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.openstack('network flavor profile set --disable ' + ID)
|
self.openstack('network flavor profile set --disable ' + ID)
|
||||||
|
|
||||||
json_output = json.loads(self.openstack('network flavor profile show '
|
json_output = json.loads(self.openstack(
|
||||||
'-f json ' + ID))
|
'network flavor profile show -f json ' + ID
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output.get('enabled'))
|
json_output.get('enabled'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description'))
|
json_output.get('description'),
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Extrainfo',
|
'Extrainfo',
|
||||||
json_output.get('meta_info')
|
json_output.get('meta_info'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
@ -127,24 +157,32 @@ class NetworkFlavorProfileTests(base.TestCase):
|
|||||||
|
|
||||||
def test_network_flavor_profile_show(self):
|
def test_network_flavor_profile_show(self):
|
||||||
json_output_1 = json.loads(self.openstack(
|
json_output_1 = json.loads(self.openstack(
|
||||||
' network flavor profile create -f json --description '
|
'network flavor profile create -f json ' +
|
||||||
+ self.DESCRIPTION + ' --enable --metainfo ' + self.METAINFO))
|
'--description ' + self.DESCRIPTION + ' ' +
|
||||||
|
'--enable ' +
|
||||||
|
'--metainfo ' + self.METAINFO
|
||||||
|
))
|
||||||
ID = json_output_1.get('id')
|
ID = json_output_1.get('id')
|
||||||
self.assertIsNotNone(ID)
|
self.assertIsNotNone(ID)
|
||||||
json_output = json.loads(self.openstack('network flavor profile show '
|
json_output = json.loads(self.openstack(
|
||||||
'-f json ' + ID))
|
'network flavor profile show -f json ' + ID
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
ID,
|
ID,
|
||||||
json_output["id"])
|
json_output["id"],
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
True,
|
True,
|
||||||
json_output["enabled"])
|
json_output["enabled"],
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output["description"])
|
json_output["description"],
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Extrainfo',
|
'Extrainfo',
|
||||||
json_output["meta_info"])
|
json_output["meta_info"],
|
||||||
|
)
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
raw_output = self.openstack('network flavor profile delete ' + ID)
|
raw_output = self.openstack('network flavor profile delete ' + ID)
|
||||||
|
@ -16,26 +16,33 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional.network.v2 import common
|
||||||
|
|
||||||
|
|
||||||
class TestMeter(base.TestCase):
|
class TestMeter(common.NetworkTests):
|
||||||
"""Functional tests for network meter."""
|
"""Functional tests for network meter"""
|
||||||
|
|
||||||
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
|
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
|
||||||
# creation and deletion. Little is gained when each test
|
# creation and deletion. Little is gained when each test
|
||||||
# has its own needs and there are collisions when running
|
# has its own needs and there are collisions when running
|
||||||
# tests in parallel.
|
# tests in parallel.
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestMeter, self).setUp()
|
||||||
|
# Nothing in this class works with Nova Network
|
||||||
|
if not self.haz_network:
|
||||||
|
self.skipTest("No Network service present")
|
||||||
|
|
||||||
def test_meter_delete(self):
|
def test_meter_delete(self):
|
||||||
"""Test create, delete multiple"""
|
"""Test create, delete multiple"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
description = 'fakedescription'
|
description = 'fakedescription'
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter create -f json ' + name1 + ' --description '
|
'network meter create -f json ' +
|
||||||
+ description)
|
' --description ' + description + ' ' +
|
||||||
)
|
name1
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name1,
|
name1,
|
||||||
json_output.get('name'),
|
json_output.get('name'),
|
||||||
@ -43,17 +50,18 @@ class TestMeter(base.TestCase):
|
|||||||
# Check if default shared values
|
# Check if default shared values
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output.get('shared')
|
json_output.get('shared'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description')
|
json_output.get('description'),
|
||||||
)
|
)
|
||||||
|
|
||||||
json_output_2 = json.loads(self.openstack(
|
json_output_2 = json.loads(self.openstack(
|
||||||
'network meter create -f json ' + name2 + ' --description '
|
'network meter create -f json ' +
|
||||||
+ description)
|
'--description ' + description + ' ' +
|
||||||
)
|
name2
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name2,
|
name2,
|
||||||
json_output_2.get('name'),
|
json_output_2.get('name'),
|
||||||
@ -61,11 +69,11 @@ class TestMeter(base.TestCase):
|
|||||||
# Check if default shared values
|
# Check if default shared values
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output_2.get('shared')
|
json_output_2.get('shared'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output_2.get('description')
|
json_output_2.get('description'),
|
||||||
)
|
)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -77,10 +85,15 @@ class TestMeter(base.TestCase):
|
|||||||
"""Test create, list filters, delete"""
|
"""Test create, list filters, delete"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter create -f json --description Test1 --share '
|
'network meter create -f json ' +
|
||||||
+ name1)
|
'--description Test1 ' +
|
||||||
|
'--share ' +
|
||||||
|
name1
|
||||||
|
))
|
||||||
|
self.addCleanup(
|
||||||
|
self.openstack,
|
||||||
|
'network meter delete ' + name1
|
||||||
)
|
)
|
||||||
self.addCleanup(self.openstack, 'network meter delete ' + name1)
|
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Test1',
|
'Test1',
|
||||||
@ -93,18 +106,20 @@ class TestMeter(base.TestCase):
|
|||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
json_output_2 = json.loads(self.openstack(
|
json_output_2 = json.loads(self.openstack(
|
||||||
'network meter create -f json --description Test2 --no-share '
|
'network meter create -f json ' +
|
||||||
+ name2)
|
'--description Test2 ' +
|
||||||
)
|
'--no-share ' +
|
||||||
|
name2
|
||||||
|
))
|
||||||
self.addCleanup(self.openstack, 'network meter delete ' + name2)
|
self.addCleanup(self.openstack, 'network meter delete ' + name2)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Test2',
|
'Test2',
|
||||||
json_output_2.get('description')
|
json_output_2.get('description'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output_2.get('shared')
|
json_output_2.get('shared'),
|
||||||
)
|
)
|
||||||
|
|
||||||
raw_output = json.loads(self.openstack('network meter list -f json'))
|
raw_output = json.loads(self.openstack('network meter list -f json'))
|
||||||
@ -117,42 +132,43 @@ class TestMeter(base.TestCase):
|
|||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
description = 'fakedescription'
|
description = 'fakedescription'
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter create -f json ' + name1 + ' --description '
|
'network meter create -f json ' +
|
||||||
+ description)
|
' --description ' + description + ' ' +
|
||||||
)
|
name1
|
||||||
|
))
|
||||||
meter_id = json_output.get('id')
|
meter_id = json_output.get('id')
|
||||||
self.addCleanup(self.openstack, 'network meter delete ' + name1)
|
self.addCleanup(self.openstack, 'network meter delete ' + name1)
|
||||||
|
|
||||||
# Test show with ID
|
# Test show with ID
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter show -f json ' + meter_id)
|
'network meter show -f json ' + meter_id
|
||||||
)
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output.get('shared')
|
json_output.get('shared'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description')
|
json_output.get('description'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name1,
|
name1,
|
||||||
json_output.get('name')
|
json_output.get('name'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test show with name
|
# Test show with name
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter show -f json ' + name1)
|
'network meter show -f json ' + name1
|
||||||
)
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
meter_id,
|
meter_id,
|
||||||
json_output.get('id')
|
json_output.get('id'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
False,
|
False,
|
||||||
json_output.get('shared')
|
json_output.get('shared'),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'fakedescription',
|
'fakedescription',
|
||||||
json_output.get('description')
|
json_output.get('description'),
|
||||||
)
|
)
|
||||||
|
@ -16,31 +16,40 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional.network.v2 import common
|
||||||
|
|
||||||
|
|
||||||
class TestMeterRule(base.TestCase):
|
class TestMeterRule(common.NetworkTests):
|
||||||
"""Functional tests for meter rule"""
|
"""Functional tests for meter rule"""
|
||||||
|
|
||||||
METER_NAME = uuid.uuid4().hex
|
METER_NAME = uuid.uuid4().hex
|
||||||
METER_ID = None
|
METER_ID = None
|
||||||
METER_RULE_ID = None
|
METER_RULE_ID = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
json_output = json.loads(cls.openstack(
|
common.NetworkTests.setUpClass()
|
||||||
'network meter create -f json ' + cls.METER_NAME
|
if cls.haz_network:
|
||||||
))
|
json_output = json.loads(cls.openstack(
|
||||||
|
'network meter create -f json ' + cls.METER_NAME
|
||||||
cls.METER_ID = json_output.get('id')
|
))
|
||||||
|
cls.METER_ID = json_output.get('id')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
raw_output = cls.openstack('network meter delete ' + cls.METER_ID)
|
common.NetworkTests.tearDownClass()
|
||||||
cls.assertOutput('', raw_output)
|
if cls.haz_network:
|
||||||
|
raw_output = cls.openstack('network meter delete ' + cls.METER_ID)
|
||||||
|
cls.assertOutput('', raw_output)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestMeterRule, self).setUp()
|
||||||
|
# Nothing in this class works with Nova Network
|
||||||
|
if not self.haz_network:
|
||||||
|
self.skipTest("No Network service present")
|
||||||
|
|
||||||
def test_meter_rule_delete(self):
|
def test_meter_rule_delete(self):
|
||||||
"""test create, delete"""
|
"""test create, delete"""
|
||||||
|
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter rule create -f json ' +
|
'network meter rule create -f json ' +
|
||||||
'--remote-ip-prefix 10.0.0.0/8 ' +
|
'--remote-ip-prefix 10.0.0.0/8 ' +
|
||||||
@ -49,8 +58,10 @@ class TestMeterRule(base.TestCase):
|
|||||||
rule_id = json_output.get('id')
|
rule_id = json_output.get('id')
|
||||||
re_ip = json_output.get('remote_ip_prefix')
|
re_ip = json_output.get('remote_ip_prefix')
|
||||||
|
|
||||||
self.addCleanup(self.openstack,
|
self.addCleanup(
|
||||||
'network meter rule delete ' + rule_id)
|
self.openstack,
|
||||||
|
'network meter rule delete ' + rule_id
|
||||||
|
)
|
||||||
self.assertIsNotNone(re_ip)
|
self.assertIsNotNone(re_ip)
|
||||||
self.assertIsNotNone(rule_id)
|
self.assertIsNotNone(rule_id)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -65,8 +76,10 @@ class TestMeterRule(base.TestCase):
|
|||||||
self.METER_ID
|
self.METER_ID
|
||||||
))
|
))
|
||||||
rule_id_1 = json_output.get('id')
|
rule_id_1 = json_output.get('id')
|
||||||
self.addCleanup(self.openstack,
|
self.addCleanup(
|
||||||
'network meter rule delete ' + rule_id_1)
|
self.openstack,
|
||||||
|
'network meter rule delete ' + rule_id_1
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'10.0.0.0/8',
|
'10.0.0.0/8',
|
||||||
json_output.get('remote_ip_prefix')
|
json_output.get('remote_ip_prefix')
|
||||||
@ -78,15 +91,18 @@ class TestMeterRule(base.TestCase):
|
|||||||
self.METER_ID
|
self.METER_ID
|
||||||
))
|
))
|
||||||
rule_id_2 = json_output_1.get('id')
|
rule_id_2 = json_output_1.get('id')
|
||||||
self.addCleanup(self.openstack,
|
self.addCleanup(
|
||||||
'network meter rule delete ' + rule_id_2)
|
self.openstack,
|
||||||
|
'network meter rule delete ' + rule_id_2
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'11.0.0.0/8',
|
'11.0.0.0/8',
|
||||||
json_output_1.get('remote_ip_prefix')
|
json_output_1.get('remote_ip_prefix')
|
||||||
)
|
)
|
||||||
|
|
||||||
json_output = json.loads(self.openstack('network meter rule list -f '
|
json_output = json.loads(self.openstack(
|
||||||
'json'))
|
'network meter rule list -f json'
|
||||||
|
))
|
||||||
rule_id_list = [item.get('ID') for item in json_output]
|
rule_id_list = [item.get('ID') for item in json_output]
|
||||||
ip_prefix_list = [item.get('Remote IP Prefix') for item in json_output]
|
ip_prefix_list = [item.get('Remote IP Prefix') for item in json_output]
|
||||||
self.assertIn(rule_id_1, rule_id_list)
|
self.assertIn(rule_id_1, rule_id_list)
|
||||||
@ -95,7 +111,6 @@ class TestMeterRule(base.TestCase):
|
|||||||
self.assertIn('11.0.0.0/8', ip_prefix_list)
|
self.assertIn('11.0.0.0/8', ip_prefix_list)
|
||||||
|
|
||||||
def test_meter_rule_show(self):
|
def test_meter_rule_show(self):
|
||||||
|
|
||||||
"""Test create, show, delete"""
|
"""Test create, show, delete"""
|
||||||
json_output = json.loads(self.openstack(
|
json_output = json.loads(self.openstack(
|
||||||
'network meter rule create -f json ' +
|
'network meter rule create -f json ' +
|
||||||
@ -110,14 +125,16 @@ class TestMeterRule(base.TestCase):
|
|||||||
json_output.get('direction')
|
json_output.get('direction')
|
||||||
)
|
)
|
||||||
|
|
||||||
json_output = json.loads(self.openstack('network meter rule show'
|
json_output = json.loads(self.openstack(
|
||||||
' -f json ' + rule_id))
|
'network meter rule show -f json ' + rule_id
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'10.0.0.0/8',
|
'10.0.0.0/8',
|
||||||
json_output.get('remote_ip_prefix')
|
json_output.get('remote_ip_prefix')
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(rule_id)
|
self.assertIsNotNone(rule_id)
|
||||||
|
|
||||||
self.addCleanup(self.openstack,
|
self.addCleanup(
|
||||||
'network meter rule delete ' + rule_id)
|
self.openstack,
|
||||||
|
'network meter rule delete ' + rule_id
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user