Signed-off-by: joshvanl <me@joshvanl.dev> Co-authored-by: Bernd Verst <github@bernd.dev> |
||
---|---|---|
.. | ||
artifacts | ||
resources | ||
README.md | ||
config.yaml | ||
sqlite_test.go |
README.md
SQLite State Store certification testing
This project aims to test the SQLite State Store component under various conditions.
To run these tests:
go test -v -tags certtests -count=1 .
Test plan
Basic tests (in-memory)
Uses an in-memory, temporary database.
- Creates a new, in-memory database and initializes the tables.
- Able to do set, get, update and delete.
SQL Injection
- Not prone to SQL injection on write
- Not prone to SQL injection on read
- Not prone to SQL injection on delete
Read-only databases
- Open an existing database in read-only mode
- Attempt basic CRUD tests: get operations succeed; set, update, delete fail.
- Stop the Dapr sidecar and verify that the database file was not modified on-disk.
This also tests the ability to use connection strings that don't start with
file:
TTLs and cleanups
Also tests the tableName
and metadataTableName
metadata properties.
- Correctly parse the
cleanupIntervalInSeconds
metadata property:- No value uses the default value (disabled)
- A positive value sets the interval
- A zero or negative value disables the cleanup
- The cleanup method deletes expired records and updates the metadata table with the last time it ran
- The cleanup method doesn't run if the last iteration was less than
cleanupIntervalInSeconds
or if another process is doing the cleanup
Initialization and migrations
Also tests the tableName
and metadataTableName
metadata properties.
- Initializes the component with names for tables that don't exist
- Initializes the component with all migrations performed (current level is "1")
- Initializes the component with only the state table, created before the metadata table was added (implied migration level "1")
- Initializes three components at the same time and ensure no race conditions exist in performing migrations
Concurrency
- Test concurrency using a single connection (single component)
- Using 10 parallel goroutines, write to a key in the database (unique per goroutine), then retrieve the value and ensure it's the one that was just stored
- Using 10 parallel goroutines, write to the same key multiple times; at the end of the writes, ensure the last value written is the one in the database
- Test concurrency using a 3 connections (3 components)
- Using 10 parallel goroutines selecting from the 3 connections, write to a key in the database (unique per goroutine), then retrieve the value and ensure it's the one that was just stored
- Using 10 parallel goroutines selecting from the 3 connections, write to the same key multiple times; at the end of the writes, ensure the last value written is the one in the database