summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlassane Yattara <alassane.yattara@savoirfairelinux.com>2023-11-29 23:54:14 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-02 18:04:23 +0000
commit200541ec562910a583b2788fa27aba1ca7933112 (patch)
tree600ec8887eb3aaeb2097e8fca18bebf387002d68 /bitbake
parent5cd899da3944f2f3f2035f1b2e21593419c26689 (diff)
downloadpoky-200541ec562910a583b2788fa27aba1ca7933112.tar.gz
bitbake: toaster/tests: Bug-fix on tests/functional/test_project_page
- Generate a random name for create project while test - Set timeout on method _wait_until_build - update test_machines_page, test_softwareRecipe_page and test_single_layer_page to fix exception "element not interactable" (Bitbake rev: 51c051da61a0396bdaa965065796476de7340727) Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/tests/functional/test_project_page.py64
1 files changed, 32 insertions, 32 deletions
diff --git a/bitbake/lib/toaster/tests/functional/test_project_page.py b/bitbake/lib/toaster/tests/functional/test_project_page.py
index dd33e80256..7082950986 100644
--- a/bitbake/lib/toaster/tests/functional/test_project_page.py
+++ b/bitbake/lib/toaster/tests/functional/test_project_page.py
@@ -6,12 +6,15 @@
6# SPDX-License-Identifier: GPL-2.0-only 6# SPDX-License-Identifier: GPL-2.0-only
7# 7#
8 8
9import random
10import string
9import pytest 11import pytest
10from time import sleep 12from time import sleep
11from django.urls import reverse 13from django.urls import reverse
12from django.utils import timezone 14from django.utils import timezone
15from selenium.webdriver.common.keys import Keys
13from selenium.webdriver.support.select import Select 16from selenium.webdriver.support.select import Select
14from selenium.common.exceptions import NoSuchElementException 17from selenium.common.exceptions import NoSuchElementException, TimeoutException
15from tests.functional.functional_helpers import SeleniumFunctionalTestCase 18from tests.functional.functional_helpers import SeleniumFunctionalTestCase
16from orm.models import Build, Project, Target 19from orm.models import Build, Project, Target
17from selenium.webdriver.common.by import By 20from selenium.webdriver.common.by import By
@@ -23,13 +26,18 @@ class TestProjectPage(SeleniumFunctionalTestCase):
23 def setUp(self): 26 def setUp(self):
24 super().setUp() 27 super().setUp()
25 release = '3' 28 release = '3'
26 project_name = 'projectmaster' 29 project_name = 'project_' + self.generate_random_string()
27 self._create_test_new_project( 30 self._create_test_new_project(
28 project_name, 31 project_name,
29 release, 32 release,
30 False, 33 False,
31 ) 34 )
32 35
36 def generate_random_string(self, length=10):
37 characters = string.ascii_letters + string.digits # alphabetic and numerical characters
38 random_string = ''.join(random.choice(characters) for _ in range(length))
39 return random_string
40
33 def _create_test_new_project( 41 def _create_test_new_project(
34 self, 42 self,
35 project_name, 43 project_name,
@@ -204,7 +212,13 @@ class TestProjectPage(SeleniumFunctionalTestCase):
204 test_show_rows(row_to_show, show_row_link) 212 test_show_rows(row_to_show, show_row_link)
205 213
206 def _wait_until_build(self, state): 214 def _wait_until_build(self, state):
215 timeout = 10
216 start_time = 0
207 while True: 217 while True:
218 if start_time > timeout:
219 raise TimeoutException(
220 f'Build did not reach {state} state within {timeout} seconds'
221 )
208 try: 222 try:
209 last_build_state = self.driver.find_element( 223 last_build_state = self.driver.find_element(
210 By.XPATH, 224 By.XPATH,
@@ -217,7 +231,8 @@ class TestProjectPage(SeleniumFunctionalTestCase):
217 break 231 break
218 except NoSuchElementException: 232 except NoSuchElementException:
219 continue 233 continue
220 sleep(1) 234 start_time += 1
235 sleep(1) # take a breath and try again
221 236
222 def _mixin_test_table_search_input(self, **kwargs): 237 def _mixin_test_table_search_input(self, **kwargs):
223 input_selector, input_text, searchBtn_selector, table_selector, *_ = kwargs.values() 238 input_selector, input_text, searchBtn_selector, table_selector, *_ = kwargs.values()
@@ -380,11 +395,9 @@ class TestProjectPage(SeleniumFunctionalTestCase):
380 self.wait_until_visible('#topbar-configuration-tab') 395 self.wait_until_visible('#topbar-configuration-tab')
381 config_tab = self.find('#topbar-configuration-tab') 396 config_tab = self.find('#topbar-configuration-tab')
382 self.assertTrue(config_tab.get_attribute('class') == 'active') 397 self.assertTrue(config_tab.get_attribute('class') == 'active')
383 self.assertTrue('Configuration' in config_tab.text) 398 self.assertTrue('Configuration' in str(config_tab.text))
384 config_tab_link = config_tab.find_element(By.TAG_NAME, 'a')
385 self.assertTrue( 399 self.assertTrue(
386 f"/toastergui/project/1" in str(config_tab_link.get_attribute( 400 f"/toastergui/project/1" in str(self.driver.current_url)
387 'href'))
388 ) 401 )
389 402
390 def get_tabs(): 403 def get_tabs():
@@ -464,10 +477,10 @@ class TestProjectPage(SeleniumFunctionalTestCase):
464 image_to_build = rows[0] 477 image_to_build = rows[0]
465 build_btn = image_to_build.find_element( 478 build_btn = image_to_build.find_element(
466 By.XPATH, 479 By.XPATH,
467 '//td[@class="add-del-layers"]' 480 '//td[@class="add-del-layers"]//a[1]'
468 ) 481 )
469 build_btn.click() 482 build_btn.click()
470 self._wait_until_build('parsing starting cloning') 483 self._wait_until_build('parsing starting cloning queued')
471 lastest_builds = self.driver.find_elements( 484 lastest_builds = self.driver.find_elements(
472 By.XPATH, 485 By.XPATH,
473 '//div[@id="latest-builds"]/div' 486 '//div[@id="latest-builds"]/div'
@@ -517,9 +530,9 @@ class TestProjectPage(SeleniumFunctionalTestCase):
517 machine_to_select = rows[0] 530 machine_to_select = rows[0]
518 select_btn = machine_to_select.find_element( 531 select_btn = machine_to_select.find_element(
519 By.XPATH, 532 By.XPATH,
520 '//td[@class="add-del-layers"]' 533 '//td[@class="add-del-layers"]//a[1]'
521 ) 534 )
522 select_btn.click() 535 select_btn.send_keys(Keys.RETURN)
523 self.wait_until_visible('#config-nav') 536 self.wait_until_visible('#config-nav')
524 project_machine_name = self.find('#project-machine-name') 537 project_machine_name = self.find('#project-machine-name')
525 self.assertTrue( 538 self.assertTrue(
@@ -530,32 +543,19 @@ class TestProjectPage(SeleniumFunctionalTestCase):
530 # Search for a machine whit layer not in project 543 # Search for a machine whit layer not in project
531 self._mixin_test_table_search_input( 544 self._mixin_test_table_search_input(
532 input_selector='search-input-machinestable', 545 input_selector='search-input-machinestable',
533 input_text='qemux86-64-screen', 546 input_text='qemux86-64-tpm2',
534 searchBtn_selector='search-submit-machinestable', 547 searchBtn_selector='search-submit-machinestable',
535 table_selector='machinestable' 548 table_selector='machinestable'
536 ) 549 )
537 rows = self.find_all('#machinestable tbody tr') 550 rows = self.find_all('#machinestable tbody tr')
538 machine_to_add = rows[0] 551 machine_to_add = rows[0]
539 add_btn = machine_to_add.find_element( 552 add_btn = machine_to_add.find_element(By.XPATH, '//td[@class="add-del-layers"]')
540 By.XPATH,
541 '//td[@class="add-del-layers"]'
542 )
543 add_btn.click() 553 add_btn.click()
544 # check modal is displayed
545 self.wait_until_visible('#dependencies-modal')
546 list_dependencies = self.find_all('#dependencies-list li')
547 # click on add-layers button
548 add_layers_btn = self.driver.find_element(
549 By.XPATH,
550 '//form[@id="dependencies-modal-form"]//button[@class="btn btn-primary"]'
551 )
552 add_layers_btn.click()
553 self.wait_until_visible('#change-notification') 554 self.wait_until_visible('#change-notification')
554 change_notification = self.find('#change-notification') 555 change_notification = self.find('#change-notification')
555 self.assertTrue( 556 self.assertTrue(
556 f'You have added {len(list_dependencies)+1} layers to your project: meta-tanowrt and its dependencies' in change_notification.text 557 f'You have added 1 layer to your project' in str(change_notification.text)
557 ) 558 )
558
559 # check Machine table feature(show/hide column, pagination) 559 # check Machine table feature(show/hide column, pagination)
560 self._navigate_to_config_nav('machinestable', 5) 560 self._navigate_to_config_nav('machinestable', 5)
561 column_list = [ 561 column_list = [
@@ -601,7 +601,7 @@ class TestProjectPage(SeleniumFunctionalTestCase):
601 ) 601 )
602 add_btn.click() 602 add_btn.click()
603 # check modal is displayed 603 # check modal is displayed
604 self.wait_until_visible('#dependencies-modal') 604 self.wait_until_visible('#dependencies-modal', poll=2)
605 list_dependencies = self.find_all('#dependencies-list li') 605 list_dependencies = self.find_all('#dependencies-list li')
606 # click on add-layers button 606 # click on add-layers button
607 add_layers_btn = self.driver.find_element( 607 add_layers_btn = self.driver.find_element(
@@ -612,7 +612,7 @@ class TestProjectPage(SeleniumFunctionalTestCase):
612 self.wait_until_visible('#change-notification') 612 self.wait_until_visible('#change-notification')
613 change_notification = self.find('#change-notification') 613 change_notification = self.find('#change-notification')
614 self.assertTrue( 614 self.assertTrue(
615 f'You have added {len(list_dependencies)+1} layers to your project: {input_text} and its dependencies' in change_notification.text 615 f'You have added {len(list_dependencies)+1} layers to your project: {input_text} and its dependencies' in str(change_notification.text)
616 ) 616 )
617 # check "Remove layer" button works 617 # check "Remove layer" button works
618 rows = self.find_all('#layerstable tbody tr') 618 rows = self.find_all('#layerstable tbody tr')
@@ -625,7 +625,7 @@ class TestProjectPage(SeleniumFunctionalTestCase):
625 self.wait_until_visible('#change-notification', poll=2) 625 self.wait_until_visible('#change-notification', poll=2)
626 change_notification = self.find('#change-notification') 626 change_notification = self.find('#change-notification')
627 self.assertTrue( 627 self.assertTrue(
628 f'You have removed 1 layer from your project: {input_text}' in change_notification.text 628 f'You have removed 1 layer from your project: {input_text}' in str(change_notification.text)
629 ) 629 )
630 # check layers table feature(show/hide column, pagination) 630 # check layers table feature(show/hide column, pagination)
631 self._navigate_to_config_nav('layerstable', 6) 631 self._navigate_to_config_nav('layerstable', 6)
@@ -668,13 +668,13 @@ class TestProjectPage(SeleniumFunctionalTestCase):
668 distro_to_add = rows[0] 668 distro_to_add = rows[0]
669 add_btn = distro_to_add.find_element( 669 add_btn = distro_to_add.find_element(
670 By.XPATH, 670 By.XPATH,
671 '//td[@class="add-del-layers"]' 671 '//td[@class="add-del-layers"]//a[1]'
672 ) 672 )
673 add_btn.click() 673 add_btn.click()
674 self.wait_until_visible('#change-notification', poll=2) 674 self.wait_until_visible('#change-notification', poll=2)
675 change_notification = self.find('#change-notification') 675 change_notification = self.find('#change-notification')
676 self.assertTrue( 676 self.assertTrue(
677 f'You have changed the distro to: {input_text}' in change_notification.text 677 f'You have changed the distro to: {input_text}' in str(change_notification.text)
678 ) 678 )
679 # check distro table feature(show/hide column, pagination) 679 # check distro table feature(show/hide column, pagination)
680 self._navigate_to_config_nav('distrostable', 7) 680 self._navigate_to_config_nav('distrostable', 7)