mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-31 22:23:12 +08:00
instrumentation/botocore: fix failing test (#1100)
The failing test was introduced I believe by a change in behaviour noted in this issue: https://github.com/spulec/moto/issues/3292. The solution is to set a region in the create_bucket call. Fixes #1088
This commit is contained in:
@ -104,35 +104,36 @@ class TestBotocoreInstrumentor(TestBase):
|
||||
)
|
||||
|
||||
# Comment test for issue 1088
|
||||
# @mock_s3
|
||||
# def test_s3_put(self):
|
||||
# params = dict(Key="foo", Bucket="mybucket", Body=b"bar")
|
||||
# s3 = self.session.create_client("s3", region_name="us-west-2")
|
||||
# s3.create_bucket(Bucket="mybucket")
|
||||
# s3.put_object(**params)
|
||||
@mock_s3
|
||||
def test_s3_put(self):
|
||||
params = dict(Key="foo", Bucket="mybucket", Body=b"bar")
|
||||
s3 = self.session.create_client("s3", region_name="us-west-2")
|
||||
location = {"LocationConstraint": "us-west-2"}
|
||||
s3.create_bucket(Bucket="mybucket", CreateBucketConfiguration=location)
|
||||
s3.put_object(**params)
|
||||
|
||||
# spans = self.memory_exporter.get_finished_spans()
|
||||
# assert spans
|
||||
# span = spans[0]
|
||||
# self.assertEqual(len(spans), 2)
|
||||
# self.assertEqual(span.attributes["aws.operation"], "CreateBucket")
|
||||
# assert_span_http_status_code(span, 200)
|
||||
# self.assertEqual(
|
||||
# span.resource,
|
||||
# Resource(
|
||||
# attributes={"endpoint": "s3", "operation": "createbucket"}
|
||||
# ),
|
||||
# )
|
||||
# self.assertEqual(spans[1].attributes["aws.operation"], "PutObject")
|
||||
# self.assertEqual(
|
||||
# spans[1].resource,
|
||||
# Resource(attributes={"endpoint": "s3", "operation": "putobject"}),
|
||||
# )
|
||||
# self.assertEqual(spans[1].attributes["params.Key"], str(params["Key"]))
|
||||
# self.assertEqual(
|
||||
# spans[1].attributes["params.Bucket"], str(params["Bucket"])
|
||||
# )
|
||||
# self.assertTrue("params.Body" not in spans[1].attributes.keys())
|
||||
spans = self.memory_exporter.get_finished_spans()
|
||||
assert spans
|
||||
span = spans[0]
|
||||
self.assertEqual(len(spans), 2)
|
||||
self.assertEqual(span.attributes["aws.operation"], "CreateBucket")
|
||||
assert_span_http_status_code(span, 200)
|
||||
self.assertEqual(
|
||||
span.resource,
|
||||
Resource(
|
||||
attributes={"endpoint": "s3", "operation": "createbucket"}
|
||||
),
|
||||
)
|
||||
self.assertEqual(spans[1].attributes["aws.operation"], "PutObject")
|
||||
self.assertEqual(
|
||||
spans[1].resource,
|
||||
Resource(attributes={"endpoint": "s3", "operation": "putobject"}),
|
||||
)
|
||||
self.assertEqual(spans[1].attributes["params.Key"], str(params["Key"]))
|
||||
self.assertEqual(
|
||||
spans[1].attributes["params.Bucket"], str(params["Bucket"])
|
||||
)
|
||||
self.assertTrue("params.Body" not in spans[1].attributes.keys())
|
||||
|
||||
@mock_sqs
|
||||
def test_sqs_client(self):
|
||||
|
Reference in New Issue
Block a user