summaryrefslogtreecommitdiffhomepage
path: root/table/policy_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/policy_test.go')
-rw-r--r--table/policy_test.go54
1 files changed, 50 insertions, 4 deletions
diff --git a/table/policy_test.go b/table/policy_test.go
index c3a04433..6897a227 100644
--- a/table/policy_test.go
+++ b/table/policy_test.go
@@ -2728,11 +2728,12 @@ func createStatement(name, psname, nsname string, accept bool) config.Statement
NeighborSet: nsname,
},
}
+ rd := config.ROUTE_DISPOSITION_REJECT_ROUTE
+ if accept {
+ rd = config.ROUTE_DISPOSITION_ACCEPT_ROUTE
+ }
a := config.Actions{
- RouteDisposition: config.RouteDisposition{
- AcceptRoute: accept,
- RejectRoute: !accept,
- },
+ RouteDisposition: rd,
}
s := config.Statement{
Name: name,
@@ -2940,3 +2941,48 @@ func TestLargeCommunityMatchAction(t *testing.T) {
assert.Equal(t, m.Evaluate(p, nil), true)
}
+
+func TestMultipleStatementPolicy(t *testing.T) {
+ r := NewRoutingPolicy()
+ rp := config.RoutingPolicy{
+ PolicyDefinitions: []config.PolicyDefinition{config.PolicyDefinition{
+ Name: "p1",
+ Statements: []config.Statement{
+ config.Statement{
+ Actions: config.Actions{
+ BgpActions: config.BgpActions{
+ SetMed: "+100",
+ },
+ },
+ },
+ config.Statement{
+ Actions: config.Actions{
+ BgpActions: config.BgpActions{
+ SetLocalPref: 100,
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ err := r.reload(rp)
+ assert.Nil(t, err)
+
+ nlri := bgp.NewIPAddrPrefix(24, "10.10.0.0")
+
+ origin := bgp.NewPathAttributeOrigin(0)
+ aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})}
+ aspath := bgp.NewPathAttributeAsPath(aspathParam)
+ nexthop := bgp.NewPathAttributeNextHop("10.0.0.1")
+ pattrs := []bgp.PathAttributeInterface{origin, aspath, nexthop}
+
+ path := NewPath(nil, nlri, false, pattrs, time.Now(), false)
+
+ pType, newPath := r.policyMap["p1"].Apply(path, nil)
+ assert.Equal(t, ROUTE_TYPE_NONE, pType)
+ med, _ := newPath.GetMed()
+ assert.Equal(t, med, uint32(100))
+ localPref, _ := newPath.GetLocalPref()
+ assert.Equal(t, localPref, uint32(100))
+}