tests: copy desired vmi labels to vm template
The function that generated a vm spec reflecting a vmi did not copy the vmi
labels into the template. Some test cases assume the labels are copied, for
example, migration suite.
This patch copies the labels as requested.
@@ -3704,6 +3704,10 @@ func GetNodeCPUInfo(vmi *v1.VirtualMachineInstance) string {
func NewRandomVirtualMachine(vmi *v1.VirtualMachineInstance, running bool) *v1.VirtualMachine {
name := vmi.Name
namespace := vmi.Namespace
+ labels := map[string]string{"name": name}
+ for k, v := range vmi.Labels {
+ labels[k] = v
+ }
vm := &v1.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: name,
@@ -3713,7 +3717,7 @@ func NewRandomVirtualMachine(vmi *v1.VirtualMachineInstance, running bool) *v1.V
Running: &running,
Template: &v1.VirtualMachineInstanceTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
- Labels: map[string]string{"name": name},
+ Labels: labels,
Name: name,
Namespace: namespace,
},
