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
3 changes: 2 additions & 1 deletion sunbeam-python/sunbeam/features/observability/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def __init__(
self.endpoints = [
"opentelemetry-collector:grafana-dashboards-provider",
"opentelemetry-collector:send-remote-write",
"opentelemetry-collector:logging-consumer",
"opentelemetry-collector:send-loki-logs",
]

def _get_relations(self, model: str, endpoints: list[str]) -> list[tuple]:
Expand Down Expand Up @@ -1715,6 +1715,7 @@ def run_enable_plans(
self,
tfhelper_observability_agent_infra,
jhelper,
accepted_app_status=["active", "blocked"],
),
]
run_plan(infra_agent_plan, console, show_hints)
Expand Down
51 changes: 49 additions & 2 deletions sunbeam-python/tests/unit/sunbeam/features/test_observability.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ def test_run(
Mock(
apps={
"opentelemetry-collector": Mock(
relations={"logging-consumer": "loki:loki_push_api"}
relations={"send-loki-logs": "loki:loki_push_api"}
)
}
),
Expand Down Expand Up @@ -849,7 +849,7 @@ def test_run_waiting_timedout(
Mock(
apps={
"opentelemetry-collector": Mock(
relations={"logging-consumer": "loki:loki_push_api"}
relations={"send-loki-logs": "loki:loki_push_api"}
)
}
),
Expand Down Expand Up @@ -930,6 +930,53 @@ def test_run_non_maas_excludes_infra_model(
assert result.result_type == ResultType.COMPLETED


class TestExternalObservabilityEnablePlans:
"""Test enablement plans for ExternalObservabilityFeature."""

def _run_enable_plans(self, feature, deployment, run_plan_obs, is_maas):
feature._manifest = Mock()
with patch(
"sunbeam.features.observability.feature.is_maas_deployment",
return_value=is_maas,
):
feature.run_enable_plans(deployment, Mock(), False)

return [step for call in run_plan_obs.call_args_list for step in call.args[0]]

def test_maas_infra_agent_step_accepts_blocked(
self, deployment, run_plan_obs, juju_helper_obs
):
"""External COS: infra agent is blocked until offers are integrated.

With an external COS, integrations are only created by
IntegrateRemoteCosOffersStep after all agents are deployed, so the
infra agent deploy step must accept 'blocked' status (LP#2159965).
"""
feature = observability_feature.ExternalObservabilityFeature()
steps = self._run_enable_plans(feature, deployment, run_plan_obs, is_maas=True)

infra_steps = [
step
for step in steps
if isinstance(step, observability_feature.DeployObservabilityAgentInfraStep)
]
assert len(infra_steps) == 1
assert "blocked" in infra_steps[0].accepted_app_status
assert "active" in infra_steps[0].accepted_app_status

def test_maas_integrate_offers_runs_after_infra_agent(
self, deployment, run_plan_obs, juju_helper_obs
):
"""Offers are integrated only after the infra agent is deployed."""
feature = observability_feature.ExternalObservabilityFeature()
steps = self._run_enable_plans(feature, deployment, run_plan_obs, is_maas=True)

step_types = [type(step) for step in steps]
assert step_types.index(
observability_feature.IntegrateRemoteCosOffersStep
) > step_types.index(observability_feature.DeployObservabilityAgentInfraStep)


class TestObservabilityFeatureTimeouts:
"""Test timeout calculation for ObservabilityFeature."""

Expand Down
Loading