Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix moving route ip to bridge test #176

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ trap teardown EXIT SIGINT SIGTERM SIGSTOP
make cluster-down
make cluster-up
make cluster-sync
make E2E_TEST_EXTRA_ARGS="-ginkgo.noColor" test/e2e
test_args="-ginkgo.v -ginkgo.noColor -test.timeout 20m"
skip_tests=""

# FIXME: Delete it when we migrate to okd4 provider, since os-3.11.0 is not
# working alright I we don't want to debug not supported providers.
if [[ $KUBEVIRT_PROVIDER =~ os- ]]; then
skip_tests="move.*default.*IP"
fi

make E2E_TEST_EXTRA_ARGS="$test_args" E2E_TEST_SKIP="$skip_tests" test/e2e
2 changes: 1 addition & 1 deletion hack/install-kubevirtci.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

organization=kubevirt
commit="1c2922cd9ebaabf7006dc68aa8df70ad84d96d4b"
commit="db8c24bf830bb927f01829e6c9f083627fe6b832"

script_dir=$(dirname "$(readlink -f "$0")")
kubevirtci_dir=kubevirtci
Expand Down
38 changes: 18 additions & 20 deletions test/e2e/default_bridged_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,21 @@ var _ = Describe("NodeNetworkConfigurationPolicy default bridged network", func(
type: linux-bridge
state: absent
`)
// FIXME: This is a pending spec since we have to discover why the
// cluster never goes back at kubevirtci provider
XContext("when there is a default interface with dynamic address", func() {
Context("when there is a default interface with dynamic address", func() {
qinqon marked this conversation as resolved.
Show resolved Hide resolved
addressByNode := map[string]string{}
BeforeEach(func() {
By("Check eth0 is the default route interface and has dynamic address")
for _, node := range nodes {
Expect(defaultRouteNextHopInterface(node)).To(Equal("eth0"))
Expect(dhcpFlag(node, "eth0")).To(BeTrue())
defaultRouteNextHopInterface(node).Should(Equal("eth0"))
Expect(dhcpFlag(node, "eth0")).Should(BeTrue())
}

By("Fetching current IP address")
for _, node := range nodes {
address := ""
Eventually(func() string {
return ipv4Address(node, "eth0")
address = ipv4Address(node, "eth0")
return address
}, 15*time.Second, 1*time.Second).ShouldNot(BeEmpty(), "Interface eth0 has no ipv4 address")
addressByNode[node] = address
}
Expand All @@ -70,6 +69,9 @@ var _ = Describe("NodeNetworkConfigurationPolicy default bridged network", func(
By("Removing bridge and configuring eth0 with dhcp")
setDesiredStateWithPolicy("default-network", resetDefaultInterface)

By("Waiting until the node becomes ready again")
waitForNodesReady()

By("Check eth0 has the default ip address")
for _, node := range nodes {
Eventually(func() string {
Expand All @@ -79,14 +81,9 @@ var _ = Describe("NodeNetworkConfigurationPolicy default bridged network", func(

By("Check eth0 is back as the default route interface")
for _, node := range nodes {
Eventually(func() string {
return defaultRouteNextHopInterface(node)
}, 30*time.Second, 1*time.Second).Should(Equal("eth0"))
defaultRouteNextHopInterface(node).Should(Equal("eth0"))
}

By("Waiting until the node becomes ready again")
waitForNodesReady()

By("Remove the policy")
deletePolicy("default-network")
})
Expand All @@ -107,13 +104,11 @@ var _ = Describe("NodeNetworkConfigurationPolicy default bridged network", func(

By("Verify that next-hop-interface for default route is brext")
for _, node := range nodes {
Eventually(func() string {
return defaultRouteNextHopInterface(node)
}, 30*time.Second, 1*time.Second).Should(Equal("brext"))
defaultRouteNextHopInterface(node).Should(Equal("brext"))

By("Verify that VLAN configuration is done properly")
hasVlans(node, "eth0", 2, 4094).Should(Succeed())
hasVlans(node, "brext", 1, 1).Should(Succeed())
vlansCardinality(node, "brext").Should(Equal(0))
}
})
})
Expand All @@ -132,9 +127,11 @@ func ipv4Address(node string, name string) string {
return gjson.ParseBytes(currentStateJSON(node)).Get(path).String()
}

func defaultRouteNextHopInterface(node string) string {
path := "routes.running.#(destination==\"0.0.0.0/0\").next-hop-interface"
return gjson.ParseBytes(currentStateJSON(node)).Get(path).String()
func defaultRouteNextHopInterface(node string) AsyncAssertion {
return Eventually(func() string {
path := "routes.running.#(destination==\"0.0.0.0/0\").next-hop-interface"
return gjson.ParseBytes(currentStateJSON(node)).Get(path).String()
}, 15*time.Second, 1*time.Second)
}

func dhcpFlag(node string, name string) bool {
Expand All @@ -158,9 +155,10 @@ func nodeReadyConditionStatus(nodeName string) (corev1.ConditionStatus, error) {
}

func waitForNodesReady() {
time.Sleep(5 * time.Second)
for _, node := range nodes {
Eventually(func() (corev1.ConditionStatus, error) {
return nodeReadyConditionStatus(node)
}, 15*time.Second, 1*time.Second).Should(Equal(corev1.ConditionTrue))
}, 60*time.Second, 1*time.Second).Should(Equal(corev1.ConditionTrue))
}
}
2 changes: 1 addition & 1 deletion test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
nmstatev1alpha1 "github.com/nmstate/kubernetes-nmstate/pkg/apis/nmstate/v1alpha1"
)

const ReadTimeout = 15 * time.Second
const ReadTimeout = 120 * time.Second
const ReadInterval = 1 * time.Second

func writePodsLogs(namespace string, sinceTime time.Time, writer io.Writer) error {
Expand Down