diff options
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{ |