Fix CI test failures (bd-1231)
- Always recompute content_hash in importer to avoid stale hashes from JSONL
- Add .gitignore to test repos to prevent database files from being tracked
- Fix daemon auto-import test to use correct RPC operation ('show' not 'get_issue')
- Set last_import_time metadata in test helper to enable staleness check
- Add filesystem settle delay after git pull in tests
Root cause: CloseIssue updates status but not content_hash, so importer
thought issues were unchanged. Always recomputing content_hash fixes this.
Amp-Thread-ID: https://ampcode.com/threads/T-63ef3a7d-8efe-472d-97ed-6ac95bd8318b
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -131,6 +131,9 @@ func TestDaemonAutoImportAfterGitPull(t *testing.T) {
|
||||
// Agent B does git pull (updates JSONL on disk)
|
||||
runGitCmd(t, clone2Dir, "pull")
|
||||
|
||||
// Wait for filesystem to settle after git operations
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
// Start daemon server in clone2
|
||||
socketPath := filepath.Join(clone2BeadsDir, "bd.sock")
|
||||
os.Remove(socketPath) // Ensure clean state
|
||||
@@ -329,6 +332,9 @@ func TestDaemonAutoImportDataCorruption(t *testing.T) {
|
||||
// 2. Agent B does git pull (JSONL updated on disk)
|
||||
runGitCmd(t, clone2Dir, "pull")
|
||||
|
||||
// Wait for filesystem to settle after git operations
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
// 3. Agent B daemon exports STALE data (if auto-import doesn't work)
|
||||
// This would overwrite Agent A's closure with old "open" status
|
||||
|
||||
@@ -364,7 +370,7 @@ func TestDaemonAutoImportDataCorruption(t *testing.T) {
|
||||
|
||||
client.SetDatabasePath(clone2DBPath)
|
||||
|
||||
resp, err := client.Execute("get_issue", map[string]string{"id": issueID})
|
||||
resp, err := client.Execute("show", map[string]string{"id": issueID})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get issue: %v", err)
|
||||
}
|
||||
|
||||
@@ -211,6 +211,18 @@ func configureGit(t *testing.T, dir string) {
|
||||
runGitCmd(t, dir, "config", "user.email", "test@example.com")
|
||||
runGitCmd(t, dir, "config", "user.name", "Test User")
|
||||
runGitCmd(t, dir, "config", "pull.rebase", "false")
|
||||
|
||||
// Create .gitignore to prevent test database files from being tracked
|
||||
gitignorePath := filepath.Join(dir, ".gitignore")
|
||||
gitignoreContent := `# Test database files
|
||||
*.db
|
||||
*.db-journal
|
||||
*.db-wal
|
||||
*.db-shm
|
||||
`
|
||||
if err := os.WriteFile(gitignorePath, []byte(gitignoreContent), 0644); err != nil {
|
||||
t.Fatalf("Failed to create .gitignore: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func exportIssuesToJSONL(ctx context.Context, store *sqlite.SQLiteStorage, jsonlPath string) error {
|
||||
@@ -284,6 +296,11 @@ func importJSONLToStore(ctx context.Context, store *sqlite.SQLiteStorage, dbPath
|
||||
}
|
||||
}
|
||||
|
||||
// Set last_import_time metadata so staleness check works
|
||||
if err := store.SetMetadata(ctx, "last_import_time", time.Now().Format(time.RFC3339)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user