Skip to content

Commit

Permalink
[chore] receiver/vcenter - Updates govmomi to v0.37.3 and fixes unit …
Browse files Browse the repository at this point in the history
…tests (#33721)

**Description:** <Describe what has changed.>
Updates govmomi library for `vcenterreceiver` to v0.37.3. This makes use
of the `RetrievePropertiesEx` function as `RetrieveProperties` is
deprecated. All of the related unit tests had to be redone to consider
this.

There are no customer facing changes with this.

**Link to tracking Issue:** <Issue number if applicable>
#32453 

**Testing:** <Describe what testing was performed and which tests were
added.>
Unit tests/integration tests pass. Manual check against live
environment.

**Documentation:** <Describe the documentation added.>
No customer facing changes.
  • Loading branch information
StefanKurek authored Jun 28, 2024
1 parent 90a0c90 commit 450b088
Show file tree
Hide file tree
Showing 21 changed files with 13,471 additions and 13,377 deletions.
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ require (
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
github.com/vmware/go-vmware-nsxt v0.0.0-20230223012718-d31b8a1ca05e // indirect
github.com/vmware/govmomi v0.36.3 // indirect
github.com/vmware/govmomi v0.37.3 // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion receiver/vcenterreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.103.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.103.0
github.com/stretchr/testify v1.9.0
github.com/vmware/govmomi v0.36.3
github.com/vmware/govmomi v0.37.3
go.opentelemetry.io/collector/component v0.103.0
go.opentelemetry.io/collector/config/configopaque v1.10.0
go.opentelemetry.io/collector/config/configtls v0.103.0
Expand Down
4 changes: 2 additions & 2 deletions receiver/vcenterreceiver/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions receiver/vcenterreceiver/internal/mockserver/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func routeBody(t *testing.T, requestType string, body map[string]any) ([]byte, e
return loadResponse("login.xml")
case "Logout":
return loadResponse("logout.xml")
case "RetrieveProperties":
return routeRetreiveProperties(t, body)
case "RetrievePropertiesEx":
return routeRetreivePropertiesEx(t, body)
case "QueryPerf":
return routePerformanceQuery(t, body)
case "CreateContainerView":
Expand All @@ -86,8 +86,8 @@ func routeBody(t *testing.T, requestType string, body map[string]any) ([]byte, e
return []byte{}, errNotFound
}

func routeRetreiveProperties(t *testing.T, body map[string]any) ([]byte, error) {
rp, ok := body["RetrieveProperties"].(map[string]any)
func routeRetreivePropertiesEx(t *testing.T, body map[string]any) ([]byte, error) {
rp, ok := body["RetrievePropertiesEx"].(map[string]any)
require.True(t, ok)
specSet := rp["specSet"].(map[string]any)

Expand All @@ -108,13 +108,24 @@ func routeRetreiveProperties(t *testing.T, body map[string]any) ([]byte, error)
var contentType string
if !objectSetArray {
obj = objectSet["obj"].(map[string]any)
content = obj["#content"].(string)
if value, exists := obj["#content"]; exists {
content = value.(string)
} else {
content = ""
}
contentType = obj["-type"].(string)
}

switch {
case content == "group-d1" && contentType == "Folder":
return loadResponse("datacenter.xml")
for _, i := range propSetArray {
m, ok := i.(map[string]any)
require.True(t, ok)
if m["type"] == "Folder" {
return loadResponse("datacenter.xml")
}
}
return loadResponse("datacenter-folder.xml")

case content == "datacenter-3" && contentType == "Datacenter":
return loadResponse("datacenter-properties.xml")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?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">
<RetrievePropertiesExResponse xmlns="urn:vim25">
<returnval>
<obj type="ResourcePool">resgroup-9</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">Resources</val>
</propSet>
<objects>
<obj type="ResourcePool">resgroup-9</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">Resources</val>
</propSet>
</objects>
</returnval>
<returnval>
<obj type="HostSystem">host-1002</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">esxi-27971.cf5e88ac.australia-southeast1.gve.goog</val>
</propSet>
<objects>
<obj type="HostSystem">host-1002</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">esxi-27971.cf5e88ac.australia-southeast1.gve.goog</val>
</propSet>
</objects>
</returnval>
</RetrievePropertiesResponse>
</RetrievePropertiesExResponse>
</soapenv:Body>
</soapenv:Envelope>
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?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">
<RetrievePropertiesExResponse xmlns="urn:vim25">
<returnval>
<obj type="ResourcePool">resgroup-10</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">Resources</val>
</propSet>
<objects>
<obj type="ResourcePool">resgroup-10</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">Resources</val>
</propSet>
</objects>
</returnval>
<returnval>
<obj type="HostSystem">host-1003</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">esxi-111.europe-southeast1.gve.goog</val>
</propSet>
<objects>
<obj type="HostSystem">host-1003</obj>
<propSet>
<name>name</name>
<val xsi:type="xsd:string">esxi-111.europe-southeast1.gve.goog</val>
</propSet>
</objects>
</returnval>
</RetrievePropertiesResponse>
</RetrievePropertiesExResponse>
</soapenv:Body>
</soapenv:Envelope>
Loading

0 comments on commit 450b088

Please sign in to comment.