public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aditya Toshniwal <[email protected]>
To: Khushboo Vashi <[email protected]>
Cc: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][RM3936] Feature tests failing intermittently for SQL editor related test cases
Date: Tue, 5 Feb 2019 17:27:58 +0530
Message-ID: <CAM9w-_nRLFASEjHDgVgUDWPWNnbhBASW5wYpnWpiVMk9SUBfOQ@mail.gmail.com> (raw)
In-Reply-To: <CAFOhELcMR9h83h+i4PabUN=QrzARHyMndmWF2MUZ2CLHuJmC0Q@mail.gmail.com>
References: <CAM9w-_mx9D_W-H3x3HGq_pEcBiT7V65TWrW1B+Vin_VPXp=vEw@mail.gmail.com>
<CA+OCxozDzm8EpLTux7-C=wy3XZSpUHdCxFKo=9dv+eWKsbJD5A@mail.gmail.com>
<CAM9w-_n=7XEuFW+Vzi+xQgiXoJRdHu5-RrPS1QNwP7Ew9v6qdQ@mail.gmail.com>
<CA+OCxowUyiAP7rrV1nttj4kpKUednObSkVYoEbhtMvqb0CV8Ng@mail.gmail.com>
<CAM9w-_mR80KgZa5vSODppxJzushpWt14p2+Yo-6hdAJvE4WFmA@mail.gmail.com>
<CAM9w-_koTkQyNKkEKBdJ9tTJ74gcSD59_YvOqA_iaiT-xACShQ@mail.gmail.com>
<CA+OCxoyx-epUZ0n1wSoWWYjYyyVnuSWtoudMaChtJ3wO+_gaJQ@mail.gmail.com>
<CANxoLDce2y20K18cALcn09LeunwJ=FxBEsJmyWx5FsM07Gs+YA@mail.gmail.com>
<CANxoLDcbkCh0gdPYKZqJacffVkuXHRhWwPBXdLXJbv7UOkhaQQ@mail.gmail.com>
<CAM9w-_=60dr7b2zdo9HV6gKPbNPBZKQT+FYiYNZBHDz=DND8kw@mail.gmail.com>
<CANxoLDefTMG+qSNwfRAYNpC7o4suTw7dW=iKY-jBbAvarPon4Q@mail.gmail.com>
<CAFOhELcMR9h83h+i4PabUN=QrzARHyMndmWF2MUZ2CLHuJmC0Q@mail.gmail.com>
Hi Hackers,
Attached is the updated patch to fix possible causes of failure.
Kindly review (fingers crossed)
On Tue, Feb 5, 2019 at 10:48 AM Khushboo Vashi <
[email protected]> wrote:
>
>
> On Tue, Feb 5, 2019 at 10:40 AM Akshay Joshi <
> [email protected]> wrote:
>
>> Hi Aditya
>>
>> On Mon, Feb 4, 2019 at 2:18 PM Aditya Toshniwal <
>> [email protected]> wrote:
>>
>>> Hi Akshay,
>>>
>>> I tried to simulate, but no luck. It works on my system :(
>>>
>>
>> I have tried and Feature test are failing randomly for each run. I
>> have verified it on OSX and Ubuntu both.
>>
>>>
>>> +1
>
>> On Wed, Jan 30, 2019 at 7:15 PM Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>> Hi Aditya
>>>>
>>>> I have applied your patch but following test cases are failing
>>>> consistently:
>>>>
>>>> - CopySelectedQueryResultsFeatureTest
>>>> - QueryToolAutoCompleteFeatureTest
>>>>
>>>> I have verified your patch on Mac OSX and Ubuntu. Chrome Version
>>>> 71.0.3578.98
>>>>
>>>> On Tue, Jan 29, 2019 at 7:38 PM Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Tue, 29 Jan 2019, 19:09 Dave Page <[email protected] wrote:
>>>>>
>>>>>> Akshay, can you look at this please?
>>>>>>
>>>>>
>>>>> Sure.
>>>>>
>>>>>>
>>>>>> On Tue, Jan 29, 2019 at 1:36 PM Aditya Toshniwal
>>>>>> <[email protected]> wrote:
>>>>>> >
>>>>>> > Hi Hackers,
>>>>>> >
>>>>>> > Attached is the updated patch. I have changed
>>>>>> fill_input_by_field_name function to use javascript to set values of text
>>>>>> boxes and the selector is changed from xpath to CSS with a :not(:disabled)
>>>>>> clause. With this, test case will fail if tried to set the value of a
>>>>>> disabled input.
>>>>>> >
>>>>>> > Kindly review.
>>>>>> >
>>>>>> >
>>>>>> > On Mon, Jan 28, 2019 at 5:44 PM Aditya Toshniwal <
>>>>>> [email protected]> wrote:
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >> On Mon, Jan 28, 2019 at 5:39 PM Dave Page <[email protected]>
>>>>>> wrote:
>>>>>> >>>
>>>>>> >>> On Mon, Jan 28, 2019 at 12:05 PM Aditya Toshniwal
>>>>>> >>> <[email protected]> wrote:
>>>>>> >>> >
>>>>>> >>> > Hi Dave,
>>>>>> >>> >
>>>>>> >>> > On Mon, Jan 28, 2019 at 5:01 PM Dave Page <[email protected]>
>>>>>> wrote:
>>>>>> >>> >>
>>>>>> >>> >> Hi
>>>>>> >>> >>
>>>>>> >>> >> On Mon, Jan 28, 2019 at 7:00 AM Aditya Toshniwal
>>>>>> >>> >> <[email protected]> wrote:
>>>>>> >>> >> >
>>>>>> >>> >> > Hi Hackers,
>>>>>> >>> >> >
>>>>>> >>> >> > Attached is the patch to fix failing SQL editor related
>>>>>> feature tests.
>>>>>> >>> >> > The failure is occurring mostly because of send_keys
>>>>>> function of selenium which sometimes does not input the complete text. The
>>>>>> change will use Codemirror javascript object to set the text.
>>>>>> >>> >> >
>>>>>> >>> >> > I have also added new args flag "--modules" which can be
>>>>>> used after --pkg where you can test a specific module file under the pkg.
>>>>>> This is not so useful for build but definitely helpful for the developers.
>>>>>> >>> >>
>>>>>> >>> >> One of the most common failures I see is failure to fill in the
>>>>>> >>> >> details on the Add Server dialogue (it might type half of an
>>>>>> entry,
>>>>>> >>> >> then just hang). Should we get rid of all uses of send_keys?
>>>>>> >>> >
>>>>>> >>> > Setting the text using javascript executor can be done.
>>>>>> send_keys simulate an actual person, so if you try to set a disabled text
>>>>>> box using send_keys, it won't. Places where disabled fields doesn't matter,
>>>>>> send_keys can be removed.
>>>>>> >>>
>>>>>> >>> Can't we just do something like:
>>>>>> >>>
>>>>>> >>> if input.disabled == false:
>>>>>> >>> input.value = 'Foo';
>>>>>> >>> else:
>>>>>> >>> raise exception ....
>>>>>> >>
>>>>>> >> I'll check if this can be done. Will get back.
>>>>>> >>>
>>>>>> >>>
>>>>>> >>> --
>>>>>> >>> Dave Page
>>>>>> >>> Blog: http://pgsnake.blogspot.com
>>>>>> >>> Twitter: @pgsnake
>>>>>> >>>
>>>>>> >>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>> >>> The Enterprise PostgreSQL Company
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >> --
>>>>>> >> Thanks and Regards,
>>>>>> >> Aditya Toshniwal
>>>>>> >> Software Engineer | EnterpriseDB Software Solutions | Pune
>>>>>> >> "Don't Complain about Heat, Plant a tree"
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > --
>>>>>> > Thanks and Regards,
>>>>>> > Aditya Toshniwal
>>>>>> > Software Engineer | EnterpriseDB Software Solutions | Pune
>>>>>> > "Don't Complain about Heat, Plant a tree"
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dave Page
>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>> Twitter: @pgsnake
>>>>>>
>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>
>>>>
>>>> --
>>>> *Akshay Joshi*
>>>>
>>>> *Sr. Software Architect *
>>>>
>>>>
>>>>
>>>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>>>
>>>
>>>
>>> --
>>> Thanks and Regards,
>>> Aditya Toshniwal
>>> Software Engineer | EnterpriseDB Software Solutions | Pune
>>> "Don't Complain about Heat, Plant a tree"
>>>
>>
>>
>> --
>> *Akshay Joshi*
>>
>> *Sr. Software Architect *
>>
>>
>>
>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>
>
--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"
Attachments:
[application/octet-stream] RM3936_v3.patch (13.2K, 3-RM3936_v3.patch)
download | inline diff:
diff --git a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
index 1c89393d..4e11f994 100644
--- a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
+++ b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
@@ -83,6 +83,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.page.find_by_css_selector(
".pg-bg-more-details").click()
+ backup_file = None
# Check for XSS in Backup details
if self.is_xss_check:
self._check_detailed_window_for_xss('Backup')
@@ -99,7 +100,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.assertIn("pg_dump", str(command))
- backup_file = None
if command:
backup_file = command[int(command.find('--file')) +
8:int(command.find('--host')) - 2]
diff --git a/web/pgadmin/feature_tests/view_data_dml_queries.py b/web/pgadmin/feature_tests/view_data_dml_queries.py
index 1be9dcfa..36d224a8 100644
--- a/web/pgadmin/feature_tests/view_data_dml_queries.py
+++ b/web/pgadmin/feature_tests/view_data_dml_queries.py
@@ -309,6 +309,7 @@ CREATE TABLE public.defaults_{0}
if (idx != 1 and not is_new_row) or is_new_row:
self.assertEquals(element.text, config_data[str(idx)][1])
+ self.assertEquals(element.text, config_data[str(idx)][1])
# scroll browser back to the left
# to reset position so other assertions can succeed
diff --git a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py
index 27ac8c2c..365d109b 100644
--- a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py
@@ -55,10 +55,12 @@ class CheckForXssFeatureTest(BaseFeatureTest):
self._check_xss_in_dependents_tab()
# Query tool
+ self.page.open_query_tool()
self._check_xss_in_query_tool()
self.page.close_query_tool()
# Explain module
+ self.page.open_query_tool()
self._check_xss_in_explain_module()
self.page.close_query_tool()
@@ -142,17 +144,11 @@ class CheckForXssFeatureTest(BaseFeatureTest):
"Dependents tab (BackGrid)"
)
- def _open_query_tool(self):
- self.page.driver.find_element_by_link_text("Tools").click()
- self.page.find_by_partial_link_text("Query Tool").click()
- self.page.click_tab('Query -')
-
def _check_xss_in_query_tool(self):
print(
"\n\tChecking the SlickGrid cell for the XSS",
file=sys.stderr, end=""
)
- self._open_query_tool()
self.page.fill_codemirror_area_with(
"select '<img src=\"x\" onerror=\"console.log(1)\">'"
)
@@ -179,14 +175,10 @@ class CheckForXssFeatureTest(BaseFeatureTest):
"\n\tChecking the Graphical Explain plan for the XSS ...",
file=sys.stderr, end=""
)
- self._open_query_tool()
self.page.fill_codemirror_area_with(
'select * from "{0}"'.format(self.test_table_name)
)
- query_op = self.page.find_by_id("btn-query-dropdown")
- query_op.click()
-
self.page.find_by_id("btn-explain").click()
self.page.wait_for_query_tool_loading_indicator_to_disappear()
self.page.click_tab('Explain')
diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js
index df16d0bb..259d2a2a 100644
--- a/web/pgadmin/tools/datagrid/static/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js
@@ -54,14 +54,7 @@ define('pgadmin.datagrid', [
self.preferences = pgBrowser.get_preferences_for_module('sqleditor');
});
- this.spinner_el =
- `<div class="pg-sp-container">
- <div class="pg-sp-content">
- <div class="row">
- <div class="col-12 pg-sp-icon"></div>
- </div>
- </div>
- </div>`;
+
// Define list of nodes on which view data option appears
var supported_nodes = [
'table', 'view', 'mview',
@@ -514,17 +507,26 @@ define('pgadmin.datagrid', [
var openQueryToolURL = function(j) {
// add spinner element
- $(j).data('embeddedFrame').$container.append(pgAdmin.DataGrid.spinner_el);
- setTimeout(function() {
+ let $spinner_el =
+ $(`<div class="pg-sp-container">
+ <div class="pg-sp-content">
+ <div class="row">
+ <div class="col-12 pg-sp-icon"></div>
+ </div>
+ </div>
+ </div>`).appendTo($(j).data('embeddedFrame').$container);
+
+ let init_poller_id = setInterval(function() {
var frameInitialized = $(j).data('frameInitialized');
if (frameInitialized) {
+ clearInterval(init_poller_id);
var frame = $(j).data('embeddedFrame');
if (frame) {
+ frame.onLoaded(()=>{
+ $spinner_el.remove();
+ });
frame.openURL(baseUrl);
- frame.$container.find('.pg-sp-container').delay(1000).hide(1);
}
- } else {
- openQueryToolURL(j);
}
}, 100);
};
diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py
index e67f0195..b206cb2e 100644
--- a/web/pgadmin/utils/route.py
+++ b/web/pgadmin/utils/route.py
@@ -53,7 +53,7 @@ class TestsGeneratorRegistry(ABCMeta):
ABCMeta.__init__(cls, name, bases, d)
@classmethod
- def load_generators(cls, pkg_root, exclude_pkgs):
+ def load_generators(cls, pkg_root, exclude_pkgs, for_modules=[]):
cls.registry = dict()
@@ -61,6 +61,13 @@ class TestsGeneratorRegistry(ABCMeta):
all_modules += find_modules(pkg_root, False, True)
+ # If specific modules are to be tested, exclude others
+ if len(for_modules) > 0:
+ all_modules = [module_name
+ for module_name in all_modules
+ for fmod in for_modules
+ if module_name.endswith(fmod)]
+
# Check for SERVER mode
for module_name in all_modules:
try:
diff --git a/web/regression/README b/web/regression/README
index 7e668cfd..6a68d36f 100644
--- a/web/regression/README
+++ b/web/regression/README
@@ -167,6 +167,14 @@ Python Tests:
Example 2) Run test framework for 'database' node
run 'python runtests.py --pkg browser.server_groups.servers.databases.tests'
+- Execute test framework for certain modules of a test pkg
+
+ Example 1) Run test framework for 'sqleditor' package and test_start_running_query module
+ run 'python runtests.py --pkg tools.sqleditor --modules test_start_running_query'
+
+ Example 2) Run test framework for 'sqleditor' package and test_start_running_query,test_query_tool_fs_utils modules
+ run 'python runtests.py --pkg tools.sqleditor --modules test_start_running_query,test_query_tool_fs_utils'
+
- Exclude a package and its subpackages when running tests:
Example: exclude feature tests but run all others:
diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py
index 0c8f0fa3..1fb525ee 100644
--- a/web/regression/feature_utils/pgadmin_page.py
+++ b/web/regression/feature_utils/pgadmin_page.py
@@ -94,6 +94,7 @@ class PgadminPage:
self.find_by_partial_link_text("Query Tool").click()
self.click_tab('Query -')
+ self.find_by_css_selector('iframe')
def enable_menu_item(self, menu_item, wait_time):
start_time = time.time()
@@ -224,38 +225,60 @@ class PgadminPage:
"clicking the element not to throw an exception", click_succeeded
)
- def fill_input_by_field_name(self, field_name, field_content):
- field = self.find_by_xpath("//input[@name='" + field_name + "']")
+ def fill_input_by_field_name(self, field_name, field_content,
+ input_keys=False):
+ field = self.find_by_css_selector(
+ "input[name='" + field_name + "']:not(:disabled)")
backspaces = [Keys.BACKSPACE] * len(field.get_attribute('value'))
field.click()
- field.send_keys(backspaces)
- field.send_keys(str(field_content))
- self.wait_for_input_field_content(field_name, field_content)
- def fill_codemirror_area_with(self, field_content):
+ # Use send keys if input_keys true, else use javascript to set content
+ if input_keys:
+ field.send_keys(backspaces)
+ field.send_keys(str(field_content))
+ self.wait_for_input_field_content(field_name, field_content)
+ else:
+ self.driver.execute_script(
+ "arguments[0].setAttribute('value', arguments[1])",
+ field, field_content)
+
+ action = ActionChains(self.driver)
+ action.key_down(Keys.ARROW_DOWN)
+ action.perform()
+
+ def fill_codemirror_area_with(self, field_content, input_keys=False):
def find_codemirror(driver):
try:
driver.switch_to.default_content()
driver.switch_to_frame(
driver.find_element_by_tag_name("iframe"))
- element = driver.find_element_by_xpath(
- "//pre[contains(@class,'CodeMirror-line')]/../../../"
- "*[contains(@class,'CodeMirror-code')]")
+ element = driver.find_element_by_css_selector(
+ "#output-panel .CodeMirror")
if element.is_displayed() and element.is_enabled():
return element
except (NoSuchElementException, WebDriverException):
return False
+ codemirror_ele = WebDriverWait(
+ self.driver, timeout=self.timeout, poll_frequency=0.01)\
+ .until(find_codemirror,
+ "Timed out waiting for codemirror to appear")
+
time.sleep(1)
- WebDriverWait(self.driver, timeout=self.timeout, poll_frequency=0.01).\
- until(find_codemirror, "Timed out waiting for codemirror "
- "to appear").click()
- time.sleep(1)
+ codemirror_ele.click()
- action = ActionChains(self.driver)
- action.send_keys(field_content)
- action.perform()
+ # Use send keys if input_keys true, else use javascript to set content
+ if input_keys:
+ action = ActionChains(self.driver)
+ action.send_keys(field_content)
+ action.perform()
+ else:
+ self.driver.execute_script(
+ "arguments[0].CodeMirror.setValue(arguments[1]);"
+ "arguments[0].CodeMirror.setCursor("
+ "arguments[0].CodeMirror.lineCount(),0);",
+ codemirror_ele, field_content)
def click_tab(self, tab_name):
WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable(
@@ -329,10 +352,10 @@ class PgadminPage:
def wait_for_query_tool_loading_indicator_to_disappear(self):
def spinner_has_disappeared(driver):
try:
- driver.find_element_by_xpath(
- "//*[@id='fetching_data' and @class='hide']"
+ spinner = driver.find_element_by_css_selector(
+ "#editor-panel .pg-sp-container"
)
- return False
+ return "d-none" in spinner.get_attribute("class")
except NoSuchElementException:
# wait for loading indicator disappear animation to complete.
time.sleep(0.5)
diff --git a/web/regression/runtests.py b/web/regression/runtests.py
index 48d3749f..6f95370f 100644
--- a/web/regression/runtests.py
+++ b/web/regression/runtests.py
@@ -230,9 +230,14 @@ def get_test_modules(arguments):
if arguments['pkg'] is None or arguments['pkg'] == "all":
TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs)
else:
+ for_modules = []
+ if arguments['modules'] is not None:
+ for_modules = arguments['modules'].split(',')
+
TestsGeneratorRegistry.load_generators('pgadmin.%s' %
arguments['pkg'],
- exclude_pkgs)
+ exclude_pkgs,
+ for_modules)
# Sort module list so that test suite executes the test cases sequentially
module_list = TestsGeneratorRegistry.registry.items()
@@ -263,6 +268,10 @@ def add_arguments():
'--default_browser',
help='Executes the feature test in specific browser'
)
+ parser.add_argument(
+ '--modules',
+ help='Executes the feature test for specific modules in pkg'
+ )
arg = parser.parse_args()
return arg
view thread (15+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: [pgAdmin4][RM3936] Feature tests failing intermittently for SQL editor related test cases
In-Reply-To: <CAM9w-_nRLFASEjHDgVgUDWPWNnbhBASW5wYpnWpiVMk9SUBfOQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox