From 998aaf25f856dfe2e1d9e7930df9bb5c244a2358 Mon Sep 17 00:00:00 2001 From: "Brent E. Edwards" Date: Sat, 28 Mar 2026 11:15:51 +0000 Subject: [PATCH] fix(infra): ensure E2E suite setup initializes database before CLI commands Centralize E2E initialization in common suite setup so DB-dependent CLI commands no longer rely on per-suite or per-test init workarounds. This also sanitizes suite-home names to prevent invalid path-derived initialization failures in isolated Robot runs. ISSUES CLOSED: #1023 --- robot/e2e/common_e2e.resource | 8 ++++++++ robot/e2e/e2e_session_create_persist.robot | 1 - robot/e2e/m6_acceptance.robot | 6 +----- robot/e2e/wf05_db_migration.robot | 4 +--- robot/e2e/wf07_cicd.robot | 11 ++--------- robot/e2e/wf14_server_mode.robot | 5 +---- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/robot/e2e/common_e2e.resource b/robot/e2e/common_e2e.resource index 29bd6e3ff..e3b7756f3 100644 --- a/robot/e2e/common_e2e.resource +++ b/robot/e2e/common_e2e.resource @@ -24,6 +24,7 @@ E2E Suite Setup Log Setting up E2E test environment ${safe_suite}= Replace String ${SUITE NAME} ${SPACE} _ ${safe_suite}= Replace String ${safe_suite} . _ + ${safe_suite}= Replace String Using Regexp ${safe_suite} [^A-Za-z0-9_-] _ ${home}= Set Variable ${E2E_TEMP_ROOT}${/}${safe_suite} ${rm_status} ${rm_msg}= Run Keyword And Ignore Error Remove Directory ${home} recursive=True IF '${rm_status}' == 'FAIL' @@ -38,6 +39,13 @@ E2E Suite Setup # Get the actual Python executable being used ${python_exec}= Evaluate sys.executable sys Set Suite Variable ${PYTHON} ${python_exec} + # Explicitly initialize the workspace once per suite so DB-dependent + # commands do not need per-test init workarounds. + ${init}= Run CleverAgents Command init --yes --force --path ${SUITE_HOME} + Should Be Equal As Integers ${init.rc} 0 + # Post-init sanity: ensure init produced the expected workspace state. + Directory Should Exist ${SUITE_HOME}${/}.cleveragents + File Should Exist ${SUITE_HOME}${/}.cleveragents${/}db.sqlite E2E Suite Teardown [Documentation] Clean up the E2E test environment. diff --git a/robot/e2e/e2e_session_create_persist.robot b/robot/e2e/e2e_session_create_persist.robot index 8c5a8891a..cfe80e0d7 100644 --- a/robot/e2e/e2e_session_create_persist.robot +++ b/robot/e2e/e2e_session_create_persist.robot @@ -10,7 +10,6 @@ Suite Teardown E2E Suite Teardown Session Create Then List Shows Session [Documentation] Create a session and verify it appears in session list. [Tags] E2E tdd_issue tdd_issue_1141 - Run CleverAgents Command init --force --yes ${r1}= Run CleverAgents Command session list --format json Should Contain ${r1.stdout} "total": 0 Run CleverAgents Command session create --format plain diff --git a/robot/e2e/m6_acceptance.robot b/robot/e2e/m6_acceptance.robot index 52f4fab34..06eca5b2b 100644 --- a/robot/e2e/m6_acceptance.robot +++ b/robot/e2e/m6_acceptance.robot @@ -13,12 +13,8 @@ Force Tags E2E *** Keywords *** M6 Suite Setup - [Documentation] E2E Suite Setup plus database initialisation for session tests. + [Documentation] E2E Suite Setup plus unique run suffix and action registration. E2E Suite Setup - # Initialise the database so session/config commands work in all tests. - # Use --force because the workspace may already contain an initialised project. - ${init}= Run CleverAgents Command init --force --yes - Should Be Equal As Integers ${init.rc} 0 # Generate a unique suffix for resource/project names to avoid UNIQUE # constraint collisions on repeated E2E runs against the same database. # uuid4 provides ~4 billion possibilities vs randint's 9000 for parallel CI safety. diff --git a/robot/e2e/wf05_db_migration.robot b/robot/e2e/wf05_db_migration.robot index 43e76b7a1..596325061 100644 --- a/robot/e2e/wf05_db_migration.robot +++ b/robot/e2e/wf05_db_migration.robot @@ -21,10 +21,8 @@ ${RESOURCE_TYPE_NAME} local/wf05-postgres-db *** Keywords *** WF05 Suite Setup - [Documentation] E2E Suite Setup plus database init and dynamic actor selection. + [Documentation] E2E Suite Setup plus dynamic actor selection. E2E Suite Setup - ${init}= Run CleverAgents Command init --force --yes - Should Be Equal As Integers ${init.rc} 0 # Generate unique suffix for resource/project names to avoid UNIQUE # constraint collisions on repeated E2E runs against the same database. ${suffix}= Evaluate __import__('uuid').uuid4().hex[:12] diff --git a/robot/e2e/wf07_cicd.robot b/robot/e2e/wf07_cicd.robot index 790620bce..4bd92e2bb 100644 --- a/robot/e2e/wf07_cicd.robot +++ b/robot/e2e/wf07_cicd.robot @@ -29,11 +29,6 @@ WF07 E2E CI Profile Configuration ... and log level per specification Step 1. [Tags] E2E [Teardown] Log CI Profile Configuration teardown complete - # Initialize the CleverAgents data directory and database - # expected_rc=None: init may report the CWD is already initialized; this - # is harmless because CLEVERAGENTS_HOME is set to a fresh temp dir by - # Suite Setup. - Run CleverAgents Command init --yes expected_rc=None # Automation profile Run CleverAgents Command config set core.automation-profile ci ${get_profile}= Run CleverAgents Command config get core.automation-profile --format plain @@ -280,11 +275,9 @@ WF07 E2E JSON Output Verification *** Keywords *** WF07 Suite Setup - [Documentation] E2E Suite Setup plus database initialisation. + [Documentation] Delegate to shared E2E Suite Setup (includes centralized + ... database initialization for DB-dependent CLI commands). E2E Suite Setup - # Initialise the database so config/resource/project commands work. - ${init}= Run CleverAgents Command init --force --yes - Should Be Equal As Integers ${init.rc} 0 Create Temp Git Repo With Issues [Documentation] Create a temporary git repo containing Python files with diff --git a/robot/e2e/wf14_server_mode.robot b/robot/e2e/wf14_server_mode.robot index 4e51e4158..30ec3b209 100644 --- a/robot/e2e/wf14_server_mode.robot +++ b/robot/e2e/wf14_server_mode.robot @@ -16,11 +16,8 @@ Force Tags E2E *** Keywords *** WF14 Suite Setup - [Documentation] E2E Suite Setup plus database initialisation for WF14 tests. + [Documentation] E2E Suite Setup plus unique run suffix generation. E2E Suite Setup - # Initialise the database so action/actor/plan commands work in all tests. - ${init}= Run CleverAgents Command init --yes - Should Be Equal As Integers ${init.rc} 0 # Generate a unique suffix for entity names to avoid UNIQUE # constraint collisions on repeated E2E runs or parallel CI. ${suffix}= Evaluate __import__('uuid').uuid4().hex[:12] -- 2.52.0