Skip to content

Commit

Permalink
Remove more now unnecessary cloud-init payloads
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Aug 10, 2021
1 parent 4c5cdc4 commit aa9776c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 63 deletions.
18 changes: 9 additions & 9 deletions tests/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ var _ = Describe("[Serial][rfe_id:899][crit:medium][vendor:[email protected]][le

By("Running VMI")

vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdataHighMemory(
vmi := tests.NewRandomVMIWithEphemeralDiskHighMemory(
cd.ContainerDiskFor(
cd.ContainerDiskFedoraTestTooling), "#!/bin/bash\necho \"fedora\" | passwd fedora --stdin\n")
cd.ContainerDiskFedoraTestTooling))
tests.AddConfigMapDisk(vmi, configMapName, configMapName)
tests.AddSecretDisk(vmi, secretName, secretName)
tests.AddConfigMapDiskWithCustomLabel(vmi, configMapName, "random1", "configlabel")
Expand Down Expand Up @@ -401,7 +401,7 @@ var _ = Describe("[Serial][rfe_id:899][crit:medium][vendor:[email protected]][le
// mount ConfigMap image
&expect.BSnd{S: "sudo su -\n"},
&expect.BExp{R: console.PromptExpression},
&expect.BSnd{S: "mount /dev/vdc /mnt\n"},
&expect.BSnd{S: "mount /dev/vdb /mnt\n"},
&expect.BExp{R: console.PromptExpression},
&expect.BSnd{S: "echo $?\n"},
&expect.BExp{R: console.RetValue("0")},
Expand All @@ -426,7 +426,7 @@ var _ = Describe("[Serial][rfe_id:899][crit:medium][vendor:[email protected]][le

Expect(console.SafeExpectBatch(vmi, []expect.Batcher{
// mount Secret image
&expect.BSnd{S: "mount /dev/vdd /mnt\n"},
&expect.BSnd{S: "mount /dev/vdc /mnt\n"},
&expect.BExp{R: console.PromptExpression},
&expect.BSnd{S: "echo $?\n"},
&expect.BExp{R: console.RetValue("0")},
Expand All @@ -436,13 +436,13 @@ var _ = Describe("[Serial][rfe_id:899][crit:medium][vendor:[email protected]][le

By("checking that all disk labels match the expectations")
Expect(console.SafeExpectBatch(vmi, []expect.Batcher{
&expect.BSnd{S: "blkid -s LABEL -o value /dev/vdb\n"},
&expect.BExp{R: "cfgdata"}, // default value
&expect.BSnd{S: "blkid -s LABEL -o value /dev/vdc\n"},
&expect.BExp{R: "cfgdata"}, // default value
&expect.BSnd{S: "blkid -s LABEL -o value /dev/vdd\n"},
&expect.BExp{R: "cfgdata"}, // default value
&expect.BSnd{S: "blkid -s LABEL -o value /dev/vde\n"},
&expect.BExp{R: "configlabel"}, // custom value
&expect.BSnd{S: "blkid -s LABEL -o value /dev/vdf\n"},
&expect.BSnd{S: "blkid -s LABEL -o value /dev/vde\n"},
&expect.BExp{R: "secretlabel"}, // custom value
}, 200)).To(Succeed())
})
Expand Down Expand Up @@ -482,9 +482,9 @@ var _ = Describe("[Serial][rfe_id:899][crit:medium][vendor:[email protected]][le
expectedPublicKey := string(publicKeyBytes)

By("Running VMI")
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdataHighMemory(
vmi := tests.NewRandomVMIWithEphemeralDiskHighMemory(
cd.ContainerDiskFor(
cd.ContainerDiskFedoraTestTooling), "#!/bin/bash\necho \"fedora\" | passwd fedora --stdin\n")
cd.ContainerDiskFedoraTestTooling))
tests.AddSecretDisk(vmi, secretName, secretName)
vmi = tests.RunVMIAndExpectLaunch(vmi, 90)

Expand Down
12 changes: 5 additions & 7 deletions tests/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2147,9 +2147,11 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:[email protected]][leve
tests.CreateConfigMap(configMapName, config_data)
tests.CreateSecret(secretName, secret_data)

vmi := tests.NewRandomVMIWithEphemeralDisk(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling))
vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse(fedoraVMSize)
tests.AddUserData(vmi, "cloud-init", "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n")
vmi := libvmi.NewTestToolingFedora(
libvmi.WithNetwork(v1.DefaultPodNetwork()),
libvmi.WithInterface(libvmi.InterfaceDeviceWithMasqueradeBinding()),
)
tests.AddUserData(vmi, "cloud-init", "#!/bin/bash\necho 'hello'\n")
tests.AddConfigMapDisk(vmi, configMapName, configMapName)
tests.AddSecretDisk(vmi, secretName, secretName)
tests.AddServiceAccountDisk(vmi, "default")
Expand All @@ -2161,10 +2163,6 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:[email protected]][leve
}
tests.AddLabelDownwardAPIVolume(vmi, downwardAPIName)

vmi.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "default", Tag: "testnic",
InterfaceBindingMethod: v1.InterfaceBindingMethod{
Masquerade: &v1.InterfaceMasquerade{}}}}

Expect(len(vmi.Spec.Domain.Devices.Disks)).To(Equal(6))
Expect(len(vmi.Spec.Domain.Devices.Interfaces)).To(Equal(1))

Expand Down
3 changes: 1 addition & 2 deletions tests/network/vmi_networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ var _ = SIGDescribe("[Serial][rfe_id:694][crit:medium][vendor:[email protected]]
})

It("[test_id:1778]should offer extra dhcp options to pod iface", func() {
userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n"
dhcpVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling), userData)
dhcpVMI := tests.NewRandomVMIWithEphemeralDisk(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling))
tests.AddExplicitPodNetworkInterface(dhcpVMI)

dhcpVMI.Spec.Domain.Resources.Requests[k8sv1.ResourceName("memory")] = resource.MustParse("1024M")
Expand Down
28 changes: 5 additions & 23 deletions tests/storage/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"time"

expect "github.com/google/goexpect"
vsv1beta1 "github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"

vsv1beta1 "github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -472,7 +471,7 @@ var _ = SIGDescribe("[Serial]VirtualMachineSnapshot Tests", func() {
var vmi *v1.VirtualMachineInstance
vm, vmi = createAndStartVM(tests.NewRandomVMWithDataVolumeAndUserData(
dataVolume,
"#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n",
"#!/bin/bash\necho 'I don't need a cloud-init payload, refactor me'\n",
))
tests.WaitAgentConnected(virtClient, vmi)
Expect(libnet.WithIPv6(console.LoginToFedora)(vmi)).To(Succeed())
Expand All @@ -499,7 +498,7 @@ var _ = SIGDescribe("[Serial]VirtualMachineSnapshot Tests", func() {
})

It("should unfreeze vm if snapshot fails when deadline exceeded", func() {
dataVolume := tests.NewRandomDataVolumeWithHttpImportInStorageClass(
dataVolume := tests.NewRandomDataVolumeWithRegistryImportInStorageClass(
cd.DataVolumeImportUrlForContainerDisk(cd.ContainerDiskFedoraTestTooling),
util.NamespaceTestDefault,
snapshotStorageClass,
Expand All @@ -508,27 +507,10 @@ var _ = SIGDescribe("[Serial]VirtualMachineSnapshot Tests", func() {
var vmi *v1.VirtualMachineInstance
vm, vmi = createAndStartVM(tests.NewRandomVMWithDataVolumeAndUserData(
dataVolume,
"#cloud-config\npassword: fedora\nchpasswd: { expire: False }\npackages:\n qemu-guest-agent",
"#!/bin/bash\necho 'I don't need a cloud-init payload, refactor me'\n",
))
Expect(libnet.WithIPv6(console.LoginToFedora)(vmi)).To(Succeed())
Eventually(func() error {
var batch []expect.Batcher
batch = append(batch, []expect.Batcher{
&expect.BSnd{S: "\n"},
&expect.BExp{R: console.PromptExpression},
&expect.BSnd{S: "sudo systemctl start qemu-guest-agent\n"},
&expect.BExp{R: console.PromptExpression},
&expect.BSnd{S: "echo $?\n"},
&expect.BExp{R: console.RetValue("0")},
&expect.BSnd{S: "sudo systemctl enable qemu-guest-agent\n"},
&expect.BExp{R: console.PromptExpression},
&expect.BSnd{S: "echo $?\n"},
&expect.BExp{R: console.RetValue("0")},
}...)

return console.SafeExpectBatch(vmi, batch, 120)
}, 720*time.Second, 1*time.Second).Should(Succeed())
tests.WaitAgentConnected(virtClient, vmi)
Expect(libnet.WithIPv6(console.LoginToFedora)(vmi)).To(Succeed())

createDenyVolumeSnapshotCreateWebhook()
snapshot = newSnapshot()
Expand Down
17 changes: 2 additions & 15 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2120,13 +2120,6 @@ func NewRandomVMWithDataVolumeAndUserData(dataVolume *cdiv1.DataVolume, userData
return vm
}

func NewRandomVMWithBlockDataVolumeAndUserDataInStorageClass(imageUrl, namespace, userData, storageClass string) *v1.VirtualMachine {
dataVolume := NewRandomDataVolumeWithHttpImportInStorageClass(imageUrl, namespace, storageClass, k8sv1.ReadWriteOnce)
volumeMode := k8sv1.PersistentVolumeBlock
dataVolume.Spec.PVC.VolumeMode = &volumeMode
return NewRandomVMWithDataVolumeAndUserData(dataVolume, userData)
}

func NewRandomVMWithDataVolumeAndUserDataInStorageClass(imageUrl, namespace, userData, storageClass string) *v1.VirtualMachine {
dataVolume := NewRandomDataVolumeWithHttpImportInStorageClass(imageUrl, namespace, storageClass, k8sv1.ReadWriteOnce)
return NewRandomVMWithDataVolumeAndUserData(dataVolume, userData)
Expand Down Expand Up @@ -2379,18 +2372,12 @@ func NewRandomVMIWithPVCFS(claimName string) *v1.VirtualMachineInstance {
}

func NewRandomFedoraVMIWithDmidecode() *v1.VirtualMachineInstance {
userData := `#!/bin/bash
echo "fedora" |passwd fedora --stdin
`
vmi := NewRandomVMIWithEphemeralDiskAndUserdataHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling), userData)
vmi := NewRandomVMIWithEphemeralDiskHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling))
return vmi
}

func NewRandomFedoraVMIWithVirtWhatCpuidHelper() *v1.VirtualMachineInstance {
userData := `#!/bin/bash
echo "fedora" |passwd fedora --stdin
`
vmi := NewRandomVMIWithEphemeralDiskAndUserdataHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling), userData)
vmi := NewRandomVMIWithEphemeralDiskHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling))
return vmi
}

Expand Down
8 changes: 2 additions & 6 deletions tests/vmi_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2551,13 +2551,9 @@ var _ = Describe("[sig-compute]Configurations", func() {
Expect(nodes.Items).ToNot(BeEmpty(), "There should be some nodes")
node = nodes.Items[1].Name

vmi = tests.NewRandomVMIWithEphemeralDiskAndUserdata(
cd.ContainerDiskFor(
cd.ContainerDiskFedoraTestTooling), "#!/bin/bash\necho \"fedora\" | passwd fedora --stdin\n")
vmi = libvmi.NewTestToolingFedora()

cpuvmi = tests.NewRandomVMIWithEphemeralDiskAndUserdata(
cd.ContainerDiskFor(
cd.ContainerDiskFedoraTestTooling), "#!/bin/bash\necho \"fedora\" | passwd fedora --stdin\n")
cpuvmi = libvmi.NewTestToolingFedora()
cpuvmi.Spec.Domain.CPU = &v1.CPU{
Cores: 2,
DedicatedCPUPlacement: true,
Expand Down
2 changes: 1 addition & 1 deletion tests/vmi_ignition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var _ = Describe("[Serial][rfe_id:151][crit:high][vendor:[email protected]][leve
Context("with IgnitionData annotation", func() {
Context("with injected data", func() {
It("[test_id:1616]should have injected data under firmware directory", func() {
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdataHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling), "#!/bin/sh\n\necho fedora| passwd --stdin fedora\n")
vmi := tests.NewRandomVMIWithEphemeralDiskHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling))

ignitionData := "ignition injected"
vmi.Annotations = map[string]string{v1.IgnitionAnnotation: ignitionData}
Expand Down

0 comments on commit aa9776c

Please sign in to comment.