2016-04-17 09:39:08 -05:00
|
|
|
|
pgAdmin 4 Test Framework
|
|
|
|
|
========================
|
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
This regression framework is designed to execute unit tests for all modules to
|
|
|
|
|
help catch regressions in the code.
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
|
|
|
|
Assumptions
|
|
|
|
|
-----------
|
|
|
|
|
|
2016-07-27 09:35:11 -05:00
|
|
|
|
- pgAdmin must have SMTP configured if SERVER_MODE == True.
|
2016-04-17 09:39:08 -05:00
|
|
|
|
- There should be a single server group present in the browser.
|
|
|
|
|
- Currently each module will have testcases related to ONLY GET, POST, PUT,
|
|
|
|
|
and DELETE api’s.
|
|
|
|
|
|
2017-02-26 03:06:17 -06:00
|
|
|
|
Environment
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
Regression tests should be run in a Python environment that has all the
|
|
|
|
|
pre-requisite packages installed from $PGADMIN4_SRC/requirements.txt. There
|
|
|
|
|
are some additional dependencies for running the test suite; these can be
|
|
|
|
|
installed with:
|
|
|
|
|
|
|
|
|
|
(pgadmin4) $ pip install -r $PGADMIN4_SRC/web/regression/requirements.txt
|
|
|
|
|
|
2017-04-18 07:28:45 -05:00
|
|
|
|
While running in Linux environments install:
|
|
|
|
|
|
|
|
|
|
(pgadmin4) $ sudo apt-get install xsel
|
|
|
|
|
|
|
|
|
|
Otherwise the following error happens:
|
|
|
|
|
"Pyperclip could not find a copy/paste mechanism for your system"
|
|
|
|
|
|
2016-04-17 09:39:08 -05:00
|
|
|
|
General Information
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
1) The required test cases should be placed under the /tests directory of the
|
|
|
|
|
respective module.
|
|
|
|
|
|
|
|
|
|
- 'pgadmin/browser/tests' directory contains test-cases for following
|
|
|
|
|
modules:
|
|
|
|
|
|
|
|
|
|
1. Login Page
|
|
|
|
|
2. Reset Password Page
|
|
|
|
|
3. Change Password Page
|
|
|
|
|
4. Logout Page
|
|
|
|
|
|
|
|
|
|
- 'pgAdmin4/web/pgadmin/browser/server_groups/tests/' shows an example of
|
|
|
|
|
tree traversal of the pgAdmin modules and how the test folder is required
|
|
|
|
|
for each individual module.
|
2018-05-15 09:10:11 -05:00
|
|
|
|
|
2016-04-17 09:39:08 -05:00
|
|
|
|
- 'pgadmin/browser/server_groups/servers/tests/' directory will have separate
|
|
|
|
|
file for each test-case:
|
|
|
|
|
|
|
|
|
|
1. test_server_add.py
|
|
|
|
|
2. test_server_delete.py
|
|
|
|
|
3. test_server_get.py
|
|
|
|
|
4. test_server_update.py
|
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
2) The pgAdmin4 source tree includes 2 different configuration file templates.
|
|
|
|
|
One file template for the server configuration
|
|
|
|
|
named ‘test_config.json.in' and another for test configuration named
|
|
|
|
|
'test_advanced_config.json.in' in the ‘pgAdmin4/web/regression’ directory.
|
|
|
|
|
After completing the pgAdmin4 configuration, you must make a working copy of
|
|
|
|
|
the templates called test_config.json and test_advance_config.json
|
|
|
|
|
before modifying the file contents.
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
2a) The following command copies the test_config.json.in file, creating a
|
|
|
|
|
configuration file named test_config.json (same way user can copy
|
|
|
|
|
test_advance_config.json.in file into test_advance_config.json)
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
$ cp pgadmin4/web/regression/test_config.json.in \
|
|
|
|
|
pgadmin4/web/regression/test_config.json
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
2b) After creating the server and test configuration file, add (or modify)
|
2017-02-22 06:41:28 -06:00
|
|
|
|
parameter values as per requirements. The pgAdmin4 regression framework
|
|
|
|
|
expects to find the files in the directory
|
|
|
|
|
'/<installation dir>/web/regression/'. If you move the file to another
|
|
|
|
|
location, you must create a symbolic link that specifies the new location.
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
2c) Specifying Server Configuration file:
|
|
|
|
|
|
|
|
|
|
Server details and connection properties as per their local setup. The
|
|
|
|
|
test_config file is in JSON format and property values are
|
|
|
|
|
case-sensitive.
|
|
|
|
|
|
|
|
|
|
2d) Specifying the Test Configuration file:
|
|
|
|
|
|
|
|
|
|
The user can add/change test data as per their need. The
|
|
|
|
|
test_advanced_config file is in JSON format and property values are
|
|
|
|
|
case-sensitive.
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Test Data Details
|
|
|
|
|
-----------------
|
|
|
|
|
|
2016-08-09 10:05:40 -05:00
|
|
|
|
"pgAdmin4 Login Credentials" (used to login to pgAdmin):
|
|
|
|
|
|
|
|
|
|
login_username = login id
|
|
|
|
|
login_password = login password
|
|
|
|
|
new_password = new login password
|
|
|
|
|
|
|
|
|
|
"pgAdmin4 Test User Credentials" (dummy user used for testing user management):
|
|
|
|
|
|
|
|
|
|
login_username = login id
|
|
|
|
|
login_password = login password
|
|
|
|
|
new_password = new login password
|
|
|
|
|
|
|
|
|
|
"server_credentials":
|
|
|
|
|
|
|
|
|
|
name = Server/database Name
|
|
|
|
|
db_username = Database Username
|
|
|
|
|
host = IP Address of Server
|
|
|
|
|
db_password = Database Password
|
|
|
|
|
db_port = Database Port
|
|
|
|
|
maintenance_db = Maintenance Database
|
|
|
|
|
sslmode = SSL Mode
|
|
|
|
|
comment = Any Comments to add
|
|
|
|
|
tablespace_path = A path under which a tablespace can be created
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Execution:
|
|
|
|
|
-----------
|
2016-07-18 08:50:21 -05:00
|
|
|
|
|
2017-03-15 12:16:02 -05:00
|
|
|
|
Python Tests:
|
2017-03-15 12:09:22 -05:00
|
|
|
|
|
2017-02-22 06:41:28 -06:00
|
|
|
|
- For feature tests to run as part of the entire test suite, Chrome and
|
|
|
|
|
chromedriver need to be installed; get chromedriver from
|
|
|
|
|
https://sites.google.com/a/chromium.org/chromedriver/downloads or a
|
|
|
|
|
package manager and make sure it is in the PATH
|
|
|
|
|
|
2018-05-15 09:10:11 -05:00
|
|
|
|
- For feature tests to run on Firefox, geckodriver need to be installed;
|
|
|
|
|
- Get geckodriver from https://github.com/mozilla/geckodriver/releases.
|
|
|
|
|
- Extract the binary and run chmod +x geckodriver.
|
|
|
|
|
- Copy geckodriver into /usr/local/bin or make sure path of the
|
|
|
|
|
geckodriver must be specified in the PATH.
|
|
|
|
|
- Set the "default_browser" parameter in test_config file or pass the command
|
|
|
|
|
line option --default_browser. Supported browsers are "Chrome" and
|
|
|
|
|
"Firefox".
|
|
|
|
|
|
2016-04-17 09:39:08 -05:00
|
|
|
|
- The test framework is modular and pluggable and dynamically locates tests
|
|
|
|
|
for modules which are discovered at runtime. All test cases are found
|
|
|
|
|
and registered automatically by its module name in
|
|
|
|
|
'pgadmin4/web/pgadmin/utils/test.py' file.
|
|
|
|
|
|
2020-05-11 01:41:31 -05:00
|
|
|
|
- To run Feature Tests in parallel using selenoid(grid + docker), selenoid
|
Improved the extendability of the SchemaView and DataGridView. (#7876)
Restructured these modules for ease of maintenance and apply the single
responsibility principle (wherever applicable).
* SchemaView
- Split the code based on the functionality and responsibility.
- Introduced a new View 'InlineView' instead of using the
'nextInline' configuration of the fields to have a better, and
manageable view.
- Using the separate class 'SchemaState' for managing the data and
states of the SchemaView (separated from the 'useSchemaState'
custom hook).
- Introduced three new custom hooks 'useFieldValue',
'useFieldOptions', 'useFieldError' for the individual control to
use for each Schema Field.
- Don't pass value as the parameter props, and let the
'useFieldValue' and other custom hooks to decide, whether to
rerender the control itself or the whole dialog/view. (single
responsibility principle)
- Introduced a new data store with a subscription facility.
- Moving the field metadata (option) evaluation to a separate place
for better management, and each option can be defined for a
particular kind of field (for example - collection, row, cell,
general, etc).
- Allow to provide custom control for all kind of Schema field.
* DataGridView
- Same as SchemaView, split the DataGridView call into smaller,
manageable chunks. (For example - grid, row, mappedCell, etc).
- Use context based approach for providing the row and table data
instead of passing them as parameters to every component
separately.
- Have a facility to extend this feature separately in future.
(for example - selectable cell, column grouping, etc.)
- Separated the features like deletable, editable, reorder,
expandable etc. cells using the above feature support.
- Added ability to provide the CustomHeader, and CustomRow through the
Schema field, which will extend the ability to customize better.
- Removed the 'DataGridViewWithHeaderForm' as it has been achieved
through providing 'CustomHeader', and also introduced
'DataGridFormHeader' (a custom header) to achieve the same feature
as 'DataGridViewWithHeaderForm'.
2024-09-09 03:57:31 -05:00
|
|
|
|
need to be installed and should be run only with SERVER_MODE=True.
|
2021-05-27 00:31:25 -05:00
|
|
|
|
Steps to install selenoid -
|
2020-05-11 01:41:31 -05:00
|
|
|
|
|
|
|
|
|
- Install & Start docker
|
|
|
|
|
$yum -y install docker docker-registry
|
|
|
|
|
$vi /etc/sysconfig/docker # in OPTIONS add ‘--selinux-enabled=false’
|
|
|
|
|
$systemctl enable docker.service
|
|
|
|
|
$systemctl start docker.service
|
|
|
|
|
$systemctl status docker.service
|
|
|
|
|
|
|
|
|
|
- Install & Start Selenoid
|
|
|
|
|
$curl -s https://aerokube.com/cm/bash | bash
|
|
|
|
|
$./cm selenoid start --vnc --args "-limit 3 -cpu 1.5 -mem 1.5g"
|
|
|
|
|
$./cm selenoid-ui start
|
|
|
|
|
Check selenoid status -
|
|
|
|
|
http://<IP address of Selenoid Installed machine>:4444/status
|
|
|
|
|
- Should show json with browsers details
|
|
|
|
|
http://<IP address of Selenoid Installed machine>:8080/#/
|
|
|
|
|
- Capabilities shows available browser
|
|
|
|
|
Note : In --args "-limit 3 -cpu 1.5 -mem 1.5g"
|
|
|
|
|
-limit 3 :limits maximum parallel sessions(dockers) in selenoid,
|
|
|
|
|
-cpu :limit memory and CPU usage,
|
|
|
|
|
-mem :limit memory per session.
|
|
|
|
|
Generally max parallel session is the number of cores * 1.5 – 2
|
|
|
|
|
You can list available flags by using ./cm selenoid args
|
|
|
|
|
Additional Information about tool
|
|
|
|
|
- https://aerokube.com/selenoid/latest/
|
|
|
|
|
|
|
|
|
|
- Update 'test_config.json' with selenoid config information
|
|
|
|
|
pgAdmin_default_server -
|
|
|
|
|
It is the IP address for the machine where pgadmin source code is
|
|
|
|
|
present.Value should NOT be '127.0.0.1' even though everything runs
|
|
|
|
|
on the same machine.
|
|
|
|
|
You can get it on linux running command 'ifconfig | grep inet'
|
|
|
|
|
e.g. - 192.168.143.121
|
|
|
|
|
max_parallel_sessions -
|
|
|
|
|
This is other way to control number of tests to be run in parallel.
|
|
|
|
|
This should be equal or less than limit specified while setting up
|
|
|
|
|
selenoid
|
|
|
|
|
selenoid_url -
|
|
|
|
|
Url should be formed as below -
|
|
|
|
|
http://<IP address of Selenoid Installed machine>:4444/wd/hub/
|
|
|
|
|
e.g. - selenoid_url": "http://192.168.143.121:4444/wd/hub"
|
|
|
|
|
If source code & selenoid servers are on same machine then
|
|
|
|
|
selenoid url value can be - "http://localhost:4444/wd/hub"
|
|
|
|
|
browsers_list -
|
|
|
|
|
List of browser name & version enclosed in {} on which tests to be
|
|
|
|
|
executed.
|
|
|
|
|
Make sure list contains those browsers & versions only which are shown
|
|
|
|
|
in capabilities tab while in selenoid status web-page.
|
|
|
|
|
If version is mention as null, then latest version available in
|
|
|
|
|
selenoid server will be used for execution.
|
|
|
|
|
e.g. - [ {"name": "Chrome","version": "80.0"},
|
|
|
|
|
{"name": "Firefox","version": "74.0"}]
|
|
|
|
|
|
2016-09-26 10:38:27 -05:00
|
|
|
|
- Change to the regression test directory:
|
|
|
|
|
run 'cd web/regression'
|
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
- Execute the test framework for all nodes
|
2016-09-26 10:38:27 -05:00
|
|
|
|
run 'python runtests.py --pkg all' or just:
|
|
|
|
|
'python runtests.py'
|
2016-07-18 08:50:21 -05:00
|
|
|
|
|
2017-02-15 09:10:31 -06:00
|
|
|
|
- Execute test framework for entire package
|
|
|
|
|
|
|
|
|
|
Example 1) Run test framework for 'browser' package
|
|
|
|
|
run 'python runtests.py --pkg browser'
|
|
|
|
|
|
|
|
|
|
Example 2) Run test framework for 'database' package
|
|
|
|
|
run 'python runtests.py --pkg browser.server_groups.servers.databases'
|
|
|
|
|
|
2017-04-07 06:37:00 -05:00
|
|
|
|
Example 3) Run feature tests
|
|
|
|
|
run 'python runtests.py --pkg feature_tests
|
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
- Execute test framework for single node at a time
|
|
|
|
|
|
|
|
|
|
Example 1) Run test framework for 'browser' node
|
2017-02-22 06:41:28 -06:00
|
|
|
|
run 'python runtests.py --pkg browser.server_groups.tests'
|
2016-04-17 09:39:08 -05:00
|
|
|
|
|
2016-07-18 08:50:21 -05:00
|
|
|
|
Example 2) Run test framework for 'database' node
|
2017-02-15 09:10:31 -06:00
|
|
|
|
run 'python runtests.py --pkg browser.server_groups.servers.databases.tests'
|
|
|
|
|
|
2019-03-21 07:04:37 -05:00
|
|
|
|
- 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'
|
|
|
|
|
|
2017-02-15 09:10:31 -06:00
|
|
|
|
- Exclude a package and its subpackages when running tests:
|
|
|
|
|
|
2017-02-22 06:41:28 -06:00
|
|
|
|
Example: exclude feature tests but run all others:
|
|
|
|
|
run 'python runtests.py --exclude feature_tests'
|
2017-02-15 09:10:31 -06:00
|
|
|
|
|
|
|
|
|
Example: exclude multiple packages:
|
|
|
|
|
run 'python runtests.py --exclude browser.server_groups.servers.databases,browser.server_groups.servers.tablespaces'
|
2017-03-15 12:09:22 -05:00
|
|
|
|
|
2019-08-07 05:24:10 -05:00
|
|
|
|
- Execute reverse engineered SQL test framework
|
|
|
|
|
Example 1) Execute only reverse engineered sql test framework for all nodes
|
|
|
|
|
run 'python runtests.py --pkg resql'
|
|
|
|
|
|
|
|
|
|
Example 2) Execute only reverse engineered SQL test framework for some modules
|
|
|
|
|
run 'python runtests.py --pkg resql --modules sequences,functions'
|
|
|
|
|
|
2020-04-22 03:27:32 -05:00
|
|
|
|
Example 3) Exclude reverse engineered SQL test framework for all modules
|
|
|
|
|
run 'python runtests.py --exclude resql'
|
|
|
|
|
|
2020-05-11 01:41:31 -05:00
|
|
|
|
- Execute ui selenium tests in parallel using selenoid(selenium grid + docker)
|
2022-02-16 06:33:42 -06:00
|
|
|
|
Example 1) Execute only all feature tests in parallel mode
|
|
|
|
|
run 'python runtests.py --pkg feature_tests --parallel'
|
|
|
|
|
|
|
|
|
|
Example 1) Execute particular module feature tests in parallel mode
|
|
|
|
|
run 'python runtests.py --pkg feature_tests --modules browser_tool_bar_test
|
|
|
|
|
--parallel'
|
|
|
|
|
|
2020-05-11 01:41:31 -05:00
|
|
|
|
|
|
|
|
|
|
2020-01-03 07:30:08 -06:00
|
|
|
|
Code Coverage:
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
- Test framework is able to calculate the code coverage.
|
|
|
|
|
- Coverage package(coverage) is added in $PGADMIN4_SRC/web/regression/requirements.txt file
|
|
|
|
|
|
|
|
|
|
How to generate code coverage report for API test-suite?
|
|
|
|
|
-------------------------------------
|
|
|
|
|
|
|
|
|
|
- Change to the regression test directory:
|
|
|
|
|
run 'cd $PGADMIN4_SRC/web/regression'
|
|
|
|
|
|
|
|
|
|
- Before running code coverage we need to configure 'regression/.coveragerc' file.
|
|
|
|
|
i). Create 'regression/.coveragerc' file.
|
|
|
|
|
ii). Copy content of 'regression/.coveragerc.in' to 'regression/.coveragerc'
|
|
|
|
|
iii). Modify 'regression/.coveragerc' file as per our need as 'regression/.coveragerc.in' has default configurations
|
|
|
|
|
|
|
|
|
|
In 'regression/.coveragerc' file we need to mention some parameters
|
|
|
|
|
like 'source'(project path),'include'(files/modules to be included for
|
|
|
|
|
coverage),'omit'(files/modules to be omitted from coverage)
|
|
|
|
|
|
|
|
|
|
We can also add more parameters according to our need.
|
|
|
|
|
For more info please read coverage.py's official document here
|
|
|
|
|
'http://coverage.readthedocs.io/en/coverage-4.2/install.html'
|
|
|
|
|
|
|
|
|
|
- Run coverage
|
|
|
|
|
With all modules
|
2020-12-06 07:46:17 -06:00
|
|
|
|
run `coverage run ./runtests.py --exclude feature_tests`
|
2020-01-03 07:30:08 -06:00
|
|
|
|
With specific module
|
2020-12-06 07:46:17 -06:00
|
|
|
|
run `coverage run ./runtests.py --exclude feature_tests --pkg browser.server_groups.servers.tests`
|
|
|
|
|
|
|
|
|
|
- After execution of coverage, you can run the following to see the code coverage report:
|
|
|
|
|
Normal report:
|
|
|
|
|
run `coverage report`
|
|
|
|
|
HTML report:
|
|
|
|
|
run `coverage html`
|
|
|
|
|
This will create a directory 'htmlcov'. Open 'index.html' file in browser and you will see detail coverage report.
|
2020-01-03 07:30:08 -06:00
|
|
|
|
|
2017-03-15 12:16:02 -05:00
|
|
|
|
Javascript Tests:
|
|
|
|
|
|
|
|
|
|
- Install node.js and yarn, in the appropriate way for your platform. On macOS with Homebrew you might use:
|
|
|
|
|
|
2017-03-15 12:09:22 -05:00
|
|
|
|
brew install nodejs
|
2017-03-15 12:13:55 -05:00
|
|
|
|
brew install yarn
|
2017-03-15 12:09:22 -05:00
|
|
|
|
|
2017-03-15 12:16:02 -05:00
|
|
|
|
Whilst with MacPorts:
|
|
|
|
|
|
|
|
|
|
sudo port install nodejs7 yarn
|
|
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
|
- See also the top-level pgadmin/README : Bundling Javascript
|
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
|
- Javascript tests must be run from the web directory (since that is where node_modules and jest.config.js reside):
|
2017-03-15 12:16:02 -05:00
|
|
|
|
|
2017-03-15 12:15:16 -05:00
|
|
|
|
cd web/
|
2017-03-15 12:16:02 -05:00
|
|
|
|
|
|
|
|
|
- Install the JS modules required for testing:
|
|
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
|
yarn install
|
2017-03-15 12:09:22 -05:00
|
|
|
|
|
2017-03-15 12:16:02 -05:00
|
|
|
|
- Now run the tests:
|
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
|
yarn run test:js
|
|
|
|
|
yarn run test:js-once
|