Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
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
goSDN
Commits
e83082b1
Commit
e83082b1
authored
3 years ago
by
Manuel Kieweg
Browse files
Options
Downloads
Patches
Plain Diff
Northbound Interface
parent
50722ba9
Branches
Branches containing commit
Tags
Tags containing commit
9 merge requests
!246
Develop
,
!245
Develop into Master
,
!244
Master into develop2 into master
,
!219
Draft: Testing
,
!214
Test pipelines
,
!195
DO NOT MERGE 2
,
!194
DO NOT MERGE! just for testing
,
!155
Northbound Interface
,
!138
Develop
Changes
63
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/integration/cmdIntegration_test.go
+49
-49
49 additions, 49 deletions
test/integration/cmdIntegration_test.go
test/integration/nucleusIntegration_test.go
+41
-37
41 additions, 37 deletions
test/integration/nucleusIntegration_test.go
test/targets.go
+3
-2
3 additions, 2 deletions
test/targets.go
with
93 additions
and
88 deletions
test/integration/cmdIntegration_test.go
+
49
−
49
View file @
e83082b1
package
integration
import
(
"os"
"testing"
tpb
"code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"code.fbi.h-da.de/cocsn/gosdn/cli"
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto"
guuid
"github.com/google/uuid"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
log
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
pb
"google.golang.org/protobuf/proto"
"os"
"testing"
)
const
unreachable
=
"203.0.113.10:6030"
const
testPath
=
"/system/config/hostname"
var
testAddress
=
"141.100.70.171:6030"
var
testAPIEndpoint
=
"http://gosdn-latest.apps.ocp.fbi.h-da.de/api"
var
testUsername
=
"admin"
var
testPassword
=
"arista"
var
defaultPath
=
[]
string
{
"/system/config/hostname"
}
var
opt
*
nucleus
.
GnmiTransportOptions
var
opt
*
tpb
.
TransportOption
func
TestMain
(
m
*
testing
.
M
)
{
testSetupIntegration
()
...
...
@@ -74,14 +75,10 @@ func testSetupIntegration() {
}
}
opt
=
&
nucleus
.
GnmiTransportOptions
{
Config
:
gnmi
.
Config
{
Addr
:
testAddress
,
Username
:
testUsername
,
Password
:
testPassword
,
Encoding
:
gpb
.
Encoding_JSON_IETF
,
},
RespChan
:
make
(
chan
*
gpb
.
SubscribeResponse
),
opt
=
&
tpb
.
TransportOption
{
Address
:
testAddress
,
Username
:
testUsername
,
Password
:
testPassword
,
}
}
...
...
@@ -101,7 +98,7 @@ func TestCmdIntegration(t *testing.T) {
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
defer
viper
.
Reset
()
if
err
:=
cli
.
HTTPGe
t
(
testAPIEndpoint
,
"init"
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
if
err
:=
cli
.
Ini
t
(
testAPIEndpoint
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
switch
err
.
(
type
)
{
case
viper
.
ConfigFileNotFoundError
:
default
:
...
...
@@ -112,65 +109,68 @@ func TestCmdIntegration(t *testing.T) {
cliPnd
:=
viper
.
GetString
(
"CLI_PND"
)
cliSbi
:=
viper
.
GetString
(
"CLI_SBI"
)
if
err
:=
cli
.
HTTPGet
(
if
_
,
err
:=
cli
.
AddDevice
(
testAPIEndpoint
,
"addDevice"
,
"address="
+
testAddress
,
"password="
+
testPassword
,
"username="
+
testUsername
,
"sbi="
+
cliSbi
,
"
pnd="
+
cliPnd
,
testUsername
,
testPassword
,
cliSbi
,
cliPnd
,
testAddress
,
"
test-device"
,
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"gosdn cli add-device error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
}
did
:=
viper
.
GetString
(
"LAST_DEVICE_UUID"
)
if
err
:=
cli
.
HTTPGet
(
_
,
err
:=
cli
.
GetDevice
(
testAPIEndpoint
,
"request"
,
"uuid="
+
did
,
"sbi="
+
cliSbi
,
"pnd="
+
cliPnd
,
"path=/system/config/hostname"
,
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
cliPnd
,
testPath
,
did
,
)
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"gosdn cli request error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
}
if
err
:
=
cli
.
HTTPGet
(
_
,
err
=
cli
.
GetDevice
(
testAPIEndpoint
,
"getDevice"
,
"address="
+
testAddress
,
"uuid="
+
did
,
"sbi="
+
cliSbi
,
"pnd="
+
cliPnd
,
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
cliPnd
,
""
,
did
,
)
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"gosdn cli get-device error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
}
hostname
:=
guuid
.
New
()
.
String
()
if
err
:
=
cli
.
HTTPGet
(
_
,
err
=
cli
.
Update
(
testAPIEndpoint
,
"update"
,
"address="
+
testAddress
,
"uuid="
+
did
,
"sbi="
+
cliSbi
,
"pnd="
+
cliPnd
,
"path=/system/config/hostname"
,
"value="
+
hostname
,
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
did
,
cliPnd
,
testPath
,
hostname
,
)
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"gosdn cli set error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
}
resp
,
err
:=
cli
.
Get
(
testAddress
,
testUsername
,
testPassword
,
"/system/config/hostname"
)
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"cli.Get() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
resp
,
err
:=
cli
.
GetDevice
(
testAddress
,
testUsername
,
testPassword
,
testPath
)
if
err
!=
nil
{
if
!
tt
.
wantErr
{
t
.
Errorf
(
"cli.Get() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
}
return
}
got
:=
resp
.
Notification
[
0
]
.
Update
[
0
]
.
Val
.
GetStringVal
()
var
got
string
if
resp
!=
nil
{
got
=
resp
.
Ond
[
0
]
.
Name
}
else
{
t
.
Errorf
(
"integration test failed got cannot be nil"
)
}
if
got
!=
hostname
{
t
.
Errorf
(
"integration test failed = got: %v, want: %v"
,
got
,
hostname
)
}
...
...
This diff is collapsed.
Click to expand it.
test/integration/nucleusIntegration_test.go
+
41
−
37
View file @
e83082b1
package
integration
import
(
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/types"
"context"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
pb
"google.golang.org/protobuf/proto"
"reflect"
"sort"
"testing"
"time"
spb
"code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
tpb
"code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/types"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
pb
"google.golang.org/protobuf/proto"
)
var
gnmiMessages
map
[
string
]
pb
.
Message
...
...
@@ -20,7 +24,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
t
.
Skip
(
"skipping integration test"
)
}
type
fields
struct
{
opt
*
nucleus
.
Gnmi
TransportOption
s
opt
*
tpb
.
TransportOption
}
type
args
struct
{
ctx
context
.
Context
...
...
@@ -34,12 +38,11 @@ func TestGnmi_SetIntegration(t *testing.T) {
}{
{
name
:
"destination unreachable"
,
fields
:
fields
{
opt
:
&
nucleus
.
GnmiTransportOptions
{
Config
:
gnmi
.
Config
{
Addr
:
"203.0.113.10:6030"
,
fields
:
fields
{
opt
:
&
tpb
.
TransportOption
{
Addr
ess
:
"203.0.113.10:6030"
,
},
},
},
args
:
args
{
ctx
:
context
.
Background
(),
params
:
[]
string
{
"/system/config/hostname"
,
"ceos3000"
},
...
...
@@ -67,7 +70,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
)
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
,
nucleus
.
NewSBI
(
spb
.
Type_OPENCONFIG
)
)
if
err
!=
nil
{
t
.
Errorf
(
"NewGnmiTransport() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
...
...
@@ -91,7 +94,7 @@ func TestGnmi_GetIntegration(t *testing.T) {
"system/config/hostname"
,
}
type
fields
struct
{
opt
*
nucleus
.
Gnmi
TransportOption
s
opt
*
tpb
.
TransportOption
}
type
args
struct
{
ctx
context
.
Context
...
...
@@ -116,12 +119,11 @@ func TestGnmi_GetIntegration(t *testing.T) {
},
{
name
:
"destination unreachable"
,
fields
:
fields
{
opt
:
&
nucleus
.
GnmiTransportOptions
{
Config
:
gnmi
.
Config
{
Addr
:
"203.0.113.10:6030"
,
fields
:
fields
{
opt
:
&
tpb
.
TransportOption
{
Addr
ess
:
"203.0.113.10:6030"
,
},
},
},
args
:
args
{
ctx
:
context
.
Background
(),
params
:
paths
,
...
...
@@ -132,7 +134,7 @@ func TestGnmi_GetIntegration(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
)
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
,
nucleus
.
NewSBI
(
spb
.
Type_OPENCONFIG
)
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
...
...
@@ -154,7 +156,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
}
type
fields
struct
{
opt
*
nucleus
.
Gnmi
TransportOption
s
opt
*
tpb
.
TransportOption
}
type
args
struct
{
ctx
context
.
Context
...
...
@@ -169,9 +171,19 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
{
name
:
"default"
,
fields
:
fields
{
opt
:
&
nucleus
.
GnmiTransportOptions
{
Config
:
opt
.
Config
,
RespChan
:
make
(
chan
*
gpb
.
SubscribeResponse
),
opt
:
&
tpb
.
TransportOption
{
Address
:
""
,
Username
:
""
,
Password
:
""
,
Tls
:
false
,
TransportOption
:
&
tpb
.
TransportOption_GnmiTransportOption
{
GnmiTransportOption
:
&
tpb
.
GnmiTransportOption
{
Compression
:
""
,
GrpcDialOptions
:
nil
,
Token
:
""
,
Encoding
:
0
,
},
},
},
},
args
:
args
{
...
...
@@ -193,10 +205,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
{
name
:
"wrong path"
,
fields
:
fields
{
opt
:
&
nucleus
.
GnmiTransportOptions
{
Config
:
opt
.
Config
,
RespChan
:
make
(
chan
*
gpb
.
SubscribeResponse
),
},
opt
:
&
tpb
.
TransportOption
{},
},
args
:
args
{
opts
:
&
gnmi
.
SubscribeOptions
{
...
...
@@ -216,11 +225,8 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
{
name
:
"destination unreachable"
,
fields
:
fields
{
opt
:
&
nucleus
.
GnmiTransportOptions
{
Config
:
gnmi
.
Config
{
Addr
:
"203.0.113.10:6030"
,
},
RespChan
:
make
(
chan
*
gpb
.
SubscribeResponse
),
opt
:
&
tpb
.
TransportOption
{
Address
:
"203.0.113.10:6030"
,
},
},
args
:
args
{
...
...
@@ -232,7 +238,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
var
wantErr
=
tt
.
wantErr
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
)
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
,
nucleus
.
NewSBI
(
spb
.
Type_OPENCONFIG
)
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
...
...
@@ -261,7 +267,7 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
t
.
Skip
(
"skipping integration test"
)
}
type
fields
struct
{
opt
*
nucleus
.
Gnmi
TransportOption
s
opt
*
tpb
.
TransportOption
}
type
args
struct
{
ctx
context
.
Context
...
...
@@ -296,10 +302,8 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
},
{
name
:
"destination unreachable"
,
fields
:
fields
{
opt
:
&
nucleus
.
GnmiTransportOptions
{
Config
:
gnmi
.
Config
{
Addr
:
"203.0.113.10:6030"
,
},
fields
:
fields
{
opt
:
&
tpb
.
TransportOption
{
Address
:
"203.0.113.10:6030"
,
},
},
args
:
args
{
ctx
:
context
.
Background
()},
...
...
@@ -309,7 +313,7 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
)
g
,
err
:=
nucleus
.
NewGnmiTransport
(
tt
.
fields
.
opt
,
nucleus
.
NewSBI
(
spb
.
Type_OPENCONFIG
)
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
...
...
This diff is collapsed.
Click to expand it.
test/targets.go
+
3
−
2
View file @
e83082b1
package
test
import
(
"net"
"reflect"
"code.fbi.h-da.de/cocsn/gosdn/forks/google/gnmi"
oc
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
pb
"github.com/openconfig/gnmi/proto/gnmi"
...
...
@@ -10,8 +13,6 @@ import (
log
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"net"
"reflect"
)
type
server
struct
{
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
Next
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