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
5281165f
Commit
5281165f
authored
2 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
WIP: First test case updates
TODO: this commit has to be rebased
parent
5469f4f2
No related branches found
No related tags found
1 merge request
!401
Change the current gosdn plugin implementation from Go's internal plugin system to hashicorp's go-plugins
Pipeline
#121579
failed
2 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controller/api/api_test.go
+2
-8
2 additions, 8 deletions
controller/api/api_test.go
controller/api/initialise_test.go
+9
-4
9 additions, 4 deletions
controller/api/initialise_test.go
controller/nucleus/gnmi_transport_test.go
+19
-41
19 additions, 41 deletions
controller/nucleus/gnmi_transport_test.go
with
30 additions
and
53 deletions
controller/api/api_test.go
+
2
−
8
View file @
5281165f
...
...
@@ -7,9 +7,7 @@ import (
"testing"
ppb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
spb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
tpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus"
"code.fbi.h-da.de/danet/gosdn/controller/store"
log
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
...
...
@@ -32,7 +30,7 @@ func Test_GetIds(t *testing.T) {
}
func
ensureFilesForTestsAreRemoved
()
{
ensureStoreFileForTestsIsRemoved
(
store
.
Sbi
FilenameSuffix
)
ensureStoreFileForTestsIsRemoved
(
store
.
Plugin
FilenameSuffix
)
ensureStoreFileForTestsIsRemoved
(
store
.
NetworkElementFilenameSuffix
)
}
...
...
@@ -59,11 +57,7 @@ func ensureStoreFileForTestsIsRemoved(storeName string) {
func
Test_AddPnd
(
t
*
testing
.
T
)
{
defer
ensureFilesForTestsAreRemoved
()
sbi
,
err
:=
nucleus
.
NewSBI
(
spb
.
Type_TYPE_OPENCONFIG
)
if
err
!=
nil
{
t
.
Errorf
(
"AddPnd() error = %v"
,
err
)
}
resp
,
err
:=
AddPnd
(
context
.
TODO
(),
bufnet
,
"test"
,
"test pnd"
,
sbi
.
ID
()
.
String
())
resp
,
err
:=
AddPnd
(
context
.
TODO
(),
bufnet
,
"test"
,
"test pnd"
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
...
...
This diff is collapsed.
Click to expand it.
controller/api/initialise_test.go
+
9
−
4
View file @
5281165f
...
...
@@ -10,6 +10,8 @@ import (
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/conflict"
cpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/core"
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi"
rpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-registry"
ppb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
apb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
tpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
...
...
@@ -121,12 +123,12 @@ func bootstrapUnitTest() {
},
})
sbi
:=
&
nucleus
.
OpenConfig
{}
plugin
:=
&
mocks
.
Plugin
{}
mockNetworkElement
:=
&
mocks
.
NetworkElement
{}
mockNetworkElement
.
On
(
"
SBI
"
)
.
Return
(
sbi
)
mockNetworkElement
.
On
(
"
Plugin
"
)
.
Return
(
plugin
)
mockNetworkElement
.
On
(
"ID"
)
.
Return
(
mneUUID
)
mockNetworkElement
.
On
(
"GetModel"
)
.
Return
(
sbi
.
Schema
()
.
Root
)
mockNetworkElement
.
On
(
"GetModel"
)
.
Return
(
plugin
.
Model
()
)
mockNetworkElement
.
On
(
"Name"
)
.
Return
(
"openconfig"
)
mockNetworkElement
.
On
(
"TransportAddress"
)
.
Return
(
"127.0.0.1:6030"
)
mockNetworkElement
.
On
(
"GetMetadata"
)
.
Return
(
conflict
.
Metadata
{
ResourceVersion
:
0
})
...
...
@@ -145,7 +147,7 @@ func bootstrapUnitTest() {
mockPnd
.
On
(
"NetworkElements"
)
.
Return
([]
networkelement
.
NetworkElement
{
&
nucleus
.
CommonNetworkElement
{
UUID
:
mneUUID
,
Plugin
:
&
openconfig
.
Device
{},
Plugin
:
&
mocks
.
Plugin
{},
},
})
mockPnd
.
On
(
"GetSBIs"
)
.
Return
([]
mocks
.
SouthboundInterface
{})
...
...
@@ -180,6 +182,9 @@ func bootstrapUnitTest() {
portService
,
routeService
,
appService
,
rpb
.
NewPluginRegistryServiceClient
(
&
grpc
.
ClientConn
{}),
csbi
.
NewCsbiServiceClient
(
&
grpc
.
ClientConn
{}),
func
(
u
uuid
.
UUID
,
c
chan
networkelement
.
Details
)
{},
&
mockPnd
,
)
...
...
This diff is collapsed.
Click to expand it.
controller/nucleus/gnmi_transport_test.go
+
19
−
41
View file @
5281165f
...
...
@@ -9,8 +9,6 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/change"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/types"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
ppb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
spb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
tpb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
...
...
@@ -18,10 +16,9 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/mocks"
"code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/danet/gosdn/models/generated/openconfig"
openconfigPlugin
"code.fbi.h-da.de/danet/gosdn/plugins/openconfig"
gpb
"github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ytypes"
"github.com/stretchr/testify/mock"
)
...
...
@@ -106,7 +103,7 @@ func TestGnmi_Capabilities(t *testing.T) {
func
TestGnmi_Close
(
t
*
testing
.
T
)
{
type
fields
struct
{
SetNode
func
(
schema
*
yang
.
Entry
,
root
interface
{},
path
*
gpb
.
Path
,
val
interface
{},
opts
...
ytypes
.
SetNodeOpt
)
error
SetNode
func
(
path
*
gpb
.
Path
,
value
*
gpb
.
TypedValue
)
error
RespChan
chan
*
gpb
.
SubscribeResponse
}
tests
:=
[]
struct
{
...
...
@@ -217,56 +214,50 @@ func TestGnmi_Get(t *testing.T) {
}
func
TestGnmi_ProcessResponse
(
t
*
testing
.
T
)
{
type
fields
struct
{
Sbi
southbound
.
SouthboundInterface
}
type
args
struct
{
path
string
root
interface
{}
}
tests
:=
[]
struct
{
name
string
fields
fields
args
args
wantErr
bool
}{
{
name
:
"Interfaces Interface"
,
fields
:
fields
{
Sbi
:
&
OpenConfig
{}},
name
:
"Interfaces Interface"
,
args
:
args
{
path
:
"../test/proto/resp-interfaces-interface-arista-ceos"
,
root
:
&
openconfig
.
Device
{},
},
wantErr
:
false
,
},
{
name
:
"Interfaces Wildcard"
,
fields
:
fields
{
Sbi
:
&
OpenConfig
{}},
name
:
"Interfaces Wildcard"
,
args
:
args
{
path
:
"../test/proto/resp-interfaces-wildcard"
,
root
:
&
openconfig
.
Device
{},
},
wantErr
:
false
,
},
{
name
:
"Root"
,
fields
:
fields
{
Sbi
:
&
OpenConfig
{}},
name
:
"Root"
,
args
:
args
{
path
:
"../test/proto/resp-full-node-arista-ceos"
,
root
:
&
openconfig
.
Device
{},
},
wantErr
:
false
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
networkElementModel
,
err
:=
openconfigPlugin
.
NewDeviceModel
()
if
err
!=
nil
{
t
.
Errorf
(
"ProcessResponse() error = %v"
,
err
)
}
g
:=
&
Gnmi
{
SetNode
:
tt
.
fields
.
Sbi
.
SetNode
,
Unmarshal
:
tt
.
fields
.
Sbi
.
(
*
OpenConfig
)
.
Unmarshal
,
SetNode
:
networkElementModel
.
SetNode
,
Unmarshal
:
networkElementModel
.
Unmarshal
,
}
s
:=
tt
.
fields
.
Sbi
.
Schema
()
resp
:=
gnmiMessages
[
tt
.
args
.
path
]
if
err
:=
g
.
ProcessResponse
(
resp
,
tt
.
args
.
root
,
s
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
if
err
:=
g
.
ProcessResponse
(
resp
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"ProcessResponse() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
}
})
...
...
@@ -388,21 +379,16 @@ func TestGnmi_Set(t *testing.T) {
}
func
TestGnmi_Subscribe
(
t
*
testing
.
T
)
{
type
fields
struct
{
SetNode
func
(
schema
*
yang
.
Entry
,
root
interface
{},
path
*
gpb
.
Path
,
val
interface
{},
opts
...
ytypes
.
SetNodeOpt
)
error
RespChan
chan
*
gpb
.
SubscribeResponse
}
type
args
struct
{
ctx
context
.
Context
params
[]
string
}
tests
:=
[]
struct
{
name
string
fields
fields
args
args
wantErr
bool
}{
{
name
:
"nil client"
,
fields
:
fields
{},
args
:
args
{},
wantErr
:
true
},
{
name
:
"nil client"
,
args
:
args
{},
wantErr
:
true
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -415,23 +401,15 @@ func TestGnmi_Subscribe(t *testing.T) {
}
func
TestGnmi_Type
(
t
*
testing
.
T
)
{
type
fields
struct
{
SetNode
func
(
schema
*
yang
.
Entry
,
root
interface
{},
path
*
gpb
.
Path
,
val
interface
{},
opts
...
ytypes
.
SetNodeOpt
)
error
RespChan
chan
*
gpb
.
SubscribeResponse
}
tests
:=
[]
struct
{
name
string
fields
fields
want
string
name
string
want
string
}{
{
name
:
"dummy"
,
fields
:
fields
{},
want
:
"gnmi"
},
{
name
:
"dummy"
,
want
:
"gnmi"
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
g
:=
&
Gnmi
{
SetNode
:
tt
.
fields
.
SetNode
,
RespChan
:
tt
.
fields
.
RespChan
,
}
g
:=
&
Gnmi
{}
if
got
:=
g
.
Type
();
got
!=
tt
.
want
{
t
.
Errorf
(
"Type() = %v, want %v"
,
got
,
tt
.
want
)
}
...
...
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