Newer
Older
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) {
if testing.Short() {
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) {
if testing.Short() {
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) {
if testing.Short() {
t.Skip("skipping integration test")
}
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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) {
if testing.Short() {
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) {
if testing.Short() {
t.Skip("skipping integration test")
}
t.Fail()
}
func TestPndImplementation_RequestIntegration(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
t.Fail()