-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config option for disabling reporting (#326)
* Add config option for disabling reporting * Fix scenario tests * Restart if command differs --------- Co-authored-by: Pietro Pasotti <[email protected]> Co-authored-by: Luca Bello <[email protected]>
- Loading branch information
1 parent
a6e47de
commit 725f0ca
Showing
11 changed files
with
113 additions
and
99 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
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 |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import shutil | ||
from pathlib import Path | ||
|
||
import pytest | ||
from ops.testing import Context | ||
|
||
CHARM_ROOT = Path(__file__).parent.parent.parent | ||
from charm import GrafanaAgentK8sCharm | ||
|
||
|
||
@pytest.fixture | ||
def vroot(tmp_path) -> Path: | ||
root = Path(str(tmp_path.absolute())) | ||
shutil.rmtree(root) | ||
shutil.copytree(CHARM_ROOT / "src", root / "src") | ||
return root | ||
def ctx(): | ||
yield Context(GrafanaAgentK8sCharm) |
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,30 @@ | ||
from ops.testing import Container, State | ||
|
||
containers = [Container(name="agent", can_connect=True)] | ||
|
||
|
||
def test_reporting_enabled(ctx): | ||
# GIVEN the "reporting_enabled" config option is set to True | ||
state = State(leader=True, config={"reporting_enabled": True}, containers=containers) | ||
|
||
# WHEN config-changed fires | ||
out = ctx.run(ctx.on.config_changed(), state) | ||
|
||
# THEN the service layer does NOT include the "-disable-reporting" arg | ||
assert ( | ||
"-disable-reporting" | ||
not in out.get_container("agent").layers["agent"].services["agent"].command | ||
) | ||
|
||
|
||
def test_reporting_disabled(ctx): | ||
# GIVEN the "reporting_enabled" config option is set to False | ||
state = State(leader=True, config={"reporting_enabled": False}, containers=containers) | ||
# WHEN config-changed fires | ||
out = ctx.run(ctx.on.config_changed(), state) | ||
|
||
# THEN the service layer INCLUDES the "-disable-reporting" arg | ||
assert ( | ||
"-disable-reporting" | ||
in out.get_container("agent").layers["agent"].services["agent"].command | ||
) |
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
Oops, something went wrong.