diff options
author | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-11-16 21:45:27 -0500 |
---|---|---|
committer | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-11-17 23:22:55 -0500 |
commit | 93d1dca70aa0ae3b34050d24ad7462b8757213bf (patch) | |
tree | 29c369dfb6d2180e62bf51a5819eff8644bbc81a /table/policy_test.go | |
parent | 24e397b0f65b1c5294ea711a953501fda944411d (diff) |
config: simplify route-disposition configuration
before:
```yaml
actions:
route-disposition:
accept-route: true
reject-route: false
```
after
```yaml
action:
router-disposition: accept-route
```
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/policy_test.go')
-rw-r--r-- | table/policy_test.go | 54 |
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)) +} |