From af42b4650a5c85a1ddaeeb0c63be0c1b16ef4c14 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 22 Mar 2019 16:20:15 -0300 Subject: [PATCH 01/27] add sockets/cores/threads --- tests/framework/types.go | 2 +- tests/framework/util.go | 24 + ...e-fedora-no-sockets-cores-and-threads.yaml | 62 +++ ...emplate-fedora-only-cores-and-threads.yaml | 71 +++ .../vm-template-fedora-only-cores.yaml | 67 +++ ...emplate-fedora-only-sockets-and-cores.yaml | 73 +++ ...plate-fedora-only-sockets-and-threads.yaml | 71 +++ .../vm-template-fedora-only-sockets.yaml | 67 +++ .../vm-template-fedora-only-threads.yaml | 67 +++ ...late-fedora-sockets-cores-and-threads.yaml | 75 +++ .../sockets_cores_threads/vmi-case1.1.yml | 23 + .../sockets_cores_threads/vmi-case1.2.1.yml | 24 + .../sockets_cores_threads/vmi-case1.2.2.yml | 26 + .../sockets_cores_threads/vmi-case1.2.3.yml | 29 + tests/sockets_cores_threads_test.go | 501 ++++++++++++++++++ 15 files changed, 1181 insertions(+), 1 deletion(-) create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml create mode 100644 tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml create mode 100644 tests/manifests/sockets_cores_threads/vmi-case1.1.yml create mode 100644 tests/manifests/sockets_cores_threads/vmi-case1.2.1.yml create mode 100644 tests/manifests/sockets_cores_threads/vmi-case1.2.2.yml create mode 100644 tests/manifests/sockets_cores_threads/vmi-case1.2.3.yml create mode 100644 tests/sockets_cores_threads_test.go diff --git a/tests/framework/types.go b/tests/framework/types.go index 2223fec1a..25de507c4 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -39,7 +39,7 @@ type VirtualMachine struct { func (vm VirtualMachine) Create() (string, string, error) { args := []string{"create", "-f", vm.Manifest} - return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtOcPath, args...) + return ktests.RunCommandWithNS(vm.Namespace, "oc", args...) } func (vm VirtualMachine) Start() (string, string, error) { diff --git a/tests/framework/util.go b/tests/framework/util.go index 5c648b3fa..f5ba8bda8 100644 --- a/tests/framework/util.go +++ b/tests/framework/util.go @@ -15,6 +15,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "kubevirt.io/kubevirt/pkg/kubecli" ktests "kubevirt.io/kubevirt/tests" + "math" ) func ProcessTemplateWithParameters(srcFilePath, dstFilePath string, params ...string) string { @@ -148,3 +149,26 @@ func RemoveDataVolume(dvName string, namespace string) { err = virtCli.CdiClient().CdiV1alpha1().DataVolumes(namespace).Delete(dvName, nil) Expect(err).ToNot(HaveOccurred()) } + +func GetAvailableResources(virtClient kubecli.KubevirtClient, cpuNeeded int64, memNeeded int64) (int, int, int) { + nodeList := ktests.GetAllSchedulableNodes(virtClient) + availableVMs, cpu_limit_total, mem_limit_total := 0, 0, 0 + + for _, node := range nodeList.Items { + cpu := node.Status.Allocatable["cpu"] + mem := node.Status.Allocatable["memory"] + available_cpu, CpuOK := (&cpu).AsInt64() + available_mem, MemOK := (&mem).AsInt64() + if CpuOK && MemOK { + cpu_limit := int(available_cpu / cpuNeeded) + mem_limit := int(available_mem / memNeeded) + cpu_limit_total += cpu_limit + mem_limit_total += mem_limit + availableVMs += int(math.Min(float64(cpu_limit), float64(mem_limit))) + // availableVMs += min(cpu_limit, mem_limit) + } + } + + return availableVMs, cpu_limit_total, mem_limit_total +} + diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml new file mode 100644 index 000000000..e4b6bcdd5 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml @@ -0,0 +1,62 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml new file mode 100644 index 000000000..b931f97c8 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml @@ -0,0 +1,71 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + cores: ${{CPU_CORES}} + threads: ${{CPU_THREADS}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of cores + name: CPU_CORES + value: "2" +- description: Amount of threads + name: CPU_THREADS + value: "2" diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml new file mode 100644 index 000000000..7e8c165b4 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml @@ -0,0 +1,67 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + cores: ${{CPU_CORES}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of cores + name: CPU_CORES + value: "2" diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml new file mode 100644 index 000000000..160102617 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml @@ -0,0 +1,73 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + cores: ${{CPU_CORES}} + sockets: ${{CPU_SOCKETS}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of cores + name: CPU_CORES + value: "2" +- description: Amount of sockets + name: CPU_SOCKETS + value: "2" + + diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml new file mode 100644 index 000000000..2df740549 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml @@ -0,0 +1,71 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + sockets: ${{CPU_SOCKETS}} + threads: ${{CPU_THREADS}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of sockets + name: CPU_SOCKETS + value: "2" +- description: Amount of threads + name: CPU_THREADS + value: "2" diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml new file mode 100644 index 000000000..e9675ca6e --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml @@ -0,0 +1,67 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + sockets: ${{CPU_SOCKETS}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of sockets + name: CPU_SOCKETS + value: "2" diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml new file mode 100644 index 000000000..d426ce85d --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml @@ -0,0 +1,67 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + threads: ${{CPU_THREADS}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of threads + name: CPU_THREADS + value: "2" diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml new file mode 100644 index 000000000..b1b25d730 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: v1 +kind: Template +metadata: + annotations: + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora + tags: kubevirt,ocp,template,linux,virtualmachine + labels: + kubevirt.io/os: fedora27 + miq.github.io/kubevirt-is-vm-template: "true" + name: vm-template-fedora +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + name: ${NAME} + spec: + running: false + template: + metadata: + creationTimestamp: null + labels: + kubevirt-vm: vm-${NAME} + kubevirt.io/os: fedora27 + spec: + domain: + cpu: + sockets: ${{CPU_SOCKETS}} + cores: ${{CPU_CORES}} + threads: ${{CPU_THREADS}} + devices: + disks: + - disk: + bus: virtio + name: registryvolume + - disk: + bus: virtio + name: cloudinitvolume + machine: + type: "" + resources: + requests: + memory: ${MEMORY} + terminationGracePeriodSeconds: 0 + volumes: + - containerDisk: + image: kubevirt/cirros-registry-disk-demo + name: registryvolume + - cloudInitNoCloud: + userData: |- + #cloud-config + password: fedora + chpasswd: { expire: False } + name: cloudinitvolume + status: {} +parameters: +- description: Name for the new VM + name: NAME +- description: Amount of memory + name: MEMORY + value: 256Mi +- description: Amount of cores + name: CPU_CORES + value: "2" +- description: Amount of threads + name: CPU_THREADS + value: "2" +- description: Amount of sockets + name: CPU_SOCKETS + value: "2" diff --git a/tests/manifests/sockets_cores_threads/vmi-case1.1.yml b/tests/manifests/sockets_cores_threads/vmi-case1.1.yml new file mode 100644 index 000000000..de5c0f6c8 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vmi-case1.1.yml @@ -0,0 +1,23 @@ +--- +apiVersion: kubevirt.io/v1alpha3 +kind: VirtualMachineInstance +metadata: + labels: + special: vmi-case1.1 + name: vmi-case1.1 +spec: + domain: + devices: + disks: + - disk: + bus: virtio + name: emptyD + machine: + type: "" + resources: + requests: + memory: 64M + volumes: + - name: emptyD + emptyDisk: + capacity: 64M diff --git a/tests/manifests/sockets_cores_threads/vmi-case1.2.1.yml b/tests/manifests/sockets_cores_threads/vmi-case1.2.1.yml new file mode 100644 index 000000000..1c974a682 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vmi-case1.2.1.yml @@ -0,0 +1,24 @@ +--- +apiVersion: kubevirt.io/v1alpha3 +kind: VirtualMachineInstance +metadata: + labels: + special: vmi-case1.2.1 + name: vmi-case1.2.1 +spec: + domain: + devices: + disks: + - disk: + bus: virtio + name: emptyD + machine: + type: "" + resources: + requests: + memory: 64M + cpu: 2 + volumes: + - name: emptyD + emptyDisk: + capacity: 64M diff --git a/tests/manifests/sockets_cores_threads/vmi-case1.2.2.yml b/tests/manifests/sockets_cores_threads/vmi-case1.2.2.yml new file mode 100644 index 000000000..40ec8d0bd --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vmi-case1.2.2.yml @@ -0,0 +1,26 @@ +--- +apiVersion: kubevirt.io/v1alpha3 +kind: VirtualMachineInstance +metadata: + labels: + special: vmi-case1.2.2 + name: vmi-case1.2.2 +spec: + domain: + devices: + disks: + - disk: + bus: virtio + name: emptyD + machine: + type: "" + resources: + requests: + memory: 64M + cpu: 2 + limits: + cpu: 2 + volumes: + - name: emptyD + emptyDisk: + capacity: 64M diff --git a/tests/manifests/sockets_cores_threads/vmi-case1.2.3.yml b/tests/manifests/sockets_cores_threads/vmi-case1.2.3.yml new file mode 100644 index 000000000..a30985448 --- /dev/null +++ b/tests/manifests/sockets_cores_threads/vmi-case1.2.3.yml @@ -0,0 +1,29 @@ +--- +apiVersion: kubevirt.io/v1alpha3 +kind: VirtualMachineInstance +metadata: + labels: + special: vmi-case1.2.3 + name: vmi-case1.2.3 +spec: + domain: + cpu: + dedicatedCpuPlacement: true + devices: + disks: + - disk: + bus: virtio + name: emptyD + machine: + type: "" + resources: + requests: + cpu: 4 + memory: 64M + limits: + cpu: 2 + memory: 64M + volumes: + - name: emptyD + emptyDisk: + capacity: 64M diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go new file mode 100644 index 000000000..fc975647e --- /dev/null +++ b/tests/sockets_cores_threads_test.go @@ -0,0 +1,501 @@ +/* + * 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 2019 Red Hat, Inc. + * + */ + +package tests_test + +import ( + "bytes" + "encoding/xml" + "flag" + "fmt" + "os" + "strconv" + "sync" + "time" + + "github.com/google/goexpect" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8syaml "k8s.io/apimachinery/pkg/util/yaml" + tframework "kubevirt.io/kubevirt-ansible/tests/framework" + "kubevirt.io/kubevirt/pkg/kubecli" + "kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api" + ktests "kubevirt.io/kubevirt/tests" +) + +func parseYAMLConfig(podYAML string) (bool, int, int) { + isCPUPresent := false + var resourcesRequests int64 = 0 + var resourcesLimits int64 = 0 + + var config corev1.Pod + buf := bytes.NewBuffer([]byte(podYAML)) + decoder := k8syaml.NewYAMLOrJSONDecoder(buf, 1024) + decoder.Decode(&config) + + // Checking that fields Requests and Limits exist + if len(config.Spec.Containers[0].Resources.Requests) != 0 && len(config.Spec.Containers[0].Resources.Limits) != 0 { + + element, doesElementExist := config.Spec.Containers[0].Resources.Requests["cpu"] + if doesElementExist { + isCPUPresent = true + resourcesRequests, _ = (&element).AsInt64() + } + + element, doesElementExist = config.Spec.Containers[0].Resources.Limits["cpu"] + if doesElementExist { + isCPUPresent = true + resourcesLimits, _ = (&element).AsInt64() + } + } + + return isCPUPresent, int(resourcesRequests), int(resourcesLimits) +} + +// Checking if the cluster can run at least one VM +func isEnoughResources(virtClient kubecli.KubevirtClient, cpuNeeded int, memNeeded int64) (bool, int, int) { + availableVMs, cpu_limit, mem_limit := tframework.GetAvailableResources(virtClient, int64(cpuNeeded), memNeeded) + if availableVMs == 0 { + return false, cpu_limit, mem_limit + + } else { + return true, cpu_limit, mem_limit + + } +} + +func getYAMLFilename(sockets, cores, threads int, address_common string) string { + // 0 means parameter set to 0, 1 means parameter set to non-zero + var file_name [2][2][2]string + file_name[0][0][0] = "vm-template-fedora-no-sockets-cores-and-threads.yaml" + file_name[1][0][0] = "vm-template-fedora-only-sockets.yaml" + file_name[0][1][0] = "vm-template-fedora-only-cores.yaml" + file_name[0][0][1] = "vm-template-fedora-only-threads.yaml" + file_name[0][1][1] = "vm-template-fedora-only-cores-and-threads.yaml" + file_name[1][0][1] = "vm-template-fedora-only-sockets-and-threads.yaml" + file_name[1][1][0] = "vm-template-fedora-only-sockets-and-cores.yaml" + file_name[1][1][1] = "vm-template-fedora-sockets-cores-and-threads.yaml" + + // Because go doesn't have ternary operators + s := 0 + if sockets > 0 { + s = 1 + } + + c := 0 + if cores > 0 { + c = 1 + } + + t := 0 + if threads > 0 { + t = 1 + } + + return address_common + file_name[s][c][t] +} + +func getArguments(vm_name string, sockets int, cores int, threads int) []string { + arguments := []string{"NAME=" + vm_name} + + if sockets != 0 { + arguments = append(arguments, "CPU_SOCKETS="+strconv.Itoa(sockets)) + } + if cores != 0 { + arguments = append(arguments, "CPU_CORES="+strconv.Itoa(cores)) + } + if threads != 0 { + arguments = append(arguments, "CPU_THREADS="+strconv.Itoa(threads)) + } + + return arguments +} + +func clean_pods(virtClient kubecli.KubevirtClient, requiredPods []*corev1.Pod) { + listOptions := metav1.ListOptions{} + podList, err := virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) + + Expect(err).ToNot(HaveOccurred()) + for _, item := range podList.Items { + + deletePod := true + for _, internalItem := range requiredPods { + fmt.Println("internalItem=", internalItem.Name) + if item.Name == internalItem.Name { + deletePod = false + fmt.Println("do not delete pod=", internalItem.Name) + } + + } + if deletePod { + fmt.Println("delete pod=", item.Name) + _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "pod", item.Name) + } + } +} + +var _ = Describe("Check CPU topology inside VM", func() { + flag.Parse() + virtClient, err := kubecli.GetKubevirtClient() + ktests.PanicOnError(err) + address_common := "tests/manifests/sockets_cores_threads/" + var vmi11, vmi121, vmi122, vmi123 tframework.VirtualMachine + BeforeEach(func() { + ktests.BeforeTestCleanup() + }) + + Context("test case 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + It("testcase 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + + vmi11.Manifest = address_common + "vmi-case1.1.yml" + vmi11.Namespace = ktests.NamespaceTestDefault + + By("Creating VMI using manifest") + _, _, err := vmi11.Create() + Expect(err).ToNot(HaveOccurred()) + vmi11.Name = "vmi-case1.1" + + By("Getting VMI object") + getVMOptions := metav1.GetOptions{} + vmi, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vmi11.Name, &getVMOptions) + Expect(err).ToNot(HaveOccurred()) + + By("Waiting until VMI start") + ktests.WaitForSuccessfulVMIStart(vmi) + + By("getting pod object") + vmiPod := ktests.GetRunningPodByVirtualMachineInstance(vmi, ktests.NamespaceTestDefault) + + By("clean old pods") + listOptions := metav1.ListOptions{} + podList, err := virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) + var requiredPods []*corev1.Pod + requiredPods = append(requiredPods, vmiPod) + clean_pods(virtClient, requiredPods) + + By("Checking that pod was created and has the right name") + listOptions = metav1.ListOptions{} + podList, err = virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) + Expect(err).ToNot(HaveOccurred()) + By("Checking resources in the pod") + podName := podList.Items[0].Name + outPodYAML, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName, "-o", "yaml") + Expect(err).ToNot(HaveOccurred()) + cpuExist, _, _ := parseYAMLConfig(outPodYAML) + + Expect(cpuExist).To(BeFalse()) + + By("Checking XML") + vmiXml, err := ktests.GetRunningVirtualMachineInstanceDomainXML( + virtClient, + vmi, + ) + + domStat := &api.DomainSpec{} + err = xml.Unmarshal([]byte(vmiXml), domStat) + Expect(err).ToNot(HaveOccurred()) + Expect(uint(domStat.VCPU.CPUs) == 1).To(BeTrue()) + + Expect(uint(domStat.CPU.Topology.Sockets) == 1).To(BeTrue()) + Expect(uint(domStat.CPU.Topology.Cores) == 1).To(BeTrue()) + Expect(uint(domStat.CPU.Topology.Threads) == 1).To(BeTrue()) + + }) + }) + + Context("test case 1.2 Check the validity of the XML file if user didn’t set the CPU topology (only standard cpus - previous releases like) ", func() { + It("testcase 1.2 Check the validity of the XML file if user didn’t set the CPU topology (only standard cpus - previous releases like) ", func() { + + By("declare variables") + vmi121.Manifest = address_common + "/vmi-case1.2.1.yml" + vmi122.Manifest = address_common + "/vmi-case1.2.2.yml" + vmi123.Manifest = address_common + "/vmi-case1.2.3.yml" + vmi121.Name = "vmi-case1.2.1" + vmi122.Name = "vmi-case1.2.2" + vmi123.Name = "vmi-case1.2.3" + vmi121.Namespace, vmi122.Namespace, vmi123.Namespace = ktests.NamespaceTestDefault, ktests.NamespaceTestDefault, ktests.NamespaceTestDefault + + By("Create VMI using manifest - only request CPU resources - VMI-2.1.1") + _, _, err := vmi121.Create() + Expect(err).ToNot(HaveOccurred()) + + By("Create VMI using manifest - request and limit cpu resources, same amount - VMI-2.2.2") + _, _, err = vmi122.Create() + Expect(err).ToNot(HaveOccurred()) + + By("create VMI using wrong manifest, request and limit has different cpu resources") + _, _, err = vmi123.Create() + Expect(err).Should(HaveOccurred()) + + By("Getting VMI object") + getVMOptions := metav1.GetOptions{} + vmi121, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vmi121.Name, &getVMOptions) + Expect(err).ToNot(HaveOccurred()) + vmi122, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vmi122.Name, &getVMOptions) + Expect(err).ToNot(HaveOccurred()) + + By("Waiting until VMI121 start") + ktests.WaitForSuccessfulVMIStart(vmi121) + + By("Waiting until VMI122 start") + ktests.WaitForSuccessfulVMIStart(vmi122) + + By("getting pods objects") + vmi121Pod := ktests.GetRunningPodByVirtualMachineInstance(vmi121, ktests.NamespaceTestDefault) + vmi122Pod := ktests.GetRunningPodByVirtualMachineInstance(vmi122, ktests.NamespaceTestDefault) + + By("workaround for CI - clean old pods") + var requiredPods []*corev1.Pod + requiredPods = append(requiredPods, vmi121Pod) + requiredPods = append(requiredPods, vmi122Pod) + fmt.Println("requiredPods[0].Name=", requiredPods[0].Name, " requiredPods[1].Name=", requiredPods[1].Name) + clean_pods(virtClient, requiredPods) + + By("Checking that pod was created and has the right name") + Expect(err).ToNot(HaveOccurred()) + Expect(vmi121Pod.Name).To(HavePrefix("virt-launcher-"+vmi121.Name), "Pod's name should contain name of the VM associated with it") + Expect(vmi122Pod.Name).To(HavePrefix("virt-launcher-"+vmi122.Name), "Pod's name should contain name of the VM associated with it") + + By("get pod-s YAML files") + podName121 := vmi121Pod.Name + podName122 := vmi122Pod.Name + outPodYAML121, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName121, "-o", "yaml") + Expect(err).ToNot(HaveOccurred()) + outPodYAML122, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName122, "-o", "yaml") + Expect(err).ToNot(HaveOccurred()) + + By("Checking resources in the pod") + var CPUresourcesRequests, CPUresourcesLimits int + cpuExist, CPUresourcesRequests, CPUresourcesLimits := parseYAMLConfig(outPodYAML121) + Expect(cpuExist).To(BeTrue()) + Expect(CPUresourcesRequests == 2).To(BeTrue()) + Expect(CPUresourcesLimits == 0).To(BeTrue()) + cpuExist, CPUresourcesRequests, CPUresourcesLimits = parseYAMLConfig(outPodYAML122) + Expect(cpuExist).To(BeTrue()) + Expect(CPUresourcesRequests == 2).To(BeTrue()) + Expect(CPUresourcesLimits == 2).To(BeTrue()) + + By("Get vmi121 XML") + vmiXml121, err := ktests.GetRunningVirtualMachineInstanceDomainXML( + virtClient, + vmi121, + ) + + By("Get vmi122 XML") + vmiXml122, err := ktests.GetRunningVirtualMachineInstanceDomainXML( + virtClient, + vmi122, + ) + + By("vmi unmarshal") + domStat121 := &api.DomainSpec{} + domStat122 := &api.DomainSpec{} + err = xml.Unmarshal([]byte(vmiXml121), domStat121) + Expect(err).ToNot(HaveOccurred()) + + err = xml.Unmarshal([]byte(vmiXml122), domStat122) + Expect(err).ToNot(HaveOccurred()) + + By("check XML") + + By("check XML - vmi121") + Expect(uint(domStat121.VCPU.CPUs) == 2).To(BeTrue()) + Expect(uint(domStat121.CPU.Topology.Sockets) == 2).To(BeTrue()) + Expect(uint(domStat121.CPU.Topology.Cores) == 1).To(BeTrue()) + Expect(uint(domStat121.CPU.Topology.Threads) == 1).To(BeTrue()) + + By("check XML - vmi122") + Expect(uint(domStat122.VCPU.CPUs) == 2).To(BeTrue()) + Expect(uint(domStat122.CPU.Topology.Sockets) == 2).To(BeTrue()) + Expect(uint(domStat122.CPU.Topology.Cores) == 1).To(BeTrue()) + Expect(uint(domStat122.CPU.Topology.Threads) == 1).To(BeTrue()) + + By("Clean old pods") + var cleanPods []*corev1.Pod + clean_pods(virtClient, cleanPods) + + }) + }) + + Context("test cases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + It("testcases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + + var wg sync.WaitGroup + vm_index := 0 + + for sockets := 0; sockets < 3; sockets++ { + for cores := 0; cores < 3; cores++ { + for threads := 0; threads < 3; threads++ { + + By("1.3 check resources in the cluster") + cpuNeeded := 1 + if sockets > 0 { + cpuNeeded *= sockets + } + if cores > 0 { + cpuNeeded *= cores + } + if threads > 0 { + cpuNeeded *= threads + } + const memNeeded int64 = 256 * 1024 * 1024 // 256mb is default in the template + + isAvailable := false + const maxWaitIterations = 15 // half of minute + var cpuLimit, memLimit int + var IsResourcesInCluster bool + for i := 0; i < maxWaitIterations; i++ { + IsResourcesInCluster, cpuLimit, memLimit = isEnoughResources(virtClient, cpuNeeded, memNeeded) + if IsResourcesInCluster { + isAvailable = true + break + } + time.Sleep(2 * time.Second) + } + //workaroud for current resources in CI + if cpuLimit >= 1 && memLimit >= 1 { + Expect(isAvailable).To(BeTrue(), "Cluster should have enough resources") + } else { + break + } + + vm_name := "vm13-" + strconv.Itoa(vm_index) + vm_index++ + + filename := getYAMLFilename(sockets, cores, threads, address_common) + arguments := getArguments(vm_name, sockets, cores, threads) + + virtRawVMFilePath := address_common + "/sockets_cores_threads_raw_manifest_" + vm_name + ".yaml" + tframework.ProcessTemplateWithParameters(filename, virtRawVMFilePath, arguments...) + + By("1.3 Starting gouroutine to create, start and test VM") + wg.Add(1) + //prevent server overloading - CI workaround (i/o error) + time.Sleep(15 * time.Second) + + go func(sockets int, cores int, threads int, wg *sync.WaitGroup) { + defer wg.Done() + By("1.3 Create VM from template and launch it") + + tframework.CreateResourceWithFilePathTestNamespace(virtRawVMFilePath) + _, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "virtctl", "start", vm_name) + Expect(err).ToNot(HaveOccurred()) + _, _, err = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "project", ktests.NamespaceTestDefault) + Expect(err).ToNot(HaveOccurred()) + + By("1.3 Getting VMI object") + getVMOptions := metav1.GetOptions{} + vmi, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vm_name, &getVMOptions) + Expect(err).ToNot(HaveOccurred()) + ktests.WaitForSuccessfulVMIStart(vmi) + + By("1.3 Checking that pod was created and has the right name") + vmiPod_vmNumName := ktests.GetRunningPodByVirtualMachineInstance(vmi, ktests.NamespaceTestDefault) + podName := vmiPod_vmNumName.Name + Expect(podName).To(HavePrefix("virt-launcher-"+vm_name), "Pod's name should contain name of the VM associated with it") + + By("1.3 Checking resources in the pod") + outPodYAML, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName, "-o", "yaml") + Expect(err).ToNot(HaveOccurred()) + cpuExist, _, _ := parseYAMLConfig(outPodYAML) + Expect(cpuExist).To(BeFalse(), "YAML should have CPUs") + + By("1.3 Get VMI XML") + vmiXml, err := ktests.GetRunningVirtualMachineInstanceDomainXML(virtClient, vmi) + Expect(err).ToNot(HaveOccurred()) + + By("1.3 VMI Unmarshal") + domStat := &api.DomainSpec{} + err = xml.Unmarshal([]byte(vmiXml), domStat) + Expect(err).ToNot(HaveOccurred()) + + XMLSockets := sockets + XMLCores := cores + XMLThreads := threads + // If CPU cores, sockets or threads set to 0, XML should have 1 for this parameter + if sockets == 0 { + XMLSockets = 1 + } + if cores == 0 { + XMLCores = 1 + } + if threads == 0 { + XMLThreads = 1 + } + + By("1.3 Checking XML topology") + Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") + Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") + Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") + + By("1.3 Checking the amount of vCPU") + vCPUAmount := XMLSockets * XMLCores * XMLThreads + Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") + + // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. + // Creating and destroying all these VMs second time may be unnecessary time consuming + // TODO: 2.1 & 2.2 - move it to independent test case? + + By("2.1 Expecting the VirtualMachineInstance console") + expecter, err := ktests.LoggedInCirrosExpecter(vmi) + Expect(err).ToNot(HaveOccurred(), "Console should be started") + defer expecter.Close() + + By("2.2 Checking the number of sockets in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLSockets)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") + + By("2.2 Checking the number of cores in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLCores)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of cores") + + By("2.2 Checking the number of threads in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLThreads)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of threads") + + By("Deleting VM") + _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) + Expect(err).ToNot(HaveOccurred()) + By("Deleting VM manifest") + err = os.Remove(virtRawVMFilePath) + Expect(err).ToNot(HaveOccurred()) + + }(sockets, cores, threads, &wg) + } + } + } + wg.Wait() + }) + }) + +}) + +// to force CI starts again - delete it From c19916a59d0c9218bd9b1461ec578c85eb7e8a84 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 22 Mar 2019 23:34:21 -0300 Subject: [PATCH 02/27] make generate --- tests/framework/util.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/framework/util.go b/tests/framework/util.go index f5ba8bda8..ae874070f 100644 --- a/tests/framework/util.go +++ b/tests/framework/util.go @@ -171,4 +171,3 @@ func GetAvailableResources(virtClient kubecli.KubevirtClient, cpuNeeded int64, m return availableVMs, cpu_limit_total, mem_limit_total } - From 5efea41ad52f4fe99926f9a9b1825adff986c0d2 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Sat, 23 Mar 2019 15:35:48 -0300 Subject: [PATCH 03/27] add resources --- playbooks/provider/lago/LagoInitFile.yml.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/provider/lago/LagoInitFile.yml.j2 b/playbooks/provider/lago/LagoInitFile.yml.j2 index d6fb07ac0..0ac3dc450 100644 --- a/playbooks/provider/lago/LagoInitFile.yml.j2 +++ b/playbooks/provider/lago/LagoInitFile.yml.j2 @@ -6,6 +6,7 @@ nat-settings: &nat-settings management: False vm-common-settings: &vm-common-settings + vCpu: 8 root-password: 123456 service_provider: systemd artifacts: From 2b56adf6a18b644013039e8334e7125ba2a655d3 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Thu, 28 Mar 2019 09:10:06 -0300 Subject: [PATCH 04/27] fix pod check & lukas suggestion regrding resources --- playbooks/provider/lago/LagoInitFile.yml.j2 | 3 ++- tests/sockets_cores_threads_test.go | 7 +------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/playbooks/provider/lago/LagoInitFile.yml.j2 b/playbooks/provider/lago/LagoInitFile.yml.j2 index 0ac3dc450..10280cbcb 100644 --- a/playbooks/provider/lago/LagoInitFile.yml.j2 +++ b/playbooks/provider/lago/LagoInitFile.yml.j2 @@ -6,7 +6,6 @@ nat-settings: &nat-settings management: False vm-common-settings: &vm-common-settings - vCpu: 8 root-password: 123456 service_provider: systemd artifacts: @@ -20,6 +19,7 @@ host-settings: &nodes-settings groups: [nodes] {% endif %} memory: 4096 + vcpu: 8 disks: - template_name: {{ lago_vm_image }} type: template @@ -50,6 +50,7 @@ domains: groups: [masters, nodes, etcd, nfs] {% endif %} memory: 4096 + vcpu: 8 nics: - ip: 192.168.200.2 net: lago-management-network diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index fc975647e..b269e8c39 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -187,17 +187,12 @@ var _ = Describe("Check CPU topology inside VM", func() { By("clean old pods") listOptions := metav1.ListOptions{} - podList, err := virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) var requiredPods []*corev1.Pod requiredPods = append(requiredPods, vmiPod) clean_pods(virtClient, requiredPods) - By("Checking that pod was created and has the right name") - listOptions = metav1.ListOptions{} - podList, err = virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) - Expect(err).ToNot(HaveOccurred()) By("Checking resources in the pod") - podName := podList.Items[0].Name + podName := vmiPod.Name outPodYAML, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName, "-o", "yaml") Expect(err).ToNot(HaveOccurred()) cpuExist, _, _ := parseYAMLConfig(outPodYAML) From caa422fbabb77e4af7a9f1ace685554547200673 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Thu, 28 Mar 2019 10:14:16 -0300 Subject: [PATCH 05/27] quick fix --- tests/sockets_cores_threads_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index b269e8c39..8addaa151 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -186,7 +186,6 @@ var _ = Describe("Check CPU topology inside VM", func() { vmiPod := ktests.GetRunningPodByVirtualMachineInstance(vmi, ktests.NamespaceTestDefault) By("clean old pods") - listOptions := metav1.ListOptions{} var requiredPods []*corev1.Pod requiredPods = append(requiredPods, vmiPod) clean_pods(virtClient, requiredPods) From 526eb00380407cafe2c48632a9898466be100f16 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Mon, 1 Apr 2019 09:38:29 -0300 Subject: [PATCH 06/27] revert changes in the framework --- tests/framework/types.go | 2 +- tests/framework/util.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/framework/types.go b/tests/framework/types.go index 25de507c4..2223fec1a 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -39,7 +39,7 @@ type VirtualMachine struct { func (vm VirtualMachine) Create() (string, string, error) { args := []string{"create", "-f", vm.Manifest} - return ktests.RunCommandWithNS(vm.Namespace, "oc", args...) + return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtOcPath, args...) } func (vm VirtualMachine) Start() (string, string, error) { diff --git a/tests/framework/util.go b/tests/framework/util.go index ae874070f..4935bf680 100644 --- a/tests/framework/util.go +++ b/tests/framework/util.go @@ -165,7 +165,6 @@ func GetAvailableResources(virtClient kubecli.KubevirtClient, cpuNeeded int64, m cpu_limit_total += cpu_limit mem_limit_total += mem_limit availableVMs += int(math.Min(float64(cpu_limit), float64(mem_limit))) - // availableVMs += min(cpu_limit, mem_limit) } } From bb1abe66a8fd9c842853f6be723ba1e4e8cd4efb Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Mon, 1 Apr 2019 11:38:49 -0300 Subject: [PATCH 07/27] fix issue in the CI --- tests/framework/types.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/framework/types.go b/tests/framework/types.go index 2223fec1a..887326631 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -23,6 +23,7 @@ const ( ShortTimeout = time.Duration(2) * time.Minute LongTimeout = time.Duration(4) * time.Minute + ocName = "oc" ) // VirtualMachine can be a vm, vmi, vmirs, vmiPreset. @@ -39,22 +40,22 @@ type VirtualMachine struct { func (vm VirtualMachine) Create() (string, string, error) { args := []string{"create", "-f", vm.Manifest} - return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtOcPath, args...) + return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) } func (vm VirtualMachine) Start() (string, string, error) { args := []string{"start", vm.Name} - return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtVirtctlPath, args...) + return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) } func (vm VirtualMachine) Stop() (string, string, error) { args := []string{"stop", vm.Name} - return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtVirtctlPath, args...) + return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) } func (vm VirtualMachine) Delete() (string, string, error) { args := []string{"delete", vm.Type, vm.Name} - return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtVirtctlPath, args...) + return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) } func (vm VirtualMachine) IsRunning() (bool, error) { @@ -73,7 +74,7 @@ func (vm VirtualMachine) IsRunning() (bool, error) { func (vm VirtualMachine) GetVMInfo(spec string) (string, string, error) { args := []string{"get", vm.Type, vm.Name, "--template", spec} - return ktests.RunCommandWithNS(vm.Namespace, ktests.KubeVirtOcPath, args...) + return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) } func (vm VirtualMachine) GetVMUID() (string, error) { @@ -100,7 +101,7 @@ func (vm VirtualMachine) ProcessTemplate() (string, error) { args = append(args, vm.TemplateParams...) - output, cmderr, err := ktests.RunCommandWithNS(NamespaceTestTemplate, ktests.KubeVirtOcPath, args...) + output, cmderr, err := ktests.RunCommandWithNS(NamespaceTestTemplate, ocName, args...) if err != nil { return "", err } From 7c35e1aa6104f1784f7b47c1858bd630d5d32713 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Wed, 3 Apr 2019 00:04:04 -0300 Subject: [PATCH 08/27] implement Lukas suggestions --- hack/run-tests.sh | 3 ++- tests/framework/types.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hack/run-tests.sh b/hack/run-tests.sh index 330c2d102..1381b74f3 100755 --- a/hack/run-tests.sh +++ b/hack/run-tests.sh @@ -7,8 +7,9 @@ source hack/common.sh prefix=${DOCKER_PREFIX:-kubevirt} tag=${DOCKER_TAG:-v0.13.3} kubeconfig=${KUBECONFIG:-~/.kube/config} +oc_in_framework="oc" [ -z "$OC_PATH" ] && OC_PATH=$(command -v oc) [ -z "$KUBECTL_PATH" ] && KUBECTL_PATH=$(which kubectl) [ -z "$VIRTCTL_PATH" ] && VIRTCTL_PATH=$(which virtctl) -${TESTS_OUT_DIR}/tests.test -kubeconfig=$kubeconfig -container-tag=$tag -container-prefix=$prefix -oc-path=${OC_PATH} -kubectl-path=${KUBECTL_PATH} -virtctl-path=${VIRTCTL_PATH} ${FUNC_TEST_ARGS} +OC_IN_FRAMEWORK=$oc_in_framework ${TESTS_OUT_DIR}/tests.test -kubeconfig=$kubeconfig -container-tag=$tag -container-prefix=$prefix -oc-path=${OC_PATH} -kubectl-path=${KUBECTL_PATH} -virtctl-path=${VIRTCTL_PATH} ${FUNC_TEST_ARGS} diff --git a/tests/framework/types.go b/tests/framework/types.go index 887326631..59e51a076 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "strings" "time" + "os" ktests "kubevirt.io/kubevirt/tests" ) @@ -23,7 +24,10 @@ const ( ShortTimeout = time.Duration(2) * time.Minute LongTimeout = time.Duration(4) * time.Minute - ocName = "oc" +) + +var ( + ocName = os.Getenv("OC_IN_FRAMEWORK") ) // VirtualMachine can be a vm, vmi, vmirs, vmiPreset. From 798397cc8a977e1a7de6b4cb389d92fafd6dbbc5 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Wed, 3 Apr 2019 01:34:17 -0300 Subject: [PATCH 09/27] add test ids --- tests/sockets_cores_threads_test.go | 83 +++++++++++++++-------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 8addaa151..4034c9342 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -153,7 +153,7 @@ func clean_pods(virtClient kubecli.KubevirtClient, requiredPods []*corev1.Pod) { } } -var _ = Describe("Check CPU topology inside VM", func() { +var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:component]Check CPU topology inside VM", func() { flag.Parse() virtClient, err := kubecli.GetKubevirtClient() ktests.PanicOnError(err) @@ -164,8 +164,8 @@ var _ = Describe("Check CPU topology inside VM", func() { }) Context("test case 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { - It("testcase 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { - + It("[test_id:1485] testcase 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + //It("Pre-checks"",func() { vmi11.Manifest = address_common + "vmi-case1.1.yml" vmi11.Namespace = ktests.NamespaceTestDefault @@ -217,7 +217,7 @@ var _ = Describe("Check CPU topology inside VM", func() { }) Context("test case 1.2 Check the validity of the XML file if user didn’t set the CPU topology (only standard cpus - previous releases like) ", func() { - It("testcase 1.2 Check the validity of the XML file if user didn’t set the CPU topology (only standard cpus - previous releases like) ", func() { + It("[test_id:1487]testcase 1.2 Check the validity of the XML file if user didn’t set the CPU topology (only standard cpus - previous releases like) ", func() { By("declare variables") vmi121.Manifest = address_common + "/vmi-case1.2.1.yml" @@ -332,14 +332,13 @@ var _ = Describe("Check CPU topology inside VM", func() { Context("test cases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { It("testcases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { - var wg sync.WaitGroup vm_index := 0 for sockets := 0; sockets < 3; sockets++ { for cores := 0; cores < 3; cores++ { for threads := 0; threads < 3; threads++ { - + By("1.3 check resources in the cluster") cpuNeeded := 1 if sockets > 0 { @@ -436,45 +435,51 @@ var _ = Describe("Check CPU topology inside VM", func() { XMLThreads = 1 } - By("1.3 Checking XML topology") - Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") - Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") - Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") + It("[test_id:1488] Test case 1.3", func() { + By("1.3 Checking XML topology") + Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") + Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") + Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") - By("1.3 Checking the amount of vCPU") - vCPUAmount := XMLSockets * XMLCores * XMLThreads - Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") + By("1.3 Checking the amount of vCPU") + vCPUAmount := XMLSockets * XMLCores * XMLThreads + Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") - // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. - // Creating and destroying all these VMs second time may be unnecessary time consuming - // TODO: 2.1 & 2.2 - move it to independent test case? + // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. + // Creating and destroying all these VMs second time may be unnecessary time consuming - By("2.1 Expecting the VirtualMachineInstance console") + }) + + By("2.1 Expecting the VirtualMachineInstance console") expecter, err := ktests.LoggedInCirrosExpecter(vmi) - Expect(err).ToNot(HaveOccurred(), "Console should be started") + It("[test_id:1489] Test case 2.1", func() { + Expect(err).ToNot(HaveOccurred(), "Console should be started") + }) defer expecter.Close() - By("2.2 Checking the number of sockets in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLSockets)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") - - By("2.2 Checking the number of cores in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLCores)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of cores") - - By("2.2 Checking the number of threads in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLThreads)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of threads") - + It("[test_id:1490] Test case 2.1", func() { + By("2.2 Checking the number of sockets in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLSockets)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") + + By("2.2 Checking the number of cores in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLCores)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of cores") + + By("2.2 Checking the number of threads in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLThreads)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of threads") + }) + By("Deleting VM") _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) Expect(err).ToNot(HaveOccurred()) From a8a687992432dfd4f70269f8e7c28e8f41b614d2 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Wed, 3 Apr 2019 10:00:53 -0300 Subject: [PATCH 10/27] make generate --- tests/framework/types.go | 2 +- tests/sockets_cores_threads_test.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/framework/types.go b/tests/framework/types.go index 59e51a076..148ff24bc 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -3,9 +3,9 @@ package framework import ( "errors" "io/ioutil" + "os" "strings" "time" - "os" ktests "kubevirt.io/kubevirt/tests" ) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 4034c9342..d96c8e65c 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -165,7 +165,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp Context("test case 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { It("[test_id:1485] testcase 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { - //It("Pre-checks"",func() { + //It("Pre-checks"",func() { vmi11.Manifest = address_common + "vmi-case1.1.yml" vmi11.Namespace = ktests.NamespaceTestDefault @@ -338,7 +338,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp for sockets := 0; sockets < 3; sockets++ { for cores := 0; cores < 3; cores++ { for threads := 0; threads < 3; threads++ { - + By("1.3 check resources in the cluster") cpuNeeded := 1 if sockets > 0 { @@ -435,7 +435,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp XMLThreads = 1 } - It("[test_id:1488] Test case 1.3", func() { + It("[test_id:1488] Test case 1.3", func() { By("1.3 Checking XML topology") Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") @@ -450,7 +450,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp }) - By("2.1 Expecting the VirtualMachineInstance console") + By("2.1 Expecting the VirtualMachineInstance console") expecter, err := ktests.LoggedInCirrosExpecter(vmi) It("[test_id:1489] Test case 2.1", func() { Expect(err).ToNot(HaveOccurred(), "Console should be started") @@ -464,14 +464,14 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp &expect.BExp{R: strconv.Itoa(XMLSockets)}, }, 60*time.Second) Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") - + By("2.2 Checking the number of cores in guest OS") _, err = expecter.ExpectBatch([]expect.Batcher{ &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, &expect.BExp{R: strconv.Itoa(XMLCores)}, }, 60*time.Second) Expect(err).ToNot(HaveOccurred(), "Should report number of cores") - + By("2.2 Checking the number of threads in guest OS") _, err = expecter.ExpectBatch([]expect.Batcher{ &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, @@ -479,7 +479,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp }, 60*time.Second) Expect(err).ToNot(HaveOccurred(), "Should report number of threads") }) - + By("Deleting VM") _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) Expect(err).ToNot(HaveOccurred()) From 1250e81430ccc95da315b178f633821fda5acf56 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Wed, 3 Apr 2019 22:01:17 -0300 Subject: [PATCH 11/27] add test ids --- tests/sockets_cores_threads_test.go | 91 ++++++++++++++++------------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index d96c8e65c..72cbc29b1 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -130,6 +130,25 @@ func getArguments(vm_name string, sockets int, cores int, threads int) []string return arguments } +func error_helper(err error) bool { + if err == nil { + return false + } else { + return true + } +} + + +//Workaround cause gomega doesn't support It() outside Context. +func panic_if_false(boolvar bool,panicText string) { + if boolvar == false { + fmt.Println("Panicking cause: " + panicText) + panic("panic!") + + } + +} + func clean_pods(virtClient kubecli.KubevirtClient, requiredPods []*corev1.Pod) { listOptions := metav1.ListOptions{} podList, err := virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) @@ -331,7 +350,8 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp }) Context("test cases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { - It("testcases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + It("[test_id:1488] [test_id:1490] [test_id:1489] [test_id:1488] testcases 1.3,2.1,2.2 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { + var wg sync.WaitGroup vm_index := 0 @@ -435,50 +455,44 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp XMLThreads = 1 } - It("[test_id:1488] Test case 1.3", func() { - By("1.3 Checking XML topology") - Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") - Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") - Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") - - By("1.3 Checking the amount of vCPU") - vCPUAmount := XMLSockets * XMLCores * XMLThreads - Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") + By("1.3 Checking XML topology") + Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") + Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") + Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") - // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. - // Creating and destroying all these VMs second time may be unnecessary time consuming + By("1.3 Checking the amount of vCPU") + vCPUAmount := XMLSockets * XMLCores * XMLThreads + Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") - }) + // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. + // Creating and destroying all these VMs second time may be unnecessary time consuming + // TODO: 2.1 & 2.2 - move it to independent test case? By("2.1 Expecting the VirtualMachineInstance console") expecter, err := ktests.LoggedInCirrosExpecter(vmi) - It("[test_id:1489] Test case 2.1", func() { - Expect(err).ToNot(HaveOccurred(), "Console should be started") - }) + Expect(err).ToNot(HaveOccurred(), "Console should be started") defer expecter.Close() - It("[test_id:1490] Test case 2.1", func() { - By("2.2 Checking the number of sockets in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLSockets)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") - - By("2.2 Checking the number of cores in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLCores)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of cores") - - By("2.2 Checking the number of threads in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLThreads)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of threads") - }) + By("2.2 Checking the number of sockets in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLSockets)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") + + By("2.2 Checking the number of cores in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLCores)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of cores") + + By("2.2 Checking the number of threads in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLThreads)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of threads") By("Deleting VM") _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) @@ -497,4 +511,3 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp }) -// to force CI starts again - delete it From be496ee89da9f861d528f38bfc680f48df0e0b0c Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Wed, 3 Apr 2019 22:07:16 -0300 Subject: [PATCH 12/27] make generate & delete not-used functions --- tests/sockets_cores_threads_test.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 72cbc29b1..8af57b30d 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -130,25 +130,6 @@ func getArguments(vm_name string, sockets int, cores int, threads int) []string return arguments } -func error_helper(err error) bool { - if err == nil { - return false - } else { - return true - } -} - - -//Workaround cause gomega doesn't support It() outside Context. -func panic_if_false(boolvar bool,panicText string) { - if boolvar == false { - fmt.Println("Panicking cause: " + panicText) - panic("panic!") - - } - -} - func clean_pods(virtClient kubecli.KubevirtClient, requiredPods []*corev1.Pod) { listOptions := metav1.ListOptions{} podList, err := virtClient.CoreV1().Pods(ktests.NamespaceTestDefault).List(listOptions) @@ -510,4 +491,3 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp }) }) - From c47e1d1a5dcf0cae60fee9838213c6f6fbce329d Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Thu, 11 Apr 2019 03:36:07 -0300 Subject: [PATCH 13/27] implement suggestions --- hack/run-tests.sh | 3 ++- tests/framework/types.go | 5 +++-- ...-cirros-no-sockets-cores-and-threads.yaml} | 14 ++++++------ ...mplate-cirros-only-cores-and-threads.yaml} | 14 ++++++------ ...aml => vm-template-cirros-only-cores.yaml} | 14 ++++++------ ...mplate-cirros-only-sockets-and-cores.yaml} | 14 ++++++------ ...late-cirros-only-sockets-and-threads.yaml} | 14 ++++++------ ...l => vm-template-cirros-only-sockets.yaml} | 14 ++++++------ ...l => vm-template-cirros-only-threads.yaml} | 14 ++++++------ ...ate-cirros-sockets-cores-and-threads.yaml} | 14 ++++++------ tests/sockets_cores_threads_test.go | 22 +++++++++---------- 11 files changed, 72 insertions(+), 70 deletions(-) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-no-sockets-cores-and-threads.yaml => vm-template-cirros-no-sockets-cores-and-threads.yaml} (83%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-only-cores-and-threads.yaml => vm-template-cirros-only-cores-and-threads.yaml} (85%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-only-cores.yaml => vm-template-cirros-only-cores.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-only-sockets-and-cores.yaml => vm-template-cirros-only-sockets-and-cores.yaml} (85%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-only-sockets-and-threads.yaml => vm-template-cirros-only-sockets-and-threads.yaml} (85%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-only-sockets.yaml => vm-template-cirros-only-sockets.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-only-threads.yaml => vm-template-cirros-only-threads.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-fedora-sockets-cores-and-threads.yaml => vm-template-cirros-sockets-cores-and-threads.yaml} (86%) diff --git a/hack/run-tests.sh b/hack/run-tests.sh index 1381b74f3..352f90614 100755 --- a/hack/run-tests.sh +++ b/hack/run-tests.sh @@ -8,8 +8,9 @@ prefix=${DOCKER_PREFIX:-kubevirt} tag=${DOCKER_TAG:-v0.13.3} kubeconfig=${KUBECONFIG:-~/.kube/config} oc_in_framework="oc" +virtctl_in_framework="virtctl" [ -z "$OC_PATH" ] && OC_PATH=$(command -v oc) [ -z "$KUBECTL_PATH" ] && KUBECTL_PATH=$(which kubectl) [ -z "$VIRTCTL_PATH" ] && VIRTCTL_PATH=$(which virtctl) -OC_IN_FRAMEWORK=$oc_in_framework ${TESTS_OUT_DIR}/tests.test -kubeconfig=$kubeconfig -container-tag=$tag -container-prefix=$prefix -oc-path=${OC_PATH} -kubectl-path=${KUBECTL_PATH} -virtctl-path=${VIRTCTL_PATH} ${FUNC_TEST_ARGS} +OC_IN_FRAMEWORK=$oc_in_framework VIRTCTL_IN_FRAMEWORK=$virtctl_in_framework ${TESTS_OUT_DIR}/tests.test -kubeconfig=$kubeconfig -container-tag=$tag -container-prefix=$prefix -oc-path=${OC_PATH} -kubectl-path=${KUBECTL_PATH} -virtctl-path=${VIRTCTL_PATH} ${FUNC_TEST_ARGS} diff --git a/tests/framework/types.go b/tests/framework/types.go index 148ff24bc..a3184926d 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -28,6 +28,7 @@ const ( var ( ocName = os.Getenv("OC_IN_FRAMEWORK") + virtctlName = os.Getenv("VIRTCTL_IN_FRAMEWORK") ) // VirtualMachine can be a vm, vmi, vmirs, vmiPreset. @@ -49,12 +50,12 @@ func (vm VirtualMachine) Create() (string, string, error) { func (vm VirtualMachine) Start() (string, string, error) { args := []string{"start", vm.Name} - return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) + return ktests.RunCommandWithNS(vm.Namespace,virtctlName, args...) } func (vm VirtualMachine) Stop() (string, string, error) { args := []string{"stop", vm.Name} - return ktests.RunCommandWithNS(vm.Namespace, ocName, args...) + return ktests.RunCommandWithNS(vm.Namespace, virtctlName, args...) } func (vm VirtualMachine) Delete() (string, string, error) { diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-no-sockets-cores-and-threads.yaml similarity index 83% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-no-sockets-cores-and-threads.yaml index e4b6bcdd5..65968feaf 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-no-sockets-cores-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: devices: @@ -45,7 +45,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores-and-threads.yaml similarity index 85% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores-and-threads.yaml index b931f97c8..c7a0c257a 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -48,7 +48,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores.yaml index 7e8c165b4..0799ebeac 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -47,7 +47,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-cores.yaml similarity index 85% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-cores.yaml index 160102617..4320f1357 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-cores.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -48,7 +48,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-threads.yaml similarity index 85% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-threads.yaml index 2df740549..ba201b24b 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -48,7 +48,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets.yaml index e9675ca6e..820f40dc4 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -47,7 +47,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-threads.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-only-threads.yaml index d426ce85d..0af8c38e6 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-only-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -47,7 +47,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-cirros-sockets-cores-and-threads.yaml similarity index 86% rename from tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-cirros-sockets-cores-and-threads.yaml index b1b25d730..d6343d2e1 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-cirros-sockets-cores-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: OCP KubeVirt Fedora 27 VM template - iconClass: icon-fedora + description: KubeVirt test template + iconClass: icon-cirros tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-fedora + name: vm-template-cirros objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: fedora27 + kubevirt.io/os: cirros spec: domain: cpu: @@ -49,7 +49,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-registry-disk-demo + image: kubevirt/cirros-container-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 8af57b30d..5da014540 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -86,14 +86,14 @@ func isEnoughResources(virtClient kubecli.KubevirtClient, cpuNeeded int, memNeed func getYAMLFilename(sockets, cores, threads int, address_common string) string { // 0 means parameter set to 0, 1 means parameter set to non-zero var file_name [2][2][2]string - file_name[0][0][0] = "vm-template-fedora-no-sockets-cores-and-threads.yaml" - file_name[1][0][0] = "vm-template-fedora-only-sockets.yaml" - file_name[0][1][0] = "vm-template-fedora-only-cores.yaml" - file_name[0][0][1] = "vm-template-fedora-only-threads.yaml" - file_name[0][1][1] = "vm-template-fedora-only-cores-and-threads.yaml" - file_name[1][0][1] = "vm-template-fedora-only-sockets-and-threads.yaml" - file_name[1][1][0] = "vm-template-fedora-only-sockets-and-cores.yaml" - file_name[1][1][1] = "vm-template-fedora-sockets-cores-and-threads.yaml" + file_name[0][0][0] = "vm-template-cirros-no-sockets-cores-and-threads.yaml" + file_name[1][0][0] = "vm-template-cirros-only-sockets.yaml" + file_name[0][1][0] = "vm-template-cirros-only-cores.yaml" + file_name[0][0][1] = "vm-template-cirros-only-threads.yaml" + file_name[0][1][1] = "vm-template-cirros-only-cores-and-threads.yaml" + file_name[1][0][1] = "vm-template-cirros-only-sockets-and-threads.yaml" + file_name[1][1][0] = "vm-template-cirros-only-sockets-and-cores.yaml" + file_name[1][1][1] = "vm-template-cirros-sockets-cores-and-threads.yaml" // Because go doesn't have ternary operators s := 0 @@ -384,7 +384,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp By("1.3 Starting gouroutine to create, start and test VM") wg.Add(1) //prevent server overloading - CI workaround (i/o error) - time.Sleep(15 * time.Second) + time.Sleep(10 * time.Second) go func(sockets int, cores int, threads int, wg *sync.WaitGroup) { defer wg.Done() @@ -461,7 +461,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp }, 60*time.Second) Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") - By("2.2 Checking the number of cores in guest OS") + /*By("2.2 Checking the number of cores in guest OS") _, err = expecter.ExpectBatch([]expect.Batcher{ &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, &expect.BExp{R: strconv.Itoa(XMLCores)}, @@ -473,7 +473,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, &expect.BExp{R: strconv.Itoa(XMLThreads)}, }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of threads") + Expect(err).ToNot(HaveOccurred(), "Should report number of threads")*/ By("Deleting VM") _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) From 271be9c3079487546d8324e49af789a640d1f5d5 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Thu, 11 Apr 2019 10:24:43 -0300 Subject: [PATCH 14/27] make generate --- tests/framework/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/framework/types.go b/tests/framework/types.go index a3184926d..7f893c364 100644 --- a/tests/framework/types.go +++ b/tests/framework/types.go @@ -27,7 +27,7 @@ const ( ) var ( - ocName = os.Getenv("OC_IN_FRAMEWORK") + ocName = os.Getenv("OC_IN_FRAMEWORK") virtctlName = os.Getenv("VIRTCTL_IN_FRAMEWORK") ) @@ -50,7 +50,7 @@ func (vm VirtualMachine) Create() (string, string, error) { func (vm VirtualMachine) Start() (string, string, error) { args := []string{"start", vm.Name} - return ktests.RunCommandWithNS(vm.Namespace,virtctlName, args...) + return ktests.RunCommandWithNS(vm.Namespace, virtctlName, args...) } func (vm VirtualMachine) Stop() (string, string, error) { From 1889302ec2ae37a9366409f64bd2a752369d7752 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Thu, 18 Apr 2019 21:59:57 -0300 Subject: [PATCH 15/27] implement Vadik suggestions --- tests/sockets_cores_threads_test.go | 206 ++++++++++++++-------------- 1 file changed, 106 insertions(+), 100 deletions(-) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 5da014540..394dc16d9 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -336,6 +336,108 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp var wg sync.WaitGroup vm_index := 0 + By("Declare goroutine function") + runVM := func(socketsN int, coresN int, threadsN int, wg *sync.WaitGroup, virtRawVMFilePath string, vm_name string) { + By("1.3 Starting gouroutine to create, start and test VM") + wg.Add(1) + defer wg.Done() + By("1.3 Create VM from template and launch it") + tframework.CreateResourceWithFilePathTestNamespace(virtRawVMFilePath) + _, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "virtctl", "start", vm_name) + Expect(err).ToNot(HaveOccurred()) + _, _, err = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "project", ktests.NamespaceTestDefault) + Expect(err).ToNot(HaveOccurred()) + + By("1.3 Getting VMI object") + getVMOptions := metav1.GetOptions{} + vmi, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vm_name, &getVMOptions) + Expect(err).ToNot(HaveOccurred()) + ktests.WaitForSuccessfulVMIStart(vmi) + + By("1.3 Checking that pod was created and has the right name") + vmiPod_vmNumName := ktests.GetRunningPodByVirtualMachineInstance(vmi, ktests.NamespaceTestDefault) + podName := vmiPod_vmNumName.Name + Expect(podName).To(HavePrefix("virt-launcher-"+vm_name), "Pod's name should contain name of the VM associated with it") + + By("1.3 Checking resources in the pod") + outPodYAML, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName, "-o", "yaml") + Expect(err).ToNot(HaveOccurred()) + cpuExist, _, _ := parseYAMLConfig(outPodYAML) + Expect(cpuExist).To(BeFalse(), "YAML should have CPUs") + + By("1.3 Get VMI XML") + vmiXml, err := ktests.GetRunningVirtualMachineInstanceDomainXML(virtClient, vmi) + Expect(err).ToNot(HaveOccurred()) + + By("1.3 VMI Unmarshal") + domStat := &api.DomainSpec{} + err = xml.Unmarshal([]byte(vmiXml), domStat) + Expect(err).ToNot(HaveOccurred()) + + XMLSockets := socketsN + XMLCores := coresN + XMLThreads := threadsN + // If CPU cores, sockets or threads set to 0, XML should have 1 for this parameter + if socketsN == 0 { + XMLSockets = 1 + } + + if coresN == 0 { + XMLCores = 1 + } + + if threadsN == 0 { + XMLThreads = 1 + } + + By("1.3 Checking XML topology") + Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") + Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") + Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") + + By("1.3 Checking the amount of vCPU") + vCPUAmount := XMLSockets * XMLCores * XMLThreads + Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") + + // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. + // Creating and destroying all these VMs second time may be unnecessary time consuming + // TODO: 2.1 & 2.2 - move it to independent test case? + + By("2.1 Expecting the VirtualMachineInstance console") + expecter, err := ktests.LoggedInCirrosExpecter(vmi) + Expect(err).ToNot(HaveOccurred(), "Console should be started") + defer expecter.Close() + + By("2.2 Checking the number of sockets in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLSockets)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") + + By("2.2 Checking the number of cores in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLCores)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of cores") + + By("2.2 Checking the number of threads in guest OS") + _, err = expecter.ExpectBatch([]expect.Batcher{ + &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, + &expect.BExp{R: strconv.Itoa(XMLThreads)}, + }, 60*time.Second) + Expect(err).ToNot(HaveOccurred(), "Should report number of threads") + + By("Deleting VM") + _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) + Expect(err).ToNot(HaveOccurred()) + By("Deleting VM manifest") + err = os.Remove(virtRawVMFilePath) + Expect(err).ToNot(HaveOccurred()) + } + + By("main cycle") for sockets := 0; sockets < 3; sockets++ { for cores := 0; cores < 3; cores++ { for threads := 0; threads < 3; threads++ { @@ -381,108 +483,12 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp virtRawVMFilePath := address_common + "/sockets_cores_threads_raw_manifest_" + vm_name + ".yaml" tframework.ProcessTemplateWithParameters(filename, virtRawVMFilePath, arguments...) - By("1.3 Starting gouroutine to create, start and test VM") - wg.Add(1) //prevent server overloading - CI workaround (i/o error) - time.Sleep(10 * time.Second) - - go func(sockets int, cores int, threads int, wg *sync.WaitGroup) { - defer wg.Done() - By("1.3 Create VM from template and launch it") - - tframework.CreateResourceWithFilePathTestNamespace(virtRawVMFilePath) - _, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "virtctl", "start", vm_name) - Expect(err).ToNot(HaveOccurred()) - _, _, err = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "project", ktests.NamespaceTestDefault) - Expect(err).ToNot(HaveOccurred()) - - By("1.3 Getting VMI object") - getVMOptions := metav1.GetOptions{} - vmi, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vm_name, &getVMOptions) - Expect(err).ToNot(HaveOccurred()) - ktests.WaitForSuccessfulVMIStart(vmi) - - By("1.3 Checking that pod was created and has the right name") - vmiPod_vmNumName := ktests.GetRunningPodByVirtualMachineInstance(vmi, ktests.NamespaceTestDefault) - podName := vmiPod_vmNumName.Name - Expect(podName).To(HavePrefix("virt-launcher-"+vm_name), "Pod's name should contain name of the VM associated with it") - - By("1.3 Checking resources in the pod") - outPodYAML, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "get", "pod", podName, "-o", "yaml") - Expect(err).ToNot(HaveOccurred()) - cpuExist, _, _ := parseYAMLConfig(outPodYAML) - Expect(cpuExist).To(BeFalse(), "YAML should have CPUs") - - By("1.3 Get VMI XML") - vmiXml, err := ktests.GetRunningVirtualMachineInstanceDomainXML(virtClient, vmi) - Expect(err).ToNot(HaveOccurred()) - - By("1.3 VMI Unmarshal") - domStat := &api.DomainSpec{} - err = xml.Unmarshal([]byte(vmiXml), domStat) - Expect(err).ToNot(HaveOccurred()) - - XMLSockets := sockets - XMLCores := cores - XMLThreads := threads - // If CPU cores, sockets or threads set to 0, XML should have 1 for this parameter - if sockets == 0 { - XMLSockets = 1 - } - if cores == 0 { - XMLCores = 1 - } - if threads == 0 { - XMLThreads = 1 - } - - By("1.3 Checking XML topology") - Expect(int(domStat.CPU.Topology.Sockets) == XMLSockets).To(BeTrue(), "XML should have right number of sockets") - Expect(int(domStat.CPU.Topology.Cores) == XMLCores).To(BeTrue(), "XML should have right number of cores") - Expect(int(domStat.CPU.Topology.Threads) == XMLThreads).To(BeTrue(), "XML should have right number of threads") - - By("1.3 Checking the amount of vCPU") - vCPUAmount := XMLSockets * XMLCores * XMLThreads - Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") - - // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. - // Creating and destroying all these VMs second time may be unnecessary time consuming - // TODO: 2.1 & 2.2 - move it to independent test case? + time.Sleep(5 * time.Second) + By("launch goroutine") + go runVM(sockets, cores, threads, &wg, virtRawVMFilePath, vm_name) + - By("2.1 Expecting the VirtualMachineInstance console") - expecter, err := ktests.LoggedInCirrosExpecter(vmi) - Expect(err).ToNot(HaveOccurred(), "Console should be started") - defer expecter.Close() - - By("2.2 Checking the number of sockets in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Socket | awk '{print $2}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLSockets)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") - - /*By("2.2 Checking the number of cores in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLCores)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of cores") - - By("2.2 Checking the number of threads in guest OS") - _, err = expecter.ExpectBatch([]expect.Batcher{ - &expect.BSnd{S: "lscpu | grep Thread | awk '{print $4}'\n"}, - &expect.BExp{R: strconv.Itoa(XMLThreads)}, - }, 60*time.Second) - Expect(err).ToNot(HaveOccurred(), "Should report number of threads")*/ - - By("Deleting VM") - _, _, _ = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "delete", "vm", vm_name) - Expect(err).ToNot(HaveOccurred()) - By("Deleting VM manifest") - err = os.Remove(virtRawVMFilePath) - Expect(err).ToNot(HaveOccurred()) - - }(sockets, cores, threads, &wg) } } } From 2f88cbfe78a4a59f6fb4957c6cc61b947eccb753 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Thu, 25 Apr 2019 02:10:18 -0300 Subject: [PATCH 16/27] revert bad commit --- ...-fedora-no-sockets-cores-and-threads.yaml} | 14 +++++----- ...mplate-fedora-only-cores-and-threads.yaml} | 14 +++++----- ...aml => vm-template-fedora-only-cores.yaml} | 14 +++++----- ...mplate-fedora-only-sockets-and-cores.yaml} | 14 +++++----- ...late-fedora-only-sockets-and-threads.yaml} | 14 +++++----- ...l => vm-template-fedora-only-sockets.yaml} | 14 +++++----- ...l => vm-template-fedora-only-threads.yaml} | 14 +++++----- ...ate-fedora-sockets-cores-and-threads.yaml} | 14 +++++----- tests/sockets_cores_threads_test.go | 26 +++++++++---------- 9 files changed, 69 insertions(+), 69 deletions(-) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-no-sockets-cores-and-threads.yaml => vm-template-fedora-no-sockets-cores-and-threads.yaml} (82%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-only-cores-and-threads.yaml => vm-template-fedora-only-cores-and-threads.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-only-cores.yaml => vm-template-fedora-only-cores.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-only-sockets-and-cores.yaml => vm-template-fedora-only-sockets-and-cores.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-only-sockets-and-threads.yaml => vm-template-fedora-only-sockets-and-threads.yaml} (85%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-only-sockets.yaml => vm-template-fedora-only-sockets.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-only-threads.yaml => vm-template-fedora-only-threads.yaml} (84%) rename tests/manifests/sockets_cores_threads/{vm-template-cirros-sockets-cores-and-threads.yaml => vm-template-fedora-sockets-cores-and-threads.yaml} (85%) diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-no-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml similarity index 82% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-no-sockets-cores-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml index 65968feaf..f67590d36 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-no-sockets-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: devices: @@ -45,7 +45,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml index c7a0c257a..d0d871d51 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -48,7 +48,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml index 0799ebeac..7c11fade2 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-cores.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -47,7 +47,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-cores.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml index 4320f1357..f96d68e2f 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-cores.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -48,7 +48,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml similarity index 85% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml index ba201b24b..decafc27b 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -48,7 +48,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml index 820f40dc4..1d75c23c6 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-sockets.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -47,7 +47,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml similarity index 84% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-only-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml index 0af8c38e6..6363d966d 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-only-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -47,7 +47,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/manifests/sockets_cores_threads/vm-template-cirros-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml similarity index 85% rename from tests/manifests/sockets_cores_threads/vm-template-cirros-sockets-cores-and-threads.yaml rename to tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml index d6343d2e1..d742c8312 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-cirros-sockets-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml @@ -3,13 +3,13 @@ apiVersion: v1 kind: Template metadata: annotations: - description: KubeVirt test template - iconClass: icon-cirros + description: OCP KubeVirt Fedora 27 VM template + iconClass: icon-fedora tags: kubevirt,ocp,template,linux,virtualmachine labels: - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 miq.github.io/kubevirt-is-vm-template: "true" - name: vm-template-cirros + name: vm-template-fedora objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine @@ -17,7 +17,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 name: ${NAME} spec: running: false @@ -26,7 +26,7 @@ objects: creationTimestamp: null labels: kubevirt-vm: vm-${NAME} - kubevirt.io/os: cirros + kubevirt.io/os: fedora27 spec: domain: cpu: @@ -49,7 +49,7 @@ objects: terminationGracePeriodSeconds: 0 volumes: - containerDisk: - image: kubevirt/cirros-container-disk-demo + image: kubevirt/fedora-cloud-registry-disk-demo name: registryvolume - cloudInitNoCloud: userData: |- diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 394dc16d9..800a9b68f 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -86,14 +86,15 @@ func isEnoughResources(virtClient kubecli.KubevirtClient, cpuNeeded int, memNeed func getYAMLFilename(sockets, cores, threads int, address_common string) string { // 0 means parameter set to 0, 1 means parameter set to non-zero var file_name [2][2][2]string - file_name[0][0][0] = "vm-template-cirros-no-sockets-cores-and-threads.yaml" - file_name[1][0][0] = "vm-template-cirros-only-sockets.yaml" - file_name[0][1][0] = "vm-template-cirros-only-cores.yaml" - file_name[0][0][1] = "vm-template-cirros-only-threads.yaml" - file_name[0][1][1] = "vm-template-cirros-only-cores-and-threads.yaml" - file_name[1][0][1] = "vm-template-cirros-only-sockets-and-threads.yaml" - file_name[1][1][0] = "vm-template-cirros-only-sockets-and-cores.yaml" - file_name[1][1][1] = "vm-template-cirros-sockets-cores-and-threads.yaml" + + file_name[0][0][0] = "vm-template-fedora-no-sockets-cores-and-threads.yaml" + file_name[1][0][0] = "vm-template-fedora-only-sockets.yaml" + file_name[0][1][0] = "vm-template-fedora-only-cores.yaml" + file_name[0][0][1] = "vm-template-fedora-only-threads.yaml" + file_name[0][1][1] = "vm-template-fedora-only-cores-and-threads.yaml" + file_name[1][0][1] = "vm-template-fedora-only-sockets-and-threads.yaml" + file_name[1][1][0] = "vm-template-fedora-only-sockets-and-cores.yaml" + file_name[1][1][1] = "vm-template-fedora-sockets-cores-and-threads.yaml" // Because go doesn't have ternary operators s := 0 @@ -399,9 +400,9 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp vCPUAmount := XMLSockets * XMLCores * XMLThreads Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") - // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. - // Creating and destroying all these VMs second time may be unnecessary time consuming - // TODO: 2.1 & 2.2 - move it to independent test case? + // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. + // Creating and destroying all these VMs second time may be unnecessary time consuming + // TODO: 2.1 & 2.2 - move it to independent test case? By("2.1 Expecting the VirtualMachineInstance console") expecter, err := ktests.LoggedInCirrosExpecter(vmi) @@ -414,7 +415,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp &expect.BExp{R: strconv.Itoa(XMLSockets)}, }, 60*time.Second) Expect(err).ToNot(HaveOccurred(), "Should report number of sockets") - + By("2.2 Checking the number of cores in guest OS") _, err = expecter.ExpectBatch([]expect.Batcher{ &expect.BSnd{S: "lscpu | grep Core | awk '{print $4}'\n"}, @@ -487,7 +488,6 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp time.Sleep(5 * time.Second) By("launch goroutine") go runVM(sockets, cores, threads, &wg, virtRawVMFilePath, vm_name) - } } From 8fd71c09d136e33727ca59ecbaf3769913c06b3b Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Tue, 14 May 2019 00:10:07 -0300 Subject: [PATCH 17/27] fix goroutine issue(timeout deleted from code); fix Fedora/cirrous bug; minor improvements --- tests/framework/util.go | 22 +++++- tests/framework/vnc_console.go | 13 +++- ...e-fedora-no-sockets-cores-and-threads.yaml | 2 - ...emplate-fedora-only-cores-and-threads.yaml | 2 - .../vm-template-fedora-only-cores.yaml | 2 - ...emplate-fedora-only-sockets-and-cores.yaml | 2 - ...plate-fedora-only-sockets-and-threads.yaml | 2 - .../vm-template-fedora-only-sockets.yaml | 2 - .../vm-template-fedora-only-threads.yaml | 2 - ...late-fedora-sockets-cores-and-threads.yaml | 2 - tests/sockets_cores_threads_test.go | 76 ++++++++----------- 11 files changed, 60 insertions(+), 67 deletions(-) diff --git a/tests/framework/util.go b/tests/framework/util.go index 4935bf680..7fc39c8c7 100644 --- a/tests/framework/util.go +++ b/tests/framework/util.go @@ -150,9 +150,9 @@ func RemoveDataVolume(dvName string, namespace string) { Expect(err).ToNot(HaveOccurred()) } -func GetAvailableResources(virtClient kubecli.KubevirtClient, cpuNeeded int64, memNeeded int64) (int, int, int) { +func GetAvailableResources(virtClient kubecli.KubevirtClient, cpuNeeded int64, memNeeded int64) (int, int) { nodeList := ktests.GetAllSchedulableNodes(virtClient) - availableVMs, cpu_limit_total, mem_limit_total := 0, 0, 0 + cpu_limit_total, mem_limit_total := 0, 0 for _, node := range nodeList.Items { cpu := node.Status.Allocatable["cpu"] @@ -164,9 +164,23 @@ func GetAvailableResources(virtClient kubecli.KubevirtClient, cpuNeeded int64, m mem_limit := int(available_mem / memNeeded) cpu_limit_total += cpu_limit mem_limit_total += mem_limit - availableVMs += int(math.Min(float64(cpu_limit), float64(mem_limit))) + //availableVMs += int(math.Min(float64(cpu_limit), float64(mem_limit))) } } - return availableVMs, cpu_limit_total, mem_limit_total + return cpu_limit_total, mem_limit_total +} + +// Checking if the cluster can run at least one VM +func IsEnoughResources(virtClient kubecli.KubevirtClient, cpuNeeded int, memNeeded int64) (bool, int) { + cpu_limit, mem_limit := GetAvailableResources(virtClient, int64(cpuNeeded), int64(memNeeded)) + availableVMs := int(math.Min(float64(cpu_limit), float64(mem_limit))) + if availableVMs == 0 { + return false, availableVMs + + } else { + return true, availableVMs + + } + } diff --git a/tests/framework/vnc_console.go b/tests/framework/vnc_console.go index a9e95852f..d36e72495 100644 --- a/tests/framework/vnc_console.go +++ b/tests/framework/vnc_console.go @@ -54,7 +54,7 @@ func OpenConsole(virtCli kubecli.KubevirtClient, vmiName string, vmiNamespace st }, timeout, opts...) } -func LoggedInFedoraExpecter(vmiName string, vmiNamespace string, timeout int64) (expect.Expecter, error) { +func LoggedInFedoraExpecter(vmiName string, vmiNamespace string, timeout int64, vmNameInPromt bool) (expect.Expecter, error) { virtClient, err := kubecli.GetKubevirtClient() ktests.PanicOnError(err) vmi, err := virtClient.VirtualMachineInstance(vmiNamespace).Get(vmiName, &metav1.GetOptions{}) @@ -63,10 +63,19 @@ func LoggedInFedoraExpecter(vmiName string, vmiNamespace string, timeout int64) if err != nil { return nil, err } + + loginPromt := "" + + if vmNameInPromt { + loginPromt = vmiName + " " + "login:" + } else { + loginPromt = "login:" + } + b := append([]expect.Batcher{ &expect.BSnd{S: "\n"}, &expect.BSnd{S: "\n"}, - &expect.BExp{R: "login:"}, + &expect.BExp{R: loginPromt}, &expect.BSnd{S: "fedora\n"}, &expect.BExp{R: "Password:"}, &expect.BSnd{S: "fedora\n"}, diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml index f67590d36..11c1f0e7a 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-no-sockets-cores-and-threads.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml index d0d871d51..23d9e1db7 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores-and-threads.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml index 7c11fade2..133745baf 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-cores.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml index f96d68e2f..0cc410df4 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-cores.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml index decafc27b..1b536427b 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets-and-threads.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml index 1d75c23c6..28b7c8012 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-sockets.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml index 6363d966d..03bc8c485 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-only-threads.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml b/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml index d742c8312..1d6dfbf05 100644 --- a/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml +++ b/tests/manifests/sockets_cores_threads/vm-template-fedora-sockets-cores-and-threads.yaml @@ -16,7 +16,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 name: ${NAME} spec: @@ -25,7 +24,6 @@ objects: metadata: creationTimestamp: null labels: - kubevirt-vm: vm-${NAME} kubevirt.io/os: fedora27 spec: domain: diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index 800a9b68f..a62664402 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -37,6 +37,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8syaml "k8s.io/apimachinery/pkg/util/yaml" tframework "kubevirt.io/kubevirt-ansible/tests/framework" + + "kubevirt.io/kubevirt/pkg/api/v1" "kubevirt.io/kubevirt/pkg/kubecli" "kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api" ktests "kubevirt.io/kubevirt/tests" @@ -71,18 +73,6 @@ func parseYAMLConfig(podYAML string) (bool, int, int) { return isCPUPresent, int(resourcesRequests), int(resourcesLimits) } -// Checking if the cluster can run at least one VM -func isEnoughResources(virtClient kubecli.KubevirtClient, cpuNeeded int, memNeeded int64) (bool, int, int) { - availableVMs, cpu_limit, mem_limit := tframework.GetAvailableResources(virtClient, int64(cpuNeeded), memNeeded) - if availableVMs == 0 { - return false, cpu_limit, mem_limit - - } else { - return true, cpu_limit, mem_limit - - } -} - func getYAMLFilename(sockets, cores, threads int, address_common string) string { // 0 means parameter set to 0, 1 means parameter set to non-zero var file_name [2][2][2]string @@ -137,13 +127,12 @@ func clean_pods(virtClient kubecli.KubevirtClient, requiredPods []*corev1.Pod) { Expect(err).ToNot(HaveOccurred()) for _, item := range podList.Items { - deletePod := true for _, internalItem := range requiredPods { - fmt.Println("internalItem=", internalItem.Name) + //fmt.Println("internalItem=", internalItem.Name) if item.Name == internalItem.Name { deletePod = false - fmt.Println("do not delete pod=", internalItem.Name) + //fmt.Println("do not delete pod=", internalItem.Name) } } @@ -166,7 +155,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp Context("test case 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { It("[test_id:1485] testcase 1.1 Check the validity of the XML file if user didn’t set the CPU topology at all", func() { - //It("Pre-checks"",func() { + vmi11.Manifest = address_common + "vmi-case1.1.yml" vmi11.Namespace = ktests.NamespaceTestDefault @@ -338,22 +327,10 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp vm_index := 0 By("Declare goroutine function") - runVM := func(socketsN int, coresN int, threadsN int, wg *sync.WaitGroup, virtRawVMFilePath string, vm_name string) { + runVM := func(socketsN int, coresN int, threadsN int, vmi *v1.VirtualMachineInstance, wg *sync.WaitGroup, virtRawVMFilePath string, vm_name string) { By("1.3 Starting gouroutine to create, start and test VM") wg.Add(1) defer wg.Done() - By("1.3 Create VM from template and launch it") - tframework.CreateResourceWithFilePathTestNamespace(virtRawVMFilePath) - _, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "virtctl", "start", vm_name) - Expect(err).ToNot(HaveOccurred()) - _, _, err = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "project", ktests.NamespaceTestDefault) - Expect(err).ToNot(HaveOccurred()) - - By("1.3 Getting VMI object") - getVMOptions := metav1.GetOptions{} - vmi, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vm_name, &getVMOptions) - Expect(err).ToNot(HaveOccurred()) - ktests.WaitForSuccessfulVMIStart(vmi) By("1.3 Checking that pod was created and has the right name") vmiPod_vmNumName := ktests.GetRunningPodByVirtualMachineInstance(vmi, ktests.NamespaceTestDefault) @@ -400,12 +377,8 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp vCPUAmount := XMLSockets * XMLCores * XMLThreads Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") - // TC 2.1 and 2.2 should do the same as 1.3 but with several additional checks at the end. - // Creating and destroying all these VMs second time may be unnecessary time consuming - // TODO: 2.1 & 2.2 - move it to independent test case? - By("2.1 Expecting the VirtualMachineInstance console") - expecter, err := ktests.LoggedInCirrosExpecter(vmi) + expecter, err := tframework.LoggedInFedoraExpecter(vm_name, ktests.NamespaceTestDefault, 240, true) Expect(err).ToNot(HaveOccurred(), "Console should be started") defer expecter.Close() @@ -456,22 +429,23 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp } const memNeeded int64 = 256 * 1024 * 1024 // 256mb is default in the template - isAvailable := false const maxWaitIterations = 15 // half of minute - var cpuLimit, memLimit int - var IsResourcesInCluster bool + isAvailable := true + for i := 0; i < maxWaitIterations; i++ { - IsResourcesInCluster, cpuLimit, memLimit = isEnoughResources(virtClient, cpuNeeded, memNeeded) + IsResourcesInCluster, amountVMs := tframework.IsEnoughResources(virtClient, cpuNeeded, memNeeded) + fmt.Println("================================") + fmt.Println("debug in a case if goroutine fails. Amount of possible VMs=", amountVMs) + fmt.Println("================================") if IsResourcesInCluster { isAvailable = true break } time.Sleep(2 * time.Second) } - //workaroud for current resources in CI - if cpuLimit >= 1 && memLimit >= 1 { - Expect(isAvailable).To(BeTrue(), "Cluster should have enough resources") - } else { + + if !isAvailable { + fmt.Println("cluster doesn't have resources to launch this VM! Try to launch next option") break } @@ -484,10 +458,22 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp virtRawVMFilePath := address_common + "/sockets_cores_threads_raw_manifest_" + vm_name + ".yaml" tframework.ProcessTemplateWithParameters(filename, virtRawVMFilePath, arguments...) - //prevent server overloading - CI workaround (i/o error) - time.Sleep(5 * time.Second) + By("1.3 Create VM from template and launch it") + tframework.CreateResourceWithFilePathTestNamespace(virtRawVMFilePath) + _, _, err := ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "virtctl", "start", vm_name) + Expect(err).ToNot(HaveOccurred()) + _, _, err = ktests.RunCommandWithNS(ktests.NamespaceTestDefault, "oc", "project", ktests.NamespaceTestDefault) + Expect(err).ToNot(HaveOccurred()) + + By("1.3 Getting VMI object") + getVMOptions := metav1.GetOptions{} + vmi, err := virtClient.VirtualMachineInstance(ktests.NamespaceTestDefault).Get(vm_name, &getVMOptions) + Expect(err).ToNot(HaveOccurred()) + ktests.WaitForSuccessfulVMIStart(vmi) + By("launch goroutine") - go runVM(sockets, cores, threads, &wg, virtRawVMFilePath, vm_name) + fmt.Println("launch goroutine for vm ", vm_name) + go runVM(sockets, cores, threads, vmi, &wg, virtRawVMFilePath, vm_name) } } From 461560555d9e59b4ed4e81dfa2c8a82d82428627 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 10:03:34 -0300 Subject: [PATCH 18/27] try to up kubevirt & kubevirt UI versions --- vars/all.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/all.yml b/vars/all.yml index e24266aa1..924a6ecf8 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -8,7 +8,7 @@ openshift_ansible_dir: "openshift-ansible/" openshift_playbook_path: "{{ openshift_ansible_dir }}/{{ 'playbooks/byo/config.yml' if kubevirt_openshift_version == '3.7' else 'playbooks/deploy_cluster.yml' }}" ### KubeVirt ### -version: 0.13.3 +version: 0.16.3 image_pull_policy: IfNotPresent deploy_demo: true @@ -26,7 +26,7 @@ deploy_skydive: false ### Web UI ## kubevirt_web_ui_operator_image_tag: "latest" kubevirt_web_ui_branding: "okdvirt" -kubevirt_web_ui_version: "v1.4.0-13" +kubevirt_web_ui_version: "v2.0.0-14.3" #kubevirt_web_ui_version: "" # From 13d48005e28d65220e029ae5cbc0af7cced4a469 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 11:04:56 -0300 Subject: [PATCH 19/27] try to revert versions to previos two --- vars/all.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/all.yml b/vars/all.yml index 924a6ecf8..8503dcaa6 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -8,7 +8,7 @@ openshift_ansible_dir: "openshift-ansible/" openshift_playbook_path: "{{ openshift_ansible_dir }}/{{ 'playbooks/byo/config.yml' if kubevirt_openshift_version == '3.7' else 'playbooks/deploy_cluster.yml' }}" ### KubeVirt ### -version: 0.16.3 +version: 0.13.2 image_pull_policy: IfNotPresent deploy_demo: true @@ -26,7 +26,7 @@ deploy_skydive: false ### Web UI ## kubevirt_web_ui_operator_image_tag: "latest" kubevirt_web_ui_branding: "okdvirt" -kubevirt_web_ui_version: "v2.0.0-14.3" +kubevirt_web_ui_version: "v1.4.0-9" #kubevirt_web_ui_version: "" # From faa34df8c256cfb18fdfc1b95e8cbc327a5b8e76 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 12:03:03 -0300 Subject: [PATCH 20/27] try to revert version of kubevirtUI image --- vars/all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/all.yml b/vars/all.yml index 8503dcaa6..4e4b6c013 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -24,7 +24,7 @@ deploy_sriov_plugin: true deploy_skydive: false ### Web UI ## -kubevirt_web_ui_operator_image_tag: "latest" +kubevirt_web_ui_operator_image_tag: "1.4" kubevirt_web_ui_branding: "okdvirt" kubevirt_web_ui_version: "v1.4.0-9" #kubevirt_web_ui_version: "" From e3aa34d65def29d75fb308ccf130a15030907ed3 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 13:01:14 -0300 Subject: [PATCH 21/27] debug --- roles/kubevirt_web_ui/tasks/provision.web-ui.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/kubevirt_web_ui/tasks/provision.web-ui.yml b/roles/kubevirt_web_ui/tasks/provision.web-ui.yml index 7af85fd22..cb9edcdad 100644 --- a/roles/kubevirt_web_ui/tasks/provision.web-ui.yml +++ b/roles/kubevirt_web_ui/tasks/provision.web-ui.yml @@ -58,6 +58,7 @@ retries: 30 delay: 10 when: kubevirt_web_ui_version_effective != "" + ignore_errors: yes # The Web UI is deprovisioned either when # - KWebUI CR is missing @@ -70,4 +71,5 @@ retries: 30 delay: 10 when: kubevirt_web_ui_version_effective == "" + ignore_errors: yes From 62bb8f6dccebb33c10701cace9e545161bf997e9 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 14:01:03 -0300 Subject: [PATCH 22/27] fix arguments --- tests/secrets_and_cfgmap_test.go | 4 ++-- tests/serviceaccount_test.go | 2 +- tests/vm_with_sidecar_hook_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/secrets_and_cfgmap_test.go b/tests/secrets_and_cfgmap_test.go index 5357c434c..ab4fa4473 100644 --- a/tests/secrets_and_cfgmap_test.go +++ b/tests/secrets_and_cfgmap_test.go @@ -91,7 +91,7 @@ var _ = Describe("[rfe_id:384][crit:medium][vendor:cnv-qe@redhat.com][level:comp Expect(podOutput_cfgMap).To(Equal(expectedOutput_cfgMap)) By("Checking mounted ConfigMap image") - expecter, err := tests.LoggedInFedoraExpecter(vmi.Name, tests.NamespaceTestDefault, 360) + expecter, err := tests.LoggedInFedoraExpecter(vmi.Name, tests.NamespaceTestDefault, 360, false) Expect(err).ToNot(HaveOccurred()) defer expecter.Close() @@ -199,7 +199,7 @@ var _ = Describe("[rfe_id:384][crit:medium][vendor:cnv-qe@redhat.com][level:comp Expect(podOutput2).To(Equal(expectedPublicKey)) By("Checking mounted secrets sshkeys image") - expecter, err := tests.LoggedInFedoraExpecter(vmi.Name, tests.NamespaceTestDefault, 360) + expecter, err := tests.LoggedInFedoraExpecter(vmi.Name, tests.NamespaceTestDefault, 360, false) Expect(err).ToNot(HaveOccurred()) defer expecter.Close() diff --git a/tests/serviceaccount_test.go b/tests/serviceaccount_test.go index 4d1fa86fb..31ce7ff6d 100644 --- a/tests/serviceaccount_test.go +++ b/tests/serviceaccount_test.go @@ -66,7 +66,7 @@ var _ = Describe("[rfe_id:905][crit:medium][vendor:cnv-qe@redhat.com][level:comp Expect(podOutput).To(Equal(tests.NamespaceTestDefault)) By("Checking mounted serviceaccount image") - expecter, err := tests.LoggedInFedoraExpecter(vmi.Name, tests.NamespaceTestDefault, 360) + expecter, err := tests.LoggedInFedoraExpecter(vmi.Name, tests.NamespaceTestDefault, 360, false) Expect(err).ToNot(HaveOccurred()) defer expecter.Close() diff --git a/tests/vm_with_sidecar_hook_test.go b/tests/vm_with_sidecar_hook_test.go index ad07b4f8a..2fb66b310 100644 --- a/tests/vm_with_sidecar_hook_test.go +++ b/tests/vm_with_sidecar_hook_test.go @@ -33,7 +33,7 @@ var _ = Describe("[rfe_id:839][crit:medium][vendor:cnv-qe@redhat.com][level:comp tests.WaitUntilResourceReadyByNameTestNamespace("vmi", vmiName, "-o=jsonpath='{.status.phase}'", "Running") By("Expecting console") - expecter, err := tests.LoggedInFedoraExpecter(vmiName, tests.NamespaceTestDefault, 720) + expecter, err := tests.LoggedInFedoraExpecter(vmiName, tests.NamespaceTestDefault, 720, false) Expect(err).ToNot(HaveOccurred()) defer expecter.Close() From 4c49127775794d912e8c3e66007cfc4732110411 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 14:03:55 -0300 Subject: [PATCH 23/27] up versions --- vars/all.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/all.yml b/vars/all.yml index 4e4b6c013..83e670ab1 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -3,12 +3,12 @@ platform: openshift apb_action: "provision" # OpenShift # -kubevirt_openshift_version: "3.10" +kubevirt_openshift_version: "3.11" openshift_ansible_dir: "openshift-ansible/" openshift_playbook_path: "{{ openshift_ansible_dir }}/{{ 'playbooks/byo/config.yml' if kubevirt_openshift_version == '3.7' else 'playbooks/deploy_cluster.yml' }}" ### KubeVirt ### -version: 0.13.2 +version: 0.17.0 image_pull_policy: IfNotPresent deploy_demo: true From cfb322de29acc5f9a32af6cf40f78196fa784a3a Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 14:06:27 -0300 Subject: [PATCH 24/27] up versions --- vars/all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/all.yml b/vars/all.yml index 83e670ab1..2d8849191 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -26,7 +26,7 @@ deploy_skydive: false ### Web UI ## kubevirt_web_ui_operator_image_tag: "1.4" kubevirt_web_ui_branding: "okdvirt" -kubevirt_web_ui_version: "v1.4.0-9" +kubevirt_web_ui_version: "v2.0.0-14.4" #kubevirt_web_ui_version: "" # From 9127e42823582523d8e7517fa8854f7b3bd7c4e3 Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 15:14:27 -0300 Subject: [PATCH 25/27] change kubevirt version --- vars/all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/all.yml b/vars/all.yml index 2d8849191..3a352bb90 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -8,7 +8,7 @@ openshift_ansible_dir: "openshift-ansible/" openshift_playbook_path: "{{ openshift_ansible_dir }}/{{ 'playbooks/byo/config.yml' if kubevirt_openshift_version == '3.7' else 'playbooks/deploy_cluster.yml' }}" ### KubeVirt ### -version: 0.17.0 +version: 0.15.0 image_pull_policy: IfNotPresent deploy_demo: true From a4eb11437e03eb96eb004f2f6b876b3475f116ab Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 15:28:38 -0300 Subject: [PATCH 26/27] change kubevirt version --- vars/all.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/all.yml b/vars/all.yml index 3a352bb90..cbe1436cb 100644 --- a/vars/all.yml +++ b/vars/all.yml @@ -8,7 +8,7 @@ openshift_ansible_dir: "openshift-ansible/" openshift_playbook_path: "{{ openshift_ansible_dir }}/{{ 'playbooks/byo/config.yml' if kubevirt_openshift_version == '3.7' else 'playbooks/deploy_cluster.yml' }}" ### KubeVirt ### -version: 0.15.0 +version: 0.16.2 image_pull_policy: IfNotPresent deploy_demo: true @@ -24,7 +24,7 @@ deploy_sriov_plugin: true deploy_skydive: false ### Web UI ## -kubevirt_web_ui_operator_image_tag: "1.4" +kubevirt_web_ui_operator_image_tag: "latest" kubevirt_web_ui_branding: "okdvirt" kubevirt_web_ui_version: "v2.0.0-14.4" #kubevirt_web_ui_version: "" From f553d0457b209c64203a8e35a401a5029910a6dd Mon Sep 17 00:00:00 2001 From: Xenia Lisovskaia Date: Fri, 17 May 2019 16:51:25 -0300 Subject: [PATCH 27/27] increase timeout --- tests/sockets_cores_threads_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sockets_cores_threads_test.go b/tests/sockets_cores_threads_test.go index a62664402..7887f27f9 100644 --- a/tests/sockets_cores_threads_test.go +++ b/tests/sockets_cores_threads_test.go @@ -378,7 +378,7 @@ var _ = Describe("[rfe_id:1443][crit:medium]vendor:cnv-qe@redhat.com][level:comp Expect(int(domStat.VCPU.CPUs) == vCPUAmount).To(BeTrue(), "XML should have right number of vCPUs") By("2.1 Expecting the VirtualMachineInstance console") - expecter, err := tframework.LoggedInFedoraExpecter(vm_name, ktests.NamespaceTestDefault, 240, true) + expecter, err := tframework.LoggedInFedoraExpecter(vm_name, ktests.NamespaceTestDefault, 380, true) Expect(err).ToNot(HaveOccurred(), "Console should be started") defer expecter.Close()