From 7f67e19b2f26fe076013b9acab252d4b3d0e33e8 Mon Sep 17 00:00:00 2001 From: Rob Shakir Date: Thu, 21 May 2026 15:18:39 +0000 Subject: [PATCH] Add test for repeated session parameters This test verifies that the server returns FailedPrecondition when a client sends SessionParameters more than once on a stream. --- compliance/compliance.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/compliance/compliance.go b/compliance/compliance.go index 4636023..6bb45aa 100644 --- a/compliance/compliance.go +++ b/compliance/compliance.go @@ -156,6 +156,11 @@ var ( Fn: ModifyConnectionSinglePrimaryPreserve, ShortName: "Modify RPC Connection with invalid persist/redundancy parameters", }, + }, { + In: Test{ + Fn: ModifyConnectionRepeatedSessionParameters, + ShortName: "Modify RPC Connection with repeated SessionParameters", + }, }, { In: Test{ Fn: InvalidElectionIDAndAFTOperation, @@ -785,6 +790,37 @@ func InvalidParamsAndAFTOperation(c *fluent.GRIBIClient, t testing.TB, _ ...Test chk.HasRecvClientErrorWithStatus(t, err, want, chk.IgnoreDetails()) } +// ModifyConnectionRepeatedSessionParameters validates that the server returns an error when a client +// specifies session parameters more than once on a stream. +func ModifyConnectionRepeatedSessionParameters(c *fluent.GRIBIClient, t testing.TB, _ ...TestOpt) { + defer electionID.Inc() + c.Connection().WithRedundancyMode(fluent.ElectedPrimaryClient).WithPersistence().WithInitialElectionID(electionID.Load(), 0) + c.Start(context.Background(), t) + defer c.Stop(t) + + c.StartSending(context.Background(), t) + + // Inject a second session parameters message. + c.Modify().InjectRequest(t, &spb.ModifyRequest{ + Params: &spb.SessionParameters{ + Redundancy: spb.SessionParameters_SINGLE_PRIMARY, + Persistence: spb.SessionParameters_PRESERVE, + }, + }) + + err := awaitTimeout(context.Background(), c, t, time.Minute) + if err == nil { + t.Fatal("did not get expected error from server, got: nil") + } + t.Logf("Received error from server: %v", err) + + want := fluent.ModifyError(). + WithCode(codes.FailedPrecondition). + AsStatus(t) + + chk.HasRecvClientErrorWithStatus(t, err, want, chk.IgnoreDetails()) +} + // AddIPv4Entry adds a fully referenced IPv4Entry and checks whether the specified ACK // type (wantACK) is returned. func AddIPv4Entry(c *fluent.GRIBIClient, wantACK fluent.ProgrammingResult, t testing.TB, _ ...TestOpt) {