Skip to content

Commit 857d899

Browse files
author
Nicolas Bouliane
committed
add tests for backward compatibility
1 parent f45fc10 commit 857d899

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

ovs/action_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,16 @@ func TestLearn(t *testing.T) {
674674
action string
675675
err error
676676
}{
677+
{
678+
desc: "learn ok",
679+
a: Learn(&LearnedFlow{
680+
DeleteLearned: true,
681+
FinHardTimeout: 10,
682+
Matches: []Match{DataLinkType(0x800)},
683+
Actions: []Action{OutputField("in_port"), Load("2", "tp_dst")},
684+
}),
685+
action: `learn(priority=0,dl_type=0x0800,table=0,idle_timeout=0,fin_hard_timeout=10,hard_timeout=0,limit=0,delete_learned,output:in_port,load:2->tp_dst)`,
686+
},
677687
{
678688
desc: "learn ok",
679689
a: Learn(&LearnedFlow{

ovs/flow_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,47 @@ func TestFlowMarshalText(t *testing.T) {
315315
},
316316
{
317317
desc: "Flow with LearnedFlow in Learn action",
318+
f: &Flow{
319+
Priority: 5000,
320+
Protocol: "tcp",
321+
InPort: 3,
322+
Matches: []Match{
323+
NetworkDestination("169.254.169.254"),
324+
TransportDestinationPort(80),
325+
},
326+
Actions: []Action{
327+
Learn(
328+
&LearnedFlow{
329+
DeleteLearned: true,
330+
FinHardTimeout: 1,
331+
Table: 0,
332+
IdleTimeout: 60,
333+
Priority: 5000,
334+
InPort: 4,
335+
Matches: []Match{
336+
DataLinkType(0x800),
337+
NetworkProtocol(6),
338+
FieldMatch("NXM_OF_IP_SRC[]", "NXM_OF_IP_DST[]"),
339+
FieldMatch("NXM_OF_TCP_SRC[]", "NXM_OF_TCP_DST[]"),
340+
NetworkDestination("1.2.3.4"),
341+
TransportDestinationPort(567),
342+
},
343+
Actions: []Action{
344+
Load("NXM_OF_ETH_SRC[]", "NXM_OF_ETH_DST[]"),
345+
Load("NXM_OF_IP_SRC[]", "NXM_OF_IP_DST[]"),
346+
Load("NXM_OF_TCP_SRC[]", "NXM_OF_TCP_DST[]"),
347+
OutputField("NXM_OF_IN_PORT[]"),
348+
},
349+
}),
350+
ModNetworkSource(net.IPv4(1, 2, 3, 4)),
351+
ModTransportSourcePort(567),
352+
Output(4),
353+
},
354+
},
355+
s: `priority=5000,tcp,in_port=3,nw_dst=169.254.169.254,tp_dst=80,table=0,idle_timeout=0,actions=learn(priority=5000,in_port=4,dl_type=0x0800,nw_proto=6,NXM_OF_IP_SRC[]=NXM_OF_IP_DST[],NXM_OF_TCP_SRC[]=NXM_OF_TCP_DST[],nw_dst=1.2.3.4,tp_dst=567,table=0,idle_timeout=60,fin_hard_timeout=1,hard_timeout=0,limit=0,delete_learned,load:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],load:NXM_OF_IP_SRC[]->NXM_OF_IP_DST[],load:NXM_OF_TCP_SRC[]->NXM_OF_TCP_DST[],output:NXM_OF_IN_PORT[]),mod_nw_src:1.2.3.4,mod_tp_src:567,output:4`,
356+
},
357+
{
358+
desc: "Flow with LearnedFlow in Learn action with hard_timeout and limit options",
318359
f: &Flow{
319360
Priority: 5000,
320361
Protocol: "tcp",

0 commit comments

Comments
 (0)