Skip to content

Commit

Permalink
Merge branch 'main' into config_doesnt_apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Abuelodelanada authored Aug 20, 2024
2 parents d401d9e + 618fefe commit f30e92b
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/alertmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import re
from typing import Callable, Dict, List, Optional, Tuple

from alertmanager_client import Alertmanager, AlertmanagerBadResponse
from ops.framework import Object
from ops.model import Container
from ops.pebble import ( # type: ignore
Expand All @@ -18,6 +17,8 @@
Layer,
)

from alertmanager_client import Alertmanager, AlertmanagerBadResponse

logger = logging.getLogger(__name__)


Expand Down
15 changes: 8 additions & 7 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
from urllib.parse import urlparse

import yaml
from alertmanager import (
ConfigFileSystemState,
ConfigUpdateFailure,
WorkloadManager,
WorkloadManagerError,
)
from charms.alertmanager_k8s.v0.alertmanager_remote_configuration import (
RemoteConfigurationRequirer,
)
Expand All @@ -38,7 +32,6 @@
from charms.tempo_k8s.v1.charm_tracing import trace_charm
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer
from charms.traefik_k8s.v2.ingress import IngressPerAppRequirer
from config_builder import ConfigBuilder, ConfigError
from ops.charm import ActionEvent, CharmBase
from ops.main import main
from ops.model import (
Expand All @@ -51,6 +44,14 @@
)
from ops.pebble import PathError, ProtocolError # type: ignore

from alertmanager import (
ConfigFileSystemState,
ConfigUpdateFailure,
WorkloadManager,
WorkloadManagerError,
)
from config_builder import ConfigBuilder, ConfigError

logger = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import pytest
import yaml
from alertmanager_client import Alertmanager
from helpers import get_unit_address, is_alertmanager_up, uk8s_group
from pytest_operator.plugin import OpsTest

from alertmanager_client import Alertmanager

logger = logging.getLogger(__name__)

METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
Expand Down
3 changes: 2 additions & 1 deletion tests/scenario/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from unittest.mock import patch

import pytest
from scenario import Context

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm
from scenario import Context


def tautology(*_, **__) -> bool:
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import ops
import yaml
from alertmanager import WorkloadManager
from charm import AlertmanagerCharm
from helpers import k8s_resource_multipatch
from ops import pebble
from ops.model import ActiveStatus, BlockedStatus
from ops.testing import Harness

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm

ops.testing.SIMULATE_CAN_CONNECT = True


Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_external_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

import ops
import yaml
from alertmanager import WorkloadManager
from charm import AlertmanagerCharm
from helpers import cli_arg, k8s_resource_multipatch
from ops.testing import Harness

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm

logger = logging.getLogger(__name__)

ops.testing.SIMULATE_CAN_CONNECT = True
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_push_config_to_workload_on_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import ops
import validators
import yaml
from alertmanager import WorkloadManager
from charm import AlertmanagerCharm
from helpers import k8s_resource_multipatch
from hypothesis import given
from ops.model import ActiveStatus, BlockedStatus
from ops.testing import Harness

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm

logger = logging.getLogger(__name__)
ops.testing.SIMULATE_CAN_CONNECT = True
CONTAINER_NAME = "alertmanager"
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_remote_configuration_requirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from unittest.mock import Mock, patch

import yaml
from alertmanager import WorkloadManager
from charm import AlertmanagerCharm
from charms.alertmanager_k8s.v0.alertmanager_remote_configuration import (
DEFAULT_RELATION_NAME,
)
Expand All @@ -18,6 +16,9 @@
from ops import testing
from ops.model import BlockedStatus

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm

logger = logging.getLogger(__name__)

testing.SIMULATE_CAN_CONNECT = True
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_self_scrape_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import unittest
from unittest.mock import PropertyMock, patch

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm
from helpers import k8s_resource_multipatch
from ops.testing import Harness

from alertmanager import WorkloadManager
from charm import AlertmanagerCharm


class TestWithInitialHooks(unittest.TestCase):
container_name: str = "alertmanager"
Expand Down

0 comments on commit f30e92b

Please sign in to comment.