components-contrib/tests/certification/state/mysql
Josh van Leeuwen 9be6d157a4
tests/certification: Updates dapr/dapr to `master` HEAD (#3084)
Signed-off-by: joshvanl <me@joshvanl.dev>
Co-authored-by: Bernd Verst <github@bernd.dev>
2023-08-21 17:06:55 -07:00
..
components/docker/default Work on cert tests 2022-11-01 19:42:55 +00:00
README.md Add MySQL TTL and Cleanup (#2641) 2023-03-30 15:45:57 -07:00
config.yaml Added tests for metadata properties schemaName/tableName 2022-11-01 16:27:16 +00:00
docker-compose.yaml Work on cert tests 2022-11-01 19:42:55 +00:00
mysql_test.go tests/certification: Updates dapr/dapr to `master` HEAD (#3084) 2023-08-21 17:06:55 -07:00

README.md

MySQL State Store certification testing

This project aims to test the MySQL State Store component under various conditions. Tests are run against both MySQL 8 and MariaDB 10.

Test plan

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

Connection Recovery

  1. When MySQL/MariaDB goes down and comes back up, client is able to connect

Concurrency

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

Transactions

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

Close component

  1. Ensure the database connection is closed when the component is closed.

Metadata options

  1. Without schemaName, check that the default one is used
  2. Without tableName, check that the default one is used
  3. Without metadataTableName, check that the default one is used
  4. Instantiate a component with a custom schemaName and validate it's used
  5. Instantiate a component with a custom tableName and validate it's used
  6. Instantiate a component with a custom metadataTableName and validate it's used

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