Skip to content

Commit

Permalink
[chore] vcenterreceiver: Updates mockserver responses for better VM R…
Browse files Browse the repository at this point in the history
…esource Pool attributes (#32448)

**Description:** <Describe what has changed.>
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:** <Issue number if applicable>
N/A

**Testing:** <Describe what testing was performed and which tests were
added.>
Unit tests updated and still working

**Documentation:** <Describe the documentation added.>
N/A

---------

Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
  • Loading branch information
StefanKurek and djaglowski authored Apr 16, 2024
1 parent 5287f6e commit 941f828
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions receiver/vcenterreceiver/internal/mockserver/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<RetrievePropertiesResponse xmlns="urn:vim25">
<returnval>
<obj type="VirtualMachine">vm-6004</obj>
<propSet>
<name>resourcePool</name>
<val type="ResourcePool" xsi:type="ManagedObjectReference">resgroup-9</val>
</propSet>
<propSet>
<name>config</name>
<val xsi:type="VirtualMachineConfigInfo">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<RetrievePropertiesResponse xmlns="urn:vim25">
<returnval>
<obj type="VirtualMachine">vm-1040</obj>
<propSet>
<name>resourcePool</name>
<val type="ResourcePool" xsi:type="ManagedObjectReference">host-1002</val>
</propSet>
</returnval>
</RetrievePropertiesResponse>
</soapenv:Body>
</soapenv:Envelope>
6 changes: 6 additions & 0 deletions receiver/vcenterreceiver/testdata/metrics/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 941f828

Please sign in to comment.