test(volume_server/http): cover replicated write failure when replication unmet

This commit is contained in:
Chris Lu
2026-02-15 17:45:25 -08:00
parent 5814729def
commit 4835d34438
2 changed files with 42 additions and 2 deletions
+10 -2
View File
@@ -14,18 +14,26 @@ import (
func AllocateVolume(t testing.TB, client volume_server_pb.VolumeServerClient, volumeID uint32, collection string) {
t.Helper()
AllocateVolumeWithReplication(t, client, volumeID, collection, "000")
}
func AllocateVolumeWithReplication(t testing.TB, client volume_server_pb.VolumeServerClient, volumeID uint32, collection, replication string) {
t.Helper()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if replication == "" {
replication = "000"
}
_, err := client.AllocateVolume(ctx, &volume_server_pb.AllocateVolumeRequest{
VolumeId: volumeID,
Collection: collection,
Replication: "000",
Replication: replication,
Version: uint32(needle.GetCurrentVersion()),
})
if err != nil {
t.Fatalf("allocate volume %d: %v", volumeID, err)
t.Fatalf("allocate volume %d (replication=%s): %v", volumeID, replication, err)
}
}