components-contrib/tests/certification/state/postgresql
Alessandro (Ale) Segala e9911a1635
Unify SQL DB migration subsystem (for Postgres and SQLite) (#3134)
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: Bernd Verst <github@bernd.dev>
2023-09-20 13:42:40 -07:00
..
components/docker/default Add postgresql certification test + connection idle time (#1778) 2022-06-10 11:07:26 -07:00
README.md We don't need locks when we do things atomically 2022-12-06 01:27:17 +00:00
config.yaml Add postgresql certification test + connection idle time (#1778) 2022-06-10 11:07:26 -07:00
docker-compose.yml Add Azure AD support to Postgres configuration store and bindings (#2971) 2023-07-12 15:03:18 -07:00
postgresql_test.go Unify SQL DB migration subsystem (for Postgres and SQLite) (#3134) 2023-09-20 13:42:40 -07:00

README.md

PostgreSQL State Store certification testing

This project aims to test the PostgreSQL State Store component under various conditions.

To run these tests:

go test -v -tags certtests -count=1 .

Test plan

Initialization and migrations

Also test the tableName and metadataTableName metadata properties.

  1. Initializes the component with names for tables that don't exist
  2. Initializes the component with names for tables that don't exist, specifying an explicit schema
  3. Initializes the component with all migrations performed (current level is "2")
  4. Initializes the component with only the state table, created before the metadata table was added (implied migration level "1")
  5. Initializes three components at the same time and ensure no race conditions exist in performing migrations

Test for CRUD operations

  1. Able to create and test connection.
  2. Able to do set, get, update and delete.
  3. Negative test to fetch record with key, that is not present.

SQL Injection

  • Not prone to SQL injection on write
  • Not prone to SQL injection on read
  • Not prone to SQL injection on delete

TTLs and cleanups

  1. Correctly parse the cleanupIntervalInSeconds metadata property:
    • No value uses the default value (3600 seconds)
    • A positive value sets the interval to the given number of seconds
    • A zero or negative value disables the cleanup
  2. The cleanup method deletes expired records and updates the metadata table with the last time it ran
  3. The cleanup method doesn't run if the last iteration was less than cleanupIntervalInSeconds or if another process is doing the cleanup

Connection Recovery

  1. When PostgreSQL goes down and then comes back up - client is able to connect

Concurrency

  1. Insert a Key-Value pair, eTag is set.
  2. Update Value v2 for this Key with current eTag - eTag is updated.
  3. Try to Update v3 for this Key with wrong eTag - value should not get updated.
  4. Get and validate eTag, which should not have changed.

Transactions

Upsert in Multi function, using 3 keys with updating values and TTL for 2 of the keys, down in the order.