summaryrefslogtreecommitdiffhomepage
path: root/server/rpki_test.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-20 06:32:54 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-20 07:09:11 -0800
commit0986a67e07aaa4253403f392a98b0ec483c5562c (patch)
tree8bab52188553855be6c5a9ec00bcccbb9ce07e0b /server/rpki_test.go
parentb42e8d9a9ff3ffbdb4ce2c03f29a810ce222db02 (diff)
rpki: improve statistics API
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/rpki_test.go')
-rw-r--r--server/rpki_test.go58
1 files changed, 45 insertions, 13 deletions
diff --git a/server/rpki_test.go b/server/rpki_test.go
index 8be709ea..3d7be7b3 100644
--- a/server/rpki_test.go
+++ b/server/rpki_test.go
@@ -60,9 +60,13 @@ func validateOne(tree *radix.Tree, cidr, aspathStr string) config.RpkiValidation
func TestValidate0(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 100, net.ParseIP("192.168.0.0").To4(), 24, 32)
- addROA("", tree, 200, net.ParseIP("192.168.0.0").To4(), 24, 24)
+ addROA(client, bgp.AFI_IP, tree, 100, net.ParseIP("192.168.0.0").To4(), 24, 32)
+ addROA(client, bgp.AFI_IP, tree, 200, net.ParseIP("192.168.0.0").To4(), 24, 24)
var r config.RpkiValidationResultType
@@ -88,8 +92,12 @@ func TestValidate0(t *testing.T) {
func TestValidate1(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 16)
+ addROA(client, bgp.AFI_IP, tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 16)
var r config.RpkiValidationResultType
@@ -117,8 +125,12 @@ func TestValidate2(t *testing.T) {
func TestValidate3(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree1 := radix.New()
- addROA("", tree1, 65000, net.ParseIP("10.0.0.0").To4(), 16, 16)
+ addROA(client, bgp.AFI_IP, tree1, 65000, net.ParseIP("10.0.0.0").To4(), 16, 16)
var r config.RpkiValidationResultType
@@ -129,7 +141,7 @@ func TestValidate3(t *testing.T) {
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_INVALID)
tree2 := radix.New()
- addROA("", tree2, 65000, net.ParseIP("10.0.0.0").To4(), 16, 24)
+ addROA(client, bgp.AFI_IP, tree2, 65000, net.ParseIP("10.0.0.0").To4(), 16, 24)
r = validateOne(tree2, "10.0.0.0/17", "65000")
assert.Equal(r, config.RPKI_VALIDATION_RESULT_TYPE_VALID)
@@ -138,9 +150,13 @@ func TestValidate3(t *testing.T) {
func TestValidate4(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 16)
- addROA("", tree, 65001, net.ParseIP("10.0.0.0").To4(), 16, 16)
+ addROA(client, bgp.AFI_IP, tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 16)
+ addROA(client, bgp.AFI_IP, tree, 65001, net.ParseIP("10.0.0.0").To4(), 16, 16)
var r config.RpkiValidationResultType
@@ -154,9 +170,13 @@ func TestValidate4(t *testing.T) {
func TestValidate5(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 65000, net.ParseIP("10.0.0.0").To4(), 17, 17)
- addROA("", tree, 65000, net.ParseIP("10.0.128.0").To4(), 17, 17)
+ addROA(client, bgp.AFI_IP, tree, 65000, net.ParseIP("10.0.0.0").To4(), 17, 17)
+ addROA(client, bgp.AFI_IP, tree, 65000, net.ParseIP("10.0.128.0").To4(), 17, 17)
var r config.RpkiValidationResultType
@@ -167,8 +187,12 @@ func TestValidate5(t *testing.T) {
func TestValidate6(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 0, net.ParseIP("10.0.0.0").To4(), 8, 32)
+ addROA(client, bgp.AFI_IP, tree, 0, net.ParseIP("10.0.0.0").To4(), 8, 32)
var r config.RpkiValidationResultType
@@ -185,8 +209,12 @@ func TestValidate6(t *testing.T) {
func TestValidate7(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 24)
+ addROA(client, bgp.AFI_IP, tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 24)
var r config.RpkiValidationResultType
@@ -203,9 +231,13 @@ func TestValidate7(t *testing.T) {
func TestValidate8(t *testing.T) {
assert := assert.New(t)
+ client := &roaClient{
+ records: make(map[int]uint32),
+ prefixes: make(map[int]uint32),
+ }
tree := radix.New()
- addROA("", tree, 0, net.ParseIP("10.0.0.0").To4(), 16, 24)
- addROA("", tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 24)
+ addROA(client, bgp.AFI_IP, tree, 0, net.ParseIP("10.0.0.0").To4(), 16, 24)
+ addROA(client, bgp.AFI_IP, tree, 65000, net.ParseIP("10.0.0.0").To4(), 16, 24)
var r config.RpkiValidationResultType