pytest-based selenium tests add tests stability improvements
Change-Id: I326048c7b952c34e65c398904ff3d2a94a81ac4a
This commit is contained in:
parent
116bd8ccdf
commit
0d6cad000a
@ -10,9 +10,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import time
|
||||
|
||||
import openstack as openstack_sdk
|
||||
from oslo_utils import uuidutils
|
||||
import pytest
|
||||
from selenium.common import exceptions
|
||||
|
||||
from openstack_dashboard.test.selenium.integration import test_volumes
|
||||
from openstack_dashboard.test.selenium import widgets
|
||||
@ -63,50 +66,53 @@ def openstack_demo(config):
|
||||
conn.close()
|
||||
|
||||
|
||||
def change_page_size(driver, config, page_size):
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'settings',
|
||||
))
|
||||
driver.get(url)
|
||||
# the text in page size field is rewritten after fully loaded page
|
||||
# repeated check
|
||||
for attempt in range(3):
|
||||
element = driver.find_element_by_id("id_pagesize")
|
||||
element.clear()
|
||||
element.send_keys(page_size)
|
||||
driver.find_element_by_css_selector(
|
||||
".btn-primary[value='Save']").click()
|
||||
try:
|
||||
driver.find_element_by_css_selector(
|
||||
f"#id_pagesize[value='{page_size}']")
|
||||
break
|
||||
except(exceptions.NoSuchElementException):
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def change_page_size_admin(login, config, driver):
|
||||
default_page_size = 20
|
||||
new_page_size = 1
|
||||
def change_size(page_size):
|
||||
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'settings',
|
||||
))
|
||||
driver.get(url)
|
||||
element = driver.find_element_by_xpath(
|
||||
".//input[@id='id_pagesize']")
|
||||
element.clear()
|
||||
element.send_keys(page_size)
|
||||
driver.find_element_by_xpath(".//input[@value='Save']").click()
|
||||
|
||||
change_size(new_page_size)
|
||||
login('admin')
|
||||
change_page_size(driver, config, new_page_size)
|
||||
yield
|
||||
change_size(default_page_size)
|
||||
change_page_size(driver, config, default_page_size)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def change_page_size_demo(login, config, driver):
|
||||
default_page_size = 20
|
||||
new_page_size = 1
|
||||
def change_size(page_size):
|
||||
|
||||
login('user')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'settings',
|
||||
))
|
||||
driver.get(url)
|
||||
element = driver.find_element_by_xpath(
|
||||
".//input[@id='id_pagesize']")
|
||||
element.clear()
|
||||
element.send_keys(page_size)
|
||||
driver.find_element_by_xpath(".//input[@value='Save']").click()
|
||||
|
||||
change_size(new_page_size)
|
||||
login('user')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'settings',
|
||||
))
|
||||
driver.get(url)
|
||||
change_page_size(driver, config, new_page_size)
|
||||
yield
|
||||
change_size(default_page_size)
|
||||
change_page_size(driver, config, default_page_size)
|
||||
|
||||
|
||||
def pytest_assertrepr_compare(op, left, right):
|
||||
|
@ -14,9 +14,11 @@ import os
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import pytest
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
from openstack_dashboard.test.selenium.integration import test_instances
|
||||
from openstack_dashboard.test.selenium import widgets
|
||||
@ -143,7 +145,7 @@ def test_image_create_from_local_file_demo(login, driver, image_names,
|
||||
temporary_file, clear_image_demo,
|
||||
config, openstack_demo):
|
||||
image_name = image_names[0]
|
||||
login('user', 'demo')
|
||||
login('user')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -170,7 +172,7 @@ def test_image_create_from_local_file_demo(login, driver, image_names,
|
||||
def test_image_delete_demo(login, driver, image_names, openstack_demo,
|
||||
new_image_demo, config):
|
||||
image_name = image_names[0]
|
||||
login('user', 'demo')
|
||||
login('user')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -203,7 +205,7 @@ def test_image_pagination_demo(login, driver, image_names, openstack_demo,
|
||||
third_page_definition = widgets.TableDefinition(next=False, prev=True,
|
||||
count=items_per_page,
|
||||
names=[img_list[2]])
|
||||
login('user', 'demo')
|
||||
login('user')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -242,7 +244,7 @@ def test_image_create_from_local_file_admin(login, driver, image_names,
|
||||
temporary_file, clear_image_admin,
|
||||
config, openstack_admin):
|
||||
image_name = image_names[0]
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -269,7 +271,7 @@ def test_image_create_from_local_file_admin(login, driver, image_names,
|
||||
def test_image_delete_admin(login, driver, image_names, openstack_admin,
|
||||
new_image_admin, config):
|
||||
image_name = image_names[0]
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -303,7 +305,7 @@ def test_image_pagination_admin(login, driver, image_names, openstack_admin,
|
||||
third_page_definition = widgets.TableDefinition(next=False, prev=True,
|
||||
count=items_per_page,
|
||||
names=[img_list[2]])
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -337,7 +339,7 @@ def test_image_pagination_admin(login, driver, image_names, openstack_admin,
|
||||
|
||||
def test_image_filtration_admin(login, driver, new_image_admin, config):
|
||||
image_name = new_image_admin.name
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -364,7 +366,7 @@ def test_remove_protected_image_admin(login, driver, image_names,
|
||||
new_protected_image_admin, config,
|
||||
openstack_admin):
|
||||
image_name = new_protected_image_admin.name
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -409,7 +411,7 @@ def test_edit_image_description_admin(login, driver, image_names,
|
||||
openstack_admin):
|
||||
image_name = new_image_admin.name
|
||||
new_description = "new_description_text"
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -446,7 +448,7 @@ def test_update_image_metadata_admin(login, driver,
|
||||
'metadata2': 'img_metadata%s' % uuidutils.generate_uuid(dashed=False)
|
||||
}
|
||||
image_name = new_image_admin.name
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -483,7 +485,7 @@ def test_launch_instance_from_image_admin(complete_default_test_network, login,
|
||||
image_name = new_image_admin.name
|
||||
network = complete_default_test_network.name
|
||||
flavor = config.launch_instances.flavor
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -525,7 +527,7 @@ def test_create_volume_from_image_admin(login, driver, volume_name,
|
||||
config, openstack_admin):
|
||||
volume_name = volume_name[0]
|
||||
image_name = new_image_admin.name
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -540,8 +542,10 @@ def test_create_volume_from_image_admin(login, driver, volume_name,
|
||||
name_field = driver.find_element_by_xpath("//input[@name='name']")
|
||||
name_field.clear()
|
||||
name_field.send_keys(volume_name)
|
||||
driver.find_element_by_xpath(
|
||||
"//button[@class='btn btn-primary finish']").click()
|
||||
create_vol_btn = WebDriverWait(driver, config.selenium.page_timeout).until(
|
||||
EC.element_to_be_clickable((By.XPATH, f"//button[@class='btn "
|
||||
f"btn-primary finish']")))
|
||||
create_vol_btn.click()
|
||||
messages = widgets.get_and_dismiss_messages(driver)
|
||||
assert f"Info: Creating volume {volume_name}" in messages
|
||||
assert openstack_admin.block_storage.find_volume(volume_name) is not None
|
||||
|
@ -10,7 +10,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from selenium.common import exceptions
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
@ -52,6 +55,26 @@ def clear_instance_admin(instance_name, openstack_admin):
|
||||
)
|
||||
|
||||
|
||||
def wait_for_angular_readiness_instance_source(driver):
|
||||
driver.set_script_timeout(10)
|
||||
driver.execute_async_script("""
|
||||
var callback = arguments[arguments.length - 1];
|
||||
var element = document.querySelector(\
|
||||
'div[ng-if="model.newInstanceSpec.vol_create == true"] .btn-group');
|
||||
if (!window.angular) {
|
||||
callback(false)
|
||||
}
|
||||
if (angular.getTestability) {
|
||||
angular.getTestability(element).whenStable(function(){callback(true)});
|
||||
} else {
|
||||
if (!angular.element(element).injector()) {
|
||||
callback(false)
|
||||
}
|
||||
var browser = angular.element(element).injector().get('$browser');
|
||||
browser.notifyWhenNoOutstandingRequests(function(){callback(true)});
|
||||
};""")
|
||||
|
||||
|
||||
def create_new_volume_during_create_instance(driver, required_state):
|
||||
create_new_volume_btn = widgets.find_already_visible_element_by_xpath(
|
||||
f".//*[@id='vol-create'][text()='{required_state}']", driver
|
||||
@ -67,13 +90,22 @@ def delete_volume_on_instance_delete(driver, required_state):
|
||||
|
||||
|
||||
def apply_instance_name_filter(driver, config, name_pattern):
|
||||
filter_field = driver.find_element_by_css_selector(
|
||||
"input[name='instances__filter__q']")
|
||||
filter_field.clear()
|
||||
filter_field.send_keys(name_pattern)
|
||||
driver.find_element_by_css_selector("#instances__action_filter").click()
|
||||
WebDriverWait(driver, config.selenium.page_timeout).until(
|
||||
EC.invisibility_of_element_located(filter_field))
|
||||
# the text in filter field is rewritten after fully loaded page
|
||||
# repeated check
|
||||
for attempt in range(3):
|
||||
filter_field = driver.find_element_by_css_selector(
|
||||
"input[name='instances__filter__q']")
|
||||
filter_field.clear()
|
||||
filter_field.send_keys(name_pattern)
|
||||
driver.find_element_by_id("instances__action_filter").click()
|
||||
WebDriverWait(driver, config.selenium.page_timeout).until(
|
||||
EC.invisibility_of_element_located(filter_field))
|
||||
try:
|
||||
driver.find_element_by_css_selector(
|
||||
f".table_search input[value='{name_pattern}']")
|
||||
break
|
||||
except(exceptions.NoSuchElementException):
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
def test_create_instance_demo(complete_default_test_network, login, driver,
|
||||
@ -108,6 +140,7 @@ def test_create_instance_demo(complete_default_test_network, login, driver,
|
||||
)
|
||||
widgets.select_from_transfer_table(flavor_table, flavor)
|
||||
navigation.find_element_by_link_text("Source").click()
|
||||
wait_for_angular_readiness_instance_source(driver)
|
||||
source_table = wizard.find_element_by_css_selector(
|
||||
"ng-include[ng-form=launchInstanceSourceForm]"
|
||||
)
|
||||
@ -161,6 +194,7 @@ def test_create_instance_from_volume_demo(complete_default_test_network, login,
|
||||
)
|
||||
widgets.select_from_transfer_table(flavor_table, flavor)
|
||||
navigation.find_element_by_link_text("Source").click()
|
||||
wait_for_angular_readiness_instance_source(driver)
|
||||
source_table = wizard.find_element_by_css_selector(
|
||||
"ng-include[ng-form=launchInstanceSourceForm]"
|
||||
)
|
||||
@ -235,19 +269,22 @@ def test_instance_pagination_demo(login, driver, instance_name,
|
||||
'instances'
|
||||
))
|
||||
driver.get(url)
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
# Turning to next page
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[0],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning back to previous page
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize('new_instance_demo', [(2, False)],
|
||||
@ -302,22 +339,26 @@ def test_instances_pagination_and_filtration_demo(login, driver, instance_name,
|
||||
driver.find_element_by_css_selector(
|
||||
"a[data-select-value='name']").click()
|
||||
apply_instance_name_filter(driver, config, instance_list[1])
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert filter_instance1_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert filter_instance1_def == current_table_status
|
||||
apply_instance_name_filter(driver, config, instance_list[0])
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert filter_instance2_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[0],
|
||||
sorting=True)
|
||||
assert filter_instance2_def == current_table_status
|
||||
apply_instance_name_filter(driver, config, instance_name)
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert common_filter_page1_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert common_filter_page1_def == current_table_status
|
||||
# Turning to next page
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert common_filter_page2_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[0],
|
||||
sorting=True)
|
||||
assert common_filter_page2_def == current_table_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize('new_instance_demo', [(2, False)],
|
||||
@ -339,7 +380,7 @@ def test_filter_instances_demo(login, driver, instance_name,
|
||||
instance_count = 2
|
||||
instance_list = [f"{instance_name}-{item}"
|
||||
for item in range(1, instance_count + 1)]
|
||||
login('user', 'demo')
|
||||
login('user')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -352,10 +393,11 @@ def test_filter_instances_demo(login, driver, instance_name,
|
||||
driver.find_element_by_css_selector(
|
||||
"a[data-select-value='name']").click()
|
||||
apply_instance_name_filter(driver, config, instance_list[1])
|
||||
current_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert(vars(current_page_definition)['names'][0] ==
|
||||
instance_list[1] and vars(current_page_definition)['count'] == 1)
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert (vars(current_table_status)['names'][0] == instance_list[1] and
|
||||
vars(current_table_status)['count'] == 1)
|
||||
# Generate random non existent image name
|
||||
random_instance_name = 'horizon_instance_%s' % \
|
||||
uuidutils.generate_uuid(dashed=False)
|
||||
@ -365,7 +407,7 @@ def test_filter_instances_demo(login, driver, instance_name,
|
||||
assert no_items_present
|
||||
|
||||
|
||||
# # Admin tests
|
||||
# Admin tests
|
||||
|
||||
|
||||
def test_create_instance_admin(complete_default_test_network, login, driver,
|
||||
@ -400,6 +442,7 @@ def test_create_instance_admin(complete_default_test_network, login, driver,
|
||||
)
|
||||
widgets.select_from_transfer_table(flavor_table, flavor)
|
||||
navigation.find_element_by_link_text("Source").click()
|
||||
wait_for_angular_readiness_instance_source(driver)
|
||||
source_table = wizard.find_element_by_css_selector(
|
||||
"ng-include[ng-form=launchInstanceSourceForm]"
|
||||
)
|
||||
@ -471,19 +514,22 @@ def test_instance_pagination_admin(login, driver, instance_name,
|
||||
'instances'
|
||||
))
|
||||
driver.get(url)
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
# Turning to next page
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[0],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning back to previous page
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize('new_instance_admin', [(2, False)],
|
||||
@ -539,22 +585,26 @@ def test_instances_pagination_and_filtration_admin(login, driver, instance_name,
|
||||
driver.find_element_by_css_selector(
|
||||
"a[data-select-value='name']").click()
|
||||
apply_instance_name_filter(driver, config, instance_list[1])
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert filter_instance1_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert filter_instance1_def == current_table_status
|
||||
apply_instance_name_filter(driver, config, instance_list[0])
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert filter_instance2_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[0],
|
||||
sorting=True)
|
||||
assert filter_instance2_def == current_table_status
|
||||
apply_instance_name_filter(driver, config, instance_name)
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert common_filter_page1_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert common_filter_page1_def == current_table_status
|
||||
# Turning to next page
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert common_filter_page2_def == actual_page_definition
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[0],
|
||||
sorting=True)
|
||||
assert common_filter_page2_def == current_table_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize('new_instance_admin', [(2, False)],
|
||||
@ -576,7 +626,7 @@ def test_filter_instances_admin(login, driver, instance_name,
|
||||
instance_count = 2
|
||||
instance_list = [f"{instance_name}-{item}"
|
||||
for item in range(1, instance_count + 1)]
|
||||
login('admin', 'admin')
|
||||
login('admin')
|
||||
url = '/'.join((
|
||||
config.dashboard.dashboard_url,
|
||||
'project',
|
||||
@ -589,10 +639,11 @@ def test_filter_instances_admin(login, driver, instance_name,
|
||||
driver.find_element_by_css_selector(
|
||||
"a[data-select-value='name']").click()
|
||||
apply_instance_name_filter(driver, config, instance_list[1])
|
||||
current_page_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert(vars(current_page_definition)['names'][0] ==
|
||||
instance_list[1] and vars(current_page_definition)['count'] == 1)
|
||||
current_table_status = widgets.get_table_status(driver, "instances",
|
||||
instance_list[1],
|
||||
sorting=True)
|
||||
assert (vars(current_table_status)['names'][0] == instance_list[1] and
|
||||
vars(current_table_status)['count'] == 1)
|
||||
# Generate random non existent image name
|
||||
random_instance_name = 'horizon_instance_%s' % \
|
||||
uuidutils.generate_uuid(dashed=False)
|
||||
|
@ -81,25 +81,13 @@ def new_interface(new_router_demo, new_network_demo, new_subnet_demo,
|
||||
@pytest.fixture
|
||||
def new_router_with_gateway(new_router_demo, openstack_demo, openstack_admin):
|
||||
network_id = openstack_admin.network.find_network('public').id
|
||||
subnet_id = openstack_admin.network.find_subnet('public-subnet').id
|
||||
ip_address = openstack_admin.network.find_subnet(
|
||||
'public-subnet').allocation_pools[0]['end']
|
||||
|
||||
openstack_demo.network.put(
|
||||
f"/routers/{new_router_demo.id}/add_external_gateways",
|
||||
f"/routers/{new_router_demo.id}",
|
||||
json={
|
||||
"router": {
|
||||
"external_gateways": [{
|
||||
"enable_snat": False,
|
||||
"external_fixed_ips": [{
|
||||
"ip_address": f"{ip_address}",
|
||||
"subnet_id": f"{subnet_id}"
|
||||
}],
|
||||
"network_id": f"{network_id}"
|
||||
}]
|
||||
}
|
||||
}
|
||||
).json()
|
||||
"external_gateway_info": {
|
||||
"network_id": f"{network_id}"}}}).json()
|
||||
yield new_router_demo
|
||||
|
||||
|
||||
|
@ -373,29 +373,34 @@ def test_volume_snapshots_pagination_demo(login, driver, volume_snapshot_names,
|
||||
'snapshots'
|
||||
))
|
||||
driver.get(url)
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
# Turning to next page(page2)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning to next page(page3)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page3_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert third_page_definition == actual_page3_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[0],
|
||||
sorting=True)
|
||||
assert third_page_definition == current_table_status
|
||||
# Turning back to previous page(page2)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning back to previous page(page1)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
|
||||
|
||||
def test_create_volume_snapshot_admin(login, driver, new_volume_admin,
|
||||
@ -523,26 +528,31 @@ def test_volume_snapshots_pagination_admin(login, driver, volume_snapshot_names,
|
||||
'snapshots'
|
||||
))
|
||||
driver.get(url)
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
# Turning to next page(page2)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning to next page(page3)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page3_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert third_page_definition == actual_page3_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[0],
|
||||
sorting=True)
|
||||
assert third_page_definition == current_table_status
|
||||
# Turning back to previous page(page2)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning back to previous page(page1)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volume_snapshots",
|
||||
volume_snapshot_names[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
|
@ -290,29 +290,34 @@ def test_volumes_pagination_demo(login, driver, volume_name,
|
||||
'volumes'
|
||||
))
|
||||
driver.get(url)
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
# Turning to next page(page2)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning to next page(page3)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page3_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert third_page_definition == actual_page3_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[0],
|
||||
sorting=True)
|
||||
assert third_page_definition == current_table_status
|
||||
# Turning back to previous page(page2)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning back to previous page(page1)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
|
||||
|
||||
# Not possible to detach volume from server via OpenstackSDK for
|
||||
@ -508,26 +513,31 @@ def test_volumes_pagination_admin(login, driver, volume_name,
|
||||
'volumes'
|
||||
))
|
||||
driver.get(url)
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
# Turning to next page(page2)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning to next page(page3)
|
||||
driver.find_element_by_link_text("Next »").click()
|
||||
actual_page3_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert third_page_definition == actual_page3_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[0],
|
||||
sorting=True)
|
||||
assert third_page_definition == current_table_status
|
||||
# Turning back to previous page(page2)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page2_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert second_page_definition == actual_page2_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[1],
|
||||
sorting=True)
|
||||
assert second_page_definition == current_table_status
|
||||
# Turning back to previous page(page1)
|
||||
driver.find_element_by_link_text("« Prev").click()
|
||||
actual_page1_definition = widgets.get_table_definition(driver,
|
||||
sorting=True)
|
||||
assert first_page_definition == actual_page1_definition
|
||||
current_table_status = widgets.get_table_status(driver, "volumes",
|
||||
volume_name[2],
|
||||
sorting=True)
|
||||
assert first_page_definition == current_table_status
|
||||
|
@ -86,14 +86,24 @@ def is_prev_link_available(driver):
|
||||
return False
|
||||
|
||||
|
||||
def get_table_definition(driver, sorting=False):
|
||||
names = driver.find_elements_by_css_selector('table tr td:nth-child(2)')
|
||||
def available_elements(driver, resource_type, name):
|
||||
try:
|
||||
driver.find_elements_by_css_selector(
|
||||
f"table#{resource_type} tr[data-display='{name}']")
|
||||
except (exceptions.NoSuchElementException):
|
||||
pass
|
||||
finally:
|
||||
return driver.find_elements_by_css_selector('table tr td:nth-child(2)')
|
||||
|
||||
|
||||
def get_table_status(driver, resource_type, name, sorting=False):
|
||||
elements = available_elements(driver, resource_type, name)
|
||||
if sorting:
|
||||
names = [name.text for name in names]
|
||||
names = [name.text for name in elements]
|
||||
names.sort()
|
||||
actual_table = TableDefinition(next=is_next_link_available(driver),
|
||||
prev=is_prev_link_available(driver),
|
||||
count=len(names), names=[names[0]])
|
||||
count=len(elements), names=[names[0]])
|
||||
return actual_table
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user