fix: Resolve flaky TestStore_Integration spurious failures (#742)
Some checks failed
Commit / Lint (push) Has been cancelled
Commit / Build Windows (push) Has been cancelled
Commit / Build & Unit Test (push) Has been cancelled
Commit / Run S3 Mock Tests (push) Has been cancelled
Commit / Run NATS Integration Tests (push) Has been cancelled
Commit / Run S3 Integration Tests (push) Has been cancelled
Commit / Run GCP Integration Tests (push) Has been cancelled
Commit / Run Azure Blob Store Integration Tests (push) Has been cancelled
Commit / Run SFTP Integration Tests (push) Has been cancelled

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Cory LaNou
2025-09-10 08:06:47 -05:00
committed by GitHub
parent 6dff76263c
commit ffb626472f

View File

@@ -134,6 +134,19 @@ func TestStore_Integration(t *testing.T) {
done := make(chan struct{})
time.AfterFunc(10*time.Second, func() { close(done) })
// Channel for insert errors
insertErr := make(chan error, 1)
// Check for any insert errors that occurred before shutdown
defer func() {
select {
case err := <-insertErr:
t.Fatalf("insert error during test: %v", err)
default:
// No insert errors
}
}()
// Start goroutine to continuously insert records
go func() {
ticker := time.NewTicker(factor * 10 * time.Millisecond)
@@ -147,8 +160,19 @@ func TestStore_Integration(t *testing.T) {
return
case <-ticker.C:
if _, err := sqldb.ExecContext(t.Context(), `INSERT INTO t (val) VALUES (?);`, time.Now().String()); err != nil {
t.Errorf("insert error: %v", err)
return
// Check if we're shutting down
select {
case <-done:
// Expected during shutdown, just exit
return
default:
// Real error, send it
select {
case insertErr <- err:
default:
}
return
}
}
}
}