Skip to content

Commit

Permalink
tests: hide BashHelloScript
Browse files Browse the repository at this point in the history
BashHelloScript should never be used, as it is an implementation detail
relevant only to Cirros VMIs. This commit does not eliminate it
completely, but hides it in the only file that still uses it.

Signed-off-by: Dan Kenigsberg <[email protected]>
  • Loading branch information
dankenigsberg committed Jun 21, 2022
1 parent d32d4eb commit ac41552
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
21 changes: 11 additions & 10 deletions tests/storage/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
creatingSnapshot = "creating snapshot"

macAddressCloningPatchPattern = `{"op": "replace", "path": "/spec/template/spec/domain/devices/interfaces/0/macAddress", "value": "%s"}`
bashHelloScript = "#!/bin/bash\necho 'hello'\n"
)

var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
Expand Down Expand Up @@ -216,7 +217,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {

BeforeEach(func() {
vmiImage := cd.ContainerDiskFor(cd.ContainerDiskCirros)
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(vmiImage, tests.BashHelloScript)
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(vmiImage, bashHelloScript)
vm = tests.NewRandomVirtualMachine(vmi, false)
vm.Labels = map[string]string{
"kubevirt.io/dummy-webhook-identifier": vm.Name,
Expand Down Expand Up @@ -419,7 +420,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {

It("should fail restoring to a different VM that already exists", func() {
By("Creating a new VM")
newVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), tests.BashHelloScript)
newVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), bashHelloScript)
newVM := tests.NewRandomVirtualMachine(newVMI, false)
newVM, err = virtClient.VirtualMachine(newVM.Namespace).Create(newVM)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -785,7 +786,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
vm, vmi = createAndStartVM(tests.NewRandomVMWithDataVolumeAndUserDataInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskCirros),
util.NamespaceTestDefault,
tests.BashHelloScript,
bashHelloScript,
snapshotStorageClass,
))

Expand Down Expand Up @@ -817,7 +818,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
vm = tests.NewRandomVMWithDataVolumeAndUserDataInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskCirros),
util.NamespaceTestDefault,
tests.BashHelloScript,
bashHelloScript,
snapshotStorageClass,
)
quantity, err := resource.ParseQuantity("1528Mi")
Expand Down Expand Up @@ -853,7 +854,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
vm, vmi = createAndStartVM(tests.NewRandomVMWithDataVolumeAndUserDataInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskCirros),
util.NamespaceTestDefault,
tests.BashHelloScript,
bashHelloScript,
snapshotStorageClass,
))

Expand All @@ -878,7 +879,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
vm = tests.NewRandomVMWithDataVolumeAndUserDataInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskCirros),
util.NamespaceTestDefault,
tests.BashHelloScript,
bashHelloScript,
snapshotStorageClass,
)

Expand Down Expand Up @@ -950,7 +951,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {

originalPVCName := pvc.Name

vmi = tests.NewRandomVMIWithPVCAndUserData(pvc.Name, tests.BashHelloScript)
vmi = tests.NewRandomVMIWithPVCAndUserData(pvc.Name, bashHelloScript)
vm = tests.NewRandomVirtualMachine(vmi, false)

vm, vmi = createAndStartVM(vm)
Expand Down Expand Up @@ -989,7 +990,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
Expect(err).ToNot(HaveOccurred())
vmi = tests.NewRandomVMIWithEphemeralDiskAndUserdata(
cd.ContainerDiskFor(cd.ContainerDiskCirros),
tests.BashHelloScript,
bashHelloScript,
)
vm = tests.NewRandomVirtualMachine(vmi, false)

Expand Down Expand Up @@ -1053,7 +1054,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
vm, vmi = createAndStartVM(tests.NewRandomVMWithDataVolumeAndUserDataInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskCirros),
util.NamespaceTestDefault,
tests.BashHelloScript,
bashHelloScript,
snapshotStorageClass,
))

Expand Down Expand Up @@ -1153,7 +1154,7 @@ var _ = SIGDescribe("VirtualMachineRestore Tests", func() {
vm, vmi = createAndStartVM(tests.NewRandomVMWithDataVolumeAndUserDataInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskCirros),
util.NamespaceTestDefault,
tests.BashHelloScript,
bashHelloScript,
snapshotStorageClass,
))

Expand Down
1 change: 0 additions & 1 deletion tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const (
WaitingVMInstanceStart = "Waiting until the VirtualMachineInstance will start"
CouldNotFindComputeContainer = "could not find compute container for pod"
EchoLastReturnValue = "echo $?\n"
BashHelloScript = "#!/bin/bash\necho 'hello'\n"
)

const defaultTestGracePeriod int64 = 0
Expand Down

0 comments on commit ac41552

Please sign in to comment.