pgAdmin 4 is the most popular and the most feature rich Open Source administration and development platform for PostgreSQL. pgAdmin can be run either in desktop mode (single user) or server mode (multi user). In server mode, pgAdmin can be accessed using a browser on a local operating system.
pgAdmin follows an Agile development process with an iterative and incremental approach to development. Testing is a critical part of the development process. pgAdmin is regularly tested with a subset of the available versions, ensuring a high-quality product. The test suite includes API testing, UI Testing (referred as Feature Testing), unit testing, and "resql" testing, a pgAdmin-specific test framework for testing the reverse engineering of SQL.
To achieve better quality in the short release cycles, test automation is required. The Selenium WebDriver with Python is used for feature test automation. Feature test frameworks currently support parallel testing/cross-browser testing. The new era of continuous testing requires faster test execution. Parallel testing involves running independent tests in parallel to reduce overall test execution time by allowing multiple OS/browser combinations to be tested simultaneously. An extended test coverage minimizes risk and reduces the chances of releasing a product with regressions or defects.
Feature Test Automation in pgAdmin
pgAdmin Test Automation Architecture
pgAdmin feature test automation has components below -
1. WebDriver API
WebDriver drives a browser natively, as a user would, either locally or on a remote machine using the Selenium server. Selenium WebDriver refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just WebDriver. WebDriver communicates to a browser through the driver. The driver is specific to the browser, such as ChromeDriver for Google’s Chrome/Chromium, GeckoDriver for Mozilla’s Firefox, etc. The driver runs on the same system as the browser. This may, or may not be, the same system where the tests themselves are executing.
2. Framework- Python-unittest
Webdriver has one job and one job only: communicate with the browser. WebDriver does not know a thing about testing: it does not know how to compare things, assert pass or fail, and it certainly does not know anything about reporting. Hence a test framework is required while using selenium WebDriver for test automation. The test framework is responsible for running and executing the WebDriver and related steps in the tests. pgAdmin uses a builtin unittest framework that comes bundled with Python. In unittest, the base class provides all assertion methods as well as the cleanup and setup routines. Also, python multithreading approach is used to launch multiple tests at a time.
WebDriver’s communication to the browser may also be remote communication through Selenium Server or RemoteWebDriver. RemoteWebDriver runs on the same system as the driver and the browser. Remote communication can also take place using Selenium Server or Selenium Grid, both of which in turn talk to the driver on the host system.
Selenoid is an implementation of selenium hub using Docker containers to launch browsers. Selenoid enables parallel testing and cross browser testing with reduced hardware cost and without the tricky setup of selenium grid. Selenoid provides a short-lived container for each selenium session (i.e. request for browser) and stops it immediately when the session is closed. Every container consists of a specific browser version, a corresponding WebDriver binary supporting this version and all required dependencies like fonts, graphics toolkits and so on. Containers provide a high enough level of isolation between browser processes that enables a theoretically unlimited number of different browser versions to be tested in parallel, subject to resource availability.
Selenoid also provides features like video recording and online/offline dashboards. It also provides live preview and ability to interact with browsers to help developers diagnose and understand test failures.
Here are some snippets for pgAdmin test automation with selenoid -
1. Available browsers and configurations -
2. Stats and sessions -
3. Live test execution
4. Video recordings
Selenoid is popular and has a strong developer community. It maintains a set of prebuilt docker container images for different browsers including Android, Firefox, Chrome, and Opera with multiple versions. Following the release of a new browser version, docker container images for browsers are released. Cross browser testing helped pgAdmin to reduce test execution time and increase test coverage.