components-contrib/tests/certification/state/cockroachdb
Bernd Verst 6b59f2908d
fix postgres error handling for upsert with etag (#2778)
Signed-off-by: Bernd Verst <github@bernd.dev>
2023-04-13 19:36:24 +00:00
..
components/standard Creation of Certification Test for CockroachDB (#2222) 2022-11-29 09:35:48 -08:00
README.md Adds TTL support to the CockroachDB state. (#2618) 2023-03-03 14:36:40 +00:00
cockroachdb_test.go fix postgres error handling for upsert with etag (#2778) 2023-04-13 19:36:24 +00:00
config.yaml Creation of Certification Test for CockroachDB (#2222) 2022-11-29 09:35:48 -08:00
docker-compose.yml Creation of Certification Test for CockroachDB (#2222) 2022-11-29 09:35:48 -08:00

README.md

CockroachDB State Store Certification

The purpose of this module is to provide tests that certify the CockroachDB State Store as a stable component.

Test plan

Connection Test

  • Verify the connection is established to CockroachDB.
    • Create component spec.
    • Run the component with docker-compose
    • Run dapr application with component.
    • Ensure that you have access to the queue and connection to the queue is established.

Basic Operations Test

  • Verify that cockroachDB can save, retrieve, and delete states
    • Save basic state information with a specified key
    • Perform a Get Operation with that same key and ensure the the data previously written is retrieved
    • Delete the state item
    • Perform another Get Operation and verify that the data retreived is a nil byte array

ETAG Test

  • Verify cockroachDB Etag behavior
    • Save state without an etag and ensure default etag (value of 1) is created
    • Save state with a new, previously unsused etag and ensure that no item is updated
    • Get state with etag of 1 and verify that our first written data is retrieved
    • Overwrite the initial data through a Set operation with an etag value of 1
    • Run a Get Operation and verify that the previous Set operation was successful

Transactions Test

  • Verify that cockroachDB can handle multiple opperations in a single request
    • Save basic state information with a specified key
    • Perform a Get Operation with that same key and ensure the the data previously written is retrieved
    • Run a suite of set and delete requests
    • Run a Get Operation on the data that should've been deleted from the Delete operation in the multi command and verify that the data no longer exists
    • Retrieve data written from set requests and verify the data was correctly written

Restart Test

  • Verify that cockroachDB can have state data persist after a restart
    • Stop cockroachDB by calling a dockercompose stop command
    • Start cockroachDB by calling a dockercompose start command
    • Perform a Get Operation using a previously inserted key and verify that the data previously saved before the restart is returned

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