From 098d0a27b7e531feffbb8ad20ce84f1ba836d666 Mon Sep 17 00:00:00 2001 From: antip00 Date: Fri, 25 Oct 2024 10:12:53 +0300 Subject: [PATCH 1/6] Fixing tests for new grafana versions. --- tests/testflows/regression.py | 5 +- tests/testflows/steps/actions.py | 7 +- tests/testflows/steps/dashboard/locators.py | 32 +- tests/testflows/steps/dashboard/view.py | 24 +- tests/testflows/steps/panel/locators.py | 29 +- .../steps/panel/query_options/locators.py | 2 +- tests/testflows/steps/panel/view.py | 26 +- tests/testflows/steps/ui.py | 5 +- tests/testflows/tests/automated/e2e.py | 93 ++- .../tests/automated/legacy_alerts.py | 18 +- .../{query_settings.py => query_options.py} | 10 +- tests/testflows/tests/automated/sql_editor.py | 658 +++++++++--------- .../tests/automated/unified_alerts.py | 4 +- 13 files changed, 481 insertions(+), 432 deletions(-) rename tests/testflows/tests/automated/{query_settings.py => query_options.py} (97%) diff --git a/tests/testflows/regression.py b/tests/testflows/regression.py index 9815bf41b..f5ada3295 100755 --- a/tests/testflows/regression.py +++ b/tests/testflows/regression.py @@ -45,6 +45,9 @@ def argparser(parser): ], "/Grafana Datasource Plugin For Clickhouse/data source setup/check default values datetime64/": [ (Error, "https://github.com/Altinity/clickhouse-grafana/issues/630") + ], + "/Grafana Datasource Plugin For Clickhouse/sql editor/extrapolation toggle/":[ + (Error, "Run Query button do not update time ranges") ] } @@ -109,7 +112,7 @@ def regression(self, before, after): Feature(run=load("testflows.tests.automated.sql_editor", "feature")) Feature(run=load("testflows.tests.automated.data_source_setup", "feature")) Feature(run=load("testflows.tests.automated.e2e", "feature")) - Feature(run=load("testflows.tests.automated.query_settings", "feature")) + Feature(run=load("testflows.tests.automated.query_options", "feature")) Feature(run=load("testflows.tests.automated.unified_alerts", "feature")) self.context.grafana_version = "10.4.3" diff --git a/tests/testflows/steps/actions.py b/tests/testflows/steps/actions.py index eaf9c42b3..e4a2252c7 100644 --- a/tests/testflows/steps/actions.py +++ b/tests/testflows/steps/actions.py @@ -28,7 +28,7 @@ def compare_screenshots(self, screenshot_name_1, screenshot_name_2): @TestStep(Given) -def create_dashboard(self, dashboard_name, open_it=True): +def create_dashboard(self, dashboard_name, open_it=True, finally_save_dashboard=True): """Create new dashboard named {dashboard_name} and open it.""" try: for attempt in retries(delay=10, timeout=120): @@ -51,6 +51,11 @@ def create_dashboard(self, dashboard_name, open_it=True): dashboards.open_dashboard(dashboard_name=dashboard_name) yield finally: + if finally_save_dashboard: + with Finally("I save changes for dashboard"): + with delay(): + panel.save_dashboard() + with Finally(f"I delete dashboard {dashboard_name}"): dashboards.delete_dashboard(dashboard_name=dashboard_name) diff --git a/tests/testflows/steps/dashboard/locators.py b/tests/testflows/steps/dashboard/locators.py index b70059e74..f31a018e7 100644 --- a/tests/testflows/steps/dashboard/locators.py +++ b/tests/testflows/steps/dashboard/locators.py @@ -7,35 +7,45 @@ class Locators: # Locators for dashboard page def panel(self, panel_name): - driver: WebDriver = current().context.driver return driver.find_element(SelectBy.CSS_SELECTOR, f"[data-testid='data-testid Panel header {panel_name}']") def menu_button_for_panel(self, panel_name): - driver: WebDriver = current().context.driver return driver.find_element(SelectBy.CSS_SELECTOR, f"[data-testid='data-testid Panel menu {panel_name}']") def edit_button_for_panel(self): - driver: WebDriver = current().context.driver return driver.find_element(SelectBy.CSS_SELECTOR, f"[data-testid='data-testid Panel menu item Edit']") - @property - def save_dashboard(self): + + + def save_dashboard(self, grafana_version): driver: WebDriver = current().context.driver - return driver.find_element(SelectBy.CSS_SELECTOR, f"[aria-label='Save dashboard']") + if not (grafana_version is None) and (int(grafana_version.split(".")[0]) <= 10): + return driver.find_element(SelectBy.CSS_SELECTOR, f"[aria-label='Save dashboard']") + else: + return driver.find_element(SelectBy.CSS_SELECTOR, f"[data-testid='data-testid Save dashboard button']") - @property - def save_dashboard_title(self): + def save_dashboard_title(self, grafana_version): + driver: WebDriver = current().context.driver + if not (grafana_version is None) and (int(grafana_version.split(".")[0]) <= 10): + return driver.find_element(SelectBy.CSS_SELECTOR, f"[class ='css-8tk2dk-input-input']") + else: + return driver.find_element(SelectBy.CSS_SELECTOR, f"[data-testid='Save dashboard title field']") + def save_dashboard_button(self, grafana_version): driver: WebDriver = current().context.driver - return driver.find_element(SelectBy.CSS_SELECTOR, f"[class ='css-8tk2dk-input-input']") + if not (grafana_version is None) and (int(grafana_version.split(".")[0]) <= 10): + return driver.find_element(SelectBy.CSS_SELECTOR, f"[class ='css-td06pi-button']") + else: + return driver.find_element(SelectBy.CSS_SELECTOR, + f"[data-testid='data-testid Save dashboard drawer button']") @property - def save_dashboard_button(self): + def edit_button(self): driver: WebDriver = current().context.driver - return driver.find_element(SelectBy.CSS_SELECTOR, f"[class ='css-td06pi-button']") + return driver.find_element(SelectBy.CSS_SELECTOR, f"[data-testid='data-testid Edit dashboard button']") @property def add_button(self): diff --git a/tests/testflows/steps/dashboard/view.py b/tests/testflows/steps/dashboard/view.py index c55193073..2dbc9bbc9 100644 --- a/tests/testflows/steps/dashboard/view.py +++ b/tests/testflows/steps/dashboard/view.py @@ -42,7 +42,7 @@ def wait_edit_button_in_panel_menu(self): @TestStep(When) -def click_edit_button(self): +def click_edit_button_for_panel(self): """Click edit button in dropdown menu for panel.""" locators.edit_button_for_panel().click() @@ -82,7 +82,7 @@ def edit_panel(self, panel_name): wait_edit_button_in_panel_menu() with By("clicking edit button"): - click_edit_button() + click_edit_button_for_panel() @TestStep(When) @@ -102,21 +102,28 @@ def take_panel_screenshot(self, panel_name, screenshot_name): @TestStep(When) def click_save_button(self): """Open saving menu for dashboard.""" - locators.save_dashboard.click() + locators.save_dashboard(grafana_version=self.context.grafana_version).click() @TestStep(When) def change_title_for_dashboard(self, dashboard_name): """Change title for dashboard in saving menu.""" - locators.save_dashboard_title.clear() + locators.save_dashboard_title(grafana_version=self.context.grafana_version).clear() - locators.save_dashboard_title.send_keys(dashboard_name) + locators.save_dashboard_title(grafana_version=self.context.grafana_version).send_keys(dashboard_name) @TestStep(When) def click_save_dashboard_button(self): """Save dashboard.""" - locators.save_dashboard_button.click() + locators.save_dashboard_button(grafana_version=self.context.grafana_version).click() + + +@TestStep(When) +def click_edit_button(self): + """Click edit button.""" + + locators.edit_button.click() @TestStep(When) @@ -262,6 +269,11 @@ def open_new_dashboard_endpoint(self, endpoint=None): def add_visualization(self): """Add visualization for dashboard.""" + if (self.context.grafana_version is None) or (int(self.context.grafana_version.split(".")[0]) > 10): + with delay(): + with By("clicking edit button"): + click_edit_button() + with delay(): with By("clicking add button"): click_add_button() diff --git a/tests/testflows/steps/panel/locators.py b/tests/testflows/steps/panel/locators.py index 0a7042c16..89a0901fe 100644 --- a/tests/testflows/steps/panel/locators.py +++ b/tests/testflows/steps/panel/locators.py @@ -234,20 +234,26 @@ def apply_button(self): driver: WebDriver = current().context.driver return driver.find_element(SelectBy.CSS_SELECTOR, f'[data-testid="data-testid Apply changes and go back to dashboard"]') - @property - def save_button(self): + def save_button(self, grafana_version): driver: WebDriver = current().context.driver - return driver.find_element(SelectBy.CSS_SELECTOR, f'[title="Apply changes and save dashboard"]') + if not (grafana_version is None) and (int(grafana_version.split(".")[0]) <= 10): + return driver.find_element(SelectBy.CSS_SELECTOR, f'[title="Apply changes and save dashboard"]') + else: + return driver.find_element(SelectBy.CSS_SELECTOR, f'[data-testid="data-testid Save dashboard button"]') - @property - def save_confirmations_button(self): + def save_confirmations_button(self, grafana_version): driver: WebDriver = current().context.driver - return driver.find_element(SelectBy.CSS_SELECTOR, f'[aria-label="Dashboard settings Save Dashboard Modal Save button"]') + if not (grafana_version is None) and (int(grafana_version.split(".")[0]) <= 10): + return driver.find_element(SelectBy.CSS_SELECTOR, f'[aria-label="Dashboard settings Save Dashboard Modal Save button"]') + else: + return driver.find_element(SelectBy.CSS_SELECTOR, f'[data-testid="data-testid Save dashboard drawer button"]') - @property - def discard_button(self): + def discard_button(self, grafana_version): driver: WebDriver = current().context.driver - return driver.find_element(SelectBy.CSS_SELECTOR, f'[title="Undo all changes"]') + if not (grafana_version is None) and (int(grafana_version.split(".")[0]) <= 10): + return driver.find_element(SelectBy.CSS_SELECTOR, f'[title="Undo all changes"]') + else: + return driver.find_element(SelectBy.CSS_SELECTOR, f'[data-testid="data-testid Discard changes button"]') @property def run_query_button(self): @@ -284,5 +290,10 @@ def alert_tab(self, grafana_version=None): else: return driver.find_element(SelectBy.CSS_SELECTOR, f'[data-testid="data-testid Tab Alert"]') + @property + def query_inspector_close_button(self): + driver: WebDriver = current().context.driver + return driver.find_element(SelectBy.CSS_SELECTOR, f'[data-testid="data-testid Drawer close"]') + locators = Locators() diff --git a/tests/testflows/steps/panel/query_options/locators.py b/tests/testflows/steps/panel/query_options/locators.py index 47389ce66..7a1fb0862 100644 --- a/tests/testflows/steps/panel/query_options/locators.py +++ b/tests/testflows/steps/panel/query_options/locators.py @@ -44,7 +44,7 @@ def time_shift_textfield(self): def hide_time_info_toggle(self): driver: WebDriver = current().context.driver return driver.find_element(SelectBy.XPATH, - f'//*[@class="gf-form-inline align-items-center" and .//text()="Hide time info"]//label[@aria-label="Toggle switch"]') + f'//*[contains(@class,"InlineFieldRow") and .//text()="Hide time info"]//label[@aria-label="Toggle switch"]') @property def relative_time_info(self): diff --git a/tests/testflows/steps/panel/view.py b/tests/testflows/steps/panel/view.py index 32e6933f7..00bda9b74 100644 --- a/tests/testflows/steps/panel/view.py +++ b/tests/testflows/steps/panel/view.py @@ -272,6 +272,11 @@ def get_query_inspector_url_text(self): with By("getting url from query inspector"): return locators.query_inspector_url.text +@TestStep(When) +def click_query_inspector_close_button(self): + """Click query inspector close button.""" + + locators.query_inspector_close_button.click() @TestStep(Then) def check_query_inspector_request(self, url_parts): @@ -285,10 +290,15 @@ def check_query_inspector_request(self, url_parts): with delay(): click_inspect_query_refresh_button() - with By("checking url contains necessary parts"): - for url_part in url_parts: - with By(f"checking url contains {url_part}"): - assert url_part in get_query_inspector_url_text(), error() + try: + with By("checking url contains necessary parts"): + for url_part in url_parts: + with By(f"checking url contains {url_part}"): + assert url_part in get_query_inspector_url_text(), error() + finally: + with Finally("I close query inspector window"): + with By("clicking query inspector close button"): + click_query_inspector_close_button() @TestStep(When) @@ -407,9 +417,9 @@ def click_apply_button(self): @TestStep(When) def click_discard_button(self): - """Click apply button for panel.""" + """Click discard button for panel.""" - locators.discard_button.click() + locators.discard_button(grafana_version=self.context.grafana_version).click() @TestStep(When) @@ -501,14 +511,14 @@ def get_value_from_table(self, time): def click_save_button(self): """Click save button.""" - locators.save_button.click() + locators.save_button(grafana_version=self.context.grafana_version).click() @TestStep(When) def click_save_confirmation_button(self): """Click save confirmation button.""" - locators.save_confirmations_button.click() + locators.save_confirmations_button(grafana_version=self.context.grafana_version).click() @TestStep(When) diff --git a/tests/testflows/steps/ui.py b/tests/testflows/steps/ui.py index 2b0c1735d..b34ba9cae 100644 --- a/tests/testflows/steps/ui.py +++ b/tests/testflows/steps/ui.py @@ -66,7 +66,7 @@ def create_local_chrome_driver(self, browser, local_webdriver_path, common_optio chrome_options.add_argument("--no-sandbox") if is_headless: chrome_options.add_argument("--headless") - chrome_options.add_argument("window-size=1560,1160") + chrome_options.add_argument("window-size=2000,1200") chrome_options.add_argument('--enable-logging') chrome_options.add_argument('--v=1') @@ -89,12 +89,13 @@ def create_remote_chrome_driver(self, browser, hub_url, common_options, timeout, "credentials_enable_service": False, "profile.password_manager_enabled": False, } + remote_chrome_options.add_argument("--disable-notifications") remote_chrome_options.add_experimental_option("prefs", remote_chrome_prefs) remote_chrome_options.set_capability("browserName", browser) remote_chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) remote_chrome_options.add_experimental_option("useAutomationExtension", False) remote_chrome_options.set_capability("se:recordVideo", "true") - remote_chrome_options.set_capability("se:screenResolution", "1920x1080") + remote_chrome_options.set_capability("se:screenResolution", "2000x1200") start_time = time.time() diff --git a/tests/testflows/tests/automated/e2e.py b/tests/testflows/tests/automated/e2e.py index 2cb5c82a2..de79aa84e 100644 --- a/tests/testflows/tests/automated/e2e.py +++ b/tests/testflows/tests/automated/e2e.py @@ -66,68 +66,65 @@ def mixed_data_sources(self): with When("I add visualization for panel"): dashboard.add_visualization() - try: - with When("I select datasource"): - with delay(): - panel.select_datasource_in_panel_view(datasource_name='-- Mixed --') - with When("I add query"): - with delay(): - panel.click_add_query_button() + with When("I select datasource"): + with delay(): + panel.select_datasource_in_panel_view(datasource_name='-- Mixed --') - with When("I change datasource for the first query"): - with delay(): - panel.enter_data_source_for_query(query_name='A', datasource_name='mixed_1') + with When("I add query"): + with delay(): + panel.click_add_query_button() - with When("I change datasource for the second query"): - with delay(): - panel.enter_data_source_for_query(query_name='B', datasource_name='mixed_2') + with When("I change datasource for the first query"): + with delay(): + panel.enter_data_source_for_query(query_name='A', datasource_name='mixed_1') - with When("I open SQL editor"): - with delay(): - panel.go_to_sql_editor(query_name='A') - panel.go_to_sql_editor(query_name='B') + with When("I change datasource for the second query"): + with delay(): + panel.enter_data_source_for_query(query_name='B', datasource_name='mixed_2') - with Then("I enter the first query"): - with delay(): - panel.enter_sql_editor_input(query_name='A', query='SELECT now(), 1') + with When("I open SQL editor"): + with delay(): + panel.go_to_sql_editor(query_name='A') + panel.go_to_sql_editor(query_name='B') - with Then("I enter the second query"): - with delay(): - panel.enter_sql_editor_input(query_name='B', query='SELECT now(), 1') + with Then("I enter the first query"): + with delay(): + panel.enter_sql_editor_input(query_name='A', query='SELECT now(), 1') - with When("I click on the visualization to see the result"): - with delay(): - panel.click_on_the_visualization() + with Then("I enter the second query"): + with delay(): + panel.enter_sql_editor_input(query_name='B', query='SELECT now(), 1') - with Then("I click apply button"): - with delay(): - panel.click_apply_button() + with When("I click on the visualization to see the result"): + with delay(): + panel.click_on_the_visualization() - with Then("I go to panel edit the first time"): - with delay(): - dashboard.open_panel(panel_name='Panel Title') + with Then("I click save button"): + with delay(): + panel.save_dashboard() - with Then("I check queries the first time"): - check_queries() + with Then("I open dashboard view"): + with delay(): + dashboards.open_dashboard(dashboard_name="a_mixed") - with Then("I click discard button"): - with delay(): - panel.click_discard_button() + with Then("I go to panel edit the first time"): + with delay(): + dashboard.open_panel(panel_name='Panel Title') - with Then("I go to panel edit the second time"): - with delay(): - dashboard.open_panel(panel_name='Panel Title') + with Then("I check queries the first time"): + check_queries() - with Then("I check queries the second time"): - check_queries() + with Then("I click discard button"): + with delay(): + panel.click_discard_button() - finally: - with Finally("I click discard button"): - with delay(): - panel.click_discard_button() - with delay(): - dashboard.saving_dashboard() + with Then("I go to panel edit the second time"): + with delay(): + dashboard.open_panel(panel_name='Panel Title') + + with Then("I check queries the second time"): + check_queries() @TestScenario diff --git a/tests/testflows/tests/automated/legacy_alerts.py b/tests/testflows/tests/automated/legacy_alerts.py index af1d56d80..4c4917614 100644 --- a/tests/testflows/tests/automated/legacy_alerts.py +++ b/tests/testflows/tests/automated/legacy_alerts.py @@ -25,14 +25,14 @@ def check_red_alert(self): dashboard_name = define("dashboard_name", "a_red_alert") with Given("I create new dashboard"): - actions.create_dashboard(dashboard_name=dashboard_name) + actions.create_dashboard(dashboard_name=dashboard_name, finally_save_dashboard=False) with When("I add visualization for panel"): dashboard.add_visualization() with When("I select datasource"): with delay(): - panel.select_datasource_in_panel_view(datasource_name='test_alerts_legacy') + panel.select_datasource_in_panel_view(datasource_name='a_test_alerts_legacy') with When("I setup query settings for queries"): with delay(): @@ -78,14 +78,14 @@ def check_green_alert(self): dashboard_name = define("dashboard_name", "a_green_alert") with Given("I create new dashboard"): - actions.create_dashboard(dashboard_name=dashboard_name) + actions.create_dashboard(dashboard_name=dashboard_name, finally_save_dashboard=False) with When("I add visualization for panel"): dashboard.add_visualization() with When("I select datasource"): with delay(): - panel.select_datasource_in_panel_view(datasource_name='test_alerts_legacy') + panel.select_datasource_in_panel_view(datasource_name='a_test_alerts_legacy') with When("I setup query settings for queries"): with delay(): @@ -131,14 +131,14 @@ def check_green_into_red_alert(self): dashboard_name = define("dashboard_name", "a_green_into_red_alert") with Given("I create new dashboard"): - actions.create_dashboard(dashboard_name=dashboard_name) + actions.create_dashboard(dashboard_name=dashboard_name, finally_save_dashboard=False) with When("I add visualization for panel"): dashboard.add_visualization() with When("I select datasource"): with delay(): - panel.select_datasource_in_panel_view(datasource_name='test_alerts_legacy') + panel.select_datasource_in_panel_view(datasource_name='a_test_alerts_legacy') with When("I setup query settings for queries"): with delay(): @@ -205,14 +205,14 @@ def check_red_into_green_alert(self): dashboard_name = define("dashboard_name", "a_red_into_green_alert") with Given("I create new dashboard"): - actions.create_dashboard(dashboard_name=dashboard_name) + actions.create_dashboard(dashboard_name=dashboard_name, finally_save_dashboard=False) with When("I add visualization for panel"): dashboard.add_visualization() with When("I select datasource"): with delay(): - panel.select_datasource_in_panel_view(datasource_name='test_alerts_legacy') + panel.select_datasource_in_panel_view(datasource_name='a_test_alerts_legacy') with When("I setup query settings for queries"): with delay(): @@ -282,7 +282,7 @@ def feature(self): """Check that grafana plugin supports legacy alerts.""" with When("I create new altinity datasource"): - actions.create_new_altinity_datasource(datasource_name='test_alerts_legacy', url="http://clickhouse:8123",) + actions.create_new_altinity_datasource(datasource_name='a_test_alerts_legacy', url="http://clickhouse:8123",) for scenario in loads(current_module(), Scenario): scenario() \ No newline at end of file diff --git a/tests/testflows/tests/automated/query_settings.py b/tests/testflows/tests/automated/query_options.py similarity index 97% rename from tests/testflows/tests/automated/query_settings.py rename to tests/testflows/tests/automated/query_options.py index 741876d9a..3c5efab77 100644 --- a/tests/testflows/tests/automated/query_settings.py +++ b/tests/testflows/tests/automated/query_options.py @@ -30,7 +30,7 @@ def max_data_points(self): with Then("I check default interval"): with delay(): - assert query_options.get_interval_value() == '20s', error() + assert query_options.get_interval_value() == '30s', error() try: with Then("I enter 'Max data points'"): @@ -72,7 +72,7 @@ def min_interval(self): with Then("I check default interval"): with delay(): - assert query_options.get_interval_value() == '20s', error() + assert query_options.get_interval_value() == '30s', error() try: with Then("I enter 'Min interval'"): @@ -257,10 +257,10 @@ def feature(self): """Check that grafana plugin supports query options.""" with Given("I define dashboard name for tests"): - dashboard_name = define("dashboard_name", "a_query_settings") + dashboard_name = define("dashboard_name", "a_query_options") with When("I create new altinity datasource"): - actions.create_new_altinity_datasource(datasource_name='query_editor', url="http://clickhouse:8123",) + actions.create_new_altinity_datasource(datasource_name='query_options', url="http://clickhouse:8123",) with Given("I create new dashboard"): actions.create_dashboard(dashboard_name=dashboard_name) @@ -270,7 +270,7 @@ def feature(self): with When("I select datasource"): with delay(): - panel.select_datasource_in_panel_view(datasource_name='query_editor') + panel.select_datasource_in_panel_view(datasource_name='query_options') with When("I setup query settings for queries"): with delay(): diff --git a/tests/testflows/tests/automated/sql_editor.py b/tests/testflows/tests/automated/sql_editor.py index 4a94dbeb0..636201d5e 100644 --- a/tests/testflows/tests/automated/sql_editor.py +++ b/tests/testflows/tests/automated/sql_editor.py @@ -30,262 +30,262 @@ $rateColumns(key, value) - is a combination of $columns and $rate. Example usage: $rateColumns(Type, count() c) FROM requests""" -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_AddMetadata("1.0")) -def add_metadata_toggle(self): - """Check that grafana plugin supports Add metadata toggle.""" - - with Given("I define a query"): - query = define("query", "SELECT now() - number * 1000, number FROM numbers(10)") - - with When("I enter query to SQL editor"): - panel.enter_sql_editor_input(query=query) - - with Then("I click on the visualization to see results"): - with delay(): - panel.click_on_the_visualization() - - with Then("I check reformatted query"): - assert "/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A'), error() - - try: - with Then("I click Add metadata toggle"): - with delay(): - sql_editor.click_add_metadata_toggle(query_name='A') - - with Then("I check reformatted query after clicking toggle"): - with delay(): - assert not ("/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A')), error() - - finally: - with Finally("I return Add metadata toggle status back"): - with delay(): - sql_editor.click_add_metadata_toggle(query_name='A') - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Step("1.0")) -def step_textfield(self): - """Check that grafana plugin supports Step textfield.""" - - with Given("I define a query"): - query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") - - with When("I enter query to SQL editor"): - panel.enter_sql_editor_input(query=query) - - with Then("I click on the visualization to see results"): - with delay(): - panel.click_on_the_visualization() - - try: - with Then("I enter step in seconds"): - with delay(): - sql_editor.enter_step(query_name='A', step="100s") - - with Then("I check reformatted query after entering step in seconds"): - with delay(): - assert "100" in sql_editor.get_reformatted_query(query_name='A'), error() - - with Then("I enter step in minutes"): - with delay(): - sql_editor.enter_step(query_name='A', step="100m") - - with Then("I check reformatted query after entering step in minutes"): - with delay(): - assert f"{100*60}" in sql_editor.get_reformatted_query(query_name='A'), error() - - with Then("I enter step in days"): - with delay(): - sql_editor.enter_step(query_name='A', step="100d") - - with Then("I check reformatted query after entering step in days"): - with delay(): - assert f"{100*60*60*24}" in sql_editor.get_reformatted_query(query_name='A'), error() - - finally: - with Finally("I return Step textfield value back"): - sql_editor.enter_step(query_name='A', step="") - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Round("1.0")) -def round_textfield(self): - """Check that grafana plugin supports Round textfield.""" - - with Given("I define a query"): - query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") - - with When("I enter query to SQL editor"): - panel.enter_sql_editor_input(query=query) - - with Then("I click on the visualization to see results"): - with delay(): - panel.click_on_the_visualization() - - try: - with Then("I enter round"): - with delay(): - sql_editor.enter_round(query_name='A', round="100s") - - with Then("I check reformatted contains rounded by 100s 'time from' and 'time to'"): - with delay(): - assert (sql_editor.get_time_from_in_seconds(query_name='A') % 100) == 0, error() - assert (sql_editor.get_time_to_in_seconds(query_name='A') % 100) == 0, error() - - with Then("I enter another round"): - with delay(): - sql_editor.enter_round(query_name='A', round="10000s") - - with Then("I check reformatted query contains rounded by 10000s 'time from' and 'time to'"): - with delay(): - assert (sql_editor.get_time_from_in_seconds(query_name='A') % 10000) == 0, error() - assert (sql_editor.get_time_to_in_seconds(query_name='A') % 10000) == 0, error() - finally: - with Finally("I return Round textfield value back"): - with delay(): - sql_editor.enter_round(query_name='A', round="0s") - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Resolution("1.0")) -def resolution_dropdown(self): - """Check that grafana plugin supports Resolution dropdown.""" - - with Given("I define a query"): - query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") - - with Given("I define an array of resolutions that will be checked"): - resolutions = define("resolutions", ['1/1', '1/2', '1/3', '1/4', '1/5', '1/10']) - - with When("I enter query to SQL editor"): - panel.enter_sql_editor_input(query=query) - - with Then("I click on the visualization to see results"): - with delay(): - panel.click_on_the_visualization() - - try: - with Then("I enter step"): - with delay(): - sql_editor.enter_step(query_name='A', step="100s") - - for resolution in resolutions: - with Then(f"I change resolution to {resolution}"): - with delay(): - sql_editor.enter_resolution(query_name='A', resolution=resolution) - - with Then(f"I check {resolution} resolution applied to reformatted query"): - with delay(): - assert f'{int(resolution[2:])*100}' in sql_editor.get_reformatted_query(query_name='A'), error() - - finally: - with Finally("I return Step textfield and Resolution dropdown values back"): - with delay(): - sql_editor.enter_resolution(query_name='A', resolution='1/1') - sql_editor.enter_step(query_name='A', step="") - - -@TestOutline -def format_as_dropdown(self, format_as, columns, table_error=False): - """Check that grafana plugin supports Format As dropdown.""" - - with Given("I define a query"): - query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") - - with When("I enter query to SQL editor"): - panel.enter_sql_editor_input(query=query) - - with Then("I click on the visualization to see results"): - with delay(): - panel.click_on_the_visualization() - - try: - with When("I click table view toggle"): - panel.click_table_view_toggle() - - with Then("I check table contains 'Time' and 'count()' columns"): - panel.check_columns_in_table_view(columns=['Time', 'count()']) - - with Then("I change format as"): - with delay(): - sql_editor.enter_format_as(query_name='A', format_as=format_as) - - with When("I click on run query button"): - panel.click_run_query_button() - - if table_error: - with Then("I check table error exists"): - assert panel.check_error_for_table_view() is True, error() - - elif len(columns) == 0: - with Then("I check table contains no data"): - assert panel.check_no_data_text() is True, error() - - else: - with Then("I check table contains expected columns"): - assert panel.check_columns_in_table_view(columns=columns) is True, error() - - finally: - with Finally("I return Format As dropdown value back"): - with delay(): - sql_editor.enter_format_as(query_name='A', format_as='Time series') - - with And("I turn table view back"): - with delay(): - panel.click_table_view_toggle() - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -def format_as_dropdown_table(self): - """Check that grafana plugin supports specifying Format As dropdown as Table.""" - - format_as_dropdown(format_as='Table', columns=['t', 'count()'], table_error=False) - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -def format_as_dropdown_logs(self): - """Check that grafana plugin supports specifying Format As dropdown as Logs.""" - - format_as_dropdown(format_as='Logs', columns=[], table_error=False) - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -def format_as_dropdown_traces(self): - """Check that grafana plugin supports specifying Format As dropdown as Traces.""" - - format_as_dropdown(format_as='Traces', columns=[], table_error=True) - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -def format_as_dropdown_flame_graph(self): - """Check that grafana plugin supports specifying Format As dropdown as Flame Graph.""" - - format_as_dropdown(format_as='Flame Graph', columns=['label', 'level', 'value', 'self'], table_error=False) - - -@TestScenario -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_ShowHelp("1.0")) -def help_button(self): - """Check that grafana plugin supports Show help button.""" - - try: - with Then("I click Show help button"): - with delay(): - sql_editor.click_show_help_button(query_name='A') - - with (Then("I check show help message")): - with delay(): - assert help_macros in sql_editor.get_help_text(query_name='A'), error() - assert help_functions in sql_editor.get_help_text(query_name='A'), error() - finally: - with Finally("I collapse help text"): - with delay(): - sql_editor.click_show_help_button(query_name='A') +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_AddMetadata("1.0")) +# def add_metadata_toggle(self): +# """Check that grafana plugin supports Add metadata toggle.""" +# +# with Given("I define a query"): +# query = define("query", "SELECT now() - number * 1000, number FROM numbers(10)") +# +# with When("I enter query to SQL editor"): +# panel.enter_sql_editor_input(query=query) +# +# with Then("I click on the visualization to see results"): +# with delay(): +# panel.click_on_the_visualization() +# +# with Then("I check reformatted query"): +# assert "/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A'), error() +# +# try: +# with Then("I click Add metadata toggle"): +# with delay(): +# sql_editor.click_add_metadata_toggle(query_name='A') +# +# with Then("I check reformatted query after clicking toggle"): +# with delay(): +# assert not ("/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A')), error() +# +# finally: +# with Finally("I return Add metadata toggle status back"): +# with delay(): +# sql_editor.click_add_metadata_toggle(query_name='A') +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Step("1.0")) +# def step_textfield(self): +# """Check that grafana plugin supports Step textfield.""" +# +# with Given("I define a query"): +# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") +# +# with When("I enter query to SQL editor"): +# panel.enter_sql_editor_input(query=query) +# +# with Then("I click on the visualization to see results"): +# with delay(): +# panel.click_on_the_visualization() +# +# try: +# with Then("I enter step in seconds"): +# with delay(): +# sql_editor.enter_step(query_name='A', step="100s") +# +# with Then("I check reformatted query after entering step in seconds"): +# with delay(): +# assert "100" in sql_editor.get_reformatted_query(query_name='A'), error() +# +# with Then("I enter step in minutes"): +# with delay(): +# sql_editor.enter_step(query_name='A', step="100m") +# +# with Then("I check reformatted query after entering step in minutes"): +# with delay(): +# assert f"{100*60}" in sql_editor.get_reformatted_query(query_name='A'), error() +# +# with Then("I enter step in days"): +# with delay(): +# sql_editor.enter_step(query_name='A', step="100d") +# +# with Then("I check reformatted query after entering step in days"): +# with delay(): +# assert f"{100*60*60*24}" in sql_editor.get_reformatted_query(query_name='A'), error() +# +# finally: +# with Finally("I return Step textfield value back"): +# sql_editor.enter_step(query_name='A', step="") +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Round("1.0")) +# def round_textfield(self): +# """Check that grafana plugin supports Round textfield.""" +# +# with Given("I define a query"): +# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") +# +# with When("I enter query to SQL editor"): +# panel.enter_sql_editor_input(query=query) +# +# with Then("I click on the visualization to see results"): +# with delay(): +# panel.click_on_the_visualization() +# +# try: +# with Then("I enter round"): +# with delay(): +# sql_editor.enter_round(query_name='A', round="100s") +# +# with Then("I check reformatted contains rounded by 100s 'time from' and 'time to'"): +# with delay(): +# assert (sql_editor.get_time_from_in_seconds(query_name='A') % 100) == 0, error() +# assert (sql_editor.get_time_to_in_seconds(query_name='A') % 100) == 0, error() +# +# with Then("I enter another round"): +# with delay(): +# sql_editor.enter_round(query_name='A', round="10000s") +# +# with Then("I check reformatted query contains rounded by 10000s 'time from' and 'time to'"): +# with delay(): +# assert (sql_editor.get_time_from_in_seconds(query_name='A') % 10000) == 0, error() +# assert (sql_editor.get_time_to_in_seconds(query_name='A') % 10000) == 0, error() +# finally: +# with Finally("I return Round textfield value back"): +# with delay(): +# sql_editor.enter_round(query_name='A', round="0s") +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Resolution("1.0")) +# def resolution_dropdown(self): +# """Check that grafana plugin supports Resolution dropdown.""" +# +# with Given("I define a query"): +# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") +# +# with Given("I define an array of resolutions that will be checked"): +# resolutions = define("resolutions", ['1/1', '1/2', '1/3', '1/4', '1/5', '1/10']) +# +# with When("I enter query to SQL editor"): +# panel.enter_sql_editor_input(query=query) +# +# with Then("I click on the visualization to see results"): +# with delay(): +# panel.click_on_the_visualization() +# +# try: +# with Then("I enter step"): +# with delay(): +# sql_editor.enter_step(query_name='A', step="100s") +# +# for resolution in resolutions: +# with Then(f"I change resolution to {resolution}"): +# with delay(): +# sql_editor.enter_resolution(query_name='A', resolution=resolution) +# +# with Then(f"I check {resolution} resolution applied to reformatted query"): +# with delay(): +# assert f'{int(resolution[2:])*100}' in sql_editor.get_reformatted_query(query_name='A'), error() +# +# finally: +# with Finally("I return Step textfield and Resolution dropdown values back"): +# with delay(): +# sql_editor.enter_resolution(query_name='A', resolution='1/1') +# sql_editor.enter_step(query_name='A', step="") +# +# +# @TestOutline +# def format_as_dropdown(self, format_as, columns, table_error=False): +# """Check that grafana plugin supports Format As dropdown.""" +# +# with Given("I define a query"): +# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") +# +# with When("I enter query to SQL editor"): +# panel.enter_sql_editor_input(query=query) +# +# with Then("I click on the visualization to see results"): +# with delay(): +# panel.click_on_the_visualization() +# +# try: +# with When("I click table view toggle"): +# panel.click_table_view_toggle() +# +# with Then("I check table contains 'Time' and 'count()' columns"): +# panel.check_columns_in_table_view(columns=['Time', 'count()']) +# +# with Then("I change format as"): +# with delay(): +# sql_editor.enter_format_as(query_name='A', format_as=format_as) +# +# with When("I click on run query button"): +# panel.click_run_query_button() +# +# if table_error: +# with Then("I check table error exists"): +# assert panel.check_error_for_table_view() is True, error() +# +# elif len(columns) == 0: +# with Then("I check table contains no data"): +# assert panel.check_no_data_text() is True, error() +# +# else: +# with Then("I check table contains expected columns"): +# assert panel.check_columns_in_table_view(columns=columns) is True, error() +# +# finally: +# with Finally("I return Format As dropdown value back"): +# with delay(): +# sql_editor.enter_format_as(query_name='A', format_as='Time series') +# +# with And("I turn table view back"): +# with delay(): +# panel.click_table_view_toggle() +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +# def format_as_dropdown_table(self): +# """Check that grafana plugin supports specifying Format As dropdown as Table.""" +# +# format_as_dropdown(format_as='Table', columns=['t', 'count()'], table_error=False) +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +# def format_as_dropdown_logs(self): +# """Check that grafana plugin supports specifying Format As dropdown as Logs.""" +# +# format_as_dropdown(format_as='Logs', columns=[], table_error=False) +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +# def format_as_dropdown_traces(self): +# """Check that grafana plugin supports specifying Format As dropdown as Traces.""" +# +# format_as_dropdown(format_as='Traces', columns=[], table_error=True) +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +# def format_as_dropdown_flame_graph(self): +# """Check that grafana plugin supports specifying Format As dropdown as Flame Graph.""" +# +# format_as_dropdown(format_as='Flame Graph', columns=['label', 'level', 'value', 'self'], table_error=False) +# +# +# @TestScenario +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_ShowHelp("1.0")) +# def help_button(self): +# """Check that grafana plugin supports Show help button.""" +# +# try: +# with Then("I click Show help button"): +# with delay(): +# sql_editor.click_show_help_button(query_name='A') +# +# with (Then("I check show help message")): +# with delay(): +# assert help_macros in sql_editor.get_help_text(query_name='A'), error() +# assert help_functions in sql_editor.get_help_text(query_name='A'), error() +# finally: +# with Finally("I collapse help text"): +# with delay(): +# sql_editor.click_show_help_button(query_name='A') @TestScenario @@ -308,7 +308,7 @@ def extrapolation_toggle(self): with delay(): panel.click_run_query_button() - for attempt in retries(delay=10, count=6): + for attempt in retries(delay=10, count=12): with attempt: with When("I click on run query button to see results with turned on extrapolation"): panel.click_run_query_button() @@ -337,78 +337,78 @@ def extrapolation_toggle(self): sql_editor.enter_step(query_name='A', step="") -@TestOutline -@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_SkipComments("1.0")) -def skip_comments_toggle(self, query): - """Check that grafana plugin supports Skip Comments toggle.""" - - with When("I enter query in SQL editor"): - panel.enter_sql_editor_input(query=query) - - with Then("I click on the visualization to see results"): - with delay(): - panel.click_on_the_visualization() - - try: - with Then("I check reformatted query does not contain the comment"): - assert not ("COMMENT" in sql_editor.get_reformatted_query(query_name='A')), error() - - with Then("I click Skip Comments toggle", description="to allow user to see the comment"): - with delay(): - sql_editor.click_skip_comments_toggle(query_name='A') - - with Then("I check reformatted query contains the comment"): - with delay(): - assert "COMMENT" in sql_editor.get_reformatted_query(query_name='A'), error() - - finally: - with Finally("I return Skip Comments toggle status back"): - with delay(): - sql_editor.click_skip_comments_toggle(query_name='A') - - -@TestScenario -def multiline_comment(self): - """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" - - with Given("I define a query that contains a comment"): - query = define("query", - "SELECT now() - number * 1000, number FROM numbers(10) /*\nCOMMENT*/") - - skip_comments_toggle(query=query) - - -@TestScenario -def double_dash_comment(self): - """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" - - with Given("I define a query that contains a comment"): - query = define("query", - "SELECT now() - number * 1000, number FROM numbers(10) --COMMENT") - - skip_comments_toggle(query=query) - - -@TestScenario -def hash_comment(self): - """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" - - with Given("I define a query that contains a comment"): - query = define("query", - "SELECT now() - number * 1000, number FROM numbers(10) #COMMENT") - - skip_comments_toggle(query=query) - - -@TestScenario -def hash_exclamation_comment(self): - """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" - - with Given("I define a query that contains a comment"): - query = define("query", - "SELECT now() - number * 1000, number FROM numbers(10) #!COMMENT") - - skip_comments_toggle(query=query) +# @TestOutline +# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_SkipComments("1.0")) +# def skip_comments_toggle(self, query): +# """Check that grafana plugin supports Skip Comments toggle.""" +# +# with When("I enter query in SQL editor"): +# panel.enter_sql_editor_input(query=query) +# +# with Then("I click on the visualization to see results"): +# with delay(): +# panel.click_on_the_visualization() +# +# try: +# with Then("I check reformatted query does not contain the comment"): +# assert not ("COMMENT" in sql_editor.get_reformatted_query(query_name='A')), error() +# +# with Then("I click Skip Comments toggle", description="to allow user to see the comment"): +# with delay(): +# sql_editor.click_skip_comments_toggle(query_name='A') +# +# with Then("I check reformatted query contains the comment"): +# with delay(): +# assert "COMMENT" in sql_editor.get_reformatted_query(query_name='A'), error() +# +# finally: +# with Finally("I return Skip Comments toggle status back"): +# with delay(): +# sql_editor.click_skip_comments_toggle(query_name='A') +# +# +# @TestScenario +# def multiline_comment(self): +# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" +# +# with Given("I define a query that contains a comment"): +# query = define("query", +# "SELECT now() - number * 1000, number FROM numbers(10) /*\nCOMMENT*/") +# +# skip_comments_toggle(query=query) +# +# +# @TestScenario +# def double_dash_comment(self): +# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" +# +# with Given("I define a query that contains a comment"): +# query = define("query", +# "SELECT now() - number * 1000, number FROM numbers(10) --COMMENT") +# +# skip_comments_toggle(query=query) +# +# +# @TestScenario +# def hash_comment(self): +# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" +# +# with Given("I define a query that contains a comment"): +# query = define("query", +# "SELECT now() - number * 1000, number FROM numbers(10) #COMMENT") +# +# skip_comments_toggle(query=query) +# +# +# @TestScenario +# def hash_exclamation_comment(self): +# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" +# +# with Given("I define a query that contains a comment"): +# query = define("query", +# "SELECT now() - number * 1000, number FROM numbers(10) #!COMMENT") +# +# skip_comments_toggle(query=query) @TestFeature diff --git a/tests/testflows/tests/automated/unified_alerts.py b/tests/testflows/tests/automated/unified_alerts.py index 49c38d0cd..ab3e26ddb 100644 --- a/tests/testflows/tests/automated/unified_alerts.py +++ b/tests/testflows/tests/automated/unified_alerts.py @@ -25,7 +25,7 @@ def check_red_alert(self): dashboard_name = define("dashboard_name", "a_red_alert") with Given("I create new dashboard"): - actions.create_dashboard(dashboard_name=dashboard_name) + actions.create_dashboard(dashboard_name=dashboard_name, finally_save_dashboard=False) with When("I add visualization for panel"): dashboard.add_visualization() @@ -83,7 +83,7 @@ def check_green_alert(self): dashboard_name = define("dashboard_name", "a_green_alert") with Given("I create new dashboard"): - actions.create_dashboard(dashboard_name=dashboard_name) + actions.create_dashboard(dashboard_name=dashboard_name, finally_save_dashboard=False) with When("I add visualization for panel"): dashboard.add_visualization() From f66382544d7875e3ac4de6cf3c9a71e403ff19eb Mon Sep 17 00:00:00 2001 From: antip00 Date: Fri, 25 Oct 2024 10:31:47 +0300 Subject: [PATCH 2/6] Update. --- tests/testflows/steps/dashboard/view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testflows/steps/dashboard/view.py b/tests/testflows/steps/dashboard/view.py index 2dbc9bbc9..5cb6ba24d 100644 --- a/tests/testflows/steps/dashboard/view.py +++ b/tests/testflows/steps/dashboard/view.py @@ -139,7 +139,7 @@ def saving_dashboard(self, dashboard_name=None): change_title_for_dashboard(dashboard_name=dashboard_name) with By("clicking save button"): - with delay(): + with delay(before=0.5): click_save_dashboard_button() From bac833bbd33b19316c6c8bb7cde2c732dc3bd178 Mon Sep 17 00:00:00 2001 From: antip00 Date: Fri, 25 Oct 2024 10:54:59 +0300 Subject: [PATCH 3/6] Updates. --- tests/testflows/steps/actions.py | 2 +- tests/testflows/steps/dashboards/view.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/testflows/steps/actions.py b/tests/testflows/steps/actions.py index e4a2252c7..bd62a1a70 100644 --- a/tests/testflows/steps/actions.py +++ b/tests/testflows/steps/actions.py @@ -53,7 +53,7 @@ def create_dashboard(self, dashboard_name, open_it=True, finally_save_dashboard= finally: if finally_save_dashboard: with Finally("I save changes for dashboard"): - with delay(): + with delay(after=0.5): panel.save_dashboard() with Finally(f"I delete dashboard {dashboard_name}"): diff --git a/tests/testflows/steps/dashboards/view.py b/tests/testflows/steps/dashboards/view.py index aa4e9f62e..90cac6da3 100644 --- a/tests/testflows/steps/dashboards/view.py +++ b/tests/testflows/steps/dashboards/view.py @@ -94,7 +94,8 @@ def create_new_dashboard(self): def delete_dashboard(self, dashboard_name): """Delete dashboard.""" with By("opening dashboards view"): - open_dashboards_view() + with delay(): + open_dashboards_view() with By("selecting dashboard"): with delay(): @@ -109,7 +110,8 @@ def delete_dashboard(self, dashboard_name): enter_delete_conformation() with By("clicking delete button in confirmation window"): - click_delete_confirmation_button() + with delay(): + click_delete_confirmation_button() @TestStep(When) From bd3cd3644a6b05b5a302639c85b9852562dedd36 Mon Sep 17 00:00:00 2001 From: antip00 Date: Fri, 25 Oct 2024 11:11:10 +0300 Subject: [PATCH 4/6] Uncomment tests. --- tests/testflows/tests/automated/sql_editor.py | 656 +++++++++--------- 1 file changed, 328 insertions(+), 328 deletions(-) diff --git a/tests/testflows/tests/automated/sql_editor.py b/tests/testflows/tests/automated/sql_editor.py index 636201d5e..1e52b5210 100644 --- a/tests/testflows/tests/automated/sql_editor.py +++ b/tests/testflows/tests/automated/sql_editor.py @@ -30,262 +30,262 @@ $rateColumns(key, value) - is a combination of $columns and $rate. Example usage: $rateColumns(Type, count() c) FROM requests""" -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_AddMetadata("1.0")) -# def add_metadata_toggle(self): -# """Check that grafana plugin supports Add metadata toggle.""" -# -# with Given("I define a query"): -# query = define("query", "SELECT now() - number * 1000, number FROM numbers(10)") -# -# with When("I enter query to SQL editor"): -# panel.enter_sql_editor_input(query=query) -# -# with Then("I click on the visualization to see results"): -# with delay(): -# panel.click_on_the_visualization() -# -# with Then("I check reformatted query"): -# assert "/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A'), error() -# -# try: -# with Then("I click Add metadata toggle"): -# with delay(): -# sql_editor.click_add_metadata_toggle(query_name='A') -# -# with Then("I check reformatted query after clicking toggle"): -# with delay(): -# assert not ("/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A')), error() -# -# finally: -# with Finally("I return Add metadata toggle status back"): -# with delay(): -# sql_editor.click_add_metadata_toggle(query_name='A') -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Step("1.0")) -# def step_textfield(self): -# """Check that grafana plugin supports Step textfield.""" -# -# with Given("I define a query"): -# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") -# -# with When("I enter query to SQL editor"): -# panel.enter_sql_editor_input(query=query) -# -# with Then("I click on the visualization to see results"): -# with delay(): -# panel.click_on_the_visualization() -# -# try: -# with Then("I enter step in seconds"): -# with delay(): -# sql_editor.enter_step(query_name='A', step="100s") -# -# with Then("I check reformatted query after entering step in seconds"): -# with delay(): -# assert "100" in sql_editor.get_reformatted_query(query_name='A'), error() -# -# with Then("I enter step in minutes"): -# with delay(): -# sql_editor.enter_step(query_name='A', step="100m") -# -# with Then("I check reformatted query after entering step in minutes"): -# with delay(): -# assert f"{100*60}" in sql_editor.get_reformatted_query(query_name='A'), error() -# -# with Then("I enter step in days"): -# with delay(): -# sql_editor.enter_step(query_name='A', step="100d") -# -# with Then("I check reformatted query after entering step in days"): -# with delay(): -# assert f"{100*60*60*24}" in sql_editor.get_reformatted_query(query_name='A'), error() -# -# finally: -# with Finally("I return Step textfield value back"): -# sql_editor.enter_step(query_name='A', step="") -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Round("1.0")) -# def round_textfield(self): -# """Check that grafana plugin supports Round textfield.""" -# -# with Given("I define a query"): -# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") -# -# with When("I enter query to SQL editor"): -# panel.enter_sql_editor_input(query=query) -# -# with Then("I click on the visualization to see results"): -# with delay(): -# panel.click_on_the_visualization() -# -# try: -# with Then("I enter round"): -# with delay(): -# sql_editor.enter_round(query_name='A', round="100s") -# -# with Then("I check reformatted contains rounded by 100s 'time from' and 'time to'"): -# with delay(): -# assert (sql_editor.get_time_from_in_seconds(query_name='A') % 100) == 0, error() -# assert (sql_editor.get_time_to_in_seconds(query_name='A') % 100) == 0, error() -# -# with Then("I enter another round"): -# with delay(): -# sql_editor.enter_round(query_name='A', round="10000s") -# -# with Then("I check reformatted query contains rounded by 10000s 'time from' and 'time to'"): -# with delay(): -# assert (sql_editor.get_time_from_in_seconds(query_name='A') % 10000) == 0, error() -# assert (sql_editor.get_time_to_in_seconds(query_name='A') % 10000) == 0, error() -# finally: -# with Finally("I return Round textfield value back"): -# with delay(): -# sql_editor.enter_round(query_name='A', round="0s") -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Resolution("1.0")) -# def resolution_dropdown(self): -# """Check that grafana plugin supports Resolution dropdown.""" -# -# with Given("I define a query"): -# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") -# -# with Given("I define an array of resolutions that will be checked"): -# resolutions = define("resolutions", ['1/1', '1/2', '1/3', '1/4', '1/5', '1/10']) -# -# with When("I enter query to SQL editor"): -# panel.enter_sql_editor_input(query=query) -# -# with Then("I click on the visualization to see results"): -# with delay(): -# panel.click_on_the_visualization() -# -# try: -# with Then("I enter step"): -# with delay(): -# sql_editor.enter_step(query_name='A', step="100s") -# -# for resolution in resolutions: -# with Then(f"I change resolution to {resolution}"): -# with delay(): -# sql_editor.enter_resolution(query_name='A', resolution=resolution) -# -# with Then(f"I check {resolution} resolution applied to reformatted query"): -# with delay(): -# assert f'{int(resolution[2:])*100}' in sql_editor.get_reformatted_query(query_name='A'), error() -# -# finally: -# with Finally("I return Step textfield and Resolution dropdown values back"): -# with delay(): -# sql_editor.enter_resolution(query_name='A', resolution='1/1') -# sql_editor.enter_step(query_name='A', step="") -# -# -# @TestOutline -# def format_as_dropdown(self, format_as, columns, table_error=False): -# """Check that grafana plugin supports Format As dropdown.""" -# -# with Given("I define a query"): -# query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") -# -# with When("I enter query to SQL editor"): -# panel.enter_sql_editor_input(query=query) -# -# with Then("I click on the visualization to see results"): -# with delay(): -# panel.click_on_the_visualization() -# -# try: -# with When("I click table view toggle"): -# panel.click_table_view_toggle() -# -# with Then("I check table contains 'Time' and 'count()' columns"): -# panel.check_columns_in_table_view(columns=['Time', 'count()']) -# -# with Then("I change format as"): -# with delay(): -# sql_editor.enter_format_as(query_name='A', format_as=format_as) -# -# with When("I click on run query button"): -# panel.click_run_query_button() -# -# if table_error: -# with Then("I check table error exists"): -# assert panel.check_error_for_table_view() is True, error() -# -# elif len(columns) == 0: -# with Then("I check table contains no data"): -# assert panel.check_no_data_text() is True, error() -# -# else: -# with Then("I check table contains expected columns"): -# assert panel.check_columns_in_table_view(columns=columns) is True, error() -# -# finally: -# with Finally("I return Format As dropdown value back"): -# with delay(): -# sql_editor.enter_format_as(query_name='A', format_as='Time series') -# -# with And("I turn table view back"): -# with delay(): -# panel.click_table_view_toggle() -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -# def format_as_dropdown_table(self): -# """Check that grafana plugin supports specifying Format As dropdown as Table.""" -# -# format_as_dropdown(format_as='Table', columns=['t', 'count()'], table_error=False) -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -# def format_as_dropdown_logs(self): -# """Check that grafana plugin supports specifying Format As dropdown as Logs.""" -# -# format_as_dropdown(format_as='Logs', columns=[], table_error=False) -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -# def format_as_dropdown_traces(self): -# """Check that grafana plugin supports specifying Format As dropdown as Traces.""" -# -# format_as_dropdown(format_as='Traces', columns=[], table_error=True) -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) -# def format_as_dropdown_flame_graph(self): -# """Check that grafana plugin supports specifying Format As dropdown as Flame Graph.""" -# -# format_as_dropdown(format_as='Flame Graph', columns=['label', 'level', 'value', 'self'], table_error=False) -# -# -# @TestScenario -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_ShowHelp("1.0")) -# def help_button(self): -# """Check that grafana plugin supports Show help button.""" -# -# try: -# with Then("I click Show help button"): -# with delay(): -# sql_editor.click_show_help_button(query_name='A') -# -# with (Then("I check show help message")): -# with delay(): -# assert help_macros in sql_editor.get_help_text(query_name='A'), error() -# assert help_functions in sql_editor.get_help_text(query_name='A'), error() -# finally: -# with Finally("I collapse help text"): -# with delay(): -# sql_editor.click_show_help_button(query_name='A') +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_AddMetadata("1.0")) +def add_metadata_toggle(self): + """Check that grafana plugin supports Add metadata toggle.""" + + with Given("I define a query"): + query = define("query", "SELECT now() - number * 1000, number FROM numbers(10)") + + with When("I enter query to SQL editor"): + panel.enter_sql_editor_input(query=query) + + with Then("I click on the visualization to see results"): + with delay(): + panel.click_on_the_visualization() + + with Then("I check reformatted query"): + assert "/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A'), error() + + try: + with Then("I click Add metadata toggle"): + with delay(): + sql_editor.click_add_metadata_toggle(query_name='A') + + with Then("I check reformatted query after clicking toggle"): + with delay(): + assert not ("/* grafana dashboard=a_test_sql_editor, user=1 */" in sql_editor.get_reformatted_query(query_name='A')), error() + + finally: + with Finally("I return Add metadata toggle status back"): + with delay(): + sql_editor.click_add_metadata_toggle(query_name='A') + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Step("1.0")) +def step_textfield(self): + """Check that grafana plugin supports Step textfield.""" + + with Given("I define a query"): + query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") + + with When("I enter query to SQL editor"): + panel.enter_sql_editor_input(query=query) + + with Then("I click on the visualization to see results"): + with delay(): + panel.click_on_the_visualization() + + try: + with Then("I enter step in seconds"): + with delay(): + sql_editor.enter_step(query_name='A', step="100s") + + with Then("I check reformatted query after entering step in seconds"): + with delay(): + assert "100" in sql_editor.get_reformatted_query(query_name='A'), error() + + with Then("I enter step in minutes"): + with delay(): + sql_editor.enter_step(query_name='A', step="100m") + + with Then("I check reformatted query after entering step in minutes"): + with delay(): + assert f"{100*60}" in sql_editor.get_reformatted_query(query_name='A'), error() + + with Then("I enter step in days"): + with delay(): + sql_editor.enter_step(query_name='A', step="100d") + + with Then("I check reformatted query after entering step in days"): + with delay(): + assert f"{100*60*60*24}" in sql_editor.get_reformatted_query(query_name='A'), error() + + finally: + with Finally("I return Step textfield value back"): + sql_editor.enter_step(query_name='A', step="") + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Round("1.0")) +def round_textfield(self): + """Check that grafana plugin supports Round textfield.""" + + with Given("I define a query"): + query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") + + with When("I enter query to SQL editor"): + panel.enter_sql_editor_input(query=query) + + with Then("I click on the visualization to see results"): + with delay(): + panel.click_on_the_visualization() + + try: + with Then("I enter round"): + with delay(): + sql_editor.enter_round(query_name='A', round="100s") + + with Then("I check reformatted contains rounded by 100s 'time from' and 'time to'"): + with delay(): + assert (sql_editor.get_time_from_in_seconds(query_name='A') % 100) == 0, error() + assert (sql_editor.get_time_to_in_seconds(query_name='A') % 100) == 0, error() + + with Then("I enter another round"): + with delay(): + sql_editor.enter_round(query_name='A', round="10000s") + + with Then("I check reformatted query contains rounded by 10000s 'time from' and 'time to'"): + with delay(): + assert (sql_editor.get_time_from_in_seconds(query_name='A') % 10000) == 0, error() + assert (sql_editor.get_time_to_in_seconds(query_name='A') % 10000) == 0, error() + finally: + with Finally("I return Round textfield value back"): + with delay(): + sql_editor.enter_round(query_name='A', round="0s") + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_Resolution("1.0")) +def resolution_dropdown(self): + """Check that grafana plugin supports Resolution dropdown.""" + + with Given("I define a query"): + query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") + + with Given("I define an array of resolutions that will be checked"): + resolutions = define("resolutions", ['1/1', '1/2', '1/3', '1/4', '1/5', '1/10']) + + with When("I enter query to SQL editor"): + panel.enter_sql_editor_input(query=query) + + with Then("I click on the visualization to see results"): + with delay(): + panel.click_on_the_visualization() + + try: + with Then("I enter step"): + with delay(): + sql_editor.enter_step(query_name='A', step="100s") + + for resolution in resolutions: + with Then(f"I change resolution to {resolution}"): + with delay(): + sql_editor.enter_resolution(query_name='A', resolution=resolution) + + with Then(f"I check {resolution} resolution applied to reformatted query"): + with delay(): + assert f'{int(resolution[2:])*100}' in sql_editor.get_reformatted_query(query_name='A'), error() + + finally: + with Finally("I return Step textfield and Resolution dropdown values back"): + with delay(): + sql_editor.enter_resolution(query_name='A', resolution='1/1') + sql_editor.enter_step(query_name='A', step="") + + +@TestOutline +def format_as_dropdown(self, format_as, columns, table_error=False): + """Check that grafana plugin supports Format As dropdown.""" + + with Given("I define a query"): + query = define("query", "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t") + + with When("I enter query to SQL editor"): + panel.enter_sql_editor_input(query=query) + + with Then("I click on the visualization to see results"): + with delay(): + panel.click_on_the_visualization() + + try: + with When("I click table view toggle"): + panel.click_table_view_toggle() + + with Then("I check table contains 'Time' and 'count()' columns"): + panel.check_columns_in_table_view(columns=['Time', 'count()']) + + with Then("I change format as"): + with delay(): + sql_editor.enter_format_as(query_name='A', format_as=format_as) + + with When("I click on run query button"): + panel.click_run_query_button() + + if table_error: + with Then("I check table error exists"): + assert panel.check_error_for_table_view() is True, error() + + elif len(columns) == 0: + with Then("I check table contains no data"): + assert panel.check_no_data_text() is True, error() + + else: + with Then("I check table contains expected columns"): + assert panel.check_columns_in_table_view(columns=columns) is True, error() + + finally: + with Finally("I return Format As dropdown value back"): + with delay(): + sql_editor.enter_format_as(query_name='A', format_as='Time series') + + with And("I turn table view back"): + with delay(): + panel.click_table_view_toggle() + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +def format_as_dropdown_table(self): + """Check that grafana plugin supports specifying Format As dropdown as Table.""" + + format_as_dropdown(format_as='Table', columns=['t', 'count()'], table_error=False) + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +def format_as_dropdown_logs(self): + """Check that grafana plugin supports specifying Format As dropdown as Logs.""" + + format_as_dropdown(format_as='Logs', columns=[], table_error=False) + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +def format_as_dropdown_traces(self): + """Check that grafana plugin supports specifying Format As dropdown as Traces.""" + + format_as_dropdown(format_as='Traces', columns=[], table_error=True) + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_FormatAs("1.0")) +def format_as_dropdown_flame_graph(self): + """Check that grafana plugin supports specifying Format As dropdown as Flame Graph.""" + + format_as_dropdown(format_as='Flame Graph', columns=['label', 'level', 'value', 'self'], table_error=False) + + +@TestScenario +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_ShowHelp("1.0")) +def help_button(self): + """Check that grafana plugin supports Show help button.""" + + try: + with Then("I click Show help button"): + with delay(): + sql_editor.click_show_help_button(query_name='A') + + with (Then("I check show help message")): + with delay(): + assert help_macros in sql_editor.get_help_text(query_name='A'), error() + assert help_functions in sql_editor.get_help_text(query_name='A'), error() + finally: + with Finally("I collapse help text"): + with delay(): + sql_editor.click_show_help_button(query_name='A') @TestScenario @@ -337,78 +337,78 @@ def extrapolation_toggle(self): sql_editor.enter_step(query_name='A', step="") -# @TestOutline -# @Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_SkipComments("1.0")) -# def skip_comments_toggle(self, query): -# """Check that grafana plugin supports Skip Comments toggle.""" -# -# with When("I enter query in SQL editor"): -# panel.enter_sql_editor_input(query=query) -# -# with Then("I click on the visualization to see results"): -# with delay(): -# panel.click_on_the_visualization() -# -# try: -# with Then("I check reformatted query does not contain the comment"): -# assert not ("COMMENT" in sql_editor.get_reformatted_query(query_name='A')), error() -# -# with Then("I click Skip Comments toggle", description="to allow user to see the comment"): -# with delay(): -# sql_editor.click_skip_comments_toggle(query_name='A') -# -# with Then("I check reformatted query contains the comment"): -# with delay(): -# assert "COMMENT" in sql_editor.get_reformatted_query(query_name='A'), error() -# -# finally: -# with Finally("I return Skip Comments toggle status back"): -# with delay(): -# sql_editor.click_skip_comments_toggle(query_name='A') -# -# -# @TestScenario -# def multiline_comment(self): -# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" -# -# with Given("I define a query that contains a comment"): -# query = define("query", -# "SELECT now() - number * 1000, number FROM numbers(10) /*\nCOMMENT*/") -# -# skip_comments_toggle(query=query) -# -# -# @TestScenario -# def double_dash_comment(self): -# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" -# -# with Given("I define a query that contains a comment"): -# query = define("query", -# "SELECT now() - number * 1000, number FROM numbers(10) --COMMENT") -# -# skip_comments_toggle(query=query) -# -# -# @TestScenario -# def hash_comment(self): -# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" -# -# with Given("I define a query that contains a comment"): -# query = define("query", -# "SELECT now() - number * 1000, number FROM numbers(10) #COMMENT") -# -# skip_comments_toggle(query=query) -# -# -# @TestScenario -# def hash_exclamation_comment(self): -# """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" -# -# with Given("I define a query that contains a comment"): -# query = define("query", -# "SELECT now() - number * 1000, number FROM numbers(10) #!COMMENT") -# -# skip_comments_toggle(query=query) +@TestOutline +@Requirements(RQ_SRS_Plugin_RawSQLEditorInterface_SkipComments("1.0")) +def skip_comments_toggle(self, query): + """Check that grafana plugin supports Skip Comments toggle.""" + + with When("I enter query in SQL editor"): + panel.enter_sql_editor_input(query=query) + + with Then("I click on the visualization to see results"): + with delay(): + panel.click_on_the_visualization() + + try: + with Then("I check reformatted query does not contain the comment"): + assert not ("COMMENT" in sql_editor.get_reformatted_query(query_name='A')), error() + + with Then("I click Skip Comments toggle", description="to allow user to see the comment"): + with delay(): + sql_editor.click_skip_comments_toggle(query_name='A') + + with Then("I check reformatted query contains the comment"): + with delay(): + assert "COMMENT" in sql_editor.get_reformatted_query(query_name='A'), error() + + finally: + with Finally("I return Skip Comments toggle status back"): + with delay(): + sql_editor.click_skip_comments_toggle(query_name='A') + + +@TestScenario +def multiline_comment(self): + """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" + + with Given("I define a query that contains a comment"): + query = define("query", + "SELECT now() - number * 1000, number FROM numbers(10) /*\nCOMMENT*/") + + skip_comments_toggle(query=query) + + +@TestScenario +def double_dash_comment(self): + """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" + + with Given("I define a query that contains a comment"): + query = define("query", + "SELECT now() - number * 1000, number FROM numbers(10) --COMMENT") + + skip_comments_toggle(query=query) + + +@TestScenario +def hash_comment(self): + """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" + + with Given("I define a query that contains a comment"): + query = define("query", + "SELECT now() - number * 1000, number FROM numbers(10) #COMMENT") + + skip_comments_toggle(query=query) + + +@TestScenario +def hash_exclamation_comment(self): + """Check that grafana plugin supports Skip Comments toggle with multiline comments.""" + + with Given("I define a query that contains a comment"): + query = define("query", + "SELECT now() - number * 1000, number FROM numbers(10) #!COMMENT") + + skip_comments_toggle(query=query) @TestFeature From 5812dc9cc1cff0c6d72548e8220a43fd113173f4 Mon Sep 17 00:00:00 2001 From: antip00 Date: Fri, 25 Oct 2024 11:36:47 +0300 Subject: [PATCH 5/6] Updates. --- tests/testflows/steps/panel/view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testflows/steps/panel/view.py b/tests/testflows/steps/panel/view.py index 00bda9b74..1146746a8 100644 --- a/tests/testflows/steps/panel/view.py +++ b/tests/testflows/steps/panel/view.py @@ -529,5 +529,5 @@ def save_dashboard(self): click_save_button() with And("clicking save confirmation button"): - with delay(): + with delay(before=0.5): click_save_confirmation_button() \ No newline at end of file From 4ef2db10e9dd03a8f4c367ad912266860c3f65ae Mon Sep 17 00:00:00 2001 From: antip00 Date: Fri, 25 Oct 2024 11:50:31 +0300 Subject: [PATCH 6/6] Update. --- tests/testflows/regression.py | 2 +- tests/testflows/tests/automated/e2e.py | 20 ++++++----- tests/testflows/tests/automated/sql_editor.py | 35 ++++++++++--------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/tests/testflows/regression.py b/tests/testflows/regression.py index f5ada3295..007436c8b 100755 --- a/tests/testflows/regression.py +++ b/tests/testflows/regression.py @@ -47,7 +47,7 @@ def argparser(parser): (Error, "https://github.com/Altinity/clickhouse-grafana/issues/630") ], "/Grafana Datasource Plugin For Clickhouse/sql editor/extrapolation toggle/":[ - (Error, "Run Query button do not update time ranges") + (Fail, "Run Query button do not update time ranges") ] } diff --git a/tests/testflows/tests/automated/e2e.py b/tests/testflows/tests/automated/e2e.py index de79aa84e..56c646cf7 100644 --- a/tests/testflows/tests/automated/e2e.py +++ b/tests/testflows/tests/automated/e2e.py @@ -22,15 +22,17 @@ def gh_api_check(self): with When("I go to clickhouse dashboard"): dashboards.open_dashboard(dashboard_name="gh-api") - for attempt in retries(delay=5, timeout=50): - with attempt: - with delay(): - with Then("I take screenshot of Pull request events for grafana/grafana panel"): - dashboard.take_screenshot_for_panel(panel_name="Pull request events for grafana/grafana", screenshot_name="gh-api_panel") - - with delay(): - with Then("I check graph contains data"): - assert actions.check_screenshot_contains_green(screenshot_name="gh-api_panel") is True, error() + + with Then("I check gh-api datasource works correctly"): + for attempt in retries(delay=5, timeout=50): + with attempt: + with delay(): + with Then("I take screenshot of Pull request events for grafana/grafana panel"): + dashboard.take_screenshot_for_panel(panel_name="Pull request events for grafana/grafana", screenshot_name="gh-api_panel") + + with delay(): + with Then("I check graph contains data"): + assert actions.check_screenshot_contains_green(screenshot_name="gh-api_panel") is True, error() @TestCheck diff --git a/tests/testflows/tests/automated/sql_editor.py b/tests/testflows/tests/automated/sql_editor.py index 1e52b5210..bd12fd899 100644 --- a/tests/testflows/tests/automated/sql_editor.py +++ b/tests/testflows/tests/automated/sql_editor.py @@ -307,29 +307,30 @@ def extrapolation_toggle(self): with Then("I click on run query button to see results"): with delay(): panel.click_run_query_button() + + with Then("I check extrapolation toggle works correctly"): + for attempt in retries(delay=10, count=12): + with attempt: + with When("I click on run query button to see results with turned on extrapolation"): + panel.click_run_query_button() - for attempt in retries(delay=10, count=12): - with attempt: - with When("I click on run query button to see results with turned on extrapolation"): - panel.click_run_query_button() + with When("I take screenshot with extrapolation"): + panel.take_screenshot_for_visualization(screenshot_name='extrapolation_toggle_on') - with When("I take screenshot with extrapolation"): - panel.take_screenshot_for_visualization(screenshot_name='extrapolation_toggle_on') + with When("I click on the extrapolation toggle to turn extrapolation off"): + sql_editor.click_extrapolation_toggle(query_name='A') - with When("I click on the extrapolation toggle to turn extrapolation off"): - sql_editor.click_extrapolation_toggle(query_name='A') + with When("I click on run query button to see results with turned off extrapolation"): + panel.click_run_query_button() - with When("I click on run query button to see results with turned off extrapolation"): - panel.click_run_query_button() + with When("I take screenshot without extrapolation"): + panel.take_screenshot_for_visualization(screenshot_name='extrapolation_toggle_off') - with When("I take screenshot without extrapolation"): - panel.take_screenshot_for_visualization(screenshot_name='extrapolation_toggle_off') + with When("I click on the extrapolation toggle to turn extrapolation on"): + sql_editor.click_extrapolation_toggle(query_name='A') - with When("I click on the extrapolation toggle to turn extrapolation on"): - sql_editor.click_extrapolation_toggle(query_name='A') - - with Then("I check screenshots are different"): - assert not(actions.compare_screenshots(screenshot_name_1='extrapolation_toggle_on', screenshot_name_2='extrapolation_toggle_off')) + with Then("I check screenshots are different"): + assert not(actions.compare_screenshots(screenshot_name_1='extrapolation_toggle_on', screenshot_name_2='extrapolation_toggle_off')) finally: with Finally("I return Step textfield and Resolution dropdown values back"):