Merge "pytest-based selenium tests add default network + video recording fix"

This commit is contained in:
Zuul 2023-11-20 22:03:35 +00:00 committed by Gerrit Code Review
commit 98b4b8a59d
4 changed files with 96 additions and 28 deletions

View File

@ -124,10 +124,10 @@ def record_video(request, report_dir, xdisplay):
display, width, height = xdisplay
command = [
'ffmpeg',
'-video_size', '{}x{}'.format(width, height),
'-video_size', f'{width}x{height}',
'-framerate', str(frame_rate),
'-f', 'x11grab',
'-i', display,
'-i', f':{display}',
filepath,
]
fnull = open(os.devnull, 'w')

View File

@ -114,3 +114,72 @@ def pytest_assertrepr_compare(op, left, right):
"Comparing TableDefinition instances:",
" vals: {} != {}".format(left, right),
]
# Create default test network (contains subnet and is connected to public
# network via router)
@pytest.fixture(scope='session')
def new_default_test_network(openstack_admin):
network = openstack_admin.network.create_network(
name="default_test_network",
is_shared=True,
)
yield network
openstack_admin.network.delete_network(network)
@pytest.fixture(scope='session')
def new_default_test_subnet(new_default_test_network, openstack_admin):
subnet_name = "default_test_subnet"
subnet = openstack_admin.network.create_subnet(
name=subnet_name,
network_id=new_default_test_network.id,
ip_version=4,
cidr="10.10.0.0/16",
)
yield subnet
openstack_admin.delete_subnet(subnet)
@pytest.fixture(scope='session')
def new_default_test_router(openstack_admin):
public_network = openstack_admin.network.find_network('public')
public_subnet = openstack_admin.network.find_subnet('public-subnet')
router = openstack_admin.network.post("/routers", json={
"router": {
"name": "default_test_router",
"external_gateway_info": {
"network_id": public_network.id,
"enable_snat": True,
"external_fixed_ips": [{
"subnet_id": public_subnet.id
}]
},
"admin_state_up": True
}
}).json()
yield router
openstack_admin.network.delete_router(router['router']['id'])
@pytest.fixture(scope='session')
def new_default_test_interface_for_router(new_default_test_router,
new_default_test_subnet,
openstack_admin):
interface = openstack_admin.network.add_interface_to_router(
router=new_default_test_router['router']['id'],
subnet_id=new_default_test_subnet.id,
)
yield interface
openstack_admin.network.remove_interface_from_router(
router=new_default_test_router['router']['id'],
subnet_id=new_default_test_subnet.id)
@pytest.fixture(scope='session')
def complete_default_test_network(new_default_test_network,
new_default_test_subnet,
new_default_test_router,
new_default_test_interface_for_router):
yield new_default_test_network

View File

@ -111,8 +111,6 @@ def test_release_floatingip(login, driver, openstack_demo, config,
new_floating_ip.floating_ip_address) is None
@pytest.mark.parametrize('new_instance_demo', [(1, "private", False)],
indirect=True)
def test_associate_floatingip(login, driver, openstack_demo, new_floating_ip,
config, instance_name, new_instance_demo):
login('user')
@ -142,7 +140,7 @@ def test_associate_floatingip(login, driver, openstack_demo, new_floating_ip,
new_floating_ip.floating_ip_address).port_details['device_id'])
@pytest.mark.parametrize('new_instance_demo', [(1, "private", True)],
@pytest.mark.parametrize('new_instance_demo', [(1, True)],
indirect=True)
def test_disassociate_floatingip(login, driver, openstack_demo, config,
instance_name, new_instance_demo,

View File

@ -17,32 +17,31 @@ from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
import test_volumes
from openstack_dashboard.test.selenium import widgets
# Imported fixtures
volume_name = test_volumes.volume_name
new_volume_demo = test_volumes.new_volume_demo
default_network = "shared"
@pytest.fixture
def instance_name():
return 'horizon_instance_%s' % uuidutils.generate_uuid(dashed=False)
@pytest.fixture(params=[(1, default_network, False)])
def new_instance_demo(request, instance_name, openstack_demo, config):
@pytest.fixture(params=[(1, False)])
def new_instance_demo(complete_default_test_network, request, instance_name,
openstack_demo, config):
count = request.param[0]
network_param = request.param[1]
auto_ip_param = request.param[2]
auto_ip_param = request.param[1]
instance = openstack_demo.create_server(
instance_name,
image=config.image.images_list[0],
flavor=config.launch_instances.flavor,
availability_zone=config.launch_instances.available_zone,
network=network_param,
network=complete_default_test_network.name,
auto_ip=auto_ip_param,
wait=True,
max_count=count,
@ -55,18 +54,18 @@ def new_instance_demo(request, instance_name, openstack_demo, config):
openstack_demo.delete_server(instance_name)
@pytest.fixture(params=[(1, default_network, False)])
def new_instance_admin(request, instance_name, openstack_admin, config):
@pytest.fixture(params=[(1, False)])
def new_instance_admin(complete_default_test_network, request, instance_name,
openstack_admin, config):
count = request.param[0]
network_param = request.param[1]
auto_ip_param = request.param[2]
auto_ip_param = request.param[1]
instance = openstack_admin.create_server(
instance_name,
image=config.image.images_list[0],
flavor=config.launch_instances.flavor,
availability_zone=config.launch_instances.available_zone,
network=network_param,
network=complete_default_test_network.name,
auto_ip=auto_ip_param,
wait=True,
max_count=count,
@ -130,10 +129,11 @@ def delete_volume_on_instance_delete(driver, required_state):
delete_volume_btn.click()
def test_create_instance_demo(login, driver, instance_name, openstack_demo,
def test_create_instance_demo(complete_default_test_network, login, driver,
instance_name, openstack_demo,
clear_instance_demo, config):
image = config.image.images_list[0]
network = default_network
network = complete_default_test_network.name
flavor = config.launch_instances.flavor
login('user')
@ -181,11 +181,11 @@ def test_create_instance_demo(login, driver, instance_name, openstack_demo,
assert openstack_demo.compute.find_server(instance_name) is not None
def test_create_instance_from_volume_demo(login, driver, instance_name,
volume_name, new_volume_demo,
def test_create_instance_from_volume_demo(complete_default_test_network, login,
driver, volume_name, new_volume_demo,
clear_instance_demo, config,
openstack_demo):
network = default_network
openstack_demo, instance_name):
network = complete_default_test_network.name
flavor = config.launch_instances.flavor
volume_name = volume_name[0]
@ -251,7 +251,7 @@ def test_delete_instance_demo(login, driver, instance_name, openstack_demo,
assert openstack_demo.compute.find_server(instance_name) is None
@pytest.mark.parametrize('new_instance_demo', [(2, default_network, False)],
@pytest.mark.parametrize('new_instance_demo', [(2, False)],
indirect=True)
def test_instance_pagination_demo(login, driver, instance_name,
new_instance_demo, change_page_size_demo,
@ -303,13 +303,14 @@ def test_instance_pagination_demo(login, driver, instance_name,
assert first_page_definition == actual_page1_definition
# Admin tests
# # Admin tests
def test_create_instance_admin(login, driver, instance_name, openstack_admin,
def test_create_instance_admin(complete_default_test_network, login, driver,
instance_name, openstack_admin,
clear_instance_admin, config):
image = config.image.images_list[0]
network = default_network
network = complete_default_test_network.name
flavor = config.launch_instances.flavor
login('admin')
@ -371,7 +372,7 @@ def test_delete_instance_admin(login, driver, instance_name, openstack_admin,
assert openstack_admin.compute.find_server(instance_name) is None
@pytest.mark.parametrize('new_instance_admin', [(2, default_network, False)],
@pytest.mark.parametrize('new_instance_admin', [(2, False)],
indirect=True)
def test_instance_pagination_admin(login, driver, instance_name,
new_instance_admin, change_page_size_admin,