|
10 | 10 |
|
11 | 11 | from charm import CassandraCharm
|
12 | 12 | from core.state import PEER_RELATION
|
| 13 | +from managers.config import ConfigManager |
13 | 14 |
|
14 | 15 | BOOTSTRAP_RELATION = "bootstrap"
|
| 16 | +PEER_SECRET = "cassandra-peers.cassandra.app" |
| 17 | + |
| 18 | +# TODO: add start change password unit test |
15 | 19 |
|
16 | 20 |
|
17 | 21 | def test_start_leader():
|
18 | 22 | """Leader should render all required configs and start workload."""
|
19 | 23 | ctx = testing.Context(CassandraCharm)
|
20 | 24 | relation = testing.PeerRelation(id=1, endpoint=PEER_RELATION)
|
21 | 25 | bootstrap_relation = testing.PeerRelation(id=2, endpoint=BOOTSTRAP_RELATION)
|
22 |
| - state = testing.State(leader=True, relations={relation, bootstrap_relation}) |
| 26 | + secret = testing.Secret(label=PEER_SECRET, tracked_content={"cassandra-password": "ua"}) |
| 27 | + state = testing.State(leader=True, relations={relation, bootstrap_relation}, secrets={secret}) |
23 | 28 |
|
24 | 29 | with (
|
25 | 30 | patch("managers.config.ConfigManager.render_env") as render_env,
|
@@ -78,7 +83,8 @@ def test_start_subordinate_only_after_leader_active():
|
78 | 83 | relation = testing.PeerRelation(
|
79 | 84 | id=1, endpoint=PEER_RELATION, local_app_data={"cluster_state": "active"}
|
80 | 85 | )
|
81 |
| - state = testing.State(leader=False, relations={relation}) |
| 86 | + secret = testing.Secret(label=PEER_SECRET, tracked_content={"cassandra-password": "ua"}) |
| 87 | + state = testing.State(leader=False, relations={relation}, secrets={secret}) |
82 | 88 |
|
83 | 89 | state = ctx.run(ctx.on.start(), state)
|
84 | 90 | bootstrap.assert_called_once()
|
@@ -165,8 +171,8 @@ def test_config_changed():
|
165 | 171 | ),
|
166 | 172 | ):
|
167 | 173 | state = ctx.run(ctx.on.config_changed(), state)
|
168 |
| - render_env.assert_called() |
169 |
| - render_cassandra_config.assert_called() |
| 174 | + render_env.assert_not_called() |
| 175 | + render_cassandra_config.assert_not_called() |
170 | 176 | workload.return_value.restart.assert_not_called()
|
171 | 177 |
|
172 | 178 | relation = testing.PeerRelation(
|
|
0 commit comments