|
ORE Studio 0.0.4
|
Manages test tenant isolation for parallel test execution. More...
#include <test_database_manager.hpp>

Static Public Member Functions | |
| static database::context | make_context () |
| Creates a database context from environment variables. | |
| static database::database_options | make_database_options () |
| Creates database options from environment variables. | |
| static std::string | generate_test_tenant_code (const std::string &test_suite_name) |
| Generates a unique tenant code for this test run. | |
| static std::string | provision_test_tenant (database::context &ctx, const std::string &tenant_code, const std::string &description) |
| Provisions a test tenant using the SQL provisioner function. | |
| static void | terminate_test_tenant (database::context &ctx, const std::string &tenant_id) |
| Terminates a test tenant using the SQL terminator function. | |
| static void | set_test_tenant_id_env (const std::string &tenant_id) |
| Sets the ORES_TEST_DB_TENANT_ID environment variable. | |
| static std::string | get_test_tenant_id_env () |
| Gets the test tenant ID from environment variable. | |
Static Public Attributes | |
| static constexpr auto | system_tenant_id |
| System tenant ID constant (max UUID per RFC 9562). | |
Manages test tenant isolation for parallel test execution.
This class provides utilities for provisioning and deprovisioning test tenants. Each test suite gets its own isolated tenant, allowing multiple test processes to run concurrently without interference.
Tenant isolation uses PostgreSQL Row Level Security (RLS) to ensure complete data separation between test suites.
|
static |
Generates a unique tenant code for this test run.
The tenant code includes the test suite name and timestamp: {test_suite}_{YYYYMMDD}_{HHMMSS}_{pid}_{random}
| test_suite_name | Name of the test suite (e.g., "ores.cli.tests") |

|
static |
Provisions a test tenant using the SQL provisioner function.
Creates a new tenant with all required base data (permissions, roles, refdata) copied from the system tenant. The caller must have a valid database context with system tenant access.
| ctx | The database context to use |
| tenant_code | The unique tenant code |
| description | Human-readable description (e.g., test suite name + version) |
| std::runtime_error | if provisioning fails |

|
static |
Terminates a test tenant using the SQL terminator function.
Marks the tenant as terminated but preserves all data for analysis. Use this after unit tests to allow debugging while preventing further use of the tenant. The caller must have system tenant context.
For complete data deletion, use ores_iam_purge_tenant_fn directly.
| ctx | The database context to use |
| tenant_id | The UUID of the tenant to terminate |

|
static |
Sets the ORES_TEST_DB_TENANT_ID environment variable.
This allows tests to retrieve the test tenant ID.
| tenant_id | The tenant ID to set |

|
static |
Gets the test tenant ID from environment variable.

|
staticconstexpr |
System tenant ID constant (max UUID per RFC 9562).