Skip to content

Commit

Permalink
fix async read prepared statement test
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-r-reis committed Oct 19, 2022
1 parent 2c97c05 commit 01120ce
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions integration-tests/prepared_statements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ func TestPreparedIdReplacement(t *testing.T) {
}

expectedTargetPrepares := 1
expectedMaxTargetPrepares := 1
expectedTargetExecutes := 0
expectedTargetBatches := 0
expectedOriginPrepares := 1
Expand All @@ -427,20 +428,27 @@ func TestPreparedIdReplacement(t *testing.T) {
expectedTargetExecutes += 1
}
if dualReadsEnabled {
// depending on goroutine scheduling, async cluster connector might receive an UNPREPARED and send a PREPARE on its own or not
// so with async reads we will assert greater or equal instead of equal
expectedTargetPrepares += 1
expectedMaxTargetPrepares += 2
}
if test.batchQuery != "" {
expectedTargetBatches += 1
expectedTargetPrepares += 1
expectedMaxTargetPrepares += 1
expectedOriginBatches += 1
expectedOriginPrepares += 1
}

utils.RequireWithRetries(t, func() (err error, fatal bool) {
targetLock.Lock()
defer targetLock.Unlock()
if expectedTargetPrepares != len(targetPrepareMessages) {
return fmt.Errorf("expectedTargetPrepares %v != %v", expectedTargetPrepares, len(targetPrepareMessages)), false
if len(targetPrepareMessages) < expectedTargetPrepares {
return fmt.Errorf("expectedTargetPrepares %v < %v", len(targetPrepareMessages), expectedTargetPrepares), false
}
if len(targetPrepareMessages) > expectedMaxTargetPrepares {
return fmt.Errorf("expectedMaxTargetPrepares %v > %v", len(targetPrepareMessages), expectedMaxTargetPrepares), false
}
if expectedTargetExecutes != len(targetExecuteMessages) {
return fmt.Errorf("expectedTargetExecutes %v != %v", expectedTargetExecutes, len(targetExecuteMessages)), false
Expand Down

0 comments on commit 01120ce

Please sign in to comment.