diff mbox

[ovs-dev,v2,2/2] system-ovn.at: Add another load-balancing test.

Message ID 1470995293-28467-2-git-send-email-guru@ovn.org
State Accepted
Headers show

Commit Message

Gurucharan Shetty Aug. 12, 2016, 9:48 a.m. UTC
The client and servers are in the same subnet.

(This would not have worked without the recent
IPv6 patches that let packets to loop back)

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
---
 tests/system-ovn.at | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

Comments

Joe Stringer Aug. 12, 2016, 10:46 p.m. UTC | #1
On 12 August 2016 at 02:48, Gurucharan Shetty <guru@ovn.org> wrote:
> The client and servers are in the same subnet.
>
> (This would not have worked without the recent
> IPv6 patches that let packets to loop back)
>
> Signed-off-by: Gurucharan Shetty <guru@ovn.org>

A couple of minor comments below, but otherwise this seems fine.

Acked-by: Joe Stringer <joe@ovn.org>

> ---
>  tests/system-ovn.at | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 118 insertions(+)
>
> diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> index 6ac5ece..efba4a7 100755
> --- a/tests/system-ovn.at
> +++ b/tests/system-ovn.at
> @@ -416,3 +416,121 @@ OVS_APP_EXIT_AND_WAIT([ovn-northd])
>  as
>  OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d"])
>  AT_CLEANUP
> +
> +AT_SETUP([ovn -- load-balancing - same subnet.])
> +AT_KEYWORDS([ovnlb])
> +
> +CHECK_CONNTRACK()
> +CHECK_CONNTRACK_NAT()
> +ovn_start
> +OVS_TRAFFIC_VSWITCHD_START()
> +ADD_BR([br-int])
> +
> +# Set external-ids in br-int needed for ovn-controller
> +ovs-vsctl \
> +        -- set Open_vSwitch . external-ids:system-id=hv1 \
> +        -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \
> +        -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \
> +        -- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \
> +        -- set bridge br-int fail-mode=secure other-config:disable-in-band=true
> +
> +# Start ovn-controller
> +start_daemon ovn-controller
> +
> +# Logical network:
> +# 1 logical switch "foo" (192.168.1.0/24) connected to router R1.
> +# foo has foo1, foo2, foo3, foo4 as logical ports.
> +#
> +# Loadbalancer VIPs in 30.0.0.0/24 network. Router is needed for default
> +# gateway. We will test load-balancing with foo1 as a client and foo2, foo3 and
> +# foo4 as servers.
> +
> +ovn-nbctl create Logical_Router name=R1
> +ovn-nbctl ls-add foo
> +
> +# Connect foo to R1
> +ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
> +ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \
> +    type=router options:router-port=foo addresses=\"00:00:01:01:02:03\"
> +
> +# Create logical port 'foo1', 'foo2', 'foo3' and 'foo4' in switch 'foo'.
> +ADD_NAMESPACES(foo1)
> +ADD_VETH(foo1, foo1, br-int, "192.168.1.2/24", "f0:00:00:01:02:03", \
> +         "192.168.1.1")
> +ovn-nbctl lsp-add foo foo1 \
> +-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
> +
> +ADD_NAMESPACES(foo2)
> +ADD_VETH(foo2, foo2, br-int, "192.168.1.3/24", "f0:00:00:01:02:04", \
> +         "192.168.1.1")
> +ovn-nbctl lsp-add foo foo2 \
> +-- lsp-set-addresses foo2 "f0:00:00:01:02:04 192.168.1.3"
> +
> +ADD_NAMESPACES(foo3)
> +ADD_VETH(foo3, foo3, br-int, "192.168.1.4/24", "f0:00:00:01:02:05", \
> +         "192.168.1.1")
> +ovn-nbctl lsp-add foo foo3 \
> +-- lsp-set-addresses foo3 "f0:00:00:01:02:05 192.168.1.4"
> +
> +ADD_NAMESPACES(foo4)
> +ADD_VETH(foo4, foo4, br-int, "192.168.1.5/24", "f0:00:00:01:02:06", \
> +         "192.168.1.1")
> +ovn-nbctl lsp-add foo foo4 \
> +-- lsp-set-addresses foo4 "f0:00:00:01:02:06 192.168.1.5"

ADD_NAMESPACES accepts multiple arguments, so you could have a single
call to create all of these.

Is there a reason why you didn't use a for loop to create these?
Gurucharan Shetty Aug. 13, 2016, 11:49 p.m. UTC | #2
On 12 August 2016 at 15:46, Joe Stringer <joe@ovn.org> wrote:

> On 12 August 2016 at 02:48, Gurucharan Shetty <guru@ovn.org> wrote:
> > The client and servers are in the same subnet.
> >
> > (This would not have worked without the recent
> > IPv6 patches that let packets to loop back)
> >
> > Signed-off-by: Gurucharan Shetty <guru@ovn.org>
>
> A couple of minor comments below, but otherwise this seems fine.
>
> Acked-by: Joe Stringer <joe@ovn.org>
>
> > ---
> >  tests/system-ovn.at | 118 ++++++++++++++++++++++++++++++
> ++++++++++++++++++++++
> >  1 file changed, 118 insertions(+)
> >
> > diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> > index 6ac5ece..efba4a7 100755
> > --- a/tests/system-ovn.at
> > +++ b/tests/system-ovn.at
> > @@ -416,3 +416,121 @@ OVS_APP_EXIT_AND_WAIT([ovn-northd])
> >  as
> >  OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d"])
> >  AT_CLEANUP
> > +
> > +AT_SETUP([ovn -- load-balancing - same subnet.])
> > +AT_KEYWORDS([ovnlb])
> > +
> > +CHECK_CONNTRACK()
> > +CHECK_CONNTRACK_NAT()
> > +ovn_start
> > +OVS_TRAFFIC_VSWITCHD_START()
> > +ADD_BR([br-int])
> > +
> > +# Set external-ids in br-int needed for ovn-controller
> > +ovs-vsctl \
> > +        -- set Open_vSwitch . external-ids:system-id=hv1 \
> > +        -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock
> \
> > +        -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \
> > +        -- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \
> > +        -- set bridge br-int fail-mode=secure
> other-config:disable-in-band=true
> > +
> > +# Start ovn-controller
> > +start_daemon ovn-controller
> > +
> > +# Logical network:
> > +# 1 logical switch "foo" (192.168.1.0/24) connected to router R1.
> > +# foo has foo1, foo2, foo3, foo4 as logical ports.
> > +#
> > +# Loadbalancer VIPs in 30.0.0.0/24 network. Router is needed for
> default
> > +# gateway. We will test load-balancing with foo1 as a client and foo2,
> foo3 and
> > +# foo4 as servers.
> > +
> > +ovn-nbctl create Logical_Router name=R1
> > +ovn-nbctl ls-add foo
> > +
> > +# Connect foo to R1
> > +ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
> > +ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \
> > +    type=router options:router-port=foo addresses=\"00:00:01:01:02:03\"
> > +
> > +# Create logical port 'foo1', 'foo2', 'foo3' and 'foo4' in switch 'foo'.
> > +ADD_NAMESPACES(foo1)
> > +ADD_VETH(foo1, foo1, br-int, "192.168.1.2/24", "f0:00:00:01:02:03", \
> > +         "192.168.1.1")
> > +ovn-nbctl lsp-add foo foo1 \
> > +-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
> > +
> > +ADD_NAMESPACES(foo2)
> > +ADD_VETH(foo2, foo2, br-int, "192.168.1.3/24", "f0:00:00:01:02:04", \
> > +         "192.168.1.1")
> > +ovn-nbctl lsp-add foo foo2 \
> > +-- lsp-set-addresses foo2 "f0:00:00:01:02:04 192.168.1.3"
> > +
> > +ADD_NAMESPACES(foo3)
> > +ADD_VETH(foo3, foo3, br-int, "192.168.1.4/24", "f0:00:00:01:02:05", \
> > +         "192.168.1.1")
> > +ovn-nbctl lsp-add foo foo3 \
> > +-- lsp-set-addresses foo3 "f0:00:00:01:02:05 192.168.1.4"
> > +
> > +ADD_NAMESPACES(foo4)
> > +ADD_VETH(foo4, foo4, br-int, "192.168.1.5/24", "f0:00:00:01:02:06", \
> > +         "192.168.1.1")
> > +ovn-nbctl lsp-add foo foo4 \
> > +-- lsp-set-addresses foo4 "f0:00:00:01:02:06 192.168.1.5"
>
> ADD_NAMESPACES accepts multiple arguments, so you could have a single
> call to create all of these.
>
> Is there a reason why you didn't use a for loop to create these?
>

I added a for loop and pushed this. Thanks!
diff mbox

Patch

diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 6ac5ece..efba4a7 100755
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -416,3 +416,121 @@  OVS_APP_EXIT_AND_WAIT([ovn-northd])
 as
 OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d"])
 AT_CLEANUP
+
+AT_SETUP([ovn -- load-balancing - same subnet.])
+AT_KEYWORDS([ovnlb])
+
+CHECK_CONNTRACK()
+CHECK_CONNTRACK_NAT()
+ovn_start
+OVS_TRAFFIC_VSWITCHD_START()
+ADD_BR([br-int])
+
+# Set external-ids in br-int needed for ovn-controller
+ovs-vsctl \
+        -- set Open_vSwitch . external-ids:system-id=hv1 \
+        -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \
+        -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \
+        -- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \
+        -- set bridge br-int fail-mode=secure other-config:disable-in-band=true
+
+# Start ovn-controller
+start_daemon ovn-controller
+
+# Logical network:
+# 1 logical switch "foo" (192.168.1.0/24) connected to router R1.
+# foo has foo1, foo2, foo3, foo4 as logical ports.
+#
+# Loadbalancer VIPs in 30.0.0.0/24 network. Router is needed for default
+# gateway. We will test load-balancing with foo1 as a client and foo2, foo3 and
+# foo4 as servers.
+
+ovn-nbctl create Logical_Router name=R1
+ovn-nbctl ls-add foo
+
+# Connect foo to R1
+ovn-nbctl lrp-add R1 foo 00:00:01:01:02:03 192.168.1.1/24
+ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo \
+    type=router options:router-port=foo addresses=\"00:00:01:01:02:03\"
+
+# Create logical port 'foo1', 'foo2', 'foo3' and 'foo4' in switch 'foo'.
+ADD_NAMESPACES(foo1)
+ADD_VETH(foo1, foo1, br-int, "192.168.1.2/24", "f0:00:00:01:02:03", \
+         "192.168.1.1")
+ovn-nbctl lsp-add foo foo1 \
+-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2"
+
+ADD_NAMESPACES(foo2)
+ADD_VETH(foo2, foo2, br-int, "192.168.1.3/24", "f0:00:00:01:02:04", \
+         "192.168.1.1")
+ovn-nbctl lsp-add foo foo2 \
+-- lsp-set-addresses foo2 "f0:00:00:01:02:04 192.168.1.3"
+
+ADD_NAMESPACES(foo3)
+ADD_VETH(foo3, foo3, br-int, "192.168.1.4/24", "f0:00:00:01:02:05", \
+         "192.168.1.1")
+ovn-nbctl lsp-add foo foo3 \
+-- lsp-set-addresses foo3 "f0:00:00:01:02:05 192.168.1.4"
+
+ADD_NAMESPACES(foo4)
+ADD_VETH(foo4, foo4, br-int, "192.168.1.5/24", "f0:00:00:01:02:06", \
+         "192.168.1.1")
+ovn-nbctl lsp-add foo foo4 \
+-- lsp-set-addresses foo4 "f0:00:00:01:02:06 192.168.1.5"
+
+# Config OVN load-balancer with a VIP.
+uuid=`ovn-nbctl  create load_balancer vips:30.0.0.1="192.168.1.3,192.168.1.4,192.168.1.5"`
+ovn-nbctl set logical_switch foo load_balancer=$uuid
+
+# Config OVN load-balancer with another VIP (this time with ports).
+ovn-nbctl set load_balancer $uuid vips:'"30.0.0.2:8000"'='"192.168.1.3:80,192.168.1.4:80,192.168.1.5:80"'
+
+# Wait for ovn-controller to catch up.
+OVS_WAIT_UNTIL([ovs-ofctl -O OpenFlow13 dump-groups br-int | grep ct\(])
+
+# Start webservers in 'foo2', 'foo3' and 'foo4'.
+NETNS_DAEMONIZE([foo2], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
+NETNS_DAEMONIZE([foo3], [[$PYTHON $srcdir/test-l7.py]], [http2.pid])
+NETNS_DAEMONIZE([foo4], [[$PYTHON $srcdir/test-l7.py]], [http3.pid])
+
+dnl Should work with the virtual IP address through NAT
+for i in `seq 1 20`; do
+    echo Request $i
+    NS_CHECK_EXEC([foo1], [wget 30.0.0.1 -t 5 -T 1 --retry-connrefused -v -o wget$i.log])
+done
+
+dnl Each server should have at least one connection.
+AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(30.0.0.1)], [0], [dnl
+tcp,orig=(src=192.168.1.2,dst=30.0.0.1,sport=<cleared>,dport=<cleared>),reply=(src=192.168.1.3,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>)
+tcp,orig=(src=192.168.1.2,dst=30.0.0.1,sport=<cleared>,dport=<cleared>),reply=(src=192.168.1.4,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>)
+tcp,orig=(src=192.168.1.2,dst=30.0.0.1,sport=<cleared>,dport=<cleared>),reply=(src=192.168.1.5,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>)
+])
+
+dnl Test load-balancing that includes L4 ports in NAT.
+for i in `seq 1 20`; do
+    echo Request $i
+    NS_CHECK_EXEC([foo1], [wget 30.0.0.2:8000 -t 5 -T 1 --retry-connrefused -v -o wget$i.log])
+done
+
+dnl Each server should have at least one connection.
+AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(30.0.0.2)], [0], [dnl
+tcp,orig=(src=192.168.1.2,dst=30.0.0.2,sport=<cleared>,dport=<cleared>),reply=(src=192.168.1.3,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>)
+tcp,orig=(src=192.168.1.2,dst=30.0.0.2,sport=<cleared>,dport=<cleared>),reply=(src=192.168.1.4,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>)
+tcp,orig=(src=192.168.1.2,dst=30.0.0.2,sport=<cleared>,dport=<cleared>),reply=(src=192.168.1.5,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>)
+])
+
+
+OVS_APP_EXIT_AND_WAIT([ovn-controller])
+
+as ovn-sb
+OVS_APP_EXIT_AND_WAIT([ovsdb-server])
+
+as ovn-nb
+OVS_APP_EXIT_AND_WAIT([ovsdb-server])
+
+as northd
+OVS_APP_EXIT_AND_WAIT([ovn-northd])
+
+as
+OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d"])
+AT_CLEANUP