Skip to content

Commit

Permalink
Fix guest agent functional tests
Browse files Browse the repository at this point in the history
The problem is we added a new condition call LiveMigratable so the len tests fails.
  • Loading branch information
SchSeba committed Feb 10, 2019
1 parent 95cec6b commit 73f6df9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
20 changes: 10 additions & 10 deletions automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ if [[ $TARGET =~ openshift-.* ]]; then
# of old vms does not go fast enough they run out of memory.
# To still allow continuing with the tests, give more memory in CI.
export KUBEVIRT_MEMORY_SIZE=6144M
if [[ $TARGET =~ .*-crio-.* ]]; then
if [[ $TARGET =~ .*-crio ]]; then
export KUBEVIRT_PROVIDER="os-3.11.0-crio"
elif [[ $TARGET =~ .*-multus-.* ]]; then
elif [[ $TARGET =~ .*-multus ]]; then
export KUBEVIRT_PROVIDER="os-3.11.0-multus"
else
export KUBEVIRT_PROVIDER="os-3.11.0"
fi
elif [[ $TARGET =~ .*-1.10.4-.* ]]; then
elif [[ $TARGET =~ .*-1.10.4 ]]; then
export KUBEVIRT_PROVIDER="k8s-1.10.11"
elif [[ $TARGET =~ .*-multus-1.12.2-.* ]]; then
elif [[ $TARGET =~ .*-multus-1.12.2 ]]; then
export KUBEVIRT_PROVIDER="k8s-multus-1.12.2"
elif [[ $TARGET =~ .*-genie-1.11.1-.* ]]; then
elif [[ $TARGET =~ .*-genie-1.11.1 ]]; then
export KUBEVIRT_PROVIDER="k8s-genie-1.11.1"
else
export KUBEVIRT_PROVIDER="k8s-1.11.0"
Expand Down Expand Up @@ -244,18 +244,18 @@ spec:
EOF
# Run only Windows tests
ginko_params="$ginko_params --ginkgo.focus=Windows"

elif [[ $TARGET =~ multus.* ]]; then
# Run networking tests only (general networking, multus, ...)
ginko_params="$ginko_params --ginkgo.focus=Multus|Networking|VMIlifecycle|Expose|Networkpolicy"
ginko_params="$ginko_params --ginkgo.focus=Multus|Networking|VMIlifecycle|Expose"
elif [[ $TARGET =~ genie.* ]]; then
ginko_params="$ginko_params --ginkgo.focus=Genie|Networking|VMIlifecycle|Expose|Networkpolicy"
ginko_params="$ginko_params --ginkgo.focus=Genie|Networking|VMIlifecycle|Expose"
else
ginko_params="$ginko_params --ginkgo.skip=Multus"
ginko_params="$ginko_params --ginkgo.skip=Multus|Genie"
fi

# Prepare RHEL PV for Template testing
if [[ $TARGET =~ openshift-.* ]]; then
ginko_params="$ginko_params|Networkpolicy"

kubectl create -f - <<EOF
---
apiVersion: v1
Expand Down
49 changes: 29 additions & 20 deletions tests/vmi_multus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,10 @@ var _ = Describe("Multus", func() {
virtClient, err := kubecli.GetKubevirtClient()
tests.PanicOnError(err)

nodes, err := virtClient.CoreV1().Nodes().List(v13.ListOptions{})
tests.PanicOnError(err)

nodeAffinity := &k8sv1.Affinity{
NodeAffinity: &k8sv1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &k8sv1.NodeSelector{
NodeSelectorTerms: []k8sv1.NodeSelectorTerm{
{
MatchExpressions: []k8sv1.NodeSelectorRequirement{
{Key: "kubernetes.io/hostname", Operator: k8sv1.NodeSelectorOpIn, Values: []string{nodes.Items[0].Name}},
},
},
},
},
},
}

var detachedVMI *v1.VirtualMachineInstance
var vmiOne *v1.VirtualMachineInstance
var vmiTwo *v1.VirtualMachineInstance
var nodeAffinity *k8sv1.Affinity

createVMI := func(interfaces []v1.Interface, networks []v1.Network) *v1.VirtualMachineInstance {
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\n")
Expand All @@ -87,6 +71,24 @@ var _ = Describe("Multus", func() {

tests.BeforeAll(func() {
tests.BeforeTestCleanup()

nodes := tests.GetAllSchedulableNodes(virtClient)
Expect(len(nodes.Items) > 1).To(BeTrue())

nodeAffinity = &k8sv1.Affinity{
NodeAffinity: &k8sv1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &k8sv1.NodeSelector{
NodeSelectorTerms: []k8sv1.NodeSelectorTerm{
{
MatchExpressions: []k8sv1.NodeSelectorRequirement{
{Key: "kubernetes.io/hostname", Operator: k8sv1.NodeSelectorOpIn, Values: []string{nodes.Items[0].Name}},
},
},
},
},
},
}

result := virtClient.RestClient().
Post().
RequestURI(fmt.Sprintf(postUrl, tests.NamespaceTestDefault, "ovs-net-vlan100")).
Expand Down Expand Up @@ -473,10 +475,17 @@ var _ = Describe("Multus", func() {
getOptions := &metav1.GetOptions{}
var updatedVmi *v1.VirtualMachineInstance

Eventually(func() int {
// Need to wait for cloud init to finnish and start the agent inside the vmi.
Eventually(func() bool {
updatedVmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Get(agentVMI.Name, getOptions)
return len(updatedVmi.Status.Conditions)
}, 120*time.Second, 2).Should(Equal(1), "Should have agent connected condition")
Expect(err).ToNot(HaveOccurred())
for _, condition := range updatedVmi.Status.Conditions {
if condition.Type == "AgentConnected" && condition.Status == "True" {
return true
}
}
return false
}, 420*time.Second, 2).Should(BeTrue(), "Should have agent connected condition")

Eventually(func() bool {
updatedVmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Get(agentVMI.Name, getOptions)
Expand Down

0 comments on commit 73f6df9

Please sign in to comment.