Skip to content

Commit

Permalink
Reset prometheus client global registry in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkdog committed Sep 28, 2023
1 parent 65cfdb4 commit a7f6a22
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_bundler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_bundler.py
"""Unit tests for lta/bundler.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

import os
from typing import Dict
from unittest.mock import AsyncMock, call, mock_open, patch
Expand Down
12 changes: 12 additions & 0 deletions tests/test_deleter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_deleter.py
"""Unit tests for lta/deleter.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call, MagicMock

Expand Down
12 changes: 12 additions & 0 deletions tests/test_desy_move_verifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_desy_move_verifier.py
"""Unit tests for lta/desy_move_verifier.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call

Expand Down
12 changes: 12 additions & 0 deletions tests/test_desy_verifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_desy_verifier.py
"""Unit tests for lta/desy_verifier.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call
from uuid import uuid1
Expand Down
12 changes: 12 additions & 0 deletions tests/test_locator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_locator.py
"""Unit tests for lta/locator.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from math import floor
from secrets import token_hex
from typing import Any, Dict, List, Union
Expand Down
12 changes: 12 additions & 0 deletions tests/test_nersc_mover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_nersc_mover.py
"""Unit tests for lta/nersc_mover.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call, MagicMock

Expand Down
12 changes: 12 additions & 0 deletions tests/test_nersc_retriever.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_nersc_retriever.py
"""Unit tests for lta/nersc_retriever.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call, MagicMock

Expand Down
12 changes: 12 additions & 0 deletions tests/test_nersc_verifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_nersc_verifier.py
"""Unit tests for lta/nersc_verifier.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call, MagicMock
from uuid import uuid1
Expand Down
12 changes: 12 additions & 0 deletions tests/test_picker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_picker.py
"""Unit tests for lta/picker.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from secrets import token_hex
from typing import Any, Dict, List, Union
from unittest.mock import AsyncMock, call, MagicMock
Expand Down
12 changes: 12 additions & 0 deletions tests/test_rate_limiter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_rate_limiter.py
"""Unit tests for lta/rate_limiter.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call, MagicMock

Expand Down
12 changes: 12 additions & 0 deletions tests/test_site_move_verifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_site_move_verifier.py
"""Unit tests for lta/site_move_verifier.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call, MagicMock

Expand Down
12 changes: 12 additions & 0 deletions tests/test_transfer_request_finisher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_transfer_request_finisher.py
"""Unit tests for lta/transfer_request_finisher.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Dict
from unittest.mock import AsyncMock, call

Expand Down
12 changes: 12 additions & 0 deletions tests/test_unpacker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# test_unpacker.py
"""Unit tests for lta/unpacker.py."""

# -----------------------------------------------------------------------------
# reset prometheus registry for unit tests
from prometheus_client import REGISTRY
collectors = list(REGISTRY._collector_to_names.keys())
for collector in collectors:
REGISTRY.unregister(collector)
from prometheus_client import gc_collector, platform_collector, process_collector
process_collector.ProcessCollector()
platform_collector.PlatformCollector()
gc_collector.GCCollector()
# -----------------------------------------------------------------------------

from typing import Any, Dict
from unittest.mock import AsyncMock, call, MagicMock, mock_open, patch

Expand Down

0 comments on commit a7f6a22

Please sign in to comment.