Skip to content

Commit

Permalink
Add functional test for kernel boot
Browse files Browse the repository at this point in the history
Currently only testing whether the example VMI for
kernel boot can boot up successfully

Signed-off-by: Itamar Holder <[email protected]>
  • Loading branch information
iholder101 committed May 21, 2021
1 parent 421413a commit 3035f4c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ go_test(
"vmi_hostdev_test.go",
"vmi_ignition_test.go",
"vmi_iothreads_test.go",
"vmi_kernel_boot_test.go",
"vmi_lifecycle_test.go",
"vmi_monitoring_test.go",
"vmi_multiqueue_test.go",
Expand Down
14 changes: 13 additions & 1 deletion tests/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"strings"
"sync"

"kubevirt.io/kubevirt/tools/vms-generator/utils"

"fmt"
"time"

Expand Down Expand Up @@ -1829,7 +1831,16 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:[email protected]][leve

Context("with sata disks", func() {

It("[test_id:1853]VM with containerDisk + CloudInit + ServiceAccount + ConfigMap + Secret + DownwardAPI", func() {
addKernelBootContainer := func(vmi *v1.VirtualMachineInstance) {
kernelBootFirmware := utils.GetVMIKernelBoot().Spec.Domain.Firmware
if vmiFirmware := vmi.Spec.Domain.Firmware; vmiFirmware == nil {
vmiFirmware = kernelBootFirmware
} else {
vmiFirmware.KernelBoot = kernelBootFirmware.KernelBoot
}
}

It("[test_id:1853]VM with containerDisk + CloudInit + ServiceAccount + ConfigMap + Secret + DownwardAPI + External Kernel Boot", func() {
configMapName := "configmap-" + rand.String(5)
secretName := "secret-" + rand.String(5)
downwardAPIName := "downwardapi-" + rand.String(5)
Expand All @@ -1853,6 +1864,7 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:[email protected]][leve
tests.AddConfigMapDisk(vmi, configMapName, configMapName)
tests.AddSecretDisk(vmi, secretName, secretName)
tests.AddServiceAccountDisk(vmi, "default")
addKernelBootContainer(vmi)

// In case there are no existing labels add labels to add some data to the downwardAPI disk
if vmi.ObjectMeta.Labels == nil {
Expand Down
50 changes: 50 additions & 0 deletions tests/vmi_kernel_boot_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of the kubevirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2021 Red Hat, Inc.
*
*/

package tests_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"kubevirt.io/client-go/kubecli"
"kubevirt.io/kubevirt/tests"
"kubevirt.io/kubevirt/tools/vms-generator/utils"
)

var _ = Describe("VMI with external kernel boot", func() {

var virtClient kubecli.KubevirtClient

BeforeEach(func() {
var err error
virtClient, err = kubecli.GetKubevirtClient()
Expect(err).ToNot(HaveOccurred())
tests.BeforeTestCleanup()
})

Context("with external alpine-based kernel & initrd images", func() {
It("ensure successful boot", func() {
vmi := utils.GetVMIKernelBoot()
obj, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
Expect(err).To(BeNil())
tests.WaitForSuccessfulVMIStart(obj)
})
})
})

0 comments on commit 3035f4c

Please sign in to comment.