Skip to content

Commit 242c183

Browse files
committed
fix: resolve factory integration test failures
Fix 3 failing tests in factory_integration_tests: 1. pool_tests::test_pool_warm_agents - Use different roles (Developer, Tester) to ensure separate agents - Previous test reused same agent due to warm pool 2. workspace_tests::test_workspace_isolation_path_validation - Create file before checking path allowance - is_path_allowed() uses canonicalize() which requires existing path 3. workspace_tests::test_workspace_list_and_cleanup - Fix list_workspaces() parsing logic for role-uuid format - Role may contain dashes (e.g., 'agent-0'), need to properly parse UUID - UUID has 5 dash-separated groups, use rsplitn(6, '-') to extract correctly All 22 factory_integration_tests now pass.
1 parent fc5b7b6 commit 242c183

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/factory/workspace/manager.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,20 @@ impl WorkspaceManager {
182182
if path.is_dir() {
183183
if let Some(name) = path.file_name().and_then(|n| n.to_str()) {
184184
// Parse workspace directory name (format: "role-uuid")
185-
if let Some((role, uuid_str)) = name.rsplit_once('-') {
186-
if let Ok(uuid) = Uuid::parse_str(uuid_str) {
185+
// UUID has 5 groups separated by dashes, so we need to find
186+
// where the UUID starts (after the 4th dash from the right)
187+
let parts: Vec<&str> = name.rsplitn(6, '-').collect();
188+
if parts.len() >= 5 {
189+
// Reconstruct UUID from last 5 parts (in reverse order due to rsplitn)
190+
let uuid_parts: Vec<&str> = parts[..5].iter().rev().copied().collect();
191+
let uuid_str = uuid_parts.join("-");
192+
if let Ok(uuid) = Uuid::parse_str(&uuid_str) {
193+
// Role is everything before the UUID
194+
let role_parts: Vec<&str> =
195+
parts[5..].iter().rev().copied().collect();
196+
let role = role_parts.join("-");
187197
workspaces.push(WorkspaceId {
188-
agent_role: role.to_string(),
198+
agent_role: role,
189199
agent_uuid: uuid,
190200
});
191201
}

tests/factory/pool_tests.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,17 @@ async fn test_pool_warm_agents() {
237237
let pool = AgentPool::with_config(workspace_manager, config);
238238

239239
// Acquire and release to create warm agents
240-
let agent_config = AgentConfig::for_role(AgentRole::Developer);
240+
// Use different roles to ensure we get separate agents
241+
let agent_config1 = AgentConfig::for_role(AgentRole::Developer);
241242
let id1 = pool
242-
.acquire_agent(AgentRole::Developer, agent_config.clone())
243+
.acquire_agent(AgentRole::Developer, agent_config1)
243244
.await
244245
.unwrap();
245246
pool.release_agent(id1).unwrap();
246247

248+
let agent_config2 = AgentConfig::for_role(AgentRole::Tester);
247249
let id2 = pool
248-
.acquire_agent(AgentRole::Developer, agent_config)
250+
.acquire_agent(AgentRole::Tester, agent_config2)
249251
.await
250252
.unwrap();
251253
pool.release_agent(id2).unwrap();

tests/factory/workspace_tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ async fn test_workspace_isolation_path_validation() {
5656

5757
// Valid paths within workspace should be allowed
5858
let valid_path = workspace.paths.sandbox.join("project/src/main.rs");
59+
// Create the file so canonicalize() works
60+
std::fs::create_dir_all(valid_path.parent().unwrap()).unwrap();
61+
std::fs::write(&valid_path, "test content").unwrap();
5962
assert!(isolation.is_path_allowed(&valid_path));
6063

6164
// Invalid path trying to escape sandbox - this might not exist so it returns false

0 commit comments

Comments
 (0)