Skip to content

Commit 85a593d

Browse files
committed
correct testcase
1 parent c484952 commit 85a593d

2 files changed

Lines changed: 15 additions & 50 deletions

File tree

internal/server/machine.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ func (s *Server) getIRIVolumeSpec(machine *api.Machine) []*iri.Volume {
7878
var connection *iri.VolumeConnection
7979
if volumeConnection := volume.Connection; volumeConnection != nil {
8080
connection = &iri.VolumeConnection{
81-
Driver: volumeConnection.Driver,
82-
Handle: volumeConnection.Handle,
83-
Attributes: volumeConnection.Attributes,
84-
SecretData: volumeConnection.SecretData,
85-
EncryptionData: volumeConnection.EncryptionData,
81+
Driver: volumeConnection.Driver,
82+
Handle: volumeConnection.Handle,
83+
Attributes: volumeConnection.Attributes,
84+
SecretData: volumeConnection.SecretData,
85+
EncryptionData: volumeConnection.EncryptionData,
86+
EffectiveStorageBytes: volumeConnection.EffectiveStorageBytes,
8687
}
8788
}
8889

internal/server/machine_volume_update_test.go

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
var _ = FDescribe("UpdateVolume", func() {
2020
It("should correctly update machine volume", func(ctx SpecContext) {
21-
By("creating a machine with empty disks and single ceph volume")
21+
By("creating a machine with ceph volume")
2222
createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{
2323
Machine: &iri.Machine{
2424
Metadata: &irimeta.ObjectMetadata{
@@ -33,16 +33,9 @@ var _ = FDescribe("UpdateVolume", func() {
3333
},
3434
Class: machineClassx3xlarge,
3535
Volumes: []*iri.Volume{
36-
{
37-
Name: "disk-1",
38-
EmptyDisk: &iri.EmptyDisk{
39-
SizeBytes: emptyDiskSize,
40-
},
41-
Device: "oda",
42-
},
4336
{
4437
Name: "volume-1",
45-
Device: "odc",
38+
Device: "oda",
4639
Connection: &iri.VolumeConnection{
4740
Driver: "ceph",
4841
Handle: "dummy",
@@ -106,11 +99,6 @@ var _ = FDescribe("UpdateVolume", func() {
10699
return listResp.Machines[0].Status
107100
}).Should(SatisfyAll(
108101
HaveField("Volumes", ContainElements(
109-
&iri.VolumeStatus{
110-
Name: "disk-1",
111-
Handle: "libvirt-provider.ironcore.dev/empty-disk/disk-1",
112-
State: iri.VolumeState_VOLUME_ATTACHED,
113-
},
114102
&iri.VolumeStatus{
115103
Name: "volume-1",
116104
Handle: "libvirt-provider.ironcore.dev/ceph/libvirt-provider.ironcore.dev/ceph^dummy",
@@ -128,9 +116,8 @@ var _ = FDescribe("UpdateVolume", func() {
128116
g.Expect(domainXML.Unmarshal(domainXMLData)).Should(Succeed())
129117
disks = domainXML.Devices.Disks
130118
return len(disks)
131-
}).Should(Equal(3))
119+
}).Should(Equal(2))
132120
Expect(disks[0].Serial).To(HavePrefix("oda"))
133-
Expect(disks[1].Serial).To(HavePrefix("odc"))
134121

135122
// wait to complete machine reconciliation
136123
time.Sleep(20 * time.Second)
@@ -140,7 +127,7 @@ var _ = FDescribe("UpdateVolume", func() {
140127
MachineId: createResp.Machine.Metadata.Id,
141128
Volume: &iri.Volume{
142129
Name: "volume-1",
143-
Device: "odc",
130+
Device: "oda",
144131
Connection: &iri.VolumeConnection{
145132
Driver: "ceph",
146133
Handle: "dummy",
@@ -159,12 +146,11 @@ var _ = FDescribe("UpdateVolume", func() {
159146
Expect(err).NotTo(HaveOccurred())
160147
Expect(updateVolumeResp).NotTo(BeNil())
161148

162-
By("ensuring volume-1 is updated")
163149
// wait to complete machine reconciliation
164150
time.Sleep(20 * time.Second)
165151

166152
By("ensuring volume-1 has been updated in machine spec field")
167-
Eventually(func(g Gomega) *iri.MachineSpec {
153+
Eventually(func(g Gomega) *iri.Volume {
168154
listResp, err := machineClient.ListMachines(ctx, &iri.ListMachinesRequest{
169155
Filter: &iri.MachineFilter{
170156
Id: createResp.Machine.Metadata.Id,
@@ -173,33 +159,11 @@ var _ = FDescribe("UpdateVolume", func() {
173159
g.Expect(err).NotTo(HaveOccurred())
174160
g.Expect(listResp.Machines).NotTo(BeEmpty())
175161
g.Expect(listResp.Machines).Should(HaveLen(1))
176-
return listResp.Machines[0].Spec
162+
return listResp.Machines[0].Spec.Volumes[0]
177163
}).Should(SatisfyAll(
178-
HaveField("Volumes", ContainElements(
179-
&iri.Volume{
180-
Name: "disk-1",
181-
EmptyDisk: &iri.EmptyDisk{
182-
SizeBytes: emptyDiskSize,
183-
},
184-
Device: "oda",
185-
},
186-
&iri.Volume{
187-
Name: "volume-1",
188-
Device: "odc",
189-
Connection: &iri.VolumeConnection{
190-
Driver: "ceph",
191-
Handle: "dummy",
192-
Attributes: map[string]string{
193-
"image": cephImage,
194-
"monitors": cephMonitors,
195-
},
196-
SecretData: map[string][]byte{
197-
"userID": []byte(cephUsername),
198-
"userKey": []byte(cephUserkey),
199-
},
200-
EffectiveStorageBytes: resource.NewQuantity(2*1024*1024*1024, resource.BinarySI).Value(),
201-
},
202-
})),
164+
HaveField("Name", Equal("volume-1")),
165+
HaveField("Device", Equal("oda")),
166+
HaveField("Connection.EffectiveStorageBytes", Equal(resource.NewQuantity(2*1024*1024*1024, resource.BinarySI).Value())),
203167
))
204168
})
205169
})

0 commit comments

Comments
 (0)