mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add context with timeout for client requests
Client timeouts are currently counted from when the client is matched with a proxy. Instead, count client timeouts from the moment when the request is received. Closes #40449
This commit is contained in:
parent
db0364ef87
commit
8343bbc336
6 changed files with 25 additions and 7 deletions
|
@ -138,7 +138,7 @@ func TestSQS(t *testing.T) {
|
|||
sqsHandlerContext, sqsCancelFunc := context.WithCancel(context.Background())
|
||||
var numTimes atomic.Uint32
|
||||
|
||||
mockSQSClient.EXPECT().ReceiveMessage(sqsHandlerContext, &sqsReceiveMessageInput).AnyTimes().DoAndReturn(
|
||||
mockSQSClient.EXPECT().ReceiveMessage(gomock.Any(), &sqsReceiveMessageInput).AnyTimes().DoAndReturn(
|
||||
func(ctx context.Context, input *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) {
|
||||
|
||||
n := numTimes.Add(1)
|
||||
|
@ -153,11 +153,11 @@ func TestSQS(t *testing.T) {
|
|||
return nil, errors.New("error")
|
||||
|
||||
})
|
||||
mockSQSClient.EXPECT().CreateQueue(sqsHandlerContext, &sqsCreateQueueInput).Return(&sqs.CreateQueueOutput{
|
||||
mockSQSClient.EXPECT().CreateQueue(gomock.Any(), &sqsCreateQueueInput).Return(&sqs.CreateQueueOutput{
|
||||
QueueUrl: responseQueueURL,
|
||||
}, nil).AnyTimes()
|
||||
mockSQSClient.EXPECT().DeleteMessage(gomock.Any(), gomock.Any()).AnyTimes()
|
||||
mockSQSClient.EXPECT().SendMessage(sqsHandlerContext, gomock.Any()).Times(1).DoAndReturn(
|
||||
mockSQSClient.EXPECT().SendMessage(gomock.Any(), gomock.Any()).Times(1).DoAndReturn(
|
||||
func(ctx context.Context, input *sqs.SendMessageInput, optFns ...func(*sqs.Options)) (*sqs.SendMessageOutput, error) {
|
||||
c.So(input.MessageBody, ShouldEqual, aws.String("{\"answer\":\"fake answer\"}"))
|
||||
// Ensure that match is correctly recorded in metrics
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue