Skip to content

Commit

Permalink
Check for leaks when removing global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Mar 26, 2024
1 parent 9546e9d commit df5db05
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/new_tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import glob
import os
import time
from typing import Optional
# from typing import Optional


# Flags for testing callbacks
Expand All @@ -14,8 +14,8 @@
snapshot_triggered = False

# Cluster objects returned from callbacks
cluster_from_disable_listener: Optional[Cluster] = None
cluster_from_snapshot_listener: Optional[Cluster] = None
# cluster_from_disable_listener: Optional[Cluster] = None
# cluster_from_snapshot_listener: Optional[Cluster] = None


class MyMetricsListeners:
Expand All @@ -26,17 +26,17 @@ def enable():
def disable(cluster: Cluster):
global disable_triggered
disable_triggered = True
global cluster_from_disable_listener
cluster_from_disable_listener = cluster
# global cluster_from_disable_listener
# cluster_from_disable_listener = cluster

def node_close(node: Node):
pass

def snapshot(cluster: Cluster):
global snapshot_triggered
snapshot_triggered = True
global cluster_from_snapshot_listener
cluster_from_snapshot_listener = cluster
# global cluster_from_snapshot_listener
# cluster_from_snapshot_listener = cluster

def throw_exc():
raise Exception()
Expand All @@ -53,10 +53,10 @@ def setup(self, as_connection, request):
disable_triggered = False
snapshot_triggered = False

global cluster_from_disable_listener
global cluster_from_snapshot_listener
cluster_from_disable_listener = None
cluster_from_snapshot_listener = None
# global cluster_from_disable_listener
# global cluster_from_snapshot_listener
# cluster_from_disable_listener = None
# cluster_from_snapshot_listener = None

# Set defaults (in case they were overwritten by a test)
self.metrics_log_folder = "."
Expand Down Expand Up @@ -140,9 +140,9 @@ def test_setting_metrics_policy_custom_settings(self):
assert snapshot_triggered is True

# The Cluster objects returned from the disable and snapshot callbacks should be populated
global cluster_from_disable_listener
global cluster_from_snapshot_listener
for cluster in [cluster_from_disable_listener, cluster_from_snapshot_listener]:
# global cluster_from_disable_listener
# global cluster_from_snapshot_listener
for cluster in []:
assert type(cluster) == Cluster
assert cluster.cluster_name is None or type(cluster.cluster_name) == str
assert type(cluster.invalid_node_count) == int
Expand Down

0 comments on commit df5db05

Please sign in to comment.