Skip to content

Commit

Permalink
Insert correct version in dvo_metrics_publisher output
Browse files Browse the repository at this point in the history
  • Loading branch information
epapbak committed Jul 24, 2024
1 parent d7bdea8 commit 57ba908
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ccx_messaging/publishers/dvo_metrics_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ def publish(self, input_msg: Dict, report: str) -> None:
if "cluster_name" not in input_msg:
raise CCXMessagingError("Can't find 'cluster_name'")

msg_version = report.pop("version", 0)
output_msg = {
"OrgID": org_id,
"AccountNumber": account_number,
"ClusterName": input_msg["cluster_name"],
"Metrics": report,
"RequestId": input_msg.get("request_id"),
"LastChecked": input_msg.get("timestamp"),
"Version": msg_version,
}
message = json.dumps(output_msg) + "\n"

Expand Down
11 changes: 10 additions & 1 deletion test/publishers/dvo_metrics_publisher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="with account",
),
Expand All @@ -173,6 +174,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="invalid account",
),
Expand All @@ -198,6 +200,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="empty account",
),
Expand All @@ -222,6 +225,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="no account",
),
Expand All @@ -247,6 +251,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="with gathering timestamp",
),
Expand All @@ -272,6 +277,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="with gathering timestamp in ISO format",
),
Expand All @@ -297,6 +303,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="with custom metadata without gathering timestamp",
),
Expand All @@ -322,6 +329,7 @@ def test_publish_bad_argument(wrong_input_msg):
"Metrics": {"workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 0,
},
id="empty metadata",
),
Expand Down Expand Up @@ -386,9 +394,10 @@ def test_error(input, output):
"OrgID": 10,
"AccountNumber": 1,
"ClusterName": "uuid",
"Metrics": {"version": 1, "pass": [], "info": [], "workload_recommendations": []},
"Metrics": {"pass": [], "info": [], "workload_recommendations": []},
"RequestId": "a request id",
"LastChecked": "a timestamp",
"Version": 1,
},
id="valid_report",
)
Expand Down

0 comments on commit 57ba908

Please sign in to comment.