Skip to content

Commit

Permalink
test: Add test for quorom to show context cancellation returns 500
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
  • Loading branch information
philipgough committed Feb 16, 2023
1 parent 7a6ad35 commit 2c235e6
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions pkg/receive/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func newTestHandlerHashring(appendables []*fakeAppendable, replicationFactor uin
TenantHeader: DefaultTenantHeader,
ReplicaHeader: DefaultReplicaHeader,
ReplicationFactor: replicationFactor,
ForwardTimeout: 5 * time.Minute,
ForwardTimeout: 2 * time.Second,
Writer: NewWriter(log.NewNopLogger(), newFakeTenantAppendable(appendables[i]), false),
Limiter: limiter,
})
Expand Down Expand Up @@ -479,6 +479,43 @@ func testReceiveQuorum(t *testing.T, hashringAlgo HashringAlgorithm, withConsist
},
},
},
{
name: "size 3 with replication and differing unrecoverable errors",
status: http.StatusConflict,
replicationFactor: 3,
wreq: wreq,
appendables: []*fakeAppendable{
{
appender: newFakeAppender(cycleErrors([]error{storage.ErrOutOfOrderSample}), nil, nil),
},
{
appender: newFakeAppender(nil, nil, nil),
},
{
appender: newFakeAppender(nil, cycleErrors([]error{storage.ErrDuplicateSampleForTimestamp}), nil),
},
},
},
{
name: "size 3 with replication one conflict and one commit error (unrecoverable) with context cancellation",
status: http.StatusInternalServerError,
replicationFactor: 3,
wreq: wreq,
appendables: []*fakeAppendable{
{
appender: newFakeAppender(nil, nil, nil),
},
{
appender: newFakeAppender(nil, cycleErrors([]error{storage.ErrOutOfBounds}), nil),
},
{
appender: newFakeAppender(nil, func() error {
time.Sleep(time.Second * 2)
return storage.ErrOutOfBounds
}, nil),
},
},
},
{
name: "size 3 with replication two commit errors",
status: http.StatusInternalServerError,
Expand All @@ -492,7 +529,7 @@ func testReceiveQuorum(t *testing.T, hashringAlgo HashringAlgorithm, withConsist
appender: newFakeAppender(nil, commitErrFn, nil),
},
{
appender: newFakeAppender(nil, nil, nil),
appender: newFakeAppender(nil, commitErrFn, nil),
},
},
},
Expand Down Expand Up @@ -1507,3 +1544,6 @@ func TestRelabel(t *testing.T) {
})
}
}

type predeterminedReceiver struct {
}

0 comments on commit 2c235e6

Please sign in to comment.