qontract-reconcile 0.10.1rc764__py3-none-any.whl → 0.10.1rc765__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {qontract_reconcile-0.10.1rc764.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc764.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/RECORD +16 -31
  3. reconcile/saas_auto_promotions_manager/meta.py +1 -1
  4. reconcile/saas_auto_promotions_manager/subscriber.py +52 -2
  5. reconcile/saas_auto_promotions_manager/utils/saas_files_inventory.py +4 -0
  6. reconcile/test/saas_auto_promotions_manager/conftest.py +63 -0
  7. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/conftest.py +0 -37
  8. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_desired_state.py +20 -14
  9. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +0 -43
  10. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_multiple_namespaces.py +4 -11
  11. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_namespace.py +12 -19
  12. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_target.py +6 -12
  13. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_json_path_selector.py +8 -15
  14. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/data_keys.py +0 -4
  15. reconcile/test/saas_auto_promotions_manager/subscriber/__init__.py +0 -0
  16. reconcile/test/saas_auto_promotions_manager/subscriber/conftest.py +0 -89
  17. reconcile/test/saas_auto_promotions_manager/subscriber/data_keys.py +0 -11
  18. reconcile/test/saas_auto_promotions_manager/subscriber/test_content_hash.py +0 -130
  19. reconcile/test/saas_auto_promotions_manager/subscriber/test_diff.py +0 -161
  20. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_channels_config_hash.py +0 -218
  21. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_channels_moving_ref.py +0 -216
  22. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_publishers_moving_ref.py +0 -129
  23. reconcile/test/saas_auto_promotions_manager/subscriber/test_single_channel_with_single_publisher.py +0 -330
  24. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/__init__.py +0 -0
  25. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_multiple_publishers_for_single_channel.py +0 -68
  26. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_use_target_config_hash.py +0 -62
  27. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_with_auto_promote.py +0 -73
  28. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_without_auto_promote.py +0 -64
  29. {qontract_reconcile-0.10.1rc764.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/WHEEL +0 -0
  30. {qontract_reconcile-0.10.1rc764.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/entry_points.txt +0 -0
  31. {qontract_reconcile-0.10.1rc764.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/top_level.txt +0 -0
@@ -11,35 +11,28 @@ from reconcile.saas_auto_promotions_manager.subscriber import (
11
11
  Subscriber,
12
12
  )
13
13
 
14
- from .data_keys import (
15
- CHANNELS,
16
- CONFIG_HASHES,
17
- NAMESPACE,
18
- REF,
19
- )
20
-
21
14
 
22
15
  def test_json_path_selector_include(
23
16
  file_contents: Callable[[str], tuple[str, str]],
24
17
  subscriber_builder: Callable[[Mapping], Subscriber],
25
18
  ):
26
19
  subscriber = subscriber_builder({
27
- NAMESPACE: {
20
+ "NAMESPACE": {
28
21
  "path": "/some/namespace.yml",
29
22
  "name": "test-namespace",
30
23
  "cluster": {
31
24
  "name": "test-cluster",
32
25
  },
33
26
  },
34
- REF: "new_sha",
35
- CONFIG_HASHES: [
27
+ "DESIRED_REF": "new_sha",
28
+ "DESIRED_TARGET_HASHES": [
36
29
  ConfigHash(
37
30
  channel="channel-a",
38
31
  target_config_hash="new_hash",
39
32
  parent_saas="parent_saas",
40
33
  )
41
34
  ],
42
- CHANNELS: ["channel-a"],
35
+ "CHANNELS": {"channel-a": {}},
43
36
  })
44
37
  saas_content, expected = file_contents("json_path_selector_includes")
45
38
  renderer = Renderer()
@@ -55,22 +48,22 @@ def test_json_path_selector_exclude(
55
48
  subscriber_builder: Callable[[Mapping], Subscriber],
56
49
  ):
57
50
  subscriber = subscriber_builder({
58
- NAMESPACE: {
51
+ "NAMESPACE": {
59
52
  "path": "/some/namespace.yml",
60
53
  "name": "test-namespace",
61
54
  "cluster": {
62
55
  "name": "test-cluster",
63
56
  },
64
57
  },
65
- REF: "hyper_sha",
66
- CONFIG_HASHES: [
58
+ "DESIRED_REF": "hyper_sha",
59
+ "DESIRED_TARGET_HASHES": [
67
60
  ConfigHash(
68
61
  channel="channel-a",
69
62
  target_config_hash="hyper_hash",
70
63
  parent_saas="parent_saas",
71
64
  )
72
65
  ],
73
- CHANNELS: ["channel-a"],
66
+ "CHANNELS": {"channel-a": {}},
74
67
  })
75
68
  saas_content, expected = file_contents("json_path_selector_excludes")
76
69
  renderer = Renderer()
@@ -1,4 +0,0 @@
1
- REF = "ref"
2
- CONFIG_HASHES = "config_hashes"
3
- CHANNELS = "channels"
4
- NAMESPACE = "namespace"
@@ -1,89 +0,0 @@
1
- from collections import defaultdict
2
- from collections.abc import (
3
- Callable,
4
- Mapping,
5
- )
6
- from typing import Any
7
-
8
- import pytest
9
-
10
- from reconcile.gql_definitions.fragments.saas_target_namespace import (
11
- SaasTargetNamespace,
12
- )
13
- from reconcile.saas_auto_promotions_manager.publisher import (
14
- DeploymentInfo,
15
- Publisher,
16
- )
17
- from reconcile.saas_auto_promotions_manager.subscriber import (
18
- Channel,
19
- ConfigHash,
20
- Subscriber,
21
- )
22
-
23
- from .data_keys import (
24
- CHANNELS,
25
- CONFIG_HASH,
26
- CUR_CONFIG_HASHES,
27
- CUR_SUBSCRIBER_REF,
28
- DESIRED_REF,
29
- DESIRED_TARGET_HASHES,
30
- NAMESPACE,
31
- REAL_WORLD_SHA,
32
- SUCCESSFUL_DEPLOYMENT,
33
- TARGET_FILE_PATH,
34
- USE_TARGET_CONFIG_HASH,
35
- )
36
-
37
-
38
- @pytest.fixture
39
- def subscriber_builder(
40
- saas_target_namespace_builder: Callable[..., SaasTargetNamespace],
41
- ) -> Callable[[Mapping[str, Any]], Subscriber]:
42
- def builder(data: Mapping[str, Any]) -> Subscriber:
43
- channels: list[Channel] = []
44
- for channel_name, channel_data in data.get(CHANNELS, {}).items():
45
- channel = Channel(name=channel_name, publishers=[])
46
- for publisher_name, publisher_data in channel_data.items():
47
- publisher = Publisher(
48
- ref="",
49
- uid="",
50
- repo_url="",
51
- cluster_name="",
52
- namespace_name="",
53
- saas_name="",
54
- saas_file_path="",
55
- app_name="",
56
- resource_template_name="",
57
- target_name=None,
58
- publish_job_logs=True,
59
- has_subscriber=True,
60
- auth_code=None,
61
- )
62
- publisher.commit_sha = publisher_data[REAL_WORLD_SHA]
63
- publisher.deployment_info_by_channel[channel_name] = DeploymentInfo(
64
- success=publisher_data.get(SUCCESSFUL_DEPLOYMENT, True),
65
- target_config_hash=publisher_data.get(CONFIG_HASH, ""),
66
- saas_file=publisher_name,
67
- )
68
- channel.publishers.append(publisher)
69
- channels.append(channel)
70
- cur_config_hashes_by_channel: dict[str, list[ConfigHash]] = defaultdict(list)
71
- for cur_config_hash in data.get(CUR_CONFIG_HASHES, []):
72
- cur_config_hashes_by_channel[cur_config_hash.channel].append(
73
- cur_config_hash
74
- )
75
- subscriber = Subscriber(
76
- target_namespace=saas_target_namespace_builder(data.get(NAMESPACE, {})),
77
- ref=data.get(CUR_SUBSCRIBER_REF, ""),
78
- saas_name="",
79
- target_file_path=data.get(TARGET_FILE_PATH, ""),
80
- template_name="",
81
- use_target_config_hash=data.get(USE_TARGET_CONFIG_HASH, True),
82
- )
83
- subscriber.channels = channels
84
- subscriber.config_hashes_by_channel_name = cur_config_hashes_by_channel
85
- subscriber.desired_ref = data.get(DESIRED_REF, "")
86
- subscriber.desired_hashes = data.get(DESIRED_TARGET_HASHES, [])
87
- return subscriber
88
-
89
- return builder
@@ -1,11 +0,0 @@
1
- CUR_SUBSCRIBER_REF = "cur_subscriber_ref"
2
- REAL_WORLD_SHA = "real_world_sha"
3
- CONFIG_HASH = "config_hash"
4
- CHANNELS = "channels"
5
- SUCCESSFUL_DEPLOYMENT = "successful_deployment"
6
- CUR_CONFIG_HASHES = "cur_config_hashes"
7
- TARGET_FILE_PATH = "target_file_path"
8
- DESIRED_REF = "desired_ref"
9
- DESIRED_TARGET_HASHES = "desired_target_hashes"
10
- USE_TARGET_CONFIG_HASH = "use_target_config_hash"
11
- NAMESPACE = "namespace"
@@ -1,130 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Mapping,
4
- )
5
-
6
- from reconcile.saas_auto_promotions_manager.subscriber import (
7
- CONTENT_HASH_LENGTH,
8
- ConfigHash,
9
- Subscriber,
10
- )
11
-
12
- from .data_keys import (
13
- DESIRED_REF,
14
- DESIRED_TARGET_HASHES,
15
- NAMESPACE,
16
- TARGET_FILE_PATH,
17
- )
18
-
19
-
20
- def test_can_compute_content_hash(subscriber_builder: Callable[[Mapping], Subscriber]):
21
- subscribers = [
22
- subscriber_builder({
23
- NAMESPACE: {"path": "some_namespace"},
24
- TARGET_FILE_PATH: "some_saas",
25
- DESIRED_REF: "new",
26
- DESIRED_TARGET_HASHES: [
27
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
28
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
29
- ],
30
- }),
31
- subscriber_builder({
32
- NAMESPACE: {"path": "other_namespace"},
33
- TARGET_FILE_PATH: "other_saas",
34
- DESIRED_REF: "new",
35
- DESIRED_TARGET_HASHES: [
36
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
37
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
38
- ],
39
- }),
40
- ]
41
- assert (
42
- len(Subscriber.combined_content_hash(subscribers=subscribers))
43
- == CONTENT_HASH_LENGTH
44
- )
45
-
46
-
47
- def test_content_hash_is_deterministic(
48
- subscriber_builder: Callable[[Mapping], Subscriber],
49
- ):
50
- subscribers = [
51
- subscriber_builder({
52
- NAMESPACE: {"path": "some_namespace"},
53
- TARGET_FILE_PATH: "some_saas",
54
- DESIRED_REF: "new",
55
- DESIRED_TARGET_HASHES: [
56
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
57
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
58
- ],
59
- }),
60
- subscriber_builder({
61
- NAMESPACE: {"path": "other_namespace"},
62
- TARGET_FILE_PATH: "other_saas",
63
- DESIRED_REF: "old",
64
- DESIRED_TARGET_HASHES: [
65
- ConfigHash(channel="h", target_config_hash="i", parent_saas="j"),
66
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
67
- ],
68
- }),
69
- ]
70
- hashes = set()
71
- for _ in range(3):
72
- hashes.add(Subscriber.combined_content_hash(subscribers=subscribers))
73
- assert len(hashes) == 1
74
-
75
-
76
- def test_content_hash_differs(subscriber_builder: Callable[[Mapping], Subscriber]):
77
- subscriber_a = subscriber_builder({
78
- NAMESPACE: {"path": "some_namespace"},
79
- TARGET_FILE_PATH: "some_saas",
80
- DESIRED_REF: "new",
81
- DESIRED_TARGET_HASHES: [
82
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
83
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
84
- ],
85
- })
86
-
87
- subscriber_b = subscriber_builder({
88
- NAMESPACE: {"path": "some_namespace"},
89
- TARGET_FILE_PATH: "some_other_saas",
90
- DESIRED_REF: "new",
91
- DESIRED_TARGET_HASHES: [
92
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
93
- ],
94
- })
95
-
96
- assert Subscriber.combined_content_hash([
97
- subscriber_a
98
- ]) != Subscriber.combined_content_hash([subscriber_b])
99
-
100
-
101
- def test_content_hash_equals(subscriber_builder: Callable[[Mapping], Subscriber]):
102
- subscriber_a = subscriber_builder({
103
- NAMESPACE: {"path": "some_namespace"},
104
- TARGET_FILE_PATH: "some_saas",
105
- DESIRED_REF: "new",
106
- DESIRED_TARGET_HASHES: [
107
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
108
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
109
- ConfigHash(channel="h", target_config_hash="i", parent_saas="j"),
110
- ConfigHash(channel="k", target_config_hash="l", parent_saas="m"),
111
- ],
112
- })
113
- subscriber_b = subscriber_builder({
114
- NAMESPACE: {"path": "some_namespace"},
115
- TARGET_FILE_PATH: "some_saas",
116
- DESIRED_REF: "new",
117
- DESIRED_TARGET_HASHES: list(
118
- reversed([
119
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
120
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
121
- ConfigHash(channel="h", target_config_hash="i", parent_saas="j"),
122
- ConfigHash(channel="k", target_config_hash="l", parent_saas="m"),
123
- ])
124
- ),
125
- })
126
-
127
- assert Subscriber.combined_content_hash([
128
- subscriber_a,
129
- subscriber_b,
130
- ]) == Subscriber.combined_content_hash([subscriber_b, subscriber_a])
@@ -1,161 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Mapping,
4
- )
5
- from typing import Any
6
-
7
- from reconcile.saas_auto_promotions_manager.subscriber import (
8
- ConfigHash,
9
- Subscriber,
10
- )
11
-
12
- from .data_keys import (
13
- CUR_CONFIG_HASHES,
14
- CUR_SUBSCRIBER_REF,
15
- DESIRED_REF,
16
- DESIRED_TARGET_HASHES,
17
- )
18
-
19
-
20
- def test_has_config_hash_diff(
21
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
22
- ) -> None:
23
- subscriber = subscriber_builder({
24
- CUR_SUBSCRIBER_REF: "current_sha",
25
- CUR_CONFIG_HASHES: [
26
- ConfigHash(
27
- channel="channel-a",
28
- parent_saas="publisher_a",
29
- target_config_hash="pub_a_hash",
30
- ),
31
- ConfigHash(
32
- channel="channel-b",
33
- parent_saas="publisher_b",
34
- target_config_hash="pub_b_hash",
35
- ),
36
- ],
37
- DESIRED_REF: "current_sha",
38
- DESIRED_TARGET_HASHES: [
39
- ConfigHash(
40
- channel="channel-a",
41
- parent_saas="publisher_a",
42
- target_config_hash="pub_a_hash",
43
- ),
44
- ConfigHash(
45
- channel="channel-b",
46
- parent_saas="publisher_b",
47
- target_config_hash="new_hash",
48
- ),
49
- ],
50
- })
51
- assert subscriber.has_diff()
52
-
53
-
54
- def test_has_ref_diff(
55
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
56
- ) -> None:
57
- subscriber = subscriber_builder({
58
- CUR_SUBSCRIBER_REF: "current_sha",
59
- CUR_CONFIG_HASHES: [],
60
- DESIRED_REF: "new_sha",
61
- DESIRED_TARGET_HASHES: [],
62
- })
63
- assert subscriber.has_diff()
64
-
65
-
66
- def test_no_diff(
67
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
68
- ) -> None:
69
- config_hashes = [
70
- ConfigHash(
71
- channel="channel-a",
72
- parent_saas="publisher_a",
73
- target_config_hash="pub_a_hash",
74
- ),
75
- ConfigHash(
76
- channel="channel-b",
77
- parent_saas="publisher_b",
78
- target_config_hash="pub_b_hash",
79
- ),
80
- ]
81
- subscriber = subscriber_builder({
82
- CUR_SUBSCRIBER_REF: "current_sha",
83
- CUR_CONFIG_HASHES: config_hashes,
84
- DESIRED_REF: "current_sha",
85
- DESIRED_TARGET_HASHES: list(reversed(config_hashes)),
86
- })
87
- assert not subscriber.has_diff()
88
-
89
-
90
- def test_hashes_desired_subset_of_current(
91
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
92
- ) -> None:
93
- """
94
- We do not react on additional current hashes, i.e., SAPM is not responsible
95
- for deleting dangling hashes -> we only care about desired hashes being in place.
96
- """
97
- subscriber = subscriber_builder({
98
- CUR_SUBSCRIBER_REF: "current_sha",
99
- CUR_CONFIG_HASHES: [
100
- ConfigHash(
101
- channel="channel-a",
102
- parent_saas="saas-a",
103
- target_config_hash="hash-a",
104
- ),
105
- ConfigHash(
106
- channel="channel-b",
107
- parent_saas="saas-b",
108
- target_config_hash="hash-b",
109
- ),
110
- ],
111
- DESIRED_REF: "current_sha",
112
- DESIRED_TARGET_HASHES: [
113
- ConfigHash(
114
- channel="channel-b",
115
- parent_saas="saas-b",
116
- target_config_hash="hash-b",
117
- ),
118
- ],
119
- })
120
- assert not subscriber.has_diff()
121
-
122
-
123
- def test_hashes_current_subset_of_desired(
124
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
125
- ) -> None:
126
- subscriber = subscriber_builder({
127
- CUR_SUBSCRIBER_REF: "current_sha",
128
- CUR_CONFIG_HASHES: [
129
- ConfigHash(
130
- channel="channel-b",
131
- parent_saas="saas-b",
132
- target_config_hash="hash-b",
133
- ),
134
- ],
135
- DESIRED_REF: "current_sha",
136
- DESIRED_TARGET_HASHES: [
137
- ConfigHash(
138
- channel="channel-a",
139
- parent_saas="saas-a",
140
- target_config_hash="hash-a",
141
- ),
142
- ConfigHash(
143
- channel="channel-b",
144
- parent_saas="saas-b",
145
- target_config_hash="hash-b",
146
- ),
147
- ],
148
- })
149
- assert subscriber.has_diff()
150
-
151
-
152
- def test_empty_hashes(
153
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
154
- ) -> None:
155
- subscriber = subscriber_builder({
156
- CUR_SUBSCRIBER_REF: "current_sha",
157
- CUR_CONFIG_HASHES: [],
158
- DESIRED_REF: "current_sha",
159
- DESIRED_TARGET_HASHES: [],
160
- })
161
- assert not subscriber.has_diff()
@@ -1,218 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Mapping,
4
- )
5
- from typing import Any
6
-
7
- from reconcile.saas_auto_promotions_manager.subscriber import (
8
- ConfigHash,
9
- Subscriber,
10
- )
11
-
12
- from .data_keys import (
13
- CHANNELS,
14
- CONFIG_HASH,
15
- CUR_CONFIG_HASHES,
16
- CUR_SUBSCRIBER_REF,
17
- REAL_WORLD_SHA,
18
- SUCCESSFUL_DEPLOYMENT,
19
- )
20
-
21
-
22
- def test_single_new_config_hash(
23
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
24
- ):
25
- subscriber = subscriber_builder({
26
- CUR_SUBSCRIBER_REF: "current_sha",
27
- CUR_CONFIG_HASHES: [
28
- ConfigHash(
29
- channel="channel-a",
30
- parent_saas="publisher_a",
31
- target_config_hash="pub_a_hash",
32
- ),
33
- ConfigHash(
34
- channel="channel-b",
35
- parent_saas="publisher_b",
36
- target_config_hash="pub_b_hash",
37
- ),
38
- ],
39
- CHANNELS: {
40
- "channel-a": {
41
- "publisher_a": {
42
- REAL_WORLD_SHA: "current_sha",
43
- CONFIG_HASH: "new_pub_a_hash",
44
- }
45
- },
46
- "channel-b": {
47
- "publisher_b": {
48
- REAL_WORLD_SHA: "current_sha",
49
- CONFIG_HASH: "pub_b_hash",
50
- }
51
- },
52
- },
53
- })
54
- subscriber.compute_desired_state()
55
- expected_config_hashes = [
56
- ConfigHash(
57
- channel="channel-a",
58
- parent_saas="publisher_a",
59
- target_config_hash="new_pub_a_hash",
60
- ),
61
- ConfigHash(
62
- channel="channel-b",
63
- parent_saas="publisher_b",
64
- target_config_hash="pub_b_hash",
65
- ),
66
- ]
67
- assert subscriber.desired_ref == "current_sha"
68
- assert subscriber.desired_hashes == expected_config_hashes
69
-
70
-
71
- def test_both_new_config_hashes(
72
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
73
- ):
74
- subscriber = subscriber_builder({
75
- CUR_SUBSCRIBER_REF: "current_sha",
76
- CUR_CONFIG_HASHES: [
77
- ConfigHash(
78
- channel="channel-a",
79
- parent_saas="publisher_a",
80
- target_config_hash="pub_a_hash",
81
- ),
82
- ConfigHash(
83
- channel="channel-b",
84
- parent_saas="publisher_b",
85
- target_config_hash="pub_b_hash",
86
- ),
87
- ],
88
- CHANNELS: {
89
- "channel-a": {
90
- "publisher_a": {
91
- REAL_WORLD_SHA: "current_sha",
92
- CONFIG_HASH: "new_pub_a_hash",
93
- }
94
- },
95
- "channel-b": {
96
- "publisher_b": {
97
- REAL_WORLD_SHA: "current_sha",
98
- CONFIG_HASH: "new_pub_b_hash",
99
- }
100
- },
101
- },
102
- })
103
- subscriber.compute_desired_state()
104
- expected_config_hashes = [
105
- ConfigHash(
106
- channel="channel-a",
107
- parent_saas="publisher_a",
108
- target_config_hash="new_pub_a_hash",
109
- ),
110
- ConfigHash(
111
- channel="channel-b",
112
- parent_saas="publisher_b",
113
- target_config_hash="new_pub_b_hash",
114
- ),
115
- ]
116
- assert subscriber.desired_ref == "current_sha"
117
- assert subscriber.desired_hashes == expected_config_hashes
118
-
119
-
120
- def test_both_new_config_hashes_one_bad_deployment(
121
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
122
- ):
123
- subscriber = subscriber_builder({
124
- CUR_SUBSCRIBER_REF: "current_sha",
125
- CUR_CONFIG_HASHES: [
126
- ConfigHash(
127
- channel="channel-a",
128
- parent_saas="publisher_a",
129
- target_config_hash="pub_a_hash",
130
- ),
131
- ConfigHash(
132
- channel="channel-b",
133
- parent_saas="publisher_b",
134
- target_config_hash="pub_b_hash",
135
- ),
136
- ],
137
- CHANNELS: {
138
- "channel-a": {
139
- "publisher_a": {
140
- REAL_WORLD_SHA: "current_sha",
141
- CONFIG_HASH: "new_pub_a_hash",
142
- SUCCESSFUL_DEPLOYMENT: False,
143
- }
144
- },
145
- "channel-b": {
146
- "publisher_b": {
147
- REAL_WORLD_SHA: "current_sha",
148
- CONFIG_HASH: "new_pub_b_hash",
149
- }
150
- },
151
- },
152
- })
153
- subscriber.compute_desired_state()
154
- expected_config_hashes = [
155
- ConfigHash(
156
- channel="channel-a",
157
- parent_saas="publisher_a",
158
- target_config_hash="pub_a_hash",
159
- ),
160
- ConfigHash(
161
- channel="channel-b",
162
- parent_saas="publisher_b",
163
- target_config_hash="new_pub_b_hash",
164
- ),
165
- ]
166
- assert subscriber.desired_ref == "current_sha"
167
- assert subscriber.desired_hashes == expected_config_hashes
168
-
169
-
170
- def test_both_new_config_hashes_all_bad_deployments(
171
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
172
- ):
173
- subscriber = subscriber_builder({
174
- CUR_SUBSCRIBER_REF: "current_sha",
175
- CUR_CONFIG_HASHES: [
176
- ConfigHash(
177
- channel="channel-a",
178
- parent_saas="publisher_a",
179
- target_config_hash="pub_a_hash",
180
- ),
181
- ConfigHash(
182
- channel="channel-b",
183
- parent_saas="publisher_b",
184
- target_config_hash="pub_b_hash",
185
- ),
186
- ],
187
- CHANNELS: {
188
- "channel-a": {
189
- "publisher_a": {
190
- REAL_WORLD_SHA: "current_sha",
191
- CONFIG_HASH: "new_pub_a_hash",
192
- SUCCESSFUL_DEPLOYMENT: False,
193
- }
194
- },
195
- "channel-b": {
196
- "publisher_b": {
197
- REAL_WORLD_SHA: "current_sha",
198
- CONFIG_HASH: "new_pub_b_hash",
199
- SUCCESSFUL_DEPLOYMENT: False,
200
- }
201
- },
202
- },
203
- })
204
- subscriber.compute_desired_state()
205
- expected_config_hashes = [
206
- ConfigHash(
207
- channel="channel-a",
208
- parent_saas="publisher_a",
209
- target_config_hash="pub_a_hash",
210
- ),
211
- ConfigHash(
212
- channel="channel-b",
213
- parent_saas="publisher_b",
214
- target_config_hash="pub_b_hash",
215
- ),
216
- ]
217
- assert subscriber.desired_ref == "current_sha"
218
- assert subscriber.desired_hashes == expected_config_hashes