diff --git a/build/ci/.terraform-ci.yml b/build/ci/.terraform-ci.yml index 6c6a08cb13eb183a3e4d0a1ff6e9de004ca3a2f7..c2dc2bda1359561e72600b136d427ecfa7f08880 100644 --- a/build/ci/.terraform-ci.yml +++ b/build/ci/.terraform-ci.yml @@ -71,5 +71,4 @@ destroy: stage: .post script: - gitlab-terraform destroy - needs: ["apply"] <<: *tf \ No newline at end of file diff --git a/cmd/gnmi-telemetry/telemetry.go b/cmd/gnmi-telemetry/telemetry.go index c083c4a9bc2a9cfa91659b5955a405d05935f772..4abcced5f0ae47ae15d090bcf3ac178ed05d487c 100644 --- a/cmd/gnmi-telemetry/telemetry.go +++ b/cmd/gnmi-telemetry/telemetry.go @@ -33,17 +33,13 @@ func main() { log.Fatal(err) } - transport := &nucleus.Gnmi{ - SetNode: sbi.SetNode(), - RespChan: make(chan *gpb.SubscribeResponse), - } cfg := &gnmi.Config{ - Addr: "portainer.danet.fbi.h-da.de:6030", + Addr: "[2003:e6:1722:fed0:0:242:ac11:5]:6030", Username: "admin", Password: "arista", Encoding: gpb.Encoding_JSON_IETF, } - transport.SetConfig(cfg) + transport,_ := nucleus.NewGnmiTransport(cfg) device.Transport = transport diff --git a/cmd/gnmi/gnmi.go b/cmd/gnmi/gnmi.go index f6f4eb9846a1b5b3e04dd6cdf9cec7afc67c331b..65b5ecb51777b623df1eb29fc028506fe3d8f365 100644 --- a/cmd/gnmi/gnmi.go +++ b/cmd/gnmi/gnmi.go @@ -32,7 +32,7 @@ func main() { } cfg := &gnmi.Config{ - Addr: "[fdfd::ce05]:6030", + Addr: "[2003:e6:1722:fed0:0:242:ac11:5]:6030", Username: "admin", Password: "arista", Encoding: gpb.Encoding_JSON_IETF, @@ -45,7 +45,7 @@ func main() { device.Transport = transport - p := []string{"/interfaces/interface"} + p := []string{"/interfaces/interface/name"} errors := 0 for _, path := range p { err := pnd.RequestAll(path) diff --git a/nucleus/integration_test.go b/nucleus/integration_test.go index 003a1802b51e619a538c9df03cd2b72d275cb35f..def64439c1c6530aad2b7669cdcbfe35efe8d08c 100644 --- a/nucleus/integration_test.go +++ b/nucleus/integration_test.go @@ -1,39 +1,142 @@ 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) { 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") } + 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() } \ No newline at end of file diff --git a/nucleus/principalNetworkDomain_test.go b/nucleus/principalNetworkDomain_test.go index 1ef15fa9cfc931e00b3c5a06bc71a3f618fdd7d2..3f8e7f00212ef62769f2c6ac386cc12574fb6b24 100644 --- a/nucleus/principalNetworkDomain_test.go +++ b/nucleus/principalNetworkDomain_test.go @@ -49,15 +49,6 @@ func mockDevice() Device { } func newPnd() pndImplementation { - return pndImplementation{ - name: "default", - description: "default test pnd", - sbic: sbiStore{store{}}, - devices: deviceStore{store{}}, - } -} - -func newPndWithId() pndImplementation { return pndImplementation{ name: "default", description: "default test pnd",