Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
1e4407d2
Commit
1e4407d2
authored
6 years ago
by
Maximilian Wilhelm
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for AdjRIBOut / iBGP RR client scenario.
Signed-off-by:
Maximilian Wilhelm
<
max@sdn.clinic
>
parent
f08419ab
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routingtable/adjRIBOut/adj_rib_out_test.go
+266
-1
266 additions, 1 deletion
routingtable/adjRIBOut/adj_rib_out_test.go
with
266 additions
and
1 deletion
routingtable/adjRIBOut/adj_rib_out_test.go
+
266
−
1
View file @
1e4407d2
...
@@ -498,7 +498,7 @@ func TestBestPathOnlyIBGP(t *testing.T) {
...
@@ -498,7 +498,7 @@ func TestBestPathOnlyIBGP(t *testing.T) {
expected
:
[]
*
route
.
Route
{},
expected
:
[]
*
route
.
Route
{},
},
},
{
{
name
:
"Try to add route with NO_
EXPORT
community set (without success)"
,
name
:
"Try to add route with NO_
ADVERTISE
community set (without success)"
,
routesAdd
:
[]
*
route
.
Route
{
routesAdd
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
Type
:
route
.
BGPPathType
,
...
@@ -532,6 +532,271 @@ func TestBestPathOnlyIBGP(t *testing.T) {
...
@@ -532,6 +532,271 @@ func TestBestPathOnlyIBGP(t *testing.T) {
}
}
}
}
/*
* Test for iBGP Route Reflector client neighbor
*/
func
TestBestPathOnlyRRClient
(
t
*
testing
.
T
)
{
neighborBestOnlyRR
:=
&
routingtable
.
Neighbor
{
Type
:
route
.
BGPPathType
,
LocalAddress
:
net
.
IPv4FromOctets
(
127
,
0
,
0
,
1
),
Address
:
net
.
IPv4FromOctets
(
127
,
0
,
0
,
2
),
IBGP
:
true
,
LocalASN
:
41981
,
RouteServerClient
:
false
,
CapAddPathRX
:
false
,
RouteReflectorClient
:
true
,
ClusterID
:
net
.
IPv4FromOctets
(
2
,
2
,
2
,
2
)
.
ToUint32
(),
}
adjRIBOut
:=
New
(
neighborBestOnlyRR
,
filter
.
NewAcceptAllFilter
())
tests
:=
[]
struct
{
name
string
routesAdd
[]
*
route
.
Route
routesRemove
[]
*
route
.
Route
expected
[]
*
route
.
Route
expectedCount
int64
}{
{
name
:
"Add an iBGP route (with success)"
,
routesAdd
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{},
}),
},
expected
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
Communities
:
[]
uint32
{},
LargeCommunities
:
[]
types
.
LargeCommunity
{},
ASPath
:
types
.
ASPath
{},
ClusterList
:
[]
uint32
{
neighborBestOnlyRR
.
ClusterID
,
},
},
}),
},
expectedCount
:
1
,
},
{
name
:
"Add an eBGP route (replacing previous iBGP route)"
,
routesAdd
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
EBGP
:
true
,
ASPath
:
types
.
ASPath
{
types
.
ASPathSegment
{
Type
:
types
.
ASSequence
,
ASNs
:
[]
uint32
{
201701
,
},
},
},
ASPathLen
:
1
,
NextHop
:
net
.
IPv4FromOctets
(
1
,
2
,
3
,
4
),
},
}),
},
expected
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
NextHop
:
net
.
IPv4FromOctets
(
1
,
2
,
3
,
4
),
ASPath
:
types
.
ASPath
{
types
.
ASPathSegment
{
Type
:
types
.
ASSequence
,
ASNs
:
[]
uint32
{
201701
,
},
},
},
ASPathLen
:
1
,
Origin
:
0
,
MED
:
0
,
EBGP
:
true
,
Communities
:
[]
uint32
{},
LargeCommunities
:
[]
types
.
LargeCommunity
{},
UnknownAttributes
:
nil
,
PathIdentifier
:
0
,
LocalPref
:
0
,
Source
:
net
.
IP
{},
ClusterList
:
[]
uint32
{
neighborBestOnlyRR
.
ClusterID
,
},
},
}),
},
expectedCount
:
1
,
},
{
name
:
"Try to remove slightly different route"
,
routesRemove
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
NextHop
:
net
.
IPv4FromOctets
(
1
,
2
,
3
,
4
),
ASPath
:
types
.
ASPath
{
types
.
ASPathSegment
{
Type
:
types
.
ASSequence
,
ASNs
:
[]
uint32
{
201701
,
},
},
},
ASPathLen
:
1
,
Origin
:
0
,
MED
:
1
,
// Existing route has MED 0
EBGP
:
true
,
Communities
:
[]
uint32
{},
LargeCommunities
:
[]
types
.
LargeCommunity
{},
UnknownAttributes
:
nil
,
PathIdentifier
:
0
,
LocalPref
:
0
,
Source
:
net
.
IP
{}},
}),
},
expected
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
NextHop
:
net
.
IPv4FromOctets
(
1
,
2
,
3
,
4
),
ASPath
:
types
.
ASPath
{
types
.
ASPathSegment
{
Type
:
types
.
ASSequence
,
ASNs
:
[]
uint32
{
201701
,
},
},
},
ASPathLen
:
1
,
Origin
:
0
,
MED
:
0
,
EBGP
:
true
,
Communities
:
[]
uint32
{},
LargeCommunities
:
[]
types
.
LargeCommunity
{},
UnknownAttributes
:
nil
,
PathIdentifier
:
0
,
LocalPref
:
0
,
Source
:
net
.
IP
{},
ClusterList
:
[]
uint32
{
neighborBestOnlyRR
.
ClusterID
,
},
},
}),
},
expectedCount
:
1
,
},
{
name
:
"Remove route added in 2nd step"
,
routesRemove
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
NextHop
:
net
.
IPv4FromOctets
(
1
,
2
,
3
,
4
),
ASPath
:
types
.
ASPath
{
types
.
ASPathSegment
{
Type
:
types
.
ASSequence
,
ASNs
:
[]
uint32
{
201701
,
},
},
},
ASPathLen
:
1
,
Origin
:
0
,
MED
:
0
,
EBGP
:
true
,
Communities
:
[]
uint32
{},
LargeCommunities
:
[]
types
.
LargeCommunity
{},
UnknownAttributes
:
nil
,
PathIdentifier
:
0
,
LocalPref
:
0
,
Source
:
net
.
IP
{},
ClusterList
:
[]
uint32
{
neighborBestOnlyRR
.
ClusterID
,
},
},
}),
},
expected
:
[]
*
route
.
Route
{},
expectedCount
:
0
,
},
{
name
:
"Try to add route with NO_ADVERTISE community set (without success)"
,
routesAdd
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
Communities
:
[]
uint32
{
types
.
WellKnownCommunityNoAdvertise
,
},
},
}),
},
expected
:
[]
*
route
.
Route
{},
expectedCount
:
0
,
},
{
name
:
"Try to add route with NO_EXPORT community set (with success)"
,
routesAdd
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
Communities
:
[]
uint32
{
types
.
WellKnownCommunityNoExport
,
},
},
}),
},
expected
:
[]
*
route
.
Route
{
route
.
NewRoute
(
net
.
NewPfx
(
net
.
IPv4FromOctets
(
10
,
0
,
0
,
0
),
8
),
&
route
.
Path
{
Type
:
route
.
BGPPathType
,
BGPPath
:
&
route
.
BGPPath
{
ASPath
:
types
.
ASPath
{},
ASPathLen
:
0
,
Origin
:
0
,
MED
:
0
,
EBGP
:
false
,
Communities
:
[]
uint32
{
types
.
WellKnownCommunityNoExport
,
},
LargeCommunities
:
[]
types
.
LargeCommunity
{},
UnknownAttributes
:
nil
,
PathIdentifier
:
0
,
LocalPref
:
0
,
Source
:
net
.
IP
{},
ClusterList
:
[]
uint32
{
neighborBestOnlyRR
.
ClusterID
,
},
},
}),
},
expectedCount
:
1
,
},
}
for
i
,
test
:=
range
tests
{
fmt
.
Printf
(
"Running RR client best only test #%d: %s
\n
"
,
i
+
1
,
test
.
name
)
for
_
,
route
:=
range
test
.
routesAdd
{
adjRIBOut
.
AddPath
(
route
.
Prefix
(),
route
.
Paths
()[
0
])
}
for
_
,
route
:=
range
test
.
routesRemove
{
adjRIBOut
.
RemovePath
(
route
.
Prefix
(),
route
.
Paths
()[
0
])
}
assert
.
Equal
(
t
,
test
.
expected
,
adjRIBOut
.
rt
.
Dump
())
actualCount
:=
adjRIBOut
.
RouteCount
()
if
test
.
expectedCount
!=
actualCount
{
t
.
Errorf
(
"Expected route count %d differs from actual route count %d!
\n
"
,
test
.
expectedCount
,
actualCount
)
}
}
}
/*
/*
* Test for AddPath capabale peer / AdjRIBOut
* Test for AddPath capabale peer / AdjRIBOut
*/
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment