Skip to content

Commit

Permalink
fixed scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti committed Nov 25, 2024
1 parent 82a179e commit ceb544d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/charms/grafana_k8s/v0/grafana_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,10 @@ def get_source_uids(self) -> Dict[str, Dict[str, str]]:
for rel in self._charm.model.relations.get(self._relation_name, []):
if not rel:
continue
uids[rel.app.name] = json.loads(rel.data[rel.app]["datasource_uids"])
ds_uids_raw = rel.data[rel.app].get("datasource_uids")
if not ds_uids_raw:
continue
uids[rel.app.name] = json.loads(ds_uids_raw)
return uids

def _set_sources_from_event(self, event: RelationJoinedEvent) -> None:
Expand Down
6 changes: 6 additions & 0 deletions tests/scenario/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def prometheus_charm():
yield PrometheusCharm


@pytest.fixture(autouse=True)
def disable_charm_tracing_buffer():
with patch("charms.tempo_coordinator_k8s.v0.charm_tracing._Buffer.save", lambda *_: None):
yield


@pytest.fixture(scope="function")
def context(prometheus_charm):
return Context(charm_type=prometheus_charm, juju_version="3.0.3")
6 changes: 3 additions & 3 deletions tests/scenario/test_server_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def initial_state(self, context, fqdn, leader) -> State:

# Add relations
rels = [
Relation("self-metrics-endpoint", relation_id=10), # external self-monitoring
Relation("grafana-source", relation_id=11), # grafana
Relation("receive-remote-write", relation_id=12), # grafana-agent
Relation("self-metrics-endpoint"), # external self-monitoring
Relation("grafana-source"), # grafana
Relation("receive-remote-write"), # grafana-agent
]
for rel in rels:
state = add_relation_sequence(context, state, rel)
Expand Down

0 comments on commit ceb544d

Please sign in to comment.