Skip to content

Commit

Permalink
Merge pull request #536 from joselsegura/aggregator_scenarios
Browse files Browse the repository at this point in the history
Adding a couple of new scenarios for aggregator
  • Loading branch information
joselsegura authored Nov 14, 2023
2 parents ca7493d + 3c138ec commit 4696960
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/scenarios_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ nav_order: 3
* Check rule hits after Insights Results Aggregator consumes two messages when the second is newer then the first one
* Check rule hits after Insights Results Aggregator consumes message and stores results into database for multiple clusters
* Check rule hits after Insights Results Aggregator consumes message with no results
* Check additions into the database when a message with empty fields is received
* Check no additions into the database when an incomplete message is received

## [`insights-results-aggregator/database_access.feature`](https://github.com/RedHatInsights/insights-behavioral-spec/blob/main/features/insights-results-aggregator/database_access.feature)

Expand Down
40 changes: 40 additions & 0 deletions features/insights-results-aggregator/consumer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,43 @@ Feature: Consuming and processing results from Kafka broker
And The returned report should contain 0 rule hits for cluster 01234567-89ab-cdef-0123-456789abcdef
When I terminate Insights Results Aggregator
Then Insights Results Aggregator process should terminate

@managed
Scenario: Check additions into the database when a message with empty fields is received
When I access endpoint /organizations/123/clusters using HTTP GET method using token for organization 123 account number 456, and user 789
Then The status code of the response is 200
And The status message of the response is "ok"
And I should retrieve empty list of clusters
When I send rules results 'no_values.json' into topic 'ccx.ocp.results'
And I wait 5 seconds
When I access endpoint /organizations/123/clusters using HTTP GET method using token for organization 123 account number 456, and user 789
Then The status code of the response is 200
And The status message of the response is "ok"
And I should retrieve following list of clusters
| Cluster name |
| 01234567-89ab-cdef-0123-456789abcdef |
When I access endpoint /organizations/123/clusters/01234567-89ab-cdef-0123-456789abcdef/reports using HTTP GET method using token for organization 123 account number 456, and user 789
Then The status code of the response is 200
And The status message of the response is "ok"
And The returned report should contain 0 rule hits for cluster 01234567-89ab-cdef-0123-456789abcdef
When I terminate Insights Results Aggregator
Then Insights Results Aggregator process should terminate

@managed
Scenario: Check no additions into the database when an incomplete message is received
When I access endpoint /organizations/123/clusters using HTTP GET method using token for organization 123 account number 456, and user 789
Then The status code of the response is 200
And The status message of the response is "ok"
And I should retrieve empty list of clusters
When I send rules results 'rule_message_some_empty_fields.json' into topic 'ccx.ocp.results'
And I wait 5 seconds
When I access endpoint /organizations/123/clusters using HTTP GET method using token for organization 123 account number 456, and user 789
Then The status code of the response is 200
And The status message of the response is "ok"
And I should retrieve empty list of clusters
When I access endpoint /organizations/123/clusters/01234567-89ab-cdef-0123-456789abcdef/reports using HTTP GET method using token for organization 123 account number 456, and user 789
Then The status code of the response is 200
And The status message of the response is "ok"
And The returned report should not contain report for cluster 01234567-89ab-cdef-0123-456789abcdef
When I terminate Insights Results Aggregator
Then Insights Results Aggregator process should terminate
13 changes: 13 additions & 0 deletions features/steps/insights_results_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,19 @@ def check_rule_hits(context, expected_count=1, cluster="11111111-2222-3333-4444-
f"Expected rule hits count: {expected_count}, actual count: {actual_count}"


@then("The returned report should not contain report for cluster {cluster}")
def check_no_report_for_cluster(context, cluster):
"""Check that cluster is not cinluded in the report returned from Aggregator."""
# retrieve reports
json = context.response.json()
assert json is not None

assert "reports" in json, "Reports attribute is missing"
reports = json["reports"]

assert cluster not in reports, "Cluster report found"


@then("I should find following rule hits in returned cluster report for cluster {cluster}")
def check_returned_cluster_report_list(context, cluster):
"""Check reported rules against table with expected rule results."""
Expand Down
14 changes: 14 additions & 0 deletions test_data/no_values.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"OrgID": 123,
"AccountNumber": 456,
"ClusterName": "01234567-89ab-cdef-0123-456789abcdef",
"LastChecked": "2020-04-02T09:00:05.268294Z",
"Version": 2,
"Report": {
"system": {},
"reports": [],
"info": [],
"fingerprints": [],
"analysis_metadata": null
}
}
275 changes: 275 additions & 0 deletions test_data/rule_message_some_empty_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
{
"path": "archives/compressed/ef/CLUSTER_ID_TO_BE_REPLACED/201306/17/233359.tar.gz",
"metadata": {
"cluster_id": "CLUSTER_ID_TO_BE_REPLACED",
"external_organization": "ef"
},
"report": {
"system": {},
"reports": [
{
"rule_id": "machine_pool_check|MACHINE_POOL_NOT_OK",
"component": "ccx_rules_ocp.internal.rules.machine_pool_check.report",
"type": "rule",
"key": "MACHINE_POOL_NOT_OK",
"details": {
"machines": [
{
"degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:10:33Z",
"reason": "",
"message": ""
},
"name": "master",
"node_degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:10:33Z",
"reason": "",
"message": ""
},
"render_degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:09:38Z",
"reason": "",
"message": ""
},
"updated": {
"status": false,
"last_trans_time": "2021-10-08T09:44:15Z",
"reason": "",
"message": ""
},
"updating": {
"status": true,
"last_trans_time": "2021-10-08T09:44:15Z",
"reason": "",
"message": "All nodes are updating to rendered-master-a40f9eb37039e079676527fd41bbef52"
}
},
{
"degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:09:41Z",
"reason": "",
"message": ""
},
"name": "worker",
"node_degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:09:41Z",
"reason": "",
"message": ""
},
"render_degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:09:38Z",
"reason": "",
"message": ""
},
"updated": {
"status": false,
"last_trans_time": "2021-10-08T09:44:15Z",
"reason": "",
"message": ""
},
"updating": {
"status": true,
"last_trans_time": "2021-10-08T09:44:15Z",
"reason": "",
"message": "All nodes are updating to rendered-worker-3c096f9626f3d5efb9113e1056ab71fa"
}
}
],
"type": "rule",
"error_key": "MACHINE_POOL_NOT_OK"
},
"tags": [],
"links": {}
},
{
"rule_id": "operators_check|OPERATOR_ISSUE",
"component": "ccx_rules_ocp.internal.rules.operators_check.report",
"type": "rule",
"key": "OPERATOR_ISSUE",
"details": {
"operators": [
{
"operator": {
"available": {
"status": true,
"last_trans_time": "2021-10-08T08:16:58Z",
"reason": "",
"message": "Cluster has deployed 4.8.12"
},
"degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:16:56Z",
"reason": "",
"message": ""
},
"name": "machine-config",
"progressing": {
"status": true,
"last_trans_time": "2021-10-08T09:40:54Z",
"reason": "",
"message": "Working towards 4.8.13"
},
"upgradeable": {
"status": true,
"last_trans_time": "2021-10-08T08:14:53Z",
"reason": "AsExpected",
"message": ""
},
"version": "4.8.12"
},
"issues": [
[
"Progressing",
{
"status": true,
"last_trans_time": "2021-10-08T09:40:54Z",
"reason": "",
"message": "Working towards 4.8.13"
}
]
]
},
{
"operator": {
"available": {
"status": true,
"last_trans_time": "2021-10-08T08:08:27Z",
"reason": "AsExpected",
"message": "All is well"
},
"degraded": {
"status": false,
"last_trans_time": "2021-10-08T08:08:24Z",
"reason": "AsExpected",
"message": "All is well"
},
"name": "service-ca",
"progressing": {
"status": true,
"last_trans_time": "2021-10-08T09:44:19Z",
"reason": "_ManagedDeploymentsAvailable",
"message": "Progressing: \nProgressing: service-ca does not have available replicas"
},
"upgradeable": {
"status": true,
"last_trans_time": "2021-10-08T08:08:27Z",
"reason": "AsExpected",
"message": "All is well"
},
"version": "4.8.13"
},
"issues": [
[
"Progressing",
{
"status": true,
"last_trans_time": "2021-10-08T09:44:19Z",
"reason": "_ManagedDeploymentsAvailable",
"message": "Progressing: \nProgressing: service-ca does not have available replicas"
}
]
]
}
],
"type": "rule",
"error_key": "OPERATOR_ISSUE"
},
"tags": [],
"links": {}
},
{
"rule_id": "version_check|CLUSTER_VERSION_WORKING_TOWARDS",
"component": "ccx_rules_ocp.internal.rules.version_check.report",
"type": "rule",
"key": "CLUSTER_VERSION_WORKING_TOWARDS",
"details": {
"current": "4.8.12",
"desired": "4.8.13",
"available": {
"status": true,
"last_trans_time": "2021-10-08T08:35:15Z",
"reason": "",
"message": "Done applying 4.8.12"
},
"progressing": {
"status": true,
"last_trans_time": "2021-10-08T08:52:20Z",
"reason": "ClusterOperatorUpdating",
"message": "Working towards 4.8.13: 570 of 678 done (84% complete), waiting on machine-config"
},
"failing": {
"status": false,
"last_trans_time": "2021-10-08T09:31:14Z",
"reason": "",
"message": ""
},
"history_count": 2,
"phased_gates_checks": [
"3.1"
],
"type": "rule",
"error_key": "CLUSTER_VERSION_WORKING_TOWARDS"
},
"tags": [
"phased_gates"
],
"links": {
"kcs": [
"https://access.redhat.com/solutions/3799561"
],
"jira": [
"https://issues.redhat.com/browse/INSIGHTOCP-455"
]
}
},
{
"rule_id": "empty_prometheus_db_volume|PROMETHEUS_DB_VOLUME_IS_EMPTY",
"component": "ccx_rules_ocp.external.rules.empty_prometheus_db_volume.report",
"type": "rule",
"key": "PROMETHEUS_DB_VOLUME_IS_EMPTY",
"details": {
"ocp_branch": "4.8",
"type": "rule",
"error_key": "PROMETHEUS_DB_VOLUME_IS_EMPTY"
},
"tags": [],
"links": {
"jira": [
"https://issues.redhat.com/browse/INSIGHTOCP-51",
"https://issues.redhat.com/browse/INSIGHTOCP-258",
"https://issues.redhat.com/browse/INSIGHTOCP-439"
]
}
}
],
"fingerprints": [],
"skips": [],
"info": [],
"pass": [],
"analysis_metadata": {
"start": "2021-12-13T15:51:02.895120+00:00",
"finish": "2021-12-13T15:51:03.187495+00:00",
"execution_context": "ccx_ocp_core.context.InsightsOperatorContext",
"plugin_sets": {
"insights-core": {
"version": "insights-core-3.0.202-1",
"commit": "placeholder"
},
"ccx_rules_ocp": {
"version": "ccx_rules_ocp-2021.10.4-1",
"commit": null
},
"ccx_ocp_core": {
"version": "ccx_ocp_core-2021.10.7-1",
"commit": null
}
}
}
}
}

0 comments on commit 4696960

Please sign in to comment.