Skip to content

Commit

Permalink
Fix tests with pre-2.0 backoff (fix #3087) (#3106)
Browse files Browse the repository at this point in the history
  • Loading branch information
musicinmybrain authored and gen-xu committed Jan 3, 2023
1 parent 4f28005 commit 7a05966
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from opentelemetry.attributes import BoundedAttributes
from opentelemetry.exporter.otlp.proto.grpc.exporter import (
_is_backoff_v2,
_translate_key_values,
)
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
Expand Down Expand Up @@ -461,7 +462,8 @@ def test_otlp_headers(self, mock_ssl_channel, mock_secure):
def test_handles_backoff_v2_api(self, mock_sleep, mock_backoff):
# In backoff ~= 2.0.0 the first value yielded from expo is None.
def generate_delays(*args, **kwargs):
yield None
if _is_backoff_v2:
yield None
yield 1

mock_backoff.expo.configure_mock(**{"side_effect": generate_delays})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
DEFAULT_METRICS_EXPORT_PATH,
DEFAULT_TIMEOUT,
OTLPMetricExporter,
_is_backoff_v2,
)
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_CERTIFICATE,
Expand Down Expand Up @@ -281,7 +282,8 @@ def test_serialization(self, mock_post):
def test_handles_backoff_v2_api(self, mock_sleep, mock_backoff):
# In backoff ~= 2.0.0 the first value yielded from expo is None.
def generate_delays(*args, **kwargs):
yield None
if _is_backoff_v2:
yield None
yield 1

mock_backoff.expo.configure_mock(**{"side_effect": generate_delays})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
DEFAULT_LOGS_EXPORT_PATH,
DEFAULT_TIMEOUT,
OTLPLogExporter,
_is_backoff_v2,
)
from opentelemetry.exporter.otlp.proto.http._log_exporter.encoder import (
_encode_attributes,
Expand Down Expand Up @@ -166,7 +167,8 @@ def test_serialize(self):
def test_handles_backoff_v2_api(self, mock_sleep, mock_backoff):
# In backoff ~= 2.0.0 the first value yielded from expo is None.
def generate_delays(*args, **kwargs):
yield None
if _is_backoff_v2:
yield None
yield 1

mock_backoff.expo.configure_mock(**{"side_effect": generate_delays})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
DEFAULT_TIMEOUT,
DEFAULT_TRACES_EXPORT_PATH,
OTLPSpanExporter,
_is_backoff_v2,
)
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_CERTIFICATE,
Expand Down Expand Up @@ -203,7 +204,8 @@ def test_headers_parse_from_env(self):
def test_handles_backoff_v2_api(self, mock_sleep, mock_backoff):
# In backoff ~= 2.0.0 the first value yielded from expo is None.
def generate_delays(*args, **kwargs):
yield None
if _is_backoff_v2:
yield None
yield 1

mock_backoff.expo.configure_mock(**{"side_effect": generate_delays})
Expand Down

0 comments on commit 7a05966

Please sign in to comment.