Hi Dave,

Please attached patch to fixed Querytool feature test cases (RM2681
<https://redmine.postgresql.org/issues/2681>).


-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Mon, Sep 4, 2017 at 9:02 PM, pgAdmin 4 Jenkins <jenk...@pgadmin.org>
wrote:

> See <https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/11/display/redirect?page=changes>
>
> Changes:
>
> [Dave Page] Allow queries to be cancelled from the dashboard, and display
> additional
>
> [Ashesh Vashi] Define the utility path lable, and help message for the
> Greenplum
>
> [Ashesh Vashi] Using the proper python syntax to fetch the default binary
> path for
>
> [akshay.joshi] Fixed issue where 'backend_type' column is exist for
> database server
>
> [Dave Page] Cleanup feature tests. Fixes #2586
>
> [Dave Page] Allow pgAdmin to run with config database versions from the
> future.
>
> [Dave Page] Rename the debugger XSS test function to 'a_test_function' to
> ensure it
>
> [Dave Page] GPDB compatibility fixes:
>
> [Dave Page] Fix RE-SQL for triggers with a single arg. Fixes #2668
>
> [Dave Page] Improve datamodel validations for default Validator if user
> (developer)
>
> [Dave Page] Fix display of types in GPDB.
>
> [Ashesh Vashi] Define the proper NODE_ENV environment during running the
> webpack. Using
>
> [akshay.joshi] 1) Fixed error in alertify.pgNotifier when server
> connection is lost. 2)
>
> [Dave Page] Fix Copy so it still works after query results have been
> copied. Fixes
>
> ------------------------------------------
> [...truncated 79.49 KB...]
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/errorhandler.py",> line 193, in check_response
>     raise exception_class(message, screen, stacktrace)
> NoSuchElementException: Message: no such element: Unable to locate
> element: {"method":"xpath","selector":"//*[contains(string(),'Total
> Cost')]"}
>   (Session info: chrome=59.0.3071.115)
>   (Driver info: chromedriver=2.29.461571 
> (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux
> 3.10.0-514.16.1.el7.x86_64 x86_64)
>
>
> ----------------------------------------------------------------------
> Ran 9 tests in 154.798s
>
> FAILED (errors=1)
>
> =============Running the test cases for 'EDB Postgres AS 9.4'=============
> runTest (pgadmin.feature_tests.copy_selected_query_results_feature_test.
> CopySelectedQueryResultsFeatureTest)
> Copy rows, column using button and keyboard shortcut ... ok
> runTest (pgadmin.feature_tests.pg_datatype_validation_test.
> PGDataypeFeatureTest)
> Test checks for PG data-types output ... ok
> runTest (pgadmin.feature_tests.query_tool_journey_test.
> QueryToolJourneyTest)
> Tests the path through the query tool ... ok
> runTest (pgadmin.feature_tests.query_tool_tests.QueryToolFeatureTest)
> Query tool feature test ...
> On demand query result...
> On demand result set on scrolling... OK.
> On demand result set on grid select all... OK.
> On demand result set on column select all... OK.
> Explain query with verbose and cost... OK.
> Explain analyze query with buffers and timing... OK.
> Auto commit disabled... OK.
> Auto commit enabled... OK.
> Auto rollback enabled... OK.
> Cancel query... OK.
> ok
> runTest (pgadmin.feature_tests.table_ddl_feature_test.TableDdlFeatureTest)
> Test table DDL generation ... ok
> runTest (pgadmin.feature_tests.view_data_dml_queries.CheckForViewDataTest)
> Validate Insert, Update operations in View/Edit data with given test data
> ... ok
> runTest (pgadmin.feature_tests.xss_checks_panels_and_query_tool_
> test.CheckForXssFeatureTest)
> Test XSS check for panels and query tool ... ok
> runTest (pgadmin.feature_tests.xss_checks_pgadmin_debugger_test.
> CheckDebuggerForXssFeatureTest)
> Tests to check if Debugger is vulnerable to XSS ... ok
> runTest (pgadmin.feature_tests.xss_checks_roles_control_test.
> CheckRoleMembershipControlFeatureTest)
> Tests to check if Role membership control is vulnerable to XSS ... ok
>
> ----------------------------------------------------------------------
> Ran 9 tests in 225.902s
>
> OK
>
> =============Running the test cases for 'EDB Postgres AS 9.5'=============
> runTest (pgadmin.feature_tests.copy_selected_query_results_feature_test.
> CopySelectedQueryResultsFeatureTest)
> Copy rows, column using button and keyboard shortcut ... ok
> runTest (pgadmin.feature_tests.pg_datatype_validation_test.
> PGDataypeFeatureTest)
> Test checks for PG data-types output ... ok
> runTest (pgadmin.feature_tests.query_tool_journey_test.
> QueryToolJourneyTest)
> Tests the path through the query tool ... ok
> runTest (pgadmin.feature_tests.query_tool_tests.QueryToolFeatureTest)
> Query tool feature test ...
> On demand query result...
> On demand result set on scrolling... OK.
> On demand result set on grid select all... OK.
> On demand result set on column select all... OK.
> Explain query with verbose and cost... ERROR
> runTest (pgadmin.feature_tests.table_ddl_feature_test.TableDdlFeatureTest)
> Test table DDL generation ... ok
> runTest (pgadmin.feature_tests.view_data_dml_queries.CheckForViewDataTest)
> Validate Insert, Update operations in View/Edit data with given test data
> ... ok
> runTest (pgadmin.feature_tests.xss_checks_panels_and_query_tool_
> test.CheckForXssFeatureTest)
> Test XSS check for panels and query tool ... ok
> runTest (pgadmin.feature_tests.xss_checks_pgadmin_debugger_test.
> CheckDebuggerForXssFeatureTest)
> Tests to check if Debugger is vulnerable to XSS ... ok
> runTest (pgadmin.feature_tests.xss_checks_roles_control_test.
> CheckRoleMembershipControlFeatureTest)
> Tests to check if Role membership control is vulnerable to XSS ... ok
>
> ======================================================================
> ERROR: runTest (pgadmin.feature_tests.query_tool_tests.
> QueryToolFeatureTest)
> Query tool feature test
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/web/pgadmin/feature_tests/query_tool_tests.py",> line 55, in
> runTest
>     self._query_tool_explain_with_verbose_and_cost()
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/web/pgadmin/feature_tests/query_tool_tests.py",> line 235, in
> _query_tool_explain_with_verbose_and_cost
>     canvas.find_element_by_xpath("//*[contains(string(),'Total Cost')]")
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webelement.py",> line 260, in
> find_element_by_xpath
>     return self.find_element(by=By.XPATH, value=xpath)
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webelement.py",> line 510, in find_element
>     {"using": by, "value": value})['value']
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webelement.py",> line 493, in _execute
>     return self._parent.execute(command, params)
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webdriver.py",> line 249, in execute
>     self.error_handler.check_response(response)
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/errorhandler.py",> line 193, in check_response
>     raise exception_class(message, screen, stacktrace)
> NoSuchElementException: Message: no such element: Unable to locate
> element: {"method":"xpath","selector":"//*[contains(string(),'Total
> Cost')]"}
>   (Session info: chrome=59.0.3071.115)
>   (Driver info: chromedriver=2.29.461571 
> (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux
> 3.10.0-514.16.1.el7.x86_64 x86_64)
>
>
> ----------------------------------------------------------------------
> Ran 9 tests in 155.286s
>
> FAILED (errors=1)
>
> =============Running the test cases for 'EDB Postgres AS 9.6'=============
> runTest (pgadmin.feature_tests.copy_selected_query_results_feature_test.
> CopySelectedQueryResultsFeatureTest)
> Copy rows, column using button and keyboard shortcut ... ok
> runTest (pgadmin.feature_tests.pg_datatype_validation_test.
> PGDataypeFeatureTest)
> Test checks for PG data-types output ... ok
> runTest (pgadmin.feature_tests.query_tool_journey_test.
> QueryToolJourneyTest)
> Tests the path through the query tool ... ok
> runTest (pgadmin.feature_tests.query_tool_tests.QueryToolFeatureTest)
> Query tool feature test ...
> On demand query result...
> On demand result set on scrolling... OK.
> On demand result set on grid select all... OK.
> On demand result set on column select all... OK.
> Explain query with verbose and cost... OK.
> Explain analyze query with buffers and timing... ERROR
> runTest (pgadmin.feature_tests.table_ddl_feature_test.TableDdlFeatureTest)
> Test table DDL generation ... ok
> runTest (pgadmin.feature_tests.view_data_dml_queries.CheckForViewDataTest)
> Validate Insert, Update operations in View/Edit data with given test data
> ... ok
> runTest (pgadmin.feature_tests.xss_checks_panels_and_query_tool_
> test.CheckForXssFeatureTest)
> Test XSS check for panels and query tool ... ok
> runTest (pgadmin.feature_tests.xss_checks_pgadmin_debugger_test.
> CheckDebuggerForXssFeatureTest)
> Tests to check if Debugger is vulnerable to XSS ... ok
> runTest (pgadmin.feature_tests.xss_checks_roles_control_test.
> CheckRoleMembershipControlFeatureTest)
> Tests to check if Role membership control is vulnerable to XSS ... ok
>
> ======================================================================
> ERROR: runTest (pgadmin.feature_tests.query_tool_tests.
> QueryToolFeatureTest)
> Query tool feature test
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/web/pgadmin/feature_tests/query_tool_tests.py",> line 62, in
> runTest
>     self._query_tool_explain_analyze_with_buffers_and_timing()
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/web/pgadmin/feature_tests/query_tool_tests.py",> line 267, in
> _query_tool_explain_analyze_with_buffers_and_timing
>     "//*[contains(string(), 'Shared Read Blocks')]"
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webelement.py",> line 260, in
> find_element_by_xpath
>     return self.find_element(by=By.XPATH, value=xpath)
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webelement.py",> line 510, in find_element
>     {"using": by, "value": value})['value']
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webelement.py",> line 493, in _execute
>     return self._parent.execute(command, params)
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/webdriver.py",> line 249, in execute
>     self.error_handler.check_response(response)
>   File "<https://jenkins.pgadmin.org/job/pgadmin4-master-python27-
> feature/ws/pgadmin-venv/lib/python2.7/site-packages/
> selenium/webdriver/remote/errorhandler.py",> line 193, in check_response
>     raise exception_class(message, screen, stacktrace)
> NoSuchElementException: Message: no such element: Unable to locate
> element: {"method":"xpath","selector":"//*[contains(string(), 'Shared
> Read Blocks')]"}
>   (Session info: chrome=59.0.3071.115)
>   (Driver info: chromedriver=2.29.461571 
> (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux
> 3.10.0-514.16.1.el7.x86_64 x86_64)
>
>
> ----------------------------------------------------------------------
> Ran 9 tests in 159.524s
>
> FAILED (errors=1)
>
> ======================================================================
> Test Result Summary
> ======================================================================
>
> PostgreSQL 9.6:
>
>         9 tests passed
>         0 tests failed
>         0 tests skipped
>
> PostgreSQL 9.5:
>
>         8 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         0 tests skipped
>
> PostgreSQL 9.4:
>
>         8 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         0 tests skipped
>
> PostgreSQL 9.3:
>
>         8 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         0 tests skipped
>
> PostgreSQL 9.2:
>
>         9 tests passed
>         0 tests failed
>         0 tests skipped
>
> PostgreSQL 10:
>
>         7 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         1 test skipped:
>                 CheckDebuggerForXssFeatureTest (Tests to check if Debugger
> is vulnerable to XSS)
>
> EDB Postgres AS 9.4:
>
>         9 tests passed
>         0 tests failed
>         0 tests skipped
>
> EDB Postgres AS 9.5:
>
>         8 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         0 tests skipped
>
> EDB Postgres AS 9.6:
>
>         8 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         0 tests skipped
>
> EDB Postgres AS 9.2:
>
>         7 tests passed
>         2 tests failed:
>                 QueryToolFeatureTest (Query tool feature test)
>                 CheckDebuggerForXssFeatureTest (Tests to check if Debugger
> is vulnerable to XSS)
>         0 tests skipped
>
> EDB Postgres AS 9.3:
>
>         8 tests passed
>         1 test failed:
>                 QueryToolFeatureTest (Query tool feature test)
>         0 tests skipped
>
> ======================================================================
>
> NOTE: Configuring authentication for DESKTOP mode.
> pgAdmin 4 - Application Initialisation
> ======================================
>
> Please check output in file: <https://jenkins.pgadmin.org/
> job/pgadmin4-master-python27-feature/ws/web/regression/regression.log>
>
> ERROR: Error detected when running the Feature tests.
> Process leaked file descriptors. See https://jenkins.io/redirect/
> troubleshooting/process-leaked-file-descriptors for more information
> Build step 'Execute shell' marked build as failure
> Not sending mail to unregistered user akshay.jo...@enterprisedb.com
>
>
diff --git a/web/pgadmin/feature_tests/query_tool_tests.py b/web/pgadmin/feature_tests/query_tool_tests.py
index e2adb6e..d9df7ad 100644
--- a/web/pgadmin/feature_tests/query_tool_tests.py
+++ b/web/pgadmin/feature_tests/query_tool_tests.py
@@ -41,6 +41,7 @@ class QueryToolFeatureTest(BaseFeatureTest):
         self.page.add_server(self.server)
         self._locate_database_tree_node()
         self.page.open_query_tool()
+        self._reset_options()
 
     def runTest(self):
         # on demand result set on scrolling.
@@ -97,6 +98,33 @@ class QueryToolFeatureTest(BaseFeatureTest):
                                                   self.server['sslmode'])
         test_utils.drop_database(connection, "acceptance_test_db")
 
+    def _reset_options(self):
+        # this will set focus to correct iframe.
+        self.page.fill_codemirror_area_with('')
+
+        query_op = self.page.find_by_id("btn-query-dropdown")
+        query_op.click()
+        ActionChains(self.driver).move_to_element(
+            query_op.find_element_by_xpath(
+                "//li[contains(.,'Explain Options')]")).perform()
+
+        # disable Explain options and auto rollback only if they are enabled.
+        for op in ('explain-verbose', 'explain-costs',
+                   'explain-buffers', 'explain-timing', 'auto-rollback'):
+            btn = self.page.find_by_id("btn-{}".format(op))
+            check = btn.find_element_by_tag_name('i')
+            if 'visibility-hidden' not in check.get_attribute('class'):
+                btn.click()
+
+        # enable autocommit only if it's disabled
+        btn = self.page.find_by_id("btn-auto-commit")
+        check = btn.find_element_by_tag_name('i')
+        if 'visibility-hidden' in check.get_attribute('class'):
+            btn.click()
+
+        # close menu
+        query_op.click()
+
     def _locate_database_tree_node(self):
         self.page.toggle_open_tree_item(self.server['name'])
         self.page.toggle_open_tree_item('Databases')

Reply via email to