diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-11 18:49:57 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-09 05:17:57 -0800 |
commit | 26c03bb779fbb59bb3de1c98a2c9d65e192b50bb (patch) | |
tree | f68629f1089561e494b26291bf3ec548c7eb93ef /table/policy_test.go | |
parent | 6733b6afb27f3dd3943d8325d2656f9e98740c17 (diff) |
tools: avoid adding a new option to bgpyang2golang.py and fix gobgp.yang
pyang has an internal flag "multiple_modules" to handle multiple yang modules.
use it instead of introducing a new option --augment
also, fix warnings and errors in gobgp.yang which were there but not has been
detected for a while due to the usage of --augment.
by using "multiple_modules" flag, pyang detected them.
most notable error is wrong usage of list, which needs a key in its
substatement.
this patch adds key to some of them, and for others uses leaf-list
instead.
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 | 285 |
1 files changed, 84 insertions, 201 deletions
diff --git a/table/policy_test.go b/table/policy_test.go index 1ab6acce..099804d7 100644 --- a/table/policy_test.go +++ b/table/policy_test.go @@ -700,45 +700,32 @@ func TestAsPathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65001"}, - }, + AsPath: []string{"^65001"}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65005$"}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65004"}, - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65004", "65005$"}, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65000$"}, - }, + AsPath: []string{"65000$"}, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65010"}, - }, + AsPath: []string{"65010"}, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65010$"}, - }, + AsPath: []string{"^65010$"}, } m := make(map[string]DefinedSet) @@ -798,65 +785,47 @@ func TestMultipleAsPathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65001_65000"}, - }, + AsPath: []string{"^65001_65000"}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65004_65005$"}, - }, + AsPath: []string{"65004_65005$"}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65001_65000_54000"}, - }, + AsPath: []string{"65001_65000_54000"}, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "54000_65004_65005"}, - }, + AsPath: []string{"54000_65004_65005"}, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65001 65000 54000 65004 65005$"}, - }, + AsPath: []string{"^65001 65000 54000 65004 65005$"}, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_[0-9]+_65005"}, - }, + AsPath: []string{".*_[0-9]+_65005"}, } asPathSet7 := config.AsPathSet{ AsPathSetName: "asset7", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_5[0-9]+_[0-9]+"}, - }, + AsPath: []string{".*_5[0-9]+_[0-9]+"}, } asPathSet8 := config.AsPathSet{ AsPathSetName: "asset8", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "6[0-9]+_6[0-9]+_5[0-9]+"}, - }, + AsPath: []string{"6[0-9]+_6[0-9]+_5[0-9]+"}, } asPathSet9 := config.AsPathSet{ AsPathSetName: "asset9", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "6[0-9]+__6[0-9]+"}, - }, + AsPath: []string{"6[0-9]+__6[0-9]+"}, } m := make(map[string]DefinedSet) @@ -945,7 +914,7 @@ func TestAsPathCondition(t *testing.T) { for k, v := range tests { s, _ := NewAsPathSet(config.AsPathSet{ AsPathSetName: k, - AsPathList: []config.AsPath{config.AsPath{AsPath: k}}, + AsPath: []string{k}, }) c, _ := NewAsPathCondition(config.MatchAsPathSet{ AsPathSet: k, @@ -987,7 +956,7 @@ func TestAsPathConditionWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{config.AsPath{AsPath: "65005$"}}, + AsPath: []string{"65005$"}, } ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -1053,44 +1022,40 @@ func TestAs4PathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d", createAs4Value("65001.1"))}, - }, + AsPath: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65005.1"))}, - }, + AsPath: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d", createAs4Value("65004.1"))}, - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("%d", createAs4Value("65004.1")), + fmt.Sprintf("%d$", createAs4Value("65005.1")), }, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65000.1"))}, + AsPath: []string{ + fmt.Sprintf("%d$", createAs4Value("65000.1")), }, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d", createAs4Value("65010.1"))}, + AsPath: []string{ + fmt.Sprintf("%d", createAs4Value("65010.1")), }, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65010.1"))}, + AsPath: []string{ + fmt.Sprintf("%d$", createAs4Value("65010.1")), }, } @@ -1160,65 +1125,59 @@ func TestMultipleAs4PathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"))}, + AsPath: []string{ + fmt.Sprintf("^%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1")), }, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d$", createAs4Value("65004.1"), createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("%d_%d$", createAs4Value("65004.1"), createAs4Value("65005.1")), }, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"))}, + AsPath: []string{ + fmt.Sprintf("%d_%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1")), }, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1")), }, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d %d %d %d %d$", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("^%d %d %d %d %d$", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1")), }, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf(".*_[0-9]+_%d", createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf(".*_[0-9]+_%d", createAs4Value("65005.1")), }, } asPathSet7 := config.AsPathSet{ AsPathSetName: "asset7", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_3[0-9]+_[0-9]+"}, - }, + AsPath: []string{".*_3[0-9]+_[0-9]+"}, } asPathSet8 := config.AsPathSet{ AsPathSetName: "asset8", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "4[0-9]+_4[0-9]+_3[0-9]+"}, - }, + AsPath: []string{"4[0-9]+_4[0-9]+_3[0-9]+"}, } asPathSet9 := config.AsPathSet{ AsPathSetName: "asset9", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "4[0-9]+__4[0-9]+"}, - }, + AsPath: []string{"4[0-9]+__4[0-9]+"}, } m := make(map[string]DefinedSet) @@ -1291,9 +1250,7 @@ func TestAs4PathConditionWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{config.AsPath{ - AsPath: fmt.Sprintf("%d$", createAs4Value("65005.1")), - }}, + AsPath: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))}, } ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -1351,52 +1308,37 @@ func TestAs4PathConditionEvaluateMixedWith2byteAS(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d", createAs4Value("65001.1"))}, - }, + AsPath: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "4000$"}, - }, + AsPath: []string{"4000$"}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d", createAs4Value("65004.1"))}, - config.AsPath{AsPath: "4000$"}, - }, + AsPath: []string{fmt.Sprintf("%d", createAs4Value("65004.1")), "4000$"}, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), 100, 5000)}, - }, + AsPath: []string{fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), 100, 5000)}, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_[0-9]+_100"}, - }, + AsPath: []string{".*_[0-9]+_100"}, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_3[0-9]+_[0]+"}, - }, + AsPath: []string{".*_3[0-9]+_[0]+"}, } asPathSet7 := config.AsPathSet{ AsPathSetName: "asset7", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_3[0-9]+_[1]+"}, - }, + AsPath: []string{".*_3[0-9]+_[1]+"}, } m := make(map[string]DefinedSet) @@ -1478,76 +1420,58 @@ func TestCommunityConditionEvaluate(t *testing.T) { // create match condition comSet1 := config.CommunitySet{ CommunitySetName: "comset1", - CommunityList: []config.Community{ - config.Community{Community: "65001:10"}, - config.Community{Community: "65001:50"}, - config.Community{Community: "65001:100"}, - }, + Community: []string{"65001:10", "65001:50", "65001:100"}, } comSet2 := config.CommunitySet{ CommunitySetName: "comset2", - CommunityList: []config.Community{ - config.Community{Community: "65001:200"}, - }, + Community: []string{"65001:200"}, } comSet3 := config.CommunitySet{ CommunitySetName: "comset3", - CommunityList: []config.Community{ - config.Community{Community: "4259905936"}, - }, + Community: []string{"4259905936"}, } comSet4 := config.CommunitySet{ CommunitySetName: "comset4", - CommunityList: []config.Community{ - config.Community{Community: "^[0-9]*:300$"}, - }, + Community: []string{"^[0-9]*:300$"}, } comSet5 := config.CommunitySet{ CommunitySetName: "comset5", - CommunityList: []config.Community{ - config.Community{Community: "INTERNET"}, - }, + Community: []string{"INTERNET"}, } comSet6 := config.CommunitySet{ CommunitySetName: "comset6", - CommunityList: []config.Community{ - config.Community{Community: "NO_EXPORT"}, - }, + Community: []string{"NO_EXPORT"}, } comSet7 := config.CommunitySet{ CommunitySetName: "comset7", - CommunityList: []config.Community{ - config.Community{Community: "NO_ADVERTISE"}, - }, + Community: []string{"NO_ADVERTISE"}, } comSet8 := config.CommunitySet{ CommunitySetName: "comset8", - CommunityList: []config.Community{ - config.Community{Community: "NO_EXPORT_SUBCONFED"}, - }, + Community: []string{"NO_EXPORT_SUBCONFED"}, } comSet9 := config.CommunitySet{ CommunitySetName: "comset9", - CommunityList: []config.Community{ - config.Community{Community: "65001:\\d+"}, - config.Community{Community: "\\d+:\\d00"}, + Community: []string{ + "65001:\\d+", + "\\d+:\\d00", }, } comSet10 := config.CommunitySet{ CommunitySetName: "comset10", - CommunityList: []config.Community{ - config.Community{Community: "65001:1"}, - config.Community{Community: "65001:2"}, - config.Community{Community: "65001:3"}, + Community: []string{ + "65001:1", + "65001:2", + "65001:3", }, } @@ -1628,25 +1552,17 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65005$"}, } comSet1 := config.CommunitySet{ CommunitySetName: "comset1", - CommunityList: []config.Community{ - config.Community{Community: "65001:100"}, - config.Community{Community: "65001:200"}, - config.Community{Community: "65001:300"}, - }, + Community: []string{"65001:100", "65001:200", "65001:300"}, } comSet2 := config.CommunitySet{ CommunitySetName: "comset2", - CommunityList: []config.Community{ - config.Community{Community: "65050:\\d+"}, - }, + Community: []string{"65050:\\d+"}, } ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") @@ -2044,72 +1960,48 @@ func TestExtCommunityConditionEvaluate(t *testing.T) { // create match condition ecomSet1 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet1", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65001:200"}, - }, + ExtCommunity: []string{"RT:65001:200"}, } ecomSet2 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet2", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:10.0.0.1:300"}, - }, + ExtCommunity: []string{"RT:10.0.0.1:300"}, } ecomSet3 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet3", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: fmt.Sprintf("RT:%s:200", convUintStr(65030000))}, - }, + ExtCommunity: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030000))}, } ecomSet4 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet4", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65002:200"}, - }, + ExtCommunity: []string{"RT:65002:200"}, } ecomSet5 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet5", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:10.0.0.2:300"}, - }, + ExtCommunity: []string{"RT:10.0.0.2:300"}, } ecomSet6 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet6", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: fmt.Sprintf("RT:%s:200", convUintStr(65030001))}, - }, + ExtCommunity: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030001))}, } ecomSet7 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet7", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "SoO:65010:300"}, - }, + ExtCommunity: []string{"SoO:65010:300"}, } ecomSet8 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet8", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "SoO:10.0.10.10:[0-9]+"}, - }, + ExtCommunity: []string{"SoO:10.0.10.10:[0-9]+"}, } ecomSet9 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet9", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:[0-9]+:[0-9]+"}, - }, + ExtCommunity: []string{"RT:[0-9]+:[0-9]+"}, } ecomSet10 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet10", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:.+:\\d00"}, - config.ExtCommunity{ExtCommunity: "SoO:.+:\\d00"}, - }, + ExtCommunity: []string{"RT:.+:\\d00", "SoO:.+:\\d00"}, } ecomSet11 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet11", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65001:2"}, - config.ExtCommunity{ExtCommunity: "SoO:11.0.10.10:[0-9]+"}, - }, + ExtCommunity: []string{"RT:65001:2", "SoO:11.0.10.10:[0-9]+"}, } m := make(map[string]DefinedSet) @@ -2240,22 +2132,16 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65005$"}, } ecomSet1 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet1", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65001:201"}, - }, + ExtCommunity: []string{"RT:65001:201"}, } ecomSet2 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet2", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:[0-9]+:[0-9]+"}, - }, + ExtCommunity: []string{"RT:[0-9]+:[0-9]+"}, } ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -2837,10 +2723,7 @@ func createPrefixSet(name string, prefix string, maskLength string) config.Prefi func createNeighborSet(name string, addr string) config.NeighborSet { ns := config.NeighborSet{ NeighborSetName: name, - NeighborInfoList: []config.NeighborInfo{ - config.NeighborInfo{ - Address: addr, - }}, + NeighborInfo: []string{addr}, } return ns } |