diff --git a/hack/config-default.sh b/hack/config-default.sh index e9df9eb79bde..9c643b9bc434 100644 --- a/hack/config-default.sh +++ b/hack/config-default.sh @@ -1,5 +1,5 @@ binaries="cmd/virt-controller cmd/virt-launcher cmd/virt-handler cmd/virtctl cmd/fake-qemu-process" -docker_images="cmd/virt-controller cmd/virt-launcher cmd/virt-handler images/iscsi-demo-target-tgtd images/vm-killer cmd/registry-disk-v1alpha images/cirros-registry-disk-demo images/fedora-cloud-registry-disk-demo" +docker_images="cmd/virt-controller cmd/virt-launcher cmd/virt-handler images/iscsi-demo-target-tgtd images/vm-killer cmd/registry-disk-v1alpha images/cirros-registry-disk-demo images/fedora-cloud-registry-disk-demo images/alpine-registry-disk-demo" docker_prefix=kubevirt docker_tag=${DOCKER_TAG:-latest} master_ip=192.168.200.2 diff --git a/hack/functests.sh b/hack/functests.sh index 0782a81f8c06..052382fcffb3 100755 --- a/hack/functests.sh +++ b/hack/functests.sh @@ -22,4 +22,4 @@ set -e source hack/common.sh source hack/config.sh -${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -test.timeout 30m ${FUNC_TEST_ARGS} +${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -test.timeout 40m ${FUNC_TEST_ARGS} diff --git a/images/alpine-registry-disk-demo/Dockerfile b/images/alpine-registry-disk-demo/Dockerfile new file mode 100644 index 000000000000..e199c22810dc --- /dev/null +++ b/images/alpine-registry-disk-demo/Dockerfile @@ -0,0 +1,24 @@ +# +# 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 2017 Red Hat, Inc. +# + +FROM kubevirt/registry-disk-v1alpha + +MAINTAINER "The KubeVirt Project" + +# Add alpine image +RUN curl http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/x86_64/alpine-virt-3.7.0-x86_64.iso > /disk/alpine.iso diff --git a/tests/console_test.go b/tests/console_test.go index 1f68a6d01383..74b3f327988f 100644 --- a/tests/console_test.go +++ b/tests/console_test.go @@ -45,7 +45,7 @@ var _ = Describe("Console", func() { Context("New VM with a serial console given", func() { It("should be returned that we are running cirros", func() { - vm := tests.NewRandomVMWithPVC("disk-cirros") + vm := tests.NewRandomVMWithEphemeralDisk("kubevirt/cirros-registry-disk-demo:devel") Expect(virtClient.RestClient().Post().Resource("virtualmachines").Namespace(tests.NamespaceTestDefault).Body(vm).Do().Error()).To(Succeed()) tests.WaitForSuccessfulVMStart(vm) @@ -56,7 +56,7 @@ var _ = Describe("Console", func() { _, err = expecter.ExpectBatch([]expect.Batcher{ &expect.BExp{R: "checking http://169.254.169.254/2009-04-04/instance-id"}, - }, 60*time.Second) + }, 120*time.Second) Expect(err).ToNot(HaveOccurred()) }) @@ -78,7 +78,7 @@ var _ = Describe("Console", func() { }, 140) It("should be able to reconnect to console multiple times", func() { - vm := tests.NewRandomVMWithPVC("disk-alpine") + vm := tests.NewRandomVMWithEphemeralDisk("kubevirt/alpine-registry-disk-demo:devel") Expect(virtClient.RestClient().Post().Resource("virtualmachines").Namespace(tests.NamespaceTestDefault).Body(vm).Do().Error()).To(Succeed()) tests.WaitForSuccessfulVMStart(vm) @@ -91,7 +91,7 @@ var _ = Describe("Console", func() { _, err = expecter.ExpectBatch([]expect.Batcher{ &expect.BSnd{S: "\n"}, &expect.BExp{R: "login"}, - }, 130*time.Second) + }, 160*time.Second) Expect(err).ToNot(HaveOccurred()) } }, 220) diff --git a/tests/storage_test.go b/tests/storage_test.go index 12772a498e01..dc8409bd16e2 100644 --- a/tests/storage_test.go +++ b/tests/storage_test.go @@ -42,6 +42,7 @@ var _ = Describe("Storage", func() { tests.PanicOnError(err) BeforeEach(func() { + Skip("Direct ISCSI storage access is not supported at the moment.") tests.BeforeTestCleanup() }) diff --git a/tests/utils.go b/tests/utils.go index 42efabe2677d..e16c4f5232f1 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -647,7 +647,7 @@ func NewRandomVMWithPVC(claimName string) *v1.VirtualMachine { } func NewRandomVMWithWatchdog() *v1.VirtualMachine { - vm := NewRandomVMWithDirectLun(2, false) + vm := NewRandomVMWithEphemeralDisk("kubevirt/alpine-registry-disk-demo:devel") vm.Spec.Domain.Devices.Watchdog = &v1.Watchdog{ Name: "mywatchdog", diff --git a/tests/vm_configuration_test.go b/tests/vm_configuration_test.go index 6d5e2850d4f3..f6c34922b308 100644 --- a/tests/vm_configuration_test.go +++ b/tests/vm_configuration_test.go @@ -48,7 +48,7 @@ var _ = Describe("Configurations", func() { var vm *v1.VirtualMachine BeforeEach(func() { - vm = tests.NewRandomVMWithDirectLun(2, false) + vm = tests.NewRandomVMWithEphemeralDisk("kubevirt/alpine-registry-disk-demo:devel") }) It("should report 3 cpu cores", func() { vm.Spec.Domain.CPU = &v1.CPU{ diff --git a/tests/vm_userdata_test.go b/tests/vm_userdata_test.go index 96cf88a5cb90..2013e7d15010 100644 --- a/tests/vm_userdata_test.go +++ b/tests/vm_userdata_test.go @@ -70,16 +70,6 @@ var _ = Describe("CloudInit UserData", func() { }) Context("CloudInit Data Source NoCloud", func() { - It("should launch vm with cloud-init data source NoCloud", func(done Done) { - magicStr := "printed from cloud-init userdata" - userData := fmt.Sprintf("#!/bin/sh\n\necho '%s'\n", magicStr) - - vm := tests.NewRandomVMWithUserData(userData) - obj := LaunchVM(vm) - VerifyUserDataVM(vm, obj, magicStr) - close(done) - }, 180) - It("should launch ephemeral vm with cloud-init data source NoCloud", func(done Done) { magicStr := "printed from cloud-init userdata" userData := fmt.Sprintf("#!/bin/sh\n\necho '%s'\n", magicStr) @@ -93,7 +83,7 @@ var _ = Describe("CloudInit UserData", func() { It("should launch VMs with user-data in k8s secret", func(done Done) { magicStr := "printed from cloud-init userdata" userData := fmt.Sprintf("#!/bin/sh\n\necho '%s'\n", magicStr) - vm := tests.NewRandomVMWithUserData(userData) + vm := tests.NewRandomVMWithEphemeralDiskAndUserdata("kubevirt/cirros-registry-disk-demo:devel", userData) for _, volume := range vm.Spec.Volumes { if volume.CloudInitNoCloud == nil { diff --git a/tests/vmlifecycle_test.go b/tests/vmlifecycle_test.go index f93bf9bd5796..cd001d1e70bf 100644 --- a/tests/vmlifecycle_test.go +++ b/tests/vmlifecycle_test.go @@ -54,7 +54,7 @@ var _ = Describe("Vmlifecycle", func() { BeforeEach(func() { tests.BeforeTestCleanup() - vm = tests.NewRandomVMWithDirectLun(2, true) + vm = tests.NewRandomVMWithEphemeralDisk("kubevirt/alpine-registry-disk-demo:devel") }) Context("New VM given", func() { @@ -90,7 +90,7 @@ var _ = Describe("Vmlifecycle", func() { tests.WaitForSuccessfulVMStart(obj) close(done) - }, 30) + }, 45) It("Virt-launcher should attach to a started VM", func(done Done) { obj, err := virtClient.RestClient().Post().Resource("virtualmachines").Namespace(tests.NamespaceTestDefault).Body(vm).Do().Get() @@ -154,7 +154,17 @@ var _ = Describe("Vmlifecycle", func() { Context("New VM which can't be started", func() { It("Should retry starting the VM", func(done Done) { - vm.Spec.Volumes[0].ISCSI.SecretRef.Name = "nonexistent" + userData := fmt.Sprintf("#!/bin/sh\n\necho 'hi'\n") + vm = tests.NewRandomVMWithEphemeralDiskAndUserdata("kubevirt/cirros-registry-disk-demo:devel", userData) + + for _, volume := range vm.Spec.Volumes { + if volume.CloudInitNoCloud != nil { + spec := volume.CloudInitNoCloud + spec.UserDataBase64 = "" + spec.UserDataSecretRef = &k8sv1.LocalObjectReference{Name: "nonexistent"} + break + } + } obj, err := virtClient.RestClient().Post().Resource("virtualmachines").Namespace(tests.NamespaceTestDefault).Body(vm).Do().Get() Expect(err).To(BeNil()) @@ -170,10 +180,22 @@ var _ = Describe("Vmlifecycle", func() { return false }) close(done) - }, 30) + }, 45) It("Should log warning if secret is not present, and proceed once the secret is there", func(done Done) { - vm.Spec.Volumes[0].ISCSI.SecretRef.Name = "nonexistent" + userData := fmt.Sprintf("#!/bin/sh\n\necho 'hi'\n") + userData64 := "" + vm = tests.NewRandomVMWithEphemeralDiskAndUserdata("kubevirt/cirros-registry-disk-demo:devel", userData) + + for _, volume := range vm.Spec.Volumes { + if volume.CloudInitNoCloud != nil { + spec := volume.CloudInitNoCloud + userData64 = spec.UserDataBase64 + spec.UserDataBase64 = "" + spec.UserDataSecretRef = &k8sv1.LocalObjectReference{Name: "nonexistent"} + break + } + } createdVM, err := virtClient.VM(tests.NamespaceTestDefault).Create(vm) Expect(err).To(BeNil()) @@ -182,11 +204,17 @@ var _ = Describe("Vmlifecycle", func() { Expect(event.Message).To(ContainSubstring("nonexistent")) // Creat nonexistent secret, so that the VM can recover - secret, err := virtClient.CoreV1().Secrets(vm.Namespace).Get("iscsi-demo-secret", metav1.GetOptions{}) - secret.ObjectMeta = metav1.ObjectMeta{ - Name: "nonexistent", + secret := k8sv1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "nonexistent", + Namespace: vm.GetObjectMeta().GetNamespace(), + }, + Type: "Opaque", + Data: map[string][]byte{ + "userdata": []byte(userData64), + }, } - _, err = virtClient.CoreV1().Secrets(vm.Namespace).Create(secret) + _, err = virtClient.CoreV1().Secrets(vm.Namespace).Create(&secret) Expect(err).ToNot(HaveOccurred()) // Wait for the VM to be started, allow warning events to occur @@ -221,7 +249,7 @@ var _ = Describe("Vmlifecycle", func() { }()).To(Equal(v1.Failed)) close(done) - }, 50) + }, 60) It("should be left alone by virt-handler", func(done Done) { obj, err := virtClient.RestClient().Post().Resource("virtualmachines").Namespace(tests.NamespaceTestDefault).Body(vm).Do().Get() Expect(err).To(BeNil()) @@ -420,8 +448,10 @@ func getVirtLauncherLogs(virtCli kubecli.KubevirtClient, vm *v1.VirtualMachine) var tailLines int64 = 100 logsRaw, err := virtCli.CoreV1(). Pods(namespace). - GetLogs(podName, - &k8sv1.PodLogOptions{TailLines: &tailLines}). + GetLogs(podName, &k8sv1.PodLogOptions{ + TailLines: &tailLines, + Container: "compute", + }). DoRaw() Expect(err).To(BeNil()) diff --git a/tests/vnc_test.go b/tests/vnc_test.go index bd9558f6ef26..717f7a3742e0 100644 --- a/tests/vnc_test.go +++ b/tests/vnc_test.go @@ -49,8 +49,6 @@ var _ = Describe("Vmlifecycle", func() { Expect(virtClient.RestClient().Post().Resource("virtualmachines").Namespace(tests.NamespaceTestDefault).Body(vm).Do().Error()).To(Succeed()) tests.WaitForSuccessfulVMStart(vm) - tests.WaitForSuccessfulVMStart(vm) - pipeInReader, _ := io.Pipe() pipeOutReader, pipeOutWriter := io.Pipe()