diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-25 02:43:31 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-25 02:53:42 +0000 |
commit | 0dbf1d87cb6f42498e6607d616572fb80d36fd83 (patch) | |
tree | a942f671dd44ee75480ad6d3f162d9d29f1be42d /table/policy_test.go | |
parent | 7c42e295e28c233fdb7a130681cd490308f116ca (diff) |
policy: add local-pref action
$ gobgp policy statement st01 add action local-pref 110
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/policy_test.go')
-rw-r--r-- | table/policy_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/table/policy_test.go b/table/policy_test.go index be301593..63cbb546 100644 --- a/table/policy_test.go +++ b/table/policy_test.go @@ -2666,6 +2666,36 @@ func TestParseCommunityRegexp(t *testing.T) { assert.Equal(t, false, exp.MatchString("65000:100")) } +func TestLocalPrefAction(t *testing.T) { + action, err := NewLocalPrefAction(10) + assert.Nil(t, err) + + nlri := bgp.NewIPAddrPrefix(24, "10.0.0.0") + + origin := bgp.NewPathAttributeOrigin(0) + aspathParam := []bgp.AsPathParamInterface{ + bgp.NewAs4PathParam(2, []uint32{ + createAs4Value("65002.1"), + createAs4Value("65001.1"), + createAs4Value("65000.1"), + }), + } + aspath := bgp.NewPathAttributeAsPath(aspathParam) + nexthop := bgp.NewPathAttributeNextHop("10.0.0.1") + med := bgp.NewPathAttributeMultiExitDisc(0) + + attrs := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} + + path := NewPath(nil, nlri, false, attrs, time.Now(), false) + p := action.Apply(path) + assert.NotNil(t, p) + + attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF) + assert.NotNil(t, attr) + lp := attr.(*bgp.PathAttributeLocalPref) + assert.Equal(t, int(lp.Value), int(10)) +} + func createStatement(name, psname, nsname string, accept bool) config.Statement { c := config.Conditions{ MatchPrefixSet: config.MatchPrefixSet{ |