|
|
|
@ -102,3 +102,35 @@ func TestWriteRejectsPayloadOverFileSizeLimit(t *testing.T) { |
|
|
|
t.Fatalf("oversized write response should mention limit, got %q", string(oversizedBody)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func TestReplicatedWriteFailsWhenReplicaRequirementsNotMet(t *testing.T) { |
|
|
|
if testing.Short() { |
|
|
|
t.Skip("skipping integration test in short mode") |
|
|
|
} |
|
|
|
|
|
|
|
clusterHarness := framework.StartSingleVolumeCluster(t, matrix.P1()) |
|
|
|
conn, grpcClient := framework.DialVolumeServer(t, clusterHarness.VolumeGRPCAddress()) |
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
const volumeID = uint32(109) |
|
|
|
framework.AllocateVolumeWithReplication(t, grpcClient, volumeID, "", "001") |
|
|
|
|
|
|
|
client := framework.NewHTTPClient() |
|
|
|
fid := framework.NewFileID(volumeID, 772003, 0x3A4B5C6D) |
|
|
|
payload := []byte("replicated-write-failure-path") |
|
|
|
|
|
|
|
writeResp := framework.UploadBytes(t, client, clusterHarness.VolumeAdminURL(), fid, payload) |
|
|
|
writeBody := framework.ReadAllAndClose(t, writeResp) |
|
|
|
if writeResp.StatusCode != http.StatusInternalServerError { |
|
|
|
t.Fatalf("replicated write with unmet replication requirements expected 500, got %d body=%s", writeResp.StatusCode, string(writeBody)) |
|
|
|
} |
|
|
|
if !strings.Contains(strings.ToLower(string(writeBody)), "replica") { |
|
|
|
t.Fatalf("replicated write failure response should mention replica write failure, got %q", string(writeBody)) |
|
|
|
} |
|
|
|
|
|
|
|
readResp := framework.ReadBytes(t, client, clusterHarness.VolumeAdminURL(), fid) |
|
|
|
_ = framework.ReadAllAndClose(t, readResp) |
|
|
|
if readResp.StatusCode != http.StatusNotFound { |
|
|
|
t.Fatalf("local read after failed replicate write expected 404 (not committed locally), got %d", readResp.StatusCode) |
|
|
|
} |
|
|
|
} |