-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a29e97
commit 2283817
Showing
6 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
ops >= 2.15 | ||
cosl>=0.0.20 | ||
cosl>=0.0.24 | ||
|
||
# Charm relation interfaces | ||
pydantic>=2 | ||
|
||
# lib/charms/tempo_k8s/v1/charm_tracing.py | ||
opentelemetry-exporter-otlp-proto-http==1.21.0 | ||
opentelemetry-exporter-otlp-proto-http==1.21.0 | ||
|
||
lightkube>=0.15.4 | ||
lightkube-models==1.24.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
import json | ||
from unittest.mock import patch, MagicMock | ||
|
||
from cosl.coordinated_workers.interface import ClusterRequirer | ||
from scenario import Container, ExecOutput, Relation, State | ||
|
||
from tests.scenario.conftest import TEMPO_VERSION_EXEC_OUTPUT | ||
from tests.scenario.helpers import set_role | ||
from ops import BlockedStatus, WaitingStatus | ||
|
||
|
||
@patch.object(ClusterRequirer, "get_worker_config", MagicMock(return_value={"config": "config"})) | ||
@patch( | ||
"cosl.coordinated_workers.worker.KubernetesComputeResourcesPatch.get_status", | ||
MagicMock(return_value=BlockedStatus("`juju trust` this application")), | ||
) | ||
def test_patch_k8s_failed(ctx): | ||
|
||
tempo_container = Container( | ||
"tempo", | ||
can_connect=True, | ||
exec_mock={ | ||
("/bin/tempo", "-version"): TEMPO_VERSION_EXEC_OUTPUT, | ||
("update-ca-certificates", "--fresh"): ExecOutput(), | ||
}, | ||
) | ||
state_out = ctx.run( | ||
"config_changed", | ||
state=set_role( | ||
State( | ||
containers=[tempo_container], | ||
relations=[ | ||
Relation( | ||
"tempo-cluster", | ||
remote_app_data={ | ||
"tempo_config": json.dumps({"alive": "beef"}), | ||
}, | ||
) | ||
], | ||
), | ||
"all", | ||
), | ||
) | ||
|
||
assert state_out.unit_status == BlockedStatus("`juju trust` this application") | ||
|
||
@patch.object(ClusterRequirer, "get_worker_config", MagicMock(return_value={"config": "config"})) | ||
@patch( | ||
"cosl.coordinated_workers.worker.KubernetesComputeResourcesPatch.get_status", | ||
MagicMock(return_value=WaitingStatus("")), | ||
) | ||
def test_patch_k8s_waiting(ctx): | ||
|
||
tempo_container = Container( | ||
"tempo", | ||
can_connect=True, | ||
exec_mock={ | ||
("/bin/tempo", "-version"): TEMPO_VERSION_EXEC_OUTPUT, | ||
("update-ca-certificates", "--fresh"): ExecOutput(), | ||
}, | ||
) | ||
state_out = ctx.run( | ||
"config_changed", | ||
state=set_role( | ||
State( | ||
containers=[tempo_container], | ||
relations=[ | ||
Relation( | ||
"tempo-cluster", | ||
remote_app_data={ | ||
"tempo_config": json.dumps({"alive": "beef"}), | ||
}, | ||
) | ||
], | ||
), | ||
"all", | ||
), | ||
) | ||
|
||
assert state_out.unit_status == WaitingStatus("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters