summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-07-15 19:53:53 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-07-31 16:26:17 +0900
commit0b4b806c06f0ee50bb1bc1b30c38399553687abd (patch)
tree6898ec9eeb21a26668012c1c7743772da7b72214 /test/scenario_test
parent2ad42ead02cce21cf71b3dde0731e8f5c6d4ac6a (diff)
config: use the latest openconfig yang
Diffstat (limited to 'test/scenario_test')
-rw-r--r--test/scenario_test/gobgp_test.py36
-rw-r--r--test/scenario_test/lib/gobgp.py23
-rw-r--r--test/scenario_test/policy/policy_generator.go948
-rw-r--r--test/scenario_test/quagga-rsconfig.go90
-rw-r--r--test/scenario_test/route_server_malformed_test.py4
-rw-r--r--test/scenario_test/route_server_policy_test.py25
6 files changed, 466 insertions, 660 deletions
diff --git a/test/scenario_test/gobgp_test.py b/test/scenario_test/gobgp_test.py
index 1333afad..03443777 100644
--- a/test/scenario_test/gobgp_test.py
+++ b/test/scenario_test/gobgp_test.py
@@ -113,9 +113,20 @@ class GoBGPTestBase(unittest.TestCase):
return
self.assertEqual(ans_nexthop, rep_nexthop)
+ def extract_bgp_section(self):
+ with open(self.gobgp_config_file) as f:
+ dst = ''
+ for line in f:
+ if 'DefinedSets' in line:
+ break
+ dst += line
+
+ return dst.encode('utf8')
+
def load_gobgp_config(self):
try:
- self.gobgp_config = toml.loads(open(self.gobgp_config_file).read())
+ t = self.extract_bgp_section()
+ self.gobgp_config = toml.loads(t)
except IOError, (errno, strerror):
print "I/O error(%s): %s" % (errno, strerror)
@@ -169,9 +180,9 @@ class GoBGPTestBase(unittest.TestCase):
# get address of each neighbor from gobpg configration
def get_neighbor_address(self, config):
address = []
- neighbors_config = config['NeighborList']
+ neighbors_config = config['Neighbors']['NeighborList']
for neighbor_config in neighbors_config:
- neighbor_ip = neighbor_config['NeighborAddress']
+ neighbor_ip = neighbor_config['NeighborConfig']['NeighborAddress']
address.append(neighbor_ip)
return address
@@ -266,6 +277,25 @@ class GoBGPTestBase(unittest.TestCase):
print "adj_rib_%s is none" % type
return None
+ # quagga login check
+ def try_login_quagga(self, peer, retry=3, interval=1):
+ print "try login to quagga : %s" % peer
+ if interval < 0:
+ interval = self.wait_per_retry
+ retry_count = 0
+ while True:
+ try:
+ tn = qaccess.login(peer)
+ return tn
+ except:
+ retry_count += 1
+ if retry_count > retry:
+ break
+ print "failed to login to %s" % peer
+ print "wait (" + str(interval) + " seconds)"
+ time.sleep(interval)
+ return None
+
# get route information on quagga
def get_route(self, neighbor_address, target_prefix, retry=3, interval=-1, af=IPv4):
diff --git a/test/scenario_test/lib/gobgp.py b/test/scenario_test/lib/gobgp.py
index 433d779e..4092882a 100644
--- a/test/scenario_test/lib/gobgp.py
+++ b/test/scenario_test/lib/gobgp.py
@@ -108,7 +108,7 @@ class GoBGPContainer(BGPContainer):
return json.loads(output)['info']['bgp_state']
def create_config(self):
- config = {'Global': {'As': self.asn, 'RouterId': self.router_id}}
+ config = {'Global': {'GlobalConfig': {'As': self.asn, 'RouterId': self.router_id}}}
for peer, info in self.peers.iteritems():
if self.asn == peer.asn:
peer_type = self.PEER_TYPE_INTERNAL
@@ -129,14 +129,17 @@ class GoBGPContainer(BGPContainer):
afi_safi_list.append({'AfiSafiName': 'encap'})
afi_safi_list.append({'AfiSafiName': 'rtc'})
- n = {'NeighborAddress': info['neigh_addr'].split('/')[0],
- 'PeerAs': peer.asn,
- 'AuthPassword': info['passwd'],
- 'PeerType': peer_type,
- 'AfiSafiList': afi_safi_list}
+ n = {'NeighborConfig':
+ {'NeighborAddress': info['neigh_addr'].split('/')[0],
+ 'PeerAs': peer.asn,
+ 'AuthPassword': info['passwd'],
+ 'PeerType': peer_type,
+ },
+ 'AfiSafis': {'AfiSafiList': afi_safi_list}
+ }
if info['passive']:
- n['TransportOptions'] = {'PassiveMode': True}
+ n['Transport'] = {'TransportConfig': {'PassiveMode': True}}
if info['is_rs_client']:
n['RouteServer'] = {'RouteServerClient': True}
@@ -146,10 +149,10 @@ class GoBGPContainer(BGPContainer):
n['RouteReflector'] = {'RouteReflectorClient': True,
'RouteReflectorClusterId': clusterId}
- if 'NeighborList' not in config:
- config['NeighborList'] = []
+ if 'Neighbors' not in config:
+ config['Neighbors'] = {'NeighborList': []}
- config['NeighborList'].append(n)
+ config['Neighbors']['NeighborList'].append(n)
with open('{0}/gobgpd.conf'.format(self.config_dir), 'w') as f:
print colors.yellow('[{0}\'s new config]'.format(self.name))
diff --git a/test/scenario_test/policy/policy_generator.go b/test/scenario_test/policy/policy_generator.go
index 5e2308d4..abf0fc0f 100644
--- a/test/scenario_test/policy/policy_generator.go
+++ b/test/scenario_test/policy/policy_generator.go
@@ -21,41 +21,41 @@ func bindPolicy(outputDir, peer, target, policyName string, isReplace bool, defa
log.Fatal(d_err)
}
- for idx, neighbor := range newConf.NeighborList {
+ for idx, neighbor := range newConf.Neighbors.NeighborList {
ip := net.ParseIP(peer)
- if ip.String() == neighbor.NeighborAddress.String() {
- ap := &neighbor.ApplyPolicy
+ if ip.String() == neighbor.NeighborConfig.NeighborAddress.String() {
+ ap := &neighbor.ApplyPolicy.ApplyPolicyConfig
switch target {
case "import":
if isReplace {
- ap.ImportPolicies = []string{policyName}
+ ap.ImportPolicy = []string{policyName}
} else {
- ap.ImportPolicies = append(ap.ImportPolicies, policyName)
+ ap.ImportPolicy = append(ap.ImportPolicy, policyName)
}
if defaultReject {
ap.DefaultImportPolicy = 1
}
case "export":
if isReplace {
- ap.ExportPolicies = []string{policyName}
+ ap.ExportPolicy = []string{policyName}
} else {
- ap.ExportPolicies = append(ap.ExportPolicies, policyName)
+ ap.ExportPolicy = append(ap.ExportPolicy, policyName)
}
if defaultReject {
ap.DefaultExportPolicy = 1
}
case "distribute":
if isReplace {
- ap.DistributePolicies = []string{policyName}
+ ap.DistributePolicy = []string{policyName}
} else {
- ap.DistributePolicies = append(ap.DistributePolicies, policyName)
+ ap.DistributePolicy = append(ap.DistributePolicy, policyName)
}
if defaultReject {
ap.DefaultDistributePolicy = 1
}
}
- newConf.NeighborList[idx] = neighbor
+ newConf.Neighbors.NeighborList[idx] = neighbor
}
}
@@ -73,12 +73,16 @@ func bindPolicy(outputDir, peer, target, policyName string, isReplace bool, defa
func createPolicyConfig() *config.RoutingPolicy {
+ cidr := func(pref string) net.IPNet {
+ _, n, _ := net.ParseCIDR(pref)
+ return *n
+ }
+
ps0 := config.PrefixSet{
PrefixSetName: "ps0",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("192.168.0.0"),
- Masklength: 16,
+ IpPrefix: cidr("192.168.0.0/16"),
MasklengthRange: "16..24",
}},
}
@@ -87,11 +91,9 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "ps1",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("192.168.20.0"),
- Masklength: 24,
+ IpPrefix: cidr("192.168.20.0/24"),
}, config.Prefix{
- Address: net.ParseIP("192.168.200.0"),
- Masklength: 24,
+ IpPrefix: cidr("192.168.200.0/24"),
}},
}
@@ -99,8 +101,7 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "ps2",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("192.168.20.0"),
- Masklength: 24,
+ IpPrefix: cidr("192.168.20.0/24"),
}},
}
@@ -108,8 +109,7 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "ps3",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("2001:0:10:2::"),
- Masklength: 64,
+ IpPrefix: cidr("2001:0:10:2::/64"),
MasklengthRange: "64..128",
}},
}
@@ -118,11 +118,9 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "ps4",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("2001:0:10:20::"),
- Masklength: 64,
+ IpPrefix: cidr("2001:0:10:20::/64"),
}, config.Prefix{
- Address: net.ParseIP("2001:0:10:200::"),
- Masklength: 64,
+ IpPrefix: cidr("2001:0:10:200::/64"),
}},
}
@@ -130,8 +128,7 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "ps5",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("2001:0:10:20::"),
- Masklength: 64,
+ IpPrefix: cidr("2001:0:10:20::/64"),
}},
}
@@ -139,8 +136,7 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "ps6",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("192.168.10.0"),
- Masklength: 24,
+ IpPrefix: cidr("192.168.10.0/24"),
}},
}
@@ -172,771 +168,531 @@ func createPolicyConfig() *config.RoutingPolicy {
PrefixSetName: "psExabgp",
PrefixList: []config.Prefix{
config.Prefix{
- Address: net.ParseIP("192.168.100.0"),
- Masklength: 24,
+ IpPrefix: cidr("192.168.100.0/24"),
MasklengthRange: "16..24",
}},
}
aspathFrom := config.AsPathSet{
- AsPathSetName: "aspathFrom",
- AsPathSetMembers: []string{"^65100"},
+ AsPathSetName: "aspathFrom",
+ AsPathSetMember: []string{"^65100"},
}
aspathAny := config.AsPathSet{
- AsPathSetName: "aspAny",
- AsPathSetMembers: []string{"65098"},
+ AsPathSetName: "aspAny",
+ AsPathSetMember: []string{"65098"},
}
aspathOrigin := config.AsPathSet{
- AsPathSetName: "aspOrigin",
- AsPathSetMembers: []string{"65091$"},
+ AsPathSetName: "aspOrigin",
+ AsPathSetMember: []string{"65091$"},
}
aspathOnly := config.AsPathSet{
- AsPathSetName: "aspOnly",
- AsPathSetMembers: []string{"^65100$"},
+ AsPathSetName: "aspOnly",
+ AsPathSetMember: []string{"^65100$"},
}
comStr := config.CommunitySet{
CommunitySetName: "comStr",
- CommunityMembers: []string{"65100:10"},
+ CommunityMember: []string{"65100:10"},
}
comRegExp := config.CommunitySet{
CommunitySetName: "comRegExp",
- CommunityMembers: []string{"6[0-9]+:[0-9]+"},
+ CommunityMember: []string{"6[0-9]+:[0-9]+"},
}
eComOrigin := config.ExtCommunitySet{
ExtCommunitySetName: "eComOrigin",
- ExtCommunityMembers: []string{"SoO:65001.65100:200"},
+ ExtCommunityMember: []string{"SoO:65001.65100:200"},
}
eComTarget := config.ExtCommunitySet{
ExtCommunitySetName: "eComTarget",
- ExtCommunityMembers: []string{"RT:6[0-9]+:3[0-9]+"},
+ ExtCommunityMember: []string{"RT:6[0-9]+:3[0-9]+"},
}
- st0 := config.Statement{
- Name: "st0",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps0",
- MatchNeighborSet: "nsPeer2",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ createStatement := func(name string, ps, ns string, accept bool) config.Statement {
+ st := config.Statement{}
+ st.Name = name
+ st.Actions.RouteDisposition.AcceptRoute = accept
- st1 := config.Statement{
- Name: "st1",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps1",
- MatchNeighborSet: "nsPeer2",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ if ps != "" {
+ st.Conditions.MatchPrefixSet.PrefixSet = ps
+ }
- st2 := config.Statement{
- Name: "st2",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps2",
- MatchNeighborSet: "nsPeer2",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- RejectRoute: true,
- },
- }
+ if ns != "" {
+ st.Conditions.MatchNeighborSet.NeighborSet = ns
+ }
- st3 := config.Statement{
- Name: "st3",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps3",
- MatchNeighborSet: "nsPeer2V6",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
+ return st
}
- st4 := config.Statement{
- Name: "st4",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps4",
- MatchNeighborSet: "nsPeer2V6",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st0 := createStatement("st0", "ps0", "nsPeer2", false)
+ st1 := createStatement("st1", "ps1", "nsPeer2", false)
+ st2 := createStatement("st2", "ps2", "nsPeer2", false)
+ st3 := createStatement("st3", "ps3", "nsPeer2V6", false)
+ st4 := createStatement("st4", "ps4", "nsPeer2V6", false)
+ st5 := createStatement("st5", "ps5", "nsPeer2V6", false)
- st5 := config.Statement{
- Name: "st5",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps5",
- MatchNeighborSet: "nsPeer2V6",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- RejectRoute: true,
- },
- }
+ st_aspathlen := createStatement("st_aspathlen", "psExabgp", "nsExabgp", false)
+ st_aspathlen.Conditions.BgpConditions.AsPathLength.Operator = "ge"
+ st_aspathlen.Conditions.BgpConditions.AsPathLength.Value = 10
- st_aspathlen := config.Statement{
- Name: "st_aspathlen",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- AsPathLength: config.AsPathLength{
- Operator: "ge",
- Value: 10,
- },
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_aspathFrom := createStatement("st_aspathFrom", "psExabgp", "nsExabgp", false)
+ st_aspathFrom.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspathFrom"
- st_aspathFrom := config.Statement{
- Name: "st_aspathlen",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchAsPathSet: "aspathFrom",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_aspathAny := createStatement("st_aspathAny", "psExabgp", "nsExabgp", false)
+ st_aspathAny.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspAny"
- st_aspathAny := config.Statement{
- Name: "st_aspathlen",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchAsPathSet: "aspAny",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_aspathOrigin := createStatement("st_aspathOrigin", "psExabgp", "nsExabgp", false)
+ st_aspathOrigin.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspOrigin"
- st_aspathOrigin := config.Statement{
- Name: "st_aspathlen",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchAsPathSet: "aspOrigin",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_aspathOnly := createStatement("st_aspathOnly", "psExabgp", "nsExabgp", false)
+ st_aspathOnly.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspOnly"
- st_aspathOnly := config.Statement{
- Name: "st_aspathlen",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchAsPathSet: "aspOnly",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_comStr := createStatement("st_community", "psExabgp", "nsExabgp", false)
+ st_comStr.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
- st_comStr := config.Statement{
- Name: "st_community",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_comRegExp := createStatement("st_community_regexp", "psExabgp", "nsExabgp", false)
+ st_comRegExp.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comRegExp"
- st_comRegExp := config.Statement{
- Name: "st_community_regexp",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comRegExp",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_comAdd := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
+ st_comAdd.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
+ st_comAdd.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20"}
+ st_comAdd.Actions.BgpActions.SetCommunity.Options = "ADD"
- st_comAdd := config.Statement{
- Name: "st_community_regexp",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetCommunity: config.SetCommunity{
- Communities: []string{"65100:20"},
- Options: "ADD",
- },
- },
- },
- }
+ st_comReplace := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
+ st_comReplace.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
+ st_comReplace.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20", "65100:30"}
+ st_comReplace.Actions.BgpActions.SetCommunity.Options = "REPLACE"
- st_comReplace := config.Statement{
- Name: "st_community_regexp",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetCommunity: config.SetCommunity{
- Communities: []string{"65100:20", "65100:30"},
- Options: "REPLACE",
- },
- },
- },
- }
+ st_comRemove := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
+ st_comRemove.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
+ st_comRemove.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20", "65100:30"}
+ st_comRemove.Actions.BgpActions.SetCommunity.Options = "REMOVE"
- st_comRemove := config.Statement{
- Name: "st_community_regexp",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetCommunity: config.SetCommunity{
- Communities: []string{"65100:20", "65100:30"},
- Options: "REMOVE",
- },
- },
- },
- }
+ st_comNull := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
+ st_comNull.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
+ st_comNull.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{}
+ //use REPLACE instead of NULL
+ st_comNull.Actions.BgpActions.SetCommunity.Options = "REPLACE"
- st_comNull := config.Statement{
- Name: "st_community_regexp",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetCommunity: config.SetCommunity{
- Communities: []string{},
- Options: "NULL",
- },
- },
- },
- }
+ st_medReplace := createStatement("st_medReplace", "psExabgp", "nsExabgp", true)
+ st_medReplace.Actions.BgpActions.SetMed = "100"
- st_medReplace := config.Statement{
- Name: "st_medReplace",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetMed: "100",
- },
- },
- }
+ st_medAdd := createStatement("st_medAdd", "psExabgp", "nsExabgp", true)
+ st_medAdd.Actions.BgpActions.SetMed = "+100"
- st_medAdd := config.Statement{
- Name: "st_medAdd",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetMed: "+100",
- },
- },
- }
+ st_medSub := createStatement("st_medSub", "psExabgp", "nsExabgp", true)
+ st_medSub.Actions.BgpActions.SetMed = "-100"
- st_medSub := config.Statement{
- Name: "st_medSub",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetMed: "-100",
- },
- },
- }
+ st_distribute_reject := createStatement("st_community_distriibute", "", "", false)
+ st_distribute_reject.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
- st_distribute_reject := config.Statement{
- Name: "st_community_distriibute",
- Conditions: config.Conditions{
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_distribute_accept := createStatement("st_distriibute_accept", "ps6", "", true)
- st_distribute_accept := config.Statement{
- Name: "st_distriibute_accept",
- Conditions: config.Conditions{
- MatchPrefixSet: "ps6",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- },
- }
+ st_distribute_comm_add := createStatement("st_distribute_comm_add", "", "", true)
+ st_distribute_comm_add.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
+ st_distribute_comm_add.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20"}
+ st_distribute_comm_add.Actions.BgpActions.SetCommunity.Options = "ADD"
- st_distribute_comm_add := config.Statement{
- Name: "st_distribute_comm_add",
- Conditions: config.Conditions{
- BgpConditions: config.BgpConditions{
- MatchCommunitySet: "comStr",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetCommunity: config.SetCommunity{
- Communities: []string{"65100:20"},
- Options: "ADD",
- },
- },
- },
- }
+ st_distribute_med_add := createStatement("st_distribute_med_add", "psExabgp", "nsExabgp", true)
+ st_distribute_med_add.Actions.BgpActions.SetMed = "+100"
- st_distribute_med_add := config.Statement{
- Name: "st_distribute_med_add",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetMed: "+100",
- },
- },
- }
+ st_asprepend := createStatement("st_asprepend", "psExabgp", "nsExabgp", true)
+ st_asprepend.Actions.BgpActions.SetAsPathPrepend.As = "65005"
+ st_asprepend.Actions.BgpActions.SetAsPathPrepend.RepeatN = 5
- st_asprepend := config.Statement{
- Name: "st_asprepend",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetAsPathPrepend: config.SetAsPathPrepend{
- As: "65005",
- RepeatN: 5,
- },
- },
- },
- }
+ st_asprepend_lastas := createStatement("st_asprepend_lastas", "psExabgp", "nsExabgp", true)
+ st_asprepend_lastas.Actions.BgpActions.SetAsPathPrepend.As = "last-as"
+ st_asprepend_lastas.Actions.BgpActions.SetAsPathPrepend.RepeatN = 5
- st_asprepend_lastas := config.Statement{
- Name: "st_asprepend_lastas",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: true,
- BgpActions: config.BgpActions{
- SetAsPathPrepend: config.SetAsPathPrepend{
- As: "last-as",
- RepeatN: 5,
- },
- },
- },
- }
- st_eComOrigin := config.Statement{
- Name: "st_eComAS4",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchExtCommunitySet: "eComOrigin",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
- st_eComTarget := config.Statement{
- Name: "st_eComRegExp",
- Conditions: config.Conditions{
- MatchPrefixSet: "psExabgp",
- MatchNeighborSet: "nsExabgp",
- BgpConditions: config.BgpConditions{
- MatchExtCommunitySet: "eComTarget",
- },
- MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL,
- },
- Actions: config.Actions{
- AcceptRoute: false,
- },
- }
+ st_eComOrigin := createStatement("st_eComAS4", "psExabgp", "nsExabgp", false)
+ st_eComOrigin.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet = "eComOrigin"
+
+ st_eComTarget := createStatement("st_eComRegExp", "psExabgp", "nsExabgp", false)
+ st_eComTarget.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet = "eComTarget"
test_01_import_policy_initial := config.PolicyDefinition{
- Name: "test_01_import_policy_initial",
- StatementList: []config.Statement{st0},
+ Name: "test_01_import_policy_initial",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st0},
+ },
}
test_02_export_policy_initial := config.PolicyDefinition{
- Name: "test_02_export_policy_initial",
- StatementList: []config.Statement{st0},
+ Name: "test_02_export_policy_initial",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st0},
+ },
}
test_03_import_policy_update := config.PolicyDefinition{
- Name: "test_03_import_policy_update",
- StatementList: []config.Statement{st1},
+ Name: "test_03_import_policy_update",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st1},
+ },
}
test_03_import_policy_update_softreset := config.PolicyDefinition{
- Name: "test_03_import_policy_update_softreset",
- StatementList: []config.Statement{st2},
+ Name: "test_03_import_policy_update_softreset",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st2},
+ },
}
test_04_export_policy_update := config.PolicyDefinition{
- Name: "test_04_export_policy_update",
- StatementList: []config.Statement{st1},
+ Name: "test_04_export_policy_update",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st1},
+ },
}
test_04_export_policy_update_softreset := config.PolicyDefinition{
- Name: "test_04_export_policy_update_softreset",
- StatementList: []config.Statement{st2},
+ Name: "test_04_export_policy_update_softreset",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st2},
+ },
}
test_05_import_policy_initial_ipv6 := config.PolicyDefinition{
- Name: "test_05_import_policy_initial_ipv6",
- StatementList: []config.Statement{st3},
+ Name: "test_05_import_policy_initial_ipv6",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st3},
+ },
}
test_06_export_policy_initial_ipv6 := config.PolicyDefinition{
- Name: "test_06_export_policy_initial_ipv6",
- StatementList: []config.Statement{st3},
+ Name: "test_06_export_policy_initial_ipv6",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st3},
+ },
}
test_07_import_policy_update := config.PolicyDefinition{
- Name: "test_07_import_policy_update",
- StatementList: []config.Statement{st4},
+ Name: "test_07_import_policy_update",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st4},
+ },
}
test_07_import_policy_update_softreset := config.PolicyDefinition{
- Name: "test_07_import_policy_update_softreset",
- StatementList: []config.Statement{st5},
+ Name: "test_07_import_policy_update_softreset",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st5},
+ },
}
test_08_export_policy_update := config.PolicyDefinition{
- Name: "test_08_export_policy_update",
- StatementList: []config.Statement{st4},
+ Name: "test_08_export_policy_update",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st4},
+ },
}
test_08_export_policy_update_softreset := config.PolicyDefinition{
- Name: "test_08_export_policy_update_softreset",
- StatementList: []config.Statement{st5},
+ Name: "test_08_export_policy_update_softreset",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st5},
+ },
}
test_09_aspath_length_condition_import := config.PolicyDefinition{
- Name: "test_09_aspath_length_condition_import",
- StatementList: []config.Statement{st_aspathlen},
+ Name: "test_09_aspath_length_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_aspathlen},
+ },
}
test_10_aspath_from_condition_import := config.PolicyDefinition{
- Name: "test_10_aspath_from_condition_import",
- StatementList: []config.Statement{st_aspathFrom},
+ Name: "test_10_aspath_from_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_aspathFrom},
+ },
}
test_11_aspath_any_condition_import := config.PolicyDefinition{
- Name: "test_11_aspath_any_condition_import",
- StatementList: []config.Statement{st_aspathAny},
+ Name: "test_11_aspath_any_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_aspathAny},
+ },
}
test_12_aspath_origin_condition_import := config.PolicyDefinition{
- Name: "test_12_aspath_origin_condition_import",
- StatementList: []config.Statement{st_aspathOrigin},
+ Name: "test_12_aspath_origin_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_aspathOrigin},
+ },
}
test_13_aspath_only_condition_import := config.PolicyDefinition{
- Name: "test_13_aspath_only_condition_import",
- StatementList: []config.Statement{st_aspathOnly},
+ Name: "test_13_aspath_only_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_aspathOnly},
+ },
}
test_14_aspath_only_condition_import := config.PolicyDefinition{
- Name: "test_14_aspath_only_condition_import",
- StatementList: []config.Statement{st_comStr},
+ Name: "test_14_aspath_only_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comStr},
+ },
}
test_15_community_condition_import := config.PolicyDefinition{
- Name: "test_15_community_condition_import",
- StatementList: []config.Statement{st_comStr},
+ Name: "test_15_community_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comStr},
+ },
}
test_16_community_condition_regexp_import := config.PolicyDefinition{
- Name: "test_16_community_condition_regexp_import",
- StatementList: []config.Statement{st_comRegExp},
+ Name: "test_16_community_condition_regexp_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comRegExp},
+ },
}
test_17_community_add_action_import := config.PolicyDefinition{
- Name: "test_17_community_add_action_import",
- StatementList: []config.Statement{st_comAdd},
+ Name: "test_17_community_add_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comAdd},
+ },
}
test_18_community_replace_action_import := config.PolicyDefinition{
- Name: "test_18_community_replace_action_import",
- StatementList: []config.Statement{st_comReplace},
+ Name: "test_18_community_replace_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comReplace},
+ },
}
test_19_community_remove_action_import := config.PolicyDefinition{
- Name: "test_19_community_remove_action_import",
- StatementList: []config.Statement{st_comRemove},
+ Name: "test_19_community_remove_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comRemove},
+ },
}
test_20_community_null_action_import := config.PolicyDefinition{
- Name: "test_20_community_null_action_import",
- StatementList: []config.Statement{st_comNull},
+ Name: "test_20_community_null_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comNull},
+ },
}
test_21_community_add_action_export := config.PolicyDefinition{
- Name: "test_21_community_add_action_export",
- StatementList: []config.Statement{st_comAdd},
+ Name: "test_21_community_add_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comAdd},
+ },
}
test_22_community_replace_action_export := config.PolicyDefinition{
- Name: "test_22_community_replace_action_export",
- StatementList: []config.Statement{st_comReplace},
+ Name: "test_22_community_replace_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comReplace},
+ },
}
test_23_community_remove_action_export := config.PolicyDefinition{
- Name: "test_23_community_remove_action_export",
- StatementList: []config.Statement{st_comRemove},
+ Name: "test_23_community_remove_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comRemove},
+ },
}
test_24_community_null_action_export := config.PolicyDefinition{
- Name: "test_24_community_null_action_export",
- StatementList: []config.Statement{st_comNull},
+ Name: "test_24_community_null_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_comNull},
+ },
}
test_25_med_replace_action_import := config.PolicyDefinition{
- Name: "test_25_med_replace_action_import",
- StatementList: []config.Statement{st_medReplace},
+ Name: "test_25_med_replace_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_medReplace},
+ },
}
test_26_med_add_action_import := config.PolicyDefinition{
- Name: "test_26_med_add_action_import",
- StatementList: []config.Statement{st_medAdd},
+ Name: "test_26_med_add_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_medAdd},
+ },
}
test_27_med_subtract_action_import := config.PolicyDefinition{
- Name: "test_27_med_subtract_action_import",
- StatementList: []config.Statement{st_medSub},
+ Name: "test_27_med_subtract_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_medSub},
+ },
}
test_28_med_replace_action_export := config.PolicyDefinition{
- Name: "test_28_med_replace_action_export",
- StatementList: []config.Statement{st_medReplace},
+ Name: "test_28_med_replace_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_medReplace},
+ },
}
test_29_med_add_action_export := config.PolicyDefinition{
- Name: "test_29_med_add_action_export",
- StatementList: []config.Statement{st_medAdd},
+ Name: "test_29_med_add_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_medAdd},
+ },
}
test_30_med_subtract_action_export := config.PolicyDefinition{
- Name: "test_30_med_subtract_action_export",
- StatementList: []config.Statement{st_medSub},
+ Name: "test_30_med_subtract_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_medSub},
+ },
}
test_31_distribute_reject := config.PolicyDefinition{
- Name: "test_31_distribute_reject",
- StatementList: []config.Statement{st_distribute_reject},
+ Name: "test_31_distribute_reject",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_distribute_reject},
+ },
}
test_32_distribute_accept := config.PolicyDefinition{
- Name: "test_32_distribute_accept",
- StatementList: []config.Statement{st_distribute_accept},
+ Name: "test_32_distribute_accept",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_distribute_accept},
+ },
}
test_33_distribute_set_community_action := config.PolicyDefinition{
- Name: "test_33_distribute_set_community_action",
- StatementList: []config.Statement{st_distribute_comm_add},
+ Name: "test_33_distribute_set_community_action",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_distribute_comm_add},
+ },
}
test_34_distribute_set_med_action := config.PolicyDefinition{
- Name: "test_34_distribute_set_med_action",
- StatementList: []config.Statement{st_distribute_med_add},
+ Name: "test_34_distribute_set_med_action",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_distribute_med_add},
+ },
}
test_35_distribute_policy_update := config.PolicyDefinition{
- Name: "test_35_distribute_policy_update",
- StatementList: []config.Statement{st1},
+ Name: "test_35_distribute_policy_update",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st1},
+ },
}
test_35_distribute_policy_update_softreset := config.PolicyDefinition{
- Name: "test_35_distribute_policy_update_softreset",
- StatementList: []config.Statement{st2},
+ Name: "test_35_distribute_policy_update_softreset",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st2},
+ },
}
test_36_aspath_prepend_action_import := config.PolicyDefinition{
- Name: "test_36_aspath_prepend_action_import",
- StatementList: []config.Statement{st_asprepend},
+ Name: "test_36_aspath_prepend_action_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_asprepend},
+ },
}
test_37_aspath_prepend_action_export := config.PolicyDefinition{
- Name: "test_37_aspath_prepend_action_export",
- StatementList: []config.Statement{st_asprepend},
+ Name: "test_37_aspath_prepend_action_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_asprepend},
+ },
}
test_38_aspath_prepend_action_lastas_import := config.PolicyDefinition{
- Name: "test_38_aspath_prepend_action_lastas_import",
- StatementList: []config.Statement{st_asprepend_lastas},
+ Name: "test_38_aspath_prepend_action_lastas_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_asprepend_lastas},
+ },
}
test_39_aspath_prepend_action_lastas_export := config.PolicyDefinition{
- Name: "test_39_aspath_prepend_action_lastas_export",
- StatementList: []config.Statement{st_asprepend_lastas},
+ Name: "test_39_aspath_prepend_action_lastas_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_asprepend_lastas},
+ },
}
test_40_ecommunity_origin_condition_import := config.PolicyDefinition{
- Name: "test_40_ecommunity_origin_condition_import",
- StatementList: []config.Statement{st_eComOrigin},
+ Name: "test_40_ecommunity_origin_condition_import",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_eComOrigin},
+ },
}
test_41_ecommunity_target_condition_export := config.PolicyDefinition{
- Name: "test_41_ecommunity_target_condition_export",
- StatementList: []config.Statement{st_eComTarget},
- }
-
- ds := config.DefinedSets{
- PrefixSetList: []config.PrefixSet{ps0, ps1, ps2, ps3, ps4, ps5, ps6, psExabgp},
- NeighborSetList: []config.NeighborSet{nsPeer2, nsPeer2V6, nsExabgp},
- BgpDefinedSets: config.BgpDefinedSets{
- AsPathSetList: []config.AsPathSet{aspathFrom, aspathAny, aspathOrigin, aspathOnly},
- CommunitySetList: []config.CommunitySet{comStr, comRegExp},
- ExtCommunitySetList: []config.ExtCommunitySet{eComOrigin, eComTarget},
+ Name: "test_41_ecommunity_target_condition_export",
+ Statements: config.Statements{
+ StatementList: []config.Statement{st_eComTarget},
},
}
+
+ ds := config.DefinedSets{}
+ ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps0, ps1, ps2, ps3, ps4, ps5, ps6, psExabgp}
+ ds.NeighborSets.NeighborSetList = []config.NeighborSet{nsPeer2, nsPeer2V6, nsExabgp}
+ ds.BgpDefinedSets.AsPathSets.AsPathSetList = []config.AsPathSet{aspathFrom, aspathAny, aspathOrigin, aspathOnly}
+ ds.BgpDefinedSets.CommunitySets.CommunitySetList = []config.CommunitySet{comStr, comRegExp}
+ ds.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList = []config.ExtCommunitySet{eComOrigin, eComTarget}
+
p := &config.RoutingPolicy{
DefinedSets: ds,
- PolicyDefinitionList: []config.PolicyDefinition{
- test_01_import_policy_initial,
- test_02_export_policy_initial,
- test_03_import_policy_update,
- test_03_import_policy_update_softreset,
- test_04_export_policy_update,
- test_04_export_policy_update_softreset,
- test_05_import_policy_initial_ipv6,
- test_06_export_policy_initial_ipv6,
- test_07_import_policy_update,
- test_07_import_policy_update_softreset,
- test_08_export_policy_update,
- test_08_export_policy_update_softreset,
- test_09_aspath_length_condition_import,
- test_10_aspath_from_condition_import,
- test_11_aspath_any_condition_import,
- test_12_aspath_origin_condition_import,
- test_13_aspath_only_condition_import,
- test_14_aspath_only_condition_import,
- test_15_community_condition_import,
- test_16_community_condition_regexp_import,
- test_17_community_add_action_import,
- test_18_community_replace_action_import,
- test_19_community_remove_action_import,
- test_20_community_null_action_import,
- test_21_community_add_action_export,
- test_22_community_replace_action_export,
- test_23_community_remove_action_export,
- test_24_community_null_action_export,
- test_25_med_replace_action_import,
- test_26_med_add_action_import,
- test_27_med_subtract_action_import,
- test_28_med_replace_action_export,
- test_29_med_add_action_export,
- test_30_med_subtract_action_export,
- test_31_distribute_reject,
- test_32_distribute_accept,
- test_33_distribute_set_community_action,
- test_34_distribute_set_med_action,
- test_35_distribute_policy_update,
- test_35_distribute_policy_update_softreset,
- test_36_aspath_prepend_action_import,
- test_37_aspath_prepend_action_export,
- test_38_aspath_prepend_action_lastas_import,
- test_39_aspath_prepend_action_lastas_export,
- test_40_ecommunity_origin_condition_import,
- test_41_ecommunity_target_condition_export,
+ PolicyDefinitions: config.PolicyDefinitions{
+ PolicyDefinitionList: []config.PolicyDefinition{
+ test_01_import_policy_initial,
+ test_02_export_policy_initial,
+ test_03_import_policy_update,
+ test_03_import_policy_update_softreset,
+ test_04_export_policy_update,
+ test_04_export_policy_update_softreset,
+ test_05_import_policy_initial_ipv6,
+ test_06_export_policy_initial_ipv6,
+ test_07_import_policy_update,
+ test_07_import_policy_update_softreset,
+ test_08_export_policy_update,
+ test_08_export_policy_update_softreset,
+ test_09_aspath_length_condition_import,
+ test_10_aspath_from_condition_import,
+ test_11_aspath_any_condition_import,
+ test_12_aspath_origin_condition_import,
+ test_13_aspath_only_condition_import,
+ test_14_aspath_only_condition_import,
+ test_15_community_condition_import,
+ test_16_community_condition_regexp_import,
+ test_17_community_add_action_import,
+ test_18_community_replace_action_import,
+ test_19_community_remove_action_import,
+ test_20_community_null_action_import,
+ test_21_community_add_action_export,
+ test_22_community_replace_action_export,
+ test_23_community_remove_action_export,
+ test_24_community_null_action_export,
+ test_25_med_replace_action_import,
+ test_26_med_add_action_import,
+ test_27_med_subtract_action_import,
+ test_28_med_replace_action_export,
+ test_29_med_add_action_export,
+ test_30_med_subtract_action_export,
+ test_31_distribute_reject,
+ test_32_distribute_accept,
+ test_33_distribute_set_community_action,
+ test_34_distribute_set_med_action,
+ test_35_distribute_policy_update,
+ test_35_distribute_policy_update_softreset,
+ test_36_aspath_prepend_action_import,
+ test_37_aspath_prepend_action_export,
+ test_38_aspath_prepend_action_lastas_import,
+ test_39_aspath_prepend_action_lastas_export,
+ test_40_ecommunity_origin_condition_import,
+ test_41_ecommunity_target_condition_export,
+ },
},
}
return p
diff --git a/test/scenario_test/quagga-rsconfig.go b/test/scenario_test/quagga-rsconfig.go
index 70d57aa7..76b93ae8 100644
--- a/test/scenario_test/quagga-rsconfig.go
+++ b/test/scenario_test/quagga-rsconfig.go
@@ -41,15 +41,15 @@ func NewQuaggaConfig(id int, gConfig *config.Global, myConfig *config.Neighbor,
func (qt *QuaggaConfig) IPv4Config() *bytes.Buffer {
buf := bytes.NewBuffer(nil)
- buf.WriteString(fmt.Sprintf("! my address %s\n", qt.config.NeighborAddress))
+ buf.WriteString(fmt.Sprintf("! my address %s\n", qt.config.NeighborConfig.NeighborAddress))
buf.WriteString(fmt.Sprintf("! my ip_version %s\n", IPv4))
buf.WriteString("hostname bgpd\n")
buf.WriteString("password zebra\n")
- buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.PeerAs))
+ buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.NeighborConfig.PeerAs))
buf.WriteString(fmt.Sprintf("bgp router-id 192.168.0.%d\n", qt.id))
buf.WriteString(fmt.Sprintf("network %s%d%s\n", baseNeighborNetwork[IPv4], qt.id, baseNeighborNetMask[IPv4]))
- buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.As))
- buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.AuthPassword))
+ buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.GlobalConfig.As))
+ buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.NeighborConfig.AuthPassword))
buf.WriteString("debug bgp as4\n")
buf.WriteString("debug bgp fsm\n")
buf.WriteString("debug bgp updates\n")
@@ -61,15 +61,15 @@ func (qt *QuaggaConfig) IPv4Config() *bytes.Buffer {
func (qt *QuaggaConfig) IPv6Config() *bytes.Buffer {
buf := bytes.NewBuffer(nil)
- buf.WriteString(fmt.Sprintf("! my address %s\n", qt.config.NeighborAddress))
+ buf.WriteString(fmt.Sprintf("! my address %s\n", qt.config.NeighborConfig.NeighborAddress))
buf.WriteString(fmt.Sprintf("! my ip_version %s\n", IPv6))
buf.WriteString("hostname bgpd\n")
buf.WriteString("password zebra\n")
- buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.PeerAs))
+ buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.NeighborConfig.PeerAs))
buf.WriteString(fmt.Sprintf("bgp router-id 192.168.0.%d\n", qt.id))
buf.WriteString("no bgp default ipv4-unicast\n")
- buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.As))
- buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.AuthPassword))
+ buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.GlobalConfig.As))
+ buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.NeighborConfig.AuthPassword))
buf.WriteString("address-family ipv6\n")
buf.WriteString(fmt.Sprintf("network %s%d%s\n", baseNeighborNetwork[IPv6], qt.id, baseNeighborNetMask[IPv6]))
buf.WriteString(fmt.Sprintf("neighbor %s activate\n", qt.serverIP))
@@ -78,7 +78,7 @@ func (qt *QuaggaConfig) IPv6Config() *bytes.Buffer {
buf.WriteString("ipv6 prefix-list pl-ipv6 seq 10 permit any\n")
buf.WriteString("route-map IPV6-OUT permit 10\n")
buf.WriteString("match ipv6 address prefix-list pl-ipv6\n")
- buf.WriteString(fmt.Sprintf("set ipv6 next-hop global %s\n", qt.config.NeighborAddress))
+ buf.WriteString(fmt.Sprintf("set ipv6 next-hop global %s\n", qt.config.NeighborConfig.NeighborAddress))
buf.WriteString("debug bgp as4\n")
buf.WriteString("debug bgp fsm\n")
buf.WriteString("debug bgp updates\n")
@@ -91,25 +91,28 @@ func (qt *QuaggaConfig) IPv6Config() *bytes.Buffer {
func create_config_files(nr int, outputDir string, IPVersion string, nonePeer bool, normalBGP bool) {
quaggaConfigList := make([]*QuaggaConfig, 0)
- gobgpConf := config.Bgp{
- Global: config.Global{
- As: 65000,
- RouterId: net.ParseIP("192.168.255.1"),
- },
- }
+ gobgpConf := config.Bgp{}
+ gobgpConf.Global.GlobalConfig.As = 65000
+ gobgpConf.Global.GlobalConfig.RouterId = net.ParseIP("192.168.255.1")
for i := 1; i < nr+1; i++ {
- c := config.Neighbor{
- PeerAs: 65000 + uint32(i),
- NeighborAddress: net.ParseIP(fmt.Sprintf("%s%d", baseNeighborAddress[IPVersion], i)),
- AuthPassword: fmt.Sprintf("hoge%d", i),
- TransportOptions: config.TransportOptions{PassiveMode: true},
- RouteServer: config.RouteServer{RouteServerClient: !normalBGP},
- Timers: config.Timers{HoldTime: 30, KeepaliveInterval: 10, IdleHoldTimeAfterReset: 10},
- PeerType: config.PEER_TYPE_EXTERNAL,
- }
- gobgpConf.NeighborList = append(gobgpConf.NeighborList, c)
+ c := config.Neighbor{}
+ c.NeighborConfig.PeerAs = 65000 + uint32(i)
+ c.NeighborConfig.NeighborAddress = net.ParseIP(fmt.Sprintf("%s%d", baseNeighborAddress[IPVersion], i))
+ c.NeighborConfig.AuthPassword = fmt.Sprintf("hoge%d", i)
+ c.Transport.TransportConfig.PassiveMode = true
+ c.RouteServer.RouteServerClient = !normalBGP
+
+ timers := config.Timers{}
+ timers.TimersConfig.HoldTime = 30
+ timers.TimersConfig.KeepaliveInterval = 10
+ timers.TimersConfig.IdleHoldTimeAfterReset = 10
+
+ c.Timers = timers
+ c.NeighborConfig.PeerType = config.PEER_TYPE_EXTERNAL
+
+ gobgpConf.Neighbors.NeighborList = append(gobgpConf.Neighbors.NeighborList, c)
if !nonePeer {
q := NewQuaggaConfig(i, &gobgpConf.Global, &c, net.ParseIP(serverAddress[IPVersion]))
quaggaConfigList = append(quaggaConfigList, q)
@@ -138,21 +141,24 @@ func create_config_files(nr int, outputDir string, IPVersion string, nonePeer bo
func append_config_files(ar int, outputDir string, IPVersion string, noQuagga bool, normalBGP bool) {
- gobgpConf := config.Bgp{
- Global: config.Global{
- As: 65000,
- RouterId: net.ParseIP("192.168.255.1"),
- },
- }
- c := config.Neighbor{
- PeerAs: 65000 + uint32(ar),
- NeighborAddress: net.ParseIP(fmt.Sprintf("%s%d", baseNeighborAddress[IPVersion], ar)),
- AuthPassword: fmt.Sprintf("hoge%d", ar),
- RouteServer: config.RouteServer{RouteServerClient: !normalBGP},
- TransportOptions: config.TransportOptions{PassiveMode: true},
- Timers: config.Timers{HoldTime: 30, KeepaliveInterval: 10, IdleHoldTimeAfterReset: 10},
- PeerType: config.PEER_TYPE_EXTERNAL,
- }
+ gobgpConf := config.Bgp{}
+ gobgpConf.Global.GlobalConfig.As = 65000
+ gobgpConf.Global.GlobalConfig.RouterId = net.ParseIP("192.168.255.1")
+
+ c := config.Neighbor{}
+ c.NeighborConfig.PeerAs = 65000 + uint32(ar)
+ c.NeighborConfig.NeighborAddress = net.ParseIP(fmt.Sprintf("%s%d", baseNeighborAddress[IPVersion], ar))
+ c.NeighborConfig.AuthPassword = fmt.Sprintf("hoge%d", ar)
+ c.RouteServer.RouteServerClient = !normalBGP
+ c.Transport.TransportConfig.PassiveMode = true
+
+ timers := config.Timers{}
+ timers.TimersConfig.HoldTime = 30
+ timers.TimersConfig.KeepaliveInterval = 10
+ timers.TimersConfig.IdleHoldTimeAfterReset = 10
+
+ c.Timers = timers
+ c.NeighborConfig.PeerType = config.PEER_TYPE_EXTERNAL
if !noQuagga {
q := NewQuaggaConfig(ar, &gobgpConf.Global, &c, net.ParseIP(serverAddress[IPVersion]))
@@ -172,7 +178,7 @@ func append_config_files(ar int, outputDir string, IPVersion string, noQuagga bo
if d_err != nil {
log.Fatal(d_err)
}
- newConf.NeighborList = append(newConf.NeighborList, c)
+ newConf.Neighbors.NeighborList = append(newConf.Neighbors.NeighborList, c)
var buffer bytes.Buffer
encoder := toml.NewEncoder(&buffer)
encoder.Encode(newConf)
@@ -183,7 +189,7 @@ func append_config_files(ar int, outputDir string, IPVersion string, noQuagga bo
log.Fatal(p_err)
}
- if policyConf != nil && len(policyConf.PolicyDefinitionList) != 0 {
+ if policyConf != nil && len(policyConf.PolicyDefinitions.PolicyDefinitionList) != 0 {
encoder.Encode(policyConf)
}
diff --git a/test/scenario_test/route_server_malformed_test.py b/test/scenario_test/route_server_malformed_test.py
index 296f3645..acb755d9 100644
--- a/test/scenario_test/route_server_malformed_test.py
+++ b/test/scenario_test/route_server_malformed_test.py
@@ -156,9 +156,9 @@ def get_neighbor_address():
address = []
try:
gobgp_config = toml.loads(open(gobgp_config_file).read())
- neighbors_config = gobgp_config['NeighborList']
+ neighbors_config = gobgp_config['Neighbors']['NeighborList']
for neighbor_config in neighbors_config:
- neighbor_ip = neighbor_config['NeighborAddress']
+ neighbor_ip = neighbor_config['NeighborConfig']['NeighborAddress']
address.append(neighbor_ip)
except IOError, (errno, strerror):
diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py
index 204b55b1..fe4304c5 100644
--- a/test/scenario_test/route_server_policy_test.py
+++ b/test/scenario_test/route_server_policy_test.py
@@ -230,7 +230,9 @@ class GoBGPTest(GoBGPTestBase):
self.initialize()
# add other network
- tn = qaccess.login(peer2)
+ tn = self.try_login_quagga(peer2)
+ self.assertIsNotNone(tn)
+
print "add network 192.168.20.0/24"
qaccess.add_network(tn, 65002, r2)
print "add network 192.168.200.0/24"
@@ -341,7 +343,9 @@ class GoBGPTest(GoBGPTestBase):
self.initialize()
# add other network
- tn = qaccess.login(peer2)
+ tn = self.try_login_quagga(peer2)
+ self.assertIsNotNone(tn)
+
print "add network 192.168.20.0/24"
qaccess.add_network(tn, 65002, r2)
print "add network 192.168.200.0/24"
@@ -565,7 +569,9 @@ class GoBGPTest(GoBGPTestBase):
self.initialize()
# add other network
- tn = qaccess.login(peer2)
+ tn = self.try_login_quagga(peer2)
+ self.assertIsNotNone(tn)
+
print "add network 2001:0:10:20::/64"
qaccess.add_network(tn, 65002, r2, use_ipv6=True)
print "add network 2001:0:10:200::/64"
@@ -678,7 +684,9 @@ class GoBGPTest(GoBGPTestBase):
self.initialize()
# add other network
- tn = qaccess.login(peer2)
+ tn = self.try_login_quagga(peer2)
+ self.assertIsNotNone(tn)
+
print "add network 2001:0:10:20::/64"
qaccess.add_network(tn, 65002, r2, use_ipv6=True)
print "add network 2001:0:10:200::/64"
@@ -934,7 +942,7 @@ class GoBGPTest(GoBGPTestBase):
# generate exabgp configuration file
prefix1 = "192.168.100.0/24"
asns = ['65100'] + [ str(asn) for asn in range(65099, 65090, -1) ]
- as_path = reduce(lambda a,b: a + " " + b, asns)
+ as_path = reduce(lambda a, b: a + " " + b, asns)
e = ExabgpConfig(EXABGP_COMMON_CONF)
e.add_route(prefix1, aspath=as_path)
@@ -953,6 +961,7 @@ class GoBGPTest(GoBGPTestBase):
self.initialize()
addresses = self.get_neighbor_address(self.gobgp_config)
+
self.retry_routine_for_state(addresses, "BGP_FSM_ESTABLISHED")
path = self.get_paths_in_localrib(peer1, prefix1, retry=self.retry_count_common)
@@ -963,7 +972,7 @@ class GoBGPTest(GoBGPTestBase):
self.assertIsNotNone(qpath)
# check local-rib in peer2
- path = self.get_paths_in_localrib(peer2, prefix1,retry=0)
+ path = self.get_paths_in_localrib(peer2, prefix1, retry=0)
self.assertIsNone(path)
# check show ip bgp on peer2(quagga2)
@@ -2309,7 +2318,9 @@ class GoBGPTest(GoBGPTestBase):
self.initialize()
# add other network
- tn = qaccess.login(peer2)
+ tn = self.try_login_quagga(peer2)
+ self.assertIsNotNone(tn)
+
print "add network 192.168.20.0/24"
qaccess.add_network(tn, 65002, r2)
print "add network 192.168.200.0/24"