Skip to content

Commit

Permalink
Turn off DirectGet for KV bucket in test
Browse files Browse the repository at this point in the history
Chaos tests checks for freshness of keys retrieved via Get.
As such, turn off DirectGet which can return stale values

Signed-off-by: Marco Primi <marco@synadia.com>
  • Loading branch information
mprimi committed Nov 8, 2023
1 parent 9c2e109 commit 6ad58b4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/jetstream_chaos_test.go
Expand Up @@ -1166,6 +1166,25 @@ func TestJetStreamChaosKvCAS(t *testing.T) {
t.Fatalf("Failed to get KV store: %v", err)
}

// Manually disable DirectGet on underlying stream
// (Ensure latest key revision is returned by routing the request through the leader)
streamInfo, err := js.StreamInfo("KV_" + chaosKvTestsBucketName)
if err != nil {
t.Fatalf("Failed to get stream info: %s", err)
}
streamInfo.Config.AllowDirect = false
streamInfo, err = js.UpdateStream(&streamInfo.Config)
if err != nil {
t.Fatalf("Failed to update KV stream: %s", err)
} else if streamInfo.Config.AllowDirect {
t.Fatalf("Failed to disable 'DirectGet'")
}

kv, err = js.KeyValue(chaosKvTestsBucketName)
if err != nil {
t.Fatalf("Failed reopen KV handle: %s", err)
}

// Create set of keys and initialize them with dummy value
keys := make([]string, numKeys)
for k := 0; k < numKeys; k++ {
Expand Down

0 comments on commit 6ad58b4

Please sign in to comment.