-
Notifications
You must be signed in to change notification settings - Fork 11
/
dvo_writer.feature
206 lines (197 loc) · 7.86 KB
/
dvo_writer.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
@dvo_writer
Feature: DVO writer
Background:
Given Kafka broker is started on host and port specified in DVO writer configuration
And the database is named test
And database user is set to postgres
And database password is set to postgres
And aggregator database is in initial state
When database connection is established
And I migrate aggregator database to latest version
And I read current migration number for DVO from database
Then I should see that migration #2 is returned
Given DVO writer service is started in background
Scenario: DVO writer does not process invalid message
Given there are 0 rows in DVO table
When I send the following message into Kafka topic "ccx.dvo.results"
"""
{}
"""
And I wait 3 seconds
Then there are 0 rows in DVO table
When I terminate DVO writer
Then DVO writer process should terminate
Scenario: DVO writer processes incoming data correctly
Given there are 0 rows in DVO table
When I send the following message into Kafka topic "ccx.dvo.results"
"""
{
"OrgID": 1,
"AccountNumber": 1,
"ClusterName": "ac91137f-fa4c-455a-b801-e2b3c1a0d82f",
"Metrics": {
"system": {
"metadata": {},
"hostname": null
},
"fingerprints": [],
"version": 1,
"analysis_metadata": {},
"workload_recommendations": [
{
"response_id": "recommendation|RECOMMENDATION_KEY",
"component": "rules.recommendation",
"key": "RECOMMENDATION_KEY",
"details": {},
"tags": [],
"links": {
"jira": [
"https://issues.redhat.com/browse/ISSUE-1111"
],
"product_documentation": [
"https://docs.com/policy.html"
]
},
"workloads": [
{
"namespace": "namespace-name-A",
"namespace_uid": "NAMESPACE-UID-A",
"kind": "DaemonSet",
"name": "test-name-0099",
"uid": "UID-0099"
},
{
"namespace": "namespace-name-B",
"namespace_uid": "NAMESPACE-UID-B",
"kind": "Deployment",
"name": "test-name-0007",
"uid": "UID-0007"
}
]
}
]
},
"LastChecked": "2024-02-06T12:25:07.418761+00:00",
"RequestId": "b0daf40cdf29/U3XGuBBKy9-000003"
}
"""
And I wait 3 seconds
Then there are 2 rows in DVO table
And DVO table contains the following data
| Organization | Cluster ID | Namespace ID | Namespace | Last checked |
| 1 | ac91137f-fa4c-455a-b801-e2b3c1a0d82f | NAMESPACE-UID-A | namespace-name-A | 2024-02-06T12:25:07.418761 |
| 1 | ac91137f-fa4c-455a-b801-e2b3c1a0d82f | NAMESPACE-UID-B | namespace-name-B | 2024-02-06T12:25:07.418761 |
When I terminate DVO writer
Then DVO writer process should terminate
Scenario: DVO writer deletes namespaces not present in the report for given cluster
Given there are 0 rows in DVO table
When I send the following message into Kafka topic "ccx.dvo.results"
"""
{
"OrgID": 1,
"AccountNumber": 1,
"ClusterName": "ac91137f-fa4c-455a-b801-e2b3c1a0d82f",
"Metrics": {
"system": {
"metadata": {},
"hostname": null
},
"fingerprints": [],
"version": 1,
"analysis_metadata": {},
"workload_recommendations": [
{
"response_id": "recommendation|RECOMMENDATION_KEY",
"component": "rules.recommendation",
"key": "RECOMMENDATION_KEY",
"details": {},
"tags": [],
"links": {
"jira": [
"https://issues.redhat.com/browse/ISSUE-1111"
],
"product_documentation": [
"https://docs.com/policy.html"
]
},
"workloads": [
{
"namespace": "namespace-name-A",
"namespace_uid": "NAMESPACE-UID-A",
"kind": "DaemonSet",
"name": "test-name-0099",
"uid": "UID-0099"
},
{
"namespace": "namespace-name-B",
"namespace_uid": "NAMESPACE-UID-B",
"kind": "Deployment",
"name": "test-name-0007",
"uid": "UID-0007"
}
]
}
]
},
"LastChecked": "2024-02-06T12:25:07.418761+00:00",
"RequestId": "b0daf40cdf29/U3XGuBBKy9-000003"
}
"""
And I wait 3 seconds
Then there are 2 rows in DVO table
And DVO table contains the following data
| Organization | Cluster ID | Namespace ID | Namespace | Last checked |
| 1 | ac91137f-fa4c-455a-b801-e2b3c1a0d82f | NAMESPACE-UID-A | namespace-name-A | 2024-02-06T12:25:07.418761 |
| 1 | ac91137f-fa4c-455a-b801-e2b3c1a0d82f | NAMESPACE-UID-B | namespace-name-B | 2024-02-06T12:25:07.418761 |
When I send the following message into Kafka topic "ccx.dvo.results"
"""
{
"OrgID": 1,
"AccountNumber": 1,
"ClusterName": "ac91137f-fa4c-455a-b801-e2b3c1a0d82f",
"Metrics": {
"system": {
"metadata": {},
"hostname": null
},
"fingerprints": [],
"version": 1,
"analysis_metadata": {},
"workload_recommendations": [
{
"response_id": "recommendation|RECOMMENDATION_KEY",
"component": "rules.recommendation",
"key": "RECOMMENDATION_KEY",
"details": {},
"tags": [],
"links": {
"jira": [
"https://issues.redhat.com/browse/ISSUE-1111"
],
"product_documentation": [
"https://docs.com/policy.html"
]
},
"workloads": [
{
"namespace": "namespace-name-A",
"namespace_uid": "NAMESPACE-UID-A",
"kind": "DaemonSet",
"name": "test-name-0099",
"uid": "UID-0099"
}
]
}
]
},
"LastChecked": "2024-02-06T12:35:07.418761+00:00",
"RequestId": "b0daf40cdf29/U3XGuBBKy9-000004"
}
"""
And I wait 3 seconds
Then there is 1 row in DVO table
And DVO table contains the following data
| Organization | Cluster ID | Namespace ID | Namespace | Last checked |
| 1 | ac91137f-fa4c-455a-b801-e2b3c1a0d82f | NAMESPACE-UID-A | namespace-name-A | 2024-02-06T12:35:07.418761 |
When I terminate DVO writer
Then DVO writer process should terminate