Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pubsub/google/cloud/pubsub_v1/subscriber/policy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from google.cloud.pubsub_v1 import types
from google.cloud.pubsub_v1.subscriber import _consumer
from google.cloud.pubsub_v1.subscriber import _histogram
from google.cloud.pubsub_v1.subscriber._protocol import histogram


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -114,7 +114,7 @@ def __init__(self, client, subscription,
self._last_histogram_size = 0
self._future = None
self.flow_control = flow_control
self.histogram = _histogram.Histogram(data=histogram_data)
self.histogram = histogram.Histogram(data=histogram_data)
""".Histogram: the histogram tracking ack latency."""
self.leased_messages = {}
"""dict[str, float]: A mapping of ack IDs to the local time when the
Expand Down
18 changes: 9 additions & 9 deletions pubsub/tests/unit/pubsub_v1/subscriber/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from google.cloud.pubsub_v1.subscriber import _histogram
from google.cloud.pubsub_v1.subscriber._protocol import histogram


def test_init():
data = {}
histo = _histogram.Histogram(data=data)
histo = histogram.Histogram(data=data)
assert histo._data is data
assert len(histo) == 0


def test_contains():
histo = _histogram.Histogram()
histo = histogram.Histogram()
histo.add(10)
histo.add(20)
assert 10 in histo
Expand All @@ -32,7 +32,7 @@ def test_contains():


def test_max():
histo = _histogram.Histogram()
histo = histogram.Histogram()
assert histo.max == 600
histo.add(120)
assert histo.max == 120
Expand All @@ -43,7 +43,7 @@ def test_max():


def test_min():
histo = _histogram.Histogram()
histo = histogram.Histogram()
assert histo.min == 10
histo.add(60)
assert histo.min == 60
Expand All @@ -54,29 +54,29 @@ def test_min():


def test_add():
histo = _histogram.Histogram()
histo = histogram.Histogram()
histo.add(60)
assert histo._data[60] == 1
histo.add(60)
assert histo._data[60] == 2


def test_add_lower_limit():
histo = _histogram.Histogram()
histo = histogram.Histogram()
histo.add(5)
assert 5 not in histo
assert 10 in histo


def test_add_upper_limit():
histo = _histogram.Histogram()
histo = histogram.Histogram()
histo.add(12000)
assert 12000 not in histo
assert 600 in histo


def test_percentile():
histo = _histogram.Histogram()
histo = histogram.Histogram()
[histo.add(i) for i in range(101, 201)]
assert histo.percentile(100) == 200
assert histo.percentile(101) == 200
Expand Down
4 changes: 2 additions & 2 deletions pubsub/tests/unit/pubsub_v1/subscriber/test_leaser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import threading

from google.cloud.pubsub_v1 import types
from google.cloud.pubsub_v1.subscriber import _histogram
from google.cloud.pubsub_v1.subscriber import subscriber
from google.cloud.pubsub_v1.subscriber._protocol import histogram
from google.cloud.pubsub_v1.subscriber._protocol import leaser
from google.cloud.pubsub_v1.subscriber._protocol import requests

Expand Down Expand Up @@ -87,7 +87,7 @@ def create_subscriber(flow_control=types.FlowControl()):
subscriber_ = mock.create_autospec(subscriber.Subscriber, instance=True)
subscriber_.is_active = True
subscriber_.flow_control = flow_control
subscriber_.ack_histogram = _histogram.Histogram()
subscriber_.ack_histogram = histogram.Histogram()
return subscriber_


Expand Down