Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Update VC Client test assertions
Browse files Browse the repository at this point in the history
CAPV version v1.5.3 pulls in the latest version of govmomi v0.30.2 which
has a change that updates the way vcsim distributed VMs across resource
pools. This led to the changes in the moID generations of the different
resource pool and VM objects.
The issue fixed in govmomi is
vmware/govmomi#2047 which has explanation
around the changes.

Signed-off-by: Sagar Muchhal <[email protected]>
(cherry picked from commit 13efdda)
  • Loading branch information
srm09 committed Feb 17, 2023
1 parent 754499d commit 511c4d5
Showing 1 changed file with 62 additions and 41 deletions.
103 changes: 62 additions & 41 deletions tkg/vc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var _ = Describe("VC Client", func() {
})
It("should return the moid of the resource pool", func() {
Expect(err).ToNot(HaveOccurred())
Expect(rpMOID).To(Equal("resgroup-399"))
Expect(rpMOID).To(Equal("resgroup-441"))
})
})

Expand Down Expand Up @@ -234,19 +234,19 @@ var _ = Describe("VC Client", func() {
)

const (
vmPathID = "DC0_C1_RP0_VM0"
vmPathID = "DC0_C1_RP1_VM0"
)
JustBeforeEach(func() {
vmMOID, err = client.FindVirtualMachine(context.Background(), vmPath, dcPath)
})
Context("when datacenter path is not specified, and vm path is the absolute path", func() {
BeforeEach(func() {
vmPath = "/DC0/vm/DC0_C1_RP0_VM0"
vmPath = "/DC0/vm/DC0_C1_RP1_VM0"
dcPath = ""
})
It("should return the vm moid", func() {
Expect(err).ToNot(HaveOccurred())
Expect(vmMOID).To(Equal("vm-370"))
Expect(vmMOID).To(Equal("vm-388"))
})
})

Expand All @@ -267,7 +267,7 @@ var _ = Describe("VC Client", func() {
})
It("should return the vm moid", func() {
Expect(err).ToNot(HaveOccurred())
Expect(vmMOID).To(Equal("vm-370"))
Expect(vmMOID).To(Equal("vm-388"))
})
})
})
Expand All @@ -290,7 +290,7 @@ var _ = Describe("VC Client", func() {
Name: "/DC0/host/DC0_C0/Resources/DC0_C0_RP2",
},
{
Moid: "resgroup-399",
Moid: "resgroup-441",
Name: "/DC0/host/DC0_C0/Resources/ChildPool",
},
{
Expand Down Expand Up @@ -442,37 +442,58 @@ var _ = Describe("VC Client", func() {
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-364",
Moid: "vm-379",
Name: "/DC0/vm/DC0_H0_VM0",
OsInfo: nil,
},
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-367",
Name: "/DC0/vm/DC0_C0_RP0_VM0",
Moid: "vm-382",
Name: "/DC0/vm/DC0_C0_RP1_VM0",
OsInfo: nil,
},
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-370",
Name: "/DC0/vm/DC0_C1_RP0_VM0",
Moid: "vm-385",
Name: "/DC0/vm/DC0_C0_RP2_VM0",
OsInfo: nil,
},
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-373",
Name: "/DC0/vm/DC0_C2_RP0_VM0",
Moid: "vm-388",
Name: "/DC0/vm/DC0_C1_RP1_VM0",
OsInfo: nil,
},
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-391",
Name: "/DC0/vm/DC0_C1_RP2_VM0",
OsInfo: nil,
},
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-394",
Name: "/DC0/vm/DC0_C2_RP1_VM0",
OsInfo: nil,
},
{
IsTemplate: nil,
K8sVersion: "",
Moid: "vm-397",
Name: "/DC0/vm/DC0_C2_RP2_VM0",
OsInfo: nil,
},
}
)
JustBeforeEach(func() {
vms, err = client.GetVirtualMachines(context.Background(), datacenterMoID)
})
Context("When retrieveing vm from datacenter-2", func() {
Context("When retrieving vm from datacenter-2", func() {
BeforeEach(func() {
datacenterMoID = datacenter2ID
})
Expand Down Expand Up @@ -502,34 +523,13 @@ var _ = Describe("VC Client", func() {
Path: "/DC0/host/DC0_C0/Resources/DC0_C0_RP1",
ResourceType: "respool",
},
{
Moid: "domain-c87",
Name: "DC0_C2",
ParentMoid: "",
Path: "/DC0/host/DC0_C2",
ResourceType: "cluster",
},
{
Moid: "resgroup-112",
Name: "DC0_C2_RP1",
ParentMoid: "domain-c87",
Path: "/DC0/host/DC0_C2/Resources/DC0_C2_RP1",
ResourceType: "respool",
},
{
Moid: "resgroup-55",
Name: "DC0_C0_RP2",
ParentMoid: "domain-c29",
Path: "/DC0/host/DC0_C0/Resources/DC0_C0_RP2",
ResourceType: "respool",
},
{
Moid: "resgroup-399",
Name: "ChildPool",
ParentMoid: "domain-c29",
Path: "/DC0/host/DC0_C0/Resources/ChildPool",
ResourceType: "respool",
},
{
Moid: "domain-c58",
Name: "DC0_C1",
Expand All @@ -551,13 +551,34 @@ var _ = Describe("VC Client", func() {
Path: "/DC0/host/DC0_C1/Resources/DC0_C1_RP2",
ResourceType: "respool",
},
{
Moid: "domain-c87",
Name: "DC0_C2",
ParentMoid: "",
Path: "/DC0/host/DC0_C2",
ResourceType: "cluster",
},
{
Moid: "resgroup-112",
Name: "DC0_C2_RP1",
ParentMoid: "domain-c87",
Path: "/DC0/host/DC0_C2/Resources/DC0_C2_RP1",
ResourceType: "respool",
},
{
Moid: "resgroup-113",
Name: "DC0_C2_RP2",
ParentMoid: "domain-c87",
Path: "/DC0/host/DC0_C2/Resources/DC0_C2_RP2",
ResourceType: "respool",
},
{
Moid: "resgroup-441",
Name: "ChildPool",
ParentMoid: "domain-c29",
Path: "/DC0/host/DC0_C0/Resources/ChildPool",
ResourceType: "respool",
},
}
)
JustBeforeEach(func() {
Expand All @@ -582,17 +603,17 @@ var _ = Describe("VC Client", func() {
datastores []*models.VSphereDatastore
datacenterMoID string
desiredResult = []string{
"LocalDS_0",
"LocalDS_1",
"LocalDS_2",
"LocalDS_3",
"LocalDS_4",
"/DC0/datastore/LocalDS_0",
"/DC0/datastore/LocalDS_1",
"/DC0/datastore/LocalDS_2",
"/DC0/datastore/LocalDS_3",
"/DC0/datastore/LocalDS_4",
}
)
JustBeforeEach(func() {
datastores, err = client.GetDatastores(context.Background(), datacenterMoID)
})
Context("When retrieveing datastore from datacenter-2", func() {
Context("When retrieving datastore from datacenter-2", func() {
BeforeEach(func() {
datacenterMoID = datacenter2ID
})
Expand Down

0 comments on commit 511c4d5

Please sign in to comment.