Integration tests - networkspage and test

Added the networkspage based on the new regions. The method
test_network_create uses the new page navigation and checks basic
private network creation and deletion.

A few other modifications being made:
* horizon.conf:
  * the network section, containing network_cidr, The cidr block to
    allocate tenant ipv4 subnets from, same as in tempest.conf
  * added neutron to service_available section
* config.py:
  * 'network_cidr' under the new NetworkGroup
  * 'neutron' under AvailableServiceGroup, default=True

Implements blueprint: horizon-integration-tests-coverage
Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Change-Id: Ia4a499bc93ac79aaf03c291c7bdbc96ccea93351
This commit is contained in:
dkorn 2014-11-30 20:24:23 +02:00 committed by Timur Sufiev
parent 8f459658e6
commit 91c385d0b3
4 changed files with 187 additions and 0 deletions

View File

@ -54,6 +54,17 @@ ImageGroup = [
help='default list of images')
]
NetworkGroup = [
cfg.StrOpt('network_cidr',
default='10.100.0.0/16',
help='The cidr block to allocate tenant ipv4 subnets from'),
]
AvailableServiceGroup = [
cfg.BoolOpt('neutron',
default=True),
]
SeleniumGroup = [
cfg.IntOpt('implicit_wait',
default=10,
@ -119,6 +130,8 @@ def get_config():
cfg.CONF.register_opts(DashboardGroup, group="dashboard")
cfg.CONF.register_opts(IdentityGroup, group="identity")
cfg.CONF.register_opts(NetworkGroup, group="network")
cfg.CONF.register_opts(AvailableServiceGroup, group="service_available")
cfg.CONF.register_opts(SeleniumGroup, group="selenium")
cfg.CONF.register_opts(ImageGroup, group="image")
cfg.CONF.register_opts(ScenarioGroup, group="scenario")

View File

@ -50,6 +50,14 @@ admin_username=admin
# API key to use when authenticating as admin. (string value)
admin_password=secretadmin
[network]
# The cidr block to allocate tenant ipv4 subnets from (string value)
tenant_network_cidr=10.100.0.0/16
[service_available]
# Whether is Neutron expected to be available (boolean value)
neutron=True
[scenario]
# ssh username for image file (string value)
ssh_user=cirros

View File

@ -0,0 +1,119 @@
# 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 selenium.common import exceptions
from openstack_dashboard.test.integration_tests.pages import basepage
from openstack_dashboard.test.integration_tests.regions import forms
from openstack_dashboard.test.integration_tests.regions import tables
class NetworksTable(tables.TableRegion):
name = "networks"
CREATE_NETWORK_FORM_FIELDS = (("net_name", "admin_state", "shared",
"with_subnet"),
("subnet_name", "cidr", "ip_version",
"gateway_ip", "no_gateway"),
("enable_dhcp", "allocation_pools",
"dns_nameservers", "host_routes"))
@tables.bind_table_action('create')
def create_network(self, create_button):
create_button.click()
return forms.TabbedFormRegion(self.driver, self.conf,
self.CREATE_NETWORK_FORM_FIELDS)
@tables.bind_table_action('delete')
def delete_network(self, delete_button):
delete_button.click()
return forms.BaseFormRegion(self.driver, self.conf)
class NetworksPage(basepage.BaseNavigationPage):
DEFAULT_ADMIN_STATE = 'True'
DEFAULT_CREATE_SUBNET = True
DEFAULT_IP_VERSION = '4'
DEFAULT_DISABLE_GATEWAY = False
DEFAULT_ENABLE_DHCP = True
NETWORKS_TABLE_NAME_COLUMN = 'name'
NETWORKS_TABLE_STATUS_COLUMN = 'status'
SUBNET_TAB_INDEX = 1
DETAILS_TAB_INDEX = 2
def __init__(self, driver, conf):
super(NetworksPage, self).__init__(driver, conf)
self._page_title = "Networks"
def _get_row_with_network_name(self, name):
return self.networks_table.get_row(
self.NETWORKS_TABLE_NAME_COLUMN, name)
@property
def networks_table(self):
return NetworksTable(self.driver, self.conf)
def create_network(self, network_name, subnet_name,
admin_state=DEFAULT_ADMIN_STATE,
create_subnet=DEFAULT_CREATE_SUBNET,
network_address=None, ip_version=DEFAULT_IP_VERSION,
gateway_ip=None,
disable_gateway=DEFAULT_DISABLE_GATEWAY,
enable_dhcp=DEFAULT_ENABLE_DHCP, allocation_pools=None,
dns_name_servers=None, host_routes=None):
create_network_form = self.networks_table.create_network()
create_network_form.net_name.text = network_name
create_network_form.admin_state.value = admin_state
if not create_subnet:
create_network_form.with_subnet.unmark()
else:
create_network_form.switch_to(self.SUBNET_TAB_INDEX)
create_network_form.subnet_name.text = subnet_name
if network_address is None:
network_address = self.conf.network.network_cidr
create_network_form.cidr.text = network_address
create_network_form.ip_version.value = ip_version
if gateway_ip is not None:
create_network_form.gateway_ip.text = gateway_ip
if disable_gateway:
create_network_form.disable_gateway.mark()
create_network_form.switch_to(self.DETAILS_TAB_INDEX)
if not enable_dhcp:
create_network_form.enable_dhcp.unmark()
if allocation_pools is not None:
create_network_form.allocation_pools.text = allocation_pools
if dns_name_servers is not None:
create_network_form.dns_nameservers.text = dns_name_servers
if host_routes is not None:
create_network_form.host_routes.text = host_routes
create_network_form.submit()
def delete_network(self, name):
row = self._get_row_with_network_name(name)
row.mark()
confirm_delete_networks_form = self.networks_table.delete_network()
confirm_delete_networks_form.submit()
def is_network_present(self, name):
return bool(self._get_row_with_network_name(name))
def is_network_active(self, name):
row = self._get_row_with_network_name(name)
def cell_getter():
return row.cells[self.NETWORKS_TABLE_STATUS_COLUMN]
try:
self._wait_till_text_present_in_element(cell_getter, 'Active')
except exceptions.TimeoutException:
return False
return True

View File

@ -0,0 +1,47 @@
# 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 openstack_dashboard.test.integration_tests import decorators
from openstack_dashboard.test.integration_tests import helpers
from openstack_dashboard.test.integration_tests.regions import messages
@decorators.services_required("neutron")
class TestNetworks(helpers.TestCase):
NETWORK_NAME = helpers.gen_random_resource_name("network")
SUBNET_NAME = helpers.gen_random_resource_name("subnet")
def test_private_network_create(self):
"""tests the network creation and deletion functionalities:
* creates a new private network and a new subnet associated with it
* verifies the network appears in the networks table as active
* deletes the newly created network
* verifies the network does not appear in the table after deletion
"""
networks_page = self.home_pg.go_to_network_networkspage()
networks_page.create_network(self.NETWORK_NAME, self.SUBNET_NAME)
self.assertTrue(
networks_page.find_message_and_dismiss(messages.SUCCESS))
self.assertFalse(
networks_page.find_message_and_dismiss(messages.ERROR))
self.assertTrue(networks_page.is_network_present(self.NETWORK_NAME))
self.assertTrue(networks_page.is_network_active(self.NETWORK_NAME))
networks_page.delete_network(self.NETWORK_NAME)
self.assertTrue(
networks_page.find_message_and_dismiss(messages.SUCCESS))
self.assertFalse(
networks_page.find_message_and_dismiss(messages.ERROR))
self.assertFalse(networks_page.is_network_present(self.NETWORK_NAME))