From b5ccf39233b7dcdd18e1c1f689dcefc8b1a544ae Mon Sep 17 00:00:00 2001 From: Sotirios Mantziaris Date: Tue, 29 Dec 2020 18:27:02 +0200 Subject: [PATCH] Fixed broken tests --- test/docker/aws/aws_test.go | 15 +++++---------- test/docker/aws/consumer_integration_test.go | 6 +++--- test/docker/aws/sns_integration_test.go | 17 +++++------------ test/docker/aws/sqs_integration_test.go | 2 -- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/test/docker/aws/aws_test.go b/test/docker/aws/aws_test.go index 31dae54625..a8ba0eabae 100644 --- a/test/docker/aws/aws_test.go +++ b/test/docker/aws/aws_test.go @@ -5,7 +5,6 @@ package aws import ( "fmt" "os" - "sync" "testing" "time" @@ -32,7 +31,7 @@ const ( var ( runtime *awsRuntime - muTrace sync.Mutex + mtr *mocktracer.MockTracer ) func TestMain(m *testing.M) { @@ -43,6 +42,10 @@ func TestMain(m *testing.M) { os.Exit(1) } + mtr = mocktracer.New() + opentracing.SetGlobalTracer(mtr) + defer mtr.Reset() + exitCode := m.Run() ee := runtime.Teardown() @@ -190,11 +193,3 @@ func createSQSQueue(api sqsiface.SQSAPI, queueName string) (string, error) { } return *out.QueueUrl, nil } - -func setupTrace() *mocktracer.MockTracer { - muTrace.Lock() - defer muTrace.Unlock() - mtr := mocktracer.New() - opentracing.SetGlobalTracer(mtr) - return mtr -} diff --git a/test/docker/aws/consumer_integration_test.go b/test/docker/aws/consumer_integration_test.go index 7150f6f70a..33c539d5f1 100644 --- a/test/docker/aws/consumer_integration_test.go +++ b/test/docker/aws/consumer_integration_test.go @@ -21,6 +21,8 @@ type message struct { } func Test_SQS_Consume(t *testing.T) { + defer mtr.Reset() + const queueName = "test-sqs-consume" const correlationID = "123" @@ -30,9 +32,7 @@ func Test_SQS_Consume(t *testing.T) { require.NoError(t, err) sent := sendMessage(t, api, correlationID, queue, "1", "2", "3") - - mtr := setupTrace() - defer mtr.Reset() + mtr.Reset() factory, err := sqsConsumer.NewFactory( api, diff --git a/test/docker/aws/sns_integration_test.go b/test/docker/aws/sns_integration_test.go index 1593a74773..1c5ac9c0c1 100644 --- a/test/docker/aws/sns_integration_test.go +++ b/test/docker/aws/sns_integration_test.go @@ -16,11 +16,10 @@ import ( ) func Test_SNS_Publish_Message(t *testing.T) { - const topic = "test_publish_message" - - mtr := setupTrace() defer mtr.Reset() + const topic = "test_publish_message" + api, err := createSNSAPI(runtime.getSNSEndpoint()) require.NoError(t, err) arn, err := createSNSTopic(api, topic) @@ -42,11 +41,10 @@ func Test_SNS_Publish_Message(t *testing.T) { } func Test_SNS_Publish_Message_v2(t *testing.T) { - const topic = "test_publish_message_v2" - - mtr := setupTrace() defer mtr.Reset() + const topic = "test_publish_message_v2" + api, err := createSNSAPI(runtime.getSNSEndpoint()) require.NoError(t, err) arn, err := createSNSTopic(api, topic) @@ -71,12 +69,7 @@ func Test_SNS_Publish_Message_v2(t *testing.T) { } func createMsg(t *testing.T, topicArn string) v1.Message { - b := v1.NewMessageBuilder() - - msg, err := b. - Message("test msg"). - TopicArn(topicArn). - Build() + msg, err := v1.NewMessageBuilder().Message("test msg").TopicArn(topicArn).Build() require.NoError(t, err) return *msg } diff --git a/test/docker/aws/sqs_integration_test.go b/test/docker/aws/sqs_integration_test.go index b35e60149d..d571f20784 100644 --- a/test/docker/aws/sqs_integration_test.go +++ b/test/docker/aws/sqs_integration_test.go @@ -22,7 +22,6 @@ type sampleMsg struct { } func Test_SQS_Publish_Message(t *testing.T) { - mtr := setupTrace() defer mtr.Reset() const queueName = "test-sqs-publish" @@ -70,7 +69,6 @@ func Test_SQS_Publish_Message(t *testing.T) { } func Test_SQS_Publish_Message_v2(t *testing.T) { - mtr := setupTrace() defer mtr.Reset() const queueName = "test-sqs-publish-v2"