PostgreSQL exporter

The PostgreSQL exporter writes test case results into a PostgreSQL database table instead of a file. It reuses the PostgreSQL connector to connect and run the queries.

The exporter automatically creates the destination table if it does not exist, then inserts one row per test case.

Connection configuration

The exporter connects through a dedicated export connection declared in the connections file. The type of this connection must match the exporter name (postgresql).

The connection accepts the same parameters as the PostgreSQL connector.

connections:
  export:
    type: postgresql
    hostname: my-server.postgres.database.azure.com
    database: my_database
    username: my_user
    password: $var.postgresql_password
    port: 5432
    ssl_context: false

Destination table

The exporter writes results to a table named ploosh_results. The table is created automatically with the following schema:

ColumnDescription
executionidUnique identifier for the test run
nameTest case name
stateResult: passed, failed, error, notExecuted
sourcestartSource data loading start time
sourceendSource data loading end time
sourcedurationSource loading duration in seconds
sourcecountNumber of rows in source dataset
sourceexecutedactionQuery or path executed for source
expectedstartExpected data loading start time
expectedendExpected data loading end time
expecteddurationExpected loading duration in seconds
expectedcountNumber of rows in expected dataset
expectedexecutedactionQuery or path executed for expected
comparestartComparison start time
compareendComparison end time
comparedurationComparison duration in seconds
success_ratePercentage of matching rows (0.0 to 1.0)

Usage

Command line

ploosh --connections connections.yml --cases testcases --export POSTGRESQL --ppostgresqlpassword "yourpassword"

Python API

from ploosh import execute_cases

execute_cases( cases="test_cases", connections="connections.yml", export="POSTGRESQL", variables={"postgresqlpassword": "yourpassword"} )

Requirements

  • PostgreSQL optional dependency installed (pip install ploosh[postgresql] or pip install pg8000)
  • A export connection of type postgresql declared in the connections file
  • Network access to the PostgreSQL database server