From 941f828d3c44b35a1cda1a6f9cbe0e3f93767a2e Mon Sep 17 00:00:00 2001 From: Stefan Kurek Date: Tue, 16 Apr 2024 14:26:38 -0400 Subject: [PATCH] [chore] vcenterreceiver: Updates mockserver responses for better VM Resource Pool attributes (#32448) **Description:** Minor change. VMs (not templates) typically have Resource Pool attributes associated with them, and the mockserver responses were not reflecting this for the unit tests. Updated the tests to reflect this. **Link to tracking Issue:** N/A **Testing:** Unit tests updated and still working **Documentation:** N/A --------- Co-authored-by: Daniel Jaglowski --- .../internal/mockserver/client_mock.go | 3 +++ .../mockserver/responses/vm-properties.xml | 4 ++++ .../mockserver/responses/vm-resource-pool.xml | 14 ++++++++++++++ .../vcenterreceiver/testdata/metrics/expected.yaml | 6 ++++++ 4 files changed, 27 insertions(+) create mode 100644 receiver/vcenterreceiver/internal/mockserver/responses/vm-resource-pool.xml diff --git a/receiver/vcenterreceiver/internal/mockserver/client_mock.go b/receiver/vcenterreceiver/internal/mockserver/client_mock.go index edfe2484a150..4cddd99be2ab 100644 --- a/receiver/vcenterreceiver/internal/mockserver/client_mock.go +++ b/receiver/vcenterreceiver/internal/mockserver/client_mock.go @@ -192,6 +192,9 @@ func routeRetreiveProperties(t *testing.T, body map[string]any) ([]byte, error) if propSet["pathSet"] == "summary.runtime.host" { return loadResponse("vm-host.xml") } + if propSet["pathSet"] == "resourcePool" { + return loadResponse("vm-resource-pool.xml") + } return loadResponse("vm-properties.xml") case (content == "group-v1034" || content == "group-v1001") && contentType == "Folder": diff --git a/receiver/vcenterreceiver/internal/mockserver/responses/vm-properties.xml b/receiver/vcenterreceiver/internal/mockserver/responses/vm-properties.xml index e2c700b1af9e..9f74918e57eb 100644 --- a/receiver/vcenterreceiver/internal/mockserver/responses/vm-properties.xml +++ b/receiver/vcenterreceiver/internal/mockserver/responses/vm-properties.xml @@ -4,6 +4,10 @@ vm-6004 + + resourcePool + resgroup-9 + config diff --git a/receiver/vcenterreceiver/internal/mockserver/responses/vm-resource-pool.xml b/receiver/vcenterreceiver/internal/mockserver/responses/vm-resource-pool.xml new file mode 100644 index 000000000000..95a3a4edd29e --- /dev/null +++ b/receiver/vcenterreceiver/internal/mockserver/responses/vm-resource-pool.xml @@ -0,0 +1,14 @@ + + + + + + vm-1040 + + resourcePool + host-1002 + + + + + diff --git a/receiver/vcenterreceiver/testdata/metrics/expected.yaml b/receiver/vcenterreceiver/testdata/metrics/expected.yaml index de5f893b3bc7..c03564c372fb 100644 --- a/receiver/vcenterreceiver/testdata/metrics/expected.yaml +++ b/receiver/vcenterreceiver/testdata/metrics/expected.yaml @@ -2636,6 +2636,12 @@ resourceMetrics: - key: vcenter.vm.name value: stringValue: CentOS 7 + - key: vcenter.resource_pool.name + value: + stringValue: Resources + - key: vcenter.resource_pool.inventory_path + value: + stringValue: /Datacenter/host/Cluster/Resources scopeMetrics: - metrics: - description: The amount of CPU used by the VM.