Skip to content

Commit

Permalink
e2e: Optimize and add e2e use cases for 'ip rule'
Browse files Browse the repository at this point in the history
Signed-off-by: ty-dc <tao.yang@daocloud.io>
  • Loading branch information
ty-dc committed Dec 12, 2023
1 parent 80cfad0 commit 0ca4b67
Show file tree
Hide file tree
Showing 3 changed files with 350 additions and 127 deletions.
6 changes: 3 additions & 3 deletions test/doc/coordinator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
| C00003 | coordinator in tuneMode: underlay with two NIC | p1 | smoke | | |
| C00004 | coordinator in tuneMode: overlay with two NIC | p1 | smoke | | |
| C00005 | In overlay mode: specify the NIC (eth0) where the default route is located, use 'ip r get 8.8.8.8' to see if default route nic is the specify NIC | p2 | | done | |
| C00006 | In underlay mode: specify the NIC (eth0) where the default route is located, use 'ip r get 8.8.8.8' to see if default route nic is the specify NIC | p2 | | | |
| C00006 | In underlay mode: specify the NIC (eth0) where the default route is located, use 'ip r get 8.8.8.8' to see if default route nic is the specify NIC | p2 | | done | |
| C00007 | ip conflict detection (ipv4, ipv6) | p2 | | done | |
| C00008 | override pod mac prefix | p2 | | done | |
| C00009 | gateway connection detection | p2 | | done | |
| C00010 | auto clean up the dirty rules(routing\neighborhood) while pod starting | p2 | | |
| C00011 | In the default scenario (Do not specify the NIC where the default route is located in any way) , use 'ip r get 8.8.8.8' to see if default route NIC is `net1` | p2 | | |
| C00012 | In multi-nic case , use 'ip r get <service_subnet> and <hostIP>' to see if src is from pod's eth0, note: only for ipv4. | p2 | | |
| C00011 | In the default scenario (Do not specify the NIC where the default route is located in any way) , use 'ip r get 8.8.8.8' to see if default route NIC is `net1` | p2 | | done | |
| C00012 | In multi-nic case , use 'ip r get <service_subnet> and <hostIP>' to see if src is from pod's eth0, note: only for ipv4. | p2 | | done | |
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
},
CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{
PodMACPrefix: &macPrefix,
PodDefaultRouteNIC: &common.NIC1,
PodDefaultRouteNIC: &common.NIC2,
Mode: &mode,
PodCIDRType: &podCidrType,
},
Expand Down Expand Up @@ -286,14 +286,14 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
ctx, cancel = context.WithTimeout(context.Background(), common.ExecCommandTimeout)
defer cancel()

// In this use case, the default routing NIC is specified as eth0 through `CoordinatorSpec.PodDefaultRouteNIC`
// ip r get <address outside the cluster>, should flow out from the correct NIC(eth0).
// In this use case, the default routing NIC is specified as net1 (originally the default is eth0) through `CoordinatorSpec.PodDefaultRouteNIC`
// ip r get <address outside the cluster>, should flow out from the correct NIC(net1).
GinkgoWriter.Println("ip -4 r get <address outside the cluster>")
runGetIPString := "ip -4 r get '8.8.8.8' "
executeCommandResult, err := frame.ExecCommandInPod(pod.Name, pod.Namespace, runGetIPString, ctx)
GinkgoWriter.Println("Execute command result: ", string(executeCommandResult))
Expect(err).NotTo(HaveOccurred(), "failed to execute command, error is: %v ", err)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC1), "Expected NIC %v mismatch", common.NIC1)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC2), "Expected NIC %v mismatch", common.NIC2)

// ip r get <IP in eth0 subnet>, should flow out from eth0
GinkgoWriter.Println("ip -4 r get <IP in eth0 subnet>")
Expand Down Expand Up @@ -327,14 +327,14 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
ctx, cancel = context.WithTimeout(context.Background(), common.ExecCommandTimeout)
defer cancel()

// In this use case, the default routing NIC is specified as eth0 (originally the default is net1) through `CoordinatorSpec.PodDefaultRouteNIC`
// ip r get <address outside the cluster>, should flow out from the correct NIC(eth0).
// In this use case, the default routing NIC is specified as net1 (originally the default is eth0) through `CoordinatorSpec.PodDefaultRouteNIC`
// ip r get <address outside the cluster>, should flow out from the correct NIC(net1).
GinkgoWriter.Println("ip -6 r get <IP in service subnet>")
runGetIPString := "ip -6 r get '2401:2401::1' "
executeCommandResult, err := frame.ExecCommandInPod(pod.Name, pod.Namespace, runGetIPString, ctx)
GinkgoWriter.Println("Execute ipv6 command result: ", string(executeCommandResult))
Expect(err).NotTo(HaveOccurred(), "failed to execute ipv6 command, error is: %v ", err)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC1), "Expected NIC %v mismatch", common.NIC1)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC2), "Expected NIC %v mismatch", common.NIC2)

// ip r get <IP in eth0 subnet>, should flow out from eth0
GinkgoWriter.Println("ip -6 r get <IP in eth0 subnet>")
Expand Down Expand Up @@ -724,7 +724,7 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
})
})

It("In the default scenario, the `ip rules` should be as expected and the default route should be on eth0", Label("C00011"), func() {
It("In the default scenario, the `ip rules` should be as expected and the default route should be on eth0", Label("C00011", "C00012"), func() {
podIppoolsAnno := types.AnnoPodIPPoolsValue{
types.AnnoIPPoolItem{
NIC: common.NIC2,
Expand Down Expand Up @@ -761,14 +761,14 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
defer cancel()

// In the conventional multi-card situation, the NIC where the default route is located is not specified through comments or other methods.
// Then when accessing the external address of the cluster, it should flow out from the net1 NIC.
// ip r get <address outside the cluster>, should flow out from the correct NIC(net1).
// Then when accessing the external address of the cluster, it should flow out from the eth0 NIC.
// ip r get <address outside the cluster>, should flow out from the correct NIC(eth0).
GinkgoWriter.Println("ip -4 r get <address outside the cluster>")
runGetIPString := "ip -4 r get '8.8.8.8' "
executeCommandResult, err := frame.ExecCommandInPod(pod.Name, pod.Namespace, runGetIPString, ctx)
GinkgoWriter.Println("Execute command result: ", string(executeCommandResult))
Expect(err).NotTo(HaveOccurred(), "failed to execute command, error is: %v ", err)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC1), "Expected NIC %v mismatch", common.NIC2)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC1), "Expected NIC %v mismatch", common.NIC1)

// ip r get <IP in eth0 subnet>, should flow out from eth0
GinkgoWriter.Println("ip -4 r get <IP in eth0 subnet>")
Expand Down Expand Up @@ -803,14 +803,14 @@ var _ = Describe("MacvlanOverlayOne", Label("overlay", "one-nic", "coordinator")
defer cancel()

// In the conventional multi-card situation, the NIC where the default route is located is not specified through comments or other methods.
// Then when accessing the external address of the cluster, it should flow out from the net1 NIC.
// ip r get <address outside the cluster>, should flow out from the correct NIC(net1).
// Then when accessing the external address of the cluster, it should flow out from the eth0 NIC.
// ip r get <address outside the cluster>, should flow out from the correct NIC(eth0).
GinkgoWriter.Println("ip -6 r get <address outside the cluster>")
runGetIPString := "ip -6 r get '2401:2401::1' "
executeCommandResult, err := frame.ExecCommandInPod(pod.Name, pod.Namespace, runGetIPString, ctx)
GinkgoWriter.Println("Execute ipv6 command result: ", string(executeCommandResult))
Expect(err).NotTo(HaveOccurred(), "failed to execute ipv6 command, error is: %v ", err)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC1), "Expected NIC %v mismatch", common.NIC2)
Expect(string(executeCommandResult)).Should(ContainSubstring(common.NIC1), "Expected NIC %v mismatch", common.NIC1)

// ip r get <IP in eth0 subnet>, should flow out from eth0
GinkgoWriter.Println("ip -6 r get <IP in eth0 subnet>")
Expand Down
Loading

0 comments on commit 0ca4b67

Please sign in to comment.