summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-10-18 22:39:57 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-10-24 11:24:03 +0100
commit23483ff489f99c4c5f7b33b75d15592fbb1bfde2 (patch)
treecde57b8c16b33c37f5b9498855696a52201504f9 /bitbake/lib
parentbac01b075611065a087aeb6efe1f85ee751737d8 (diff)
downloadpoky-23483ff489f99c4c5f7b33b75d15592fbb1bfde2.tar.gz
bitbake: toaster/tests/functiona/project_page_tab_config: Improve waits and drop polling
Drop the poll parameters and make the waits much more specific for the requirements of the tests. This includes looping waiting for a list of layer elements as that code was previously particularly fragile. (Bitbake rev: cf6b8e8aa5484110a41377ba42b3fdd9d6efd877) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py52
1 files changed, 32 insertions, 20 deletions
diff --git a/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py b/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py
index daf00d8f1d..80c53e1544 100644
--- a/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py
+++ b/bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py
@@ -7,12 +7,12 @@
7# 7#
8 8
9import string 9import string
10import time
10import pytest 11import pytest
11from django.urls import reverse 12from django.urls import reverse
12from selenium.webdriver import Keys 13from selenium.webdriver import Keys
13from selenium.webdriver.support.select import Select 14from selenium.webdriver.support.select import Select
14from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException, TimeoutException 15from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException, TimeoutException
15from orm.models import Project
16from tests.functional.functional_helpers import SeleniumFunctionalTestCase 16from tests.functional.functional_helpers import SeleniumFunctionalTestCase
17from selenium.webdriver.common.by import By 17from selenium.webdriver.common.by import By
18 18
@@ -210,7 +210,7 @@ class TestProjectConfigTab(TestProjectConfigTabBase):
210 def test_show_rows(row_to_show, show_row_link): 210 def test_show_rows(row_to_show, show_row_link):
211 # Check that we can show rows == row_to_show 211 # Check that we can show rows == row_to_show
212 show_row_link.select_by_value(str(row_to_show)) 212 show_row_link.select_by_value(str(row_to_show))
213 self.wait_until_visible('#imagerecipestable tbody tr', poll=3) 213 self.wait_until_visible('#imagerecipestable tbody tr')
214 # check at least some rows are visible 214 # check at least some rows are visible
215 self.assertTrue( 215 self.assertTrue(
216 len(self.find_all('#imagerecipestable tbody tr')) > 0 216 len(self.find_all('#imagerecipestable tbody tr')) > 0
@@ -289,6 +289,9 @@ class TestProjectConfigTab(TestProjectConfigTabBase):
289 self.assertIn( 289 self.assertIn(
290 f'You have changed the {item_name} to: {new_item_name}', change_notification.text 290 f'You have changed the {item_name} to: {new_item_name}', change_notification.text
291 ) 291 )
292 hide_button = self.find('#hide-alert')
293 hide_button.click()
294 self.wait_until_not_visible('#change-notification')
292 295
293 # Machine 296 # Machine
294 check_machine_distro(self, 'machine', 'qemux86-64', 'machine-section') 297 check_machine_distro(self, 'machine', 'qemux86-64', 'machine-section')
@@ -304,35 +307,44 @@ class TestProjectConfigTab(TestProjectConfigTabBase):
304 # Layers 307 # Layers
305 title = layers.find_element(By.TAG_NAME, 'h3') 308 title = layers.find_element(By.TAG_NAME, 'h3')
306 self.assertIn("Layers", title.text) 309 self.assertIn("Layers", title.text)
310 self.wait_until_clickable('#layer-add-input')
307 # check at least three layers are displayed 311 # check at least three layers are displayed
308 # openembedded-core 312 # openembedded-core
309 # meta-poky 313 # meta-poky
310 # meta-yocto-bsp 314 # meta-yocto-bsp
311 layers_list = layers.find_element(By.ID, 'layers-in-project-list') 315 layer_list_items = []
312 layers_list_items = layers_list.find_elements(By.TAG_NAME, 'li') 316 starttime = time.time()
317 while len(layer_list_items) < 3:
318 layers_list = self.driver.find_element(By.ID, 'layers-in-project-list')
319 layer_list_items = layers_list.find_elements(By.TAG_NAME, 'li')
320 if time.time() > (starttime + 30):
321 self.fail("Layer list didn't contain at least 3 items within 30s (contained %d)" % len(layer_list_items))
322
313 # remove all layers except the first three layers 323 # remove all layers except the first three layers
314 for i in range(3, len(layers_list_items)): 324 for i in range(3, len(layer_list_items)):
315 layers_list_items[i].find_element(By.TAG_NAME, 'span').click() 325 layer_list_items[i].find_element(By.TAG_NAME, 'span').click()
326
316 # check can add a layer if exists 327 # check can add a layer if exists
317 add_layer_input = layers.find_element(By.ID, 'layer-add-input') 328 add_layer_input = layers.find_element(By.ID, 'layer-add-input')
318 add_layer_input.send_keys('meta-oe') 329 add_layer_input.send_keys('meta-oe')
319 self.wait_until_visible('#layer-container > form > div > span > div') 330 self.wait_until_visible('#layer-container > form > div > span > div')
320 dropdown_item = self.driver.find_element( 331 self.wait_until_visible('.dropdown-menu')
321 By.XPATH, 332 finder = lambda driver: driver.find_element(By.XPATH, '//*[@id="layer-container"]/form/div/span/div/div/div')
322 '//*[@id="layer-container"]/form/div/span/div' 333 dropdown_item = self.wait_until_element_clickable(finder)
323 ) 334 dropdown_item.click()
324 try: 335 self.wait_until_clickable('#add-layer-btn')
325 dropdown_item.click()
326 except ElementClickInterceptedException:
327 self.skipTest(
328 "layer-container dropdown item click intercepted. Element not properly visible.")
329 add_layer_btn = layers.find_element(By.ID, 'add-layer-btn') 336 add_layer_btn = layers.find_element(By.ID, 'add-layer-btn')
330 add_layer_btn.click() 337 add_layer_btn.click()
331 self.wait_until_visible('#layers-in-project-list') 338 self.wait_until_visible('#layers-in-project-list')
332 # check layer is added
333 layers_list_items = layers_list.find_elements(By.TAG_NAME, 'li')
334 self.assertEqual(len(layers_list_items), 4)
335 339
340 # check layer is added
341 layer_list_items = []
342 starttime = time.time()
343 while len(layer_list_items) < 4:
344 layers_list = self.driver.find_element(By.ID, 'layers-in-project-list')
345 layer_list_items = layers_list.find_elements(By.TAG_NAME, 'li')
346 if time.time() > (starttime + 30):
347 self.fail("Layer list didn't contain at least 4 items within 30s (contained %d)" % len(layer_list_items))
336 348
337 def test_project_page_tab_importlayer(self): 349 def test_project_page_tab_importlayer(self):
338 """ Test project page tab import layer """ 350 """ Test project page tab import layer """
@@ -476,7 +488,7 @@ class TestProjectConfigTabDB(TestProjectConfigTabBase):
476 # back to project page 488 # back to project page
477 self.driver.get(url) 489 self.driver.get(url)
478 490
479 self.wait_until_visible('#project-page', poll=3) 491 self.wait_until_visible('#project-page')
480 492
481 # Most built recipes 493 # Most built recipes
482 most_built_recipes = self.driver.find_element( 494 most_built_recipes = self.driver.find_element(
@@ -484,7 +496,7 @@ class TestProjectConfigTabDB(TestProjectConfigTabBase):
484 title = most_built_recipes.find_element(By.TAG_NAME, 'h3') 496 title = most_built_recipes.find_element(By.TAG_NAME, 'h3')
485 self.assertIn("Most built recipes", title.text) 497 self.assertIn("Most built recipes", title.text)
486 # check can select a recipe and build it 498 # check can select a recipe and build it
487 self.wait_until_visible('#freq-build-list', poll=3) 499 self.wait_until_visible('#freq-build-list')
488 recipe_list = self.find('#freq-build-list') 500 recipe_list = self.find('#freq-build-list')
489 recipe_list_items = recipe_list.find_elements(By.TAG_NAME, 'li') 501 recipe_list_items = recipe_list.find_elements(By.TAG_NAME, 'li')
490 self.assertTrue( 502 self.assertTrue(