Skip to content
Snippets Groups Projects
Commit 4f54ea98 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

first boilerplate integration tests. only error checking for now

parent c5fdf57b
No related branches found
No related tags found
2 merge requests!110Integration test,!90Develop
Pipeline #66440 passed with warnings
...@@ -71,5 +71,4 @@ destroy: ...@@ -71,5 +71,4 @@ destroy:
stage: .post stage: .post
script: script:
- gitlab-terraform destroy - gitlab-terraform destroy
needs: ["apply"]
<<: *tf <<: *tf
\ No newline at end of file
...@@ -33,17 +33,13 @@ func main() { ...@@ -33,17 +33,13 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
transport := &nucleus.Gnmi{
SetNode: sbi.SetNode(),
RespChan: make(chan *gpb.SubscribeResponse),
}
cfg := &gnmi.Config{ cfg := &gnmi.Config{
Addr: "portainer.danet.fbi.h-da.de:6030", Addr: "[2003:e6:1722:fed0:0:242:ac11:5]:6030",
Username: "admin", Username: "admin",
Password: "arista", Password: "arista",
Encoding: gpb.Encoding_JSON_IETF, Encoding: gpb.Encoding_JSON_IETF,
} }
transport.SetConfig(cfg) transport,_ := nucleus.NewGnmiTransport(cfg)
device.Transport = transport device.Transport = transport
......
...@@ -32,7 +32,7 @@ func main() { ...@@ -32,7 +32,7 @@ func main() {
} }
cfg := &gnmi.Config{ cfg := &gnmi.Config{
Addr: "[fdfd::ce05]:6030", Addr: "[2003:e6:1722:fed0:0:242:ac11:5]:6030",
Username: "admin", Username: "admin",
Password: "arista", Password: "arista",
Encoding: gpb.Encoding_JSON_IETF, Encoding: gpb.Encoding_JSON_IETF,
...@@ -45,7 +45,7 @@ func main() { ...@@ -45,7 +45,7 @@ func main() {
device.Transport = transport device.Transport = transport
p := []string{"/interfaces/interface"} p := []string{"/interfaces/interface/name"}
errors := 0 errors := 0
for _, path := range p { for _, path := range p {
err := pnd.RequestAll(path) err := pnd.RequestAll(path)
......
package nucleus package nucleus
import "testing" import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"context"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"testing"
"time"
)
var address = "141.100.70.171:6030"
func TestGnmi_SetIntegration(t *testing.T) { func TestGnmi_SetIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
t.Run("Test GNMI Set", func(t *testing.T){
cfg := &gnmi.Config{
Addr: address,
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
}
transport,err := NewGnmiTransport(cfg)
if err != nil {
t.Error(err)
}
p := []string{"/interfaces/interface"}
resp, err := transport.Set(context.Background(), p...)
if err != nil {
t.Error(err)
}
if resp == nil {
t.Error("resp is nil")
}
})
} }
func TestGnmi_GetIntegration(t *testing.T) { func TestGnmi_GetIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
t.Run("Test GNMI Get", func(t *testing.T){
cfg := &gnmi.Config{
Addr: address,
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
}
transport,err := NewGnmiTransport(cfg)
if err != nil {
t.Error(err)
}
p := []string{"/interfaces/interface"}
resp, err := transport.Get(context.Background(), p...)
if err != nil {
t.Error(err)
}
if resp == nil {
t.Error("resp is nil")
}
})
} }
func TestGnmi_SubscribeIntegration(t *testing.T) { func TestGnmi_SubscribeIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
t.Run("Test GNMI Subscribe", func(t *testing.T){
cfg := &gnmi.Config{
Addr: address,
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
}
transport,_ := NewGnmiTransport(cfg)
paths := []string{"/interfaces/interface/name"}
opts := &gnmi.SubscribeOptions{
UpdatesOnly: false,
Prefix: "",
Mode: "stream",
StreamMode: "sample",
SampleInterval: uint64(10 * time.Second.Nanoseconds()),
SuppressRedundant: false,
HeartbeatInterval: uint64(time.Second.Nanoseconds()),
Paths: gnmi.SplitPaths(paths),
Origin: "",
Target: address,
}
ctx := context.WithValue(context.Background(), "opts", opts)
d := time.Now().Add(60 * time.Second)
ctx, cancel := context.WithDeadline(ctx, d)
defer cancel()
go func() {
if err := transport.Subscribe(ctx); err != nil {
t.Error(err)
}
}()
time.Sleep(time.Second * 50)
})
} }
func TestGnmi_CapabilitiesIntegration(t *testing.T) { func TestGnmi_CapabilitiesIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
t.Run("Test GNMI Capabilities", func(t *testing.T){
cfg := &gnmi.Config{
Addr: address,
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
}
transport,err := NewGnmiTransport(cfg)
if err != nil {
t.Error(err)
}
resp, err := transport.Capabilities(context.Background())
if err != nil {
t.Error(err)
}
if resp == nil {
t.Error("resp is nil")
}
})
} }
func TestPndImplementation_RequestAllIntegration(t *testing.T) { func TestPndImplementation_RequestAllIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
t.Fail()
} }
func TestPndImplementation_RequestIntegration(t *testing.T) { func TestPndImplementation_RequestIntegration(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("skipping integration test") t.Skip("skipping integration test")
} }
t.Fail()
} }
\ No newline at end of file
...@@ -49,15 +49,6 @@ func mockDevice() Device { ...@@ -49,15 +49,6 @@ func mockDevice() Device {
} }
func newPnd() pndImplementation { func newPnd() pndImplementation {
return pndImplementation{
name: "default",
description: "default test pnd",
sbic: sbiStore{store{}},
devices: deviceStore{store{}},
}
}
func newPndWithId() pndImplementation {
return pndImplementation{ return pndImplementation{
name: "default", name: "default",
description: "default test pnd", description: "default test pnd",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment