Commit 81601b56 authored by Manuel Kieweg's avatar Manuel Kieweg 🤷
Browse files

Merge branch '91-isolate-integration-tests' into 'develop'

Resolve "Isolate Integration Tests"

See merge request cocsn/gosdn!126
parents f51f28c6 8561d9f9
integration-test:
image: golang:1.14
stage: integration-test
needs: ["apply"]
needs: [ "apply" ]
variables:
GOSDN_LOG: "nolog"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
allow_failure: true
- if: $CI_COMMIT_BRANCH == "integration-test"
allow_failure: true
script:
- go test -race $(go list ./... | grep -v /forks/ | grep -v /api/ | grep -v /mocks ) -v -coverprofile=coverage.out
- go test -race ./test/integration -v -coverprofile=coverage.out
after_script:
- go tool cover -func=coverage.out
integration-test-merge-request:
image: golang:1.14
stage: integration-test
allow_failure: true
needs: ["apply"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
script:
- go test -race $(go list ./... | grep -v /forks/ | grep -v /api/ | grep -v /mocks ) -v -coverprofile=coverage.out
after_script:
- go tool cover -func=coverage.out
unit-test:
image: golang:1.14
stage: test
allow_failure: true
variables:
GOSDN_LOG: "nolog"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
......
......@@ -5,10 +5,9 @@ go 1.14
require (
code.fbi.h-da.de/cocsn/yang-models v0.0.4
github.com/aristanetworks/goarista v0.0.0-20201120222254-94a892eb0c6a
github.com/golang/protobuf v1.4.3
github.com/golang/protobuf v1.5.0
github.com/google/gnxi v0.0.0-20201221102247-c26672548161
github.com/google/uuid v1.1.2
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/neo4j/neo4j-go-driver v1.8.3
github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802
github.com/openconfig/goyang v0.2.3
......@@ -16,9 +15,8 @@ require (
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20201216054612-986b41b23924
google.golang.org/grpc v1.34.0
google.golang.org/protobuf v1.25.0
google.golang.org/protobuf v1.26.0
)
......@@ -106,8 +106,9 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
......@@ -120,8 +121,9 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
......@@ -187,9 +189,8 @@ github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgo
github.com/klauspost/pgzip v1.2.4/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/klauspost/reedsolomon v1.9.3/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
......@@ -323,9 +324,8 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
......@@ -515,8 +515,10 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/bsm/ratelimit.v1 v1.0.0-20160220154919-db14e161995a/go.mod h1:KF9sEfUPAXdG8Oev9e99iLGnl2uJMjc5B+4y3O7x610=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
......
......@@ -31,7 +31,6 @@ var pnd PrincipalNetworkDomain
var gnmiMessages map[string]pb.Message
var gnmiConfig *gnmi.Config
var d Device
var opt *GnmiTransportOptions
var startGnmiTarget chan string
var stopGnmiTarget chan bool
......@@ -39,7 +38,6 @@ var args string
var argsNotFound string
var mockContext = mock.MatchedBy(func(ctx context.Context) bool { return true })
var gnmiAddress = "141.100.70.171:6030"
// TestMain bootstraps all tests. Humongous beast
// TODO: Move somewhere more sensible
......@@ -73,7 +71,6 @@ func TestMain(m *testing.M) {
testSetupGnmi()
testSetupHTTP()
testSetupIntegration()
os.Exit(m.Run())
}
......
package cli
package integration
import (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"os"
"testing"
)
const unreachable = "203.0.113.10:6030"
var testAddress = "141.100.70.171:6030"
var testAPIEndpoint = "http://141.100.70.171:8080"
var testUsername = "admin"
var testPassword = "arista"
var defaultPath = []string{"/system/config/hostname"}
func testSetupIntegration() {
a := os.Getenv("GOSDN_TEST_ENDPOINT")
if a != "" {
testAddress = a
}
api := os.Getenv("GOSDN_TEST_API_ENDPOINT")
if api != "" {
testAPIEndpoint = api
}
}
func TestMain(m *testing.M) {
testSetupIntegration()
os.Exit(m.Run())
......@@ -64,7 +46,7 @@ func TestCapabilities(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := Capabilities(tt.args.a, tt.args.u, tt.args.p); (err != nil) != tt.wantErr {
if err := cli.Capabilities(tt.args.a, tt.args.u, tt.args.p); (err != nil) != tt.wantErr {
t.Errorf("Capabilities() error = %v, wantErr %v", err, tt.wantErr)
}
})
......@@ -109,7 +91,7 @@ func TestGet(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if _, err := Get(tt.args.a, tt.args.u, tt.args.p, tt.args.args...); (err != nil) != tt.wantErr {
if _, err := cli.Get(tt.args.a, tt.args.u, tt.args.p, tt.args.args...); (err != nil) != tt.wantErr {
t.Errorf("Get() error = %v, wantErr %v", err, tt.wantErr)
}
})
......@@ -151,7 +133,7 @@ func TestHttpGet(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := HTTPGet(tt.args.apiEndpoint, tt.args.f, tt.args.args...); (err != nil) != tt.wantErr {
if err := cli.HTTPGet(tt.args.apiEndpoint, tt.args.f, tt.args.args...); (err != nil) != tt.wantErr {
t.Errorf("HttpGet() error = %v, wantErr %v", err, tt.wantErr)
}
})
......@@ -210,7 +192,7 @@ func TestSet(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := Set(tt.args.a, tt.args.u, tt.args.p, tt.args.typ, tt.args.args...); (err != nil) != tt.wantErr {
if err := cli.Set(tt.args.a, tt.args.u, tt.args.p, tt.args.typ, tt.args.args...); (err != nil) != tt.wantErr {
t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr)
}
})
......
package cmd
package integration
import (
"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"
var testAddress = "141.100.70.171:6030"
var testAPIEndpoint = "http://141.100.70.171:8080"
var testUsername = "admin"
var testPassword = "arista"
var defaultPath = []string{"/system/config/hostname"}
var opt *nucleus.GnmiTransportOptions
func testSetupIntegration() {
if os.Getenv("GOSDN_LOG") == "nolog" {
log.SetLevel(log.PanicLevel)
}
a := os.Getenv("GOSDN_TEST_ENDPOINT")
if a != "" {
testAddress = a
......@@ -30,11 +44,36 @@ func testSetupIntegration() {
if p != "" {
testPassword = p
}
}
func TestMain(m *testing.M) {
testSetupIntegration()
os.Exit(m.Run())
gnmiMessages = map[string]pb.Message{
"../proto/cap-resp-arista-ceos": &gpb.CapabilityResponse{},
"../proto/req-full-node": &gpb.GetRequest{},
"../proto/req-full-node-arista-ceos": &gpb.GetRequest{},
"../proto/req-interfaces-arista-ceos": &gpb.GetRequest{},
"../proto/req-interfaces-interface-arista-ceos": &gpb.GetRequest{},
"../proto/req-interfaces-wildcard": &gpb.GetRequest{},
"../proto/resp-full-node": &gpb.GetResponse{},
"../proto/resp-full-node-arista-ceos": &gpb.GetResponse{},
"../proto/resp-interfaces-arista-ceos": &gpb.GetResponse{},
"../proto/resp-interfaces-interface-arista-ceos": &gpb.GetResponse{},
"../proto/resp-interfaces-wildcard": &gpb.GetResponse{},
"../proto/resp-set-system-config-hostname": &gpb.SetResponse{},
}
for k, v := range gnmiMessages {
if err := proto.Read(k, v); err != nil {
log.Fatalf("error parsing %v: %v", k, err)
}
}
opt = &nucleus.GnmiTransportOptions{
Config: gnmi.Config{
Addr: testAddress,
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
},
RespChan: make(chan *gpb.SubscribeResponse),
}
}
func TestCliIntegration(t *testing.T) {
......@@ -61,8 +100,8 @@ func TestCliIntegration(t *testing.T) {
return
}
}
cliPnd = viper.GetString("CLI_PND")
cliSbi = viper.GetString("CLI_SBI")
cliPnd := viper.GetString("CLI_PND")
cliSbi := viper.GetString("CLI_SBI")
if err := cli.HTTPGet(
testAPIEndpoint,
......
package nucleus
package integration
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"context"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"os"
pb "google.golang.org/protobuf/proto"
"reflect"
"sort"
"testing"
"time"
)
func testSetupIntegration() {
a := os.Getenv("GOSDN_TEST_ENDPOINT")
if a != "" {
gnmiAddress = a
}
opt = &GnmiTransportOptions{
Config: gnmi.Config{
Addr: gnmiAddress,
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
},
RespChan: make(chan *gpb.SubscribeResponse),
}
}
var gnmiMessages map[string]pb.Message
func TestGnmi_SetIntegration(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
type fields struct {
opt *GnmiTransportOptions
opt *nucleus.GnmiTransportOptions
}
type args struct {
ctx context.Context
......@@ -48,7 +34,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
}{
{
name: "destination unreachable",
fields: fields{opt: &GnmiTransportOptions{
fields: fields{opt: &nucleus.GnmiTransportOptions{
Config: gnmi.Config{
Addr: "203.0.113.10:6030",
},
......@@ -80,13 +66,13 @@ func TestGnmi_SetIntegration(t *testing.T) {
},
},
},
want: gnmiMessages["../test/proto/resp-set-system-config-hostname"],
want: gnmiMessages["../proto/resp-set-system-config-hostname"],
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g, err := NewGnmiTransport(tt.fields.opt)
g, err := nucleus.NewGnmiTransport(tt.fields.opt)
if err != nil {
t.Errorf("NewGnmiTransport() error = %v, wantErr %v", err, tt.wantErr)
return
......@@ -98,14 +84,11 @@ func TestGnmi_SetIntegration(t *testing.T) {
}
got, ok := resp.(*gpb.SetResponse)
if !ok {
t.Error(&ErrInvalidTypeAssertion{
v: reflect.TypeOf(resp),
t: reflect.TypeOf(&gpb.SetResponse{}),
})
t.Errorf("want: %v, got %v, error: %v", reflect.TypeOf(&gpb.SetResponse{}), reflect.TypeOf(resp), &nucleus.ErrInvalidTypeAssertion{})
}
if err != nil && tt.wantErr {
return
} else if got.Prefix.Target != gnmiAddress ||
} else if got.Prefix.Target != testAddress ||
got.Response[0].Op != gpb.UpdateResult_UPDATE {
t.Errorf("Set() got = %v, want %v", got, tt.want)
}
......@@ -123,7 +106,7 @@ func TestGnmi_GetIntegration(t *testing.T) {
"system/config/hostname",
}
type fields struct {
opt *GnmiTransportOptions
opt *nucleus.GnmiTransportOptions
}
type args struct {
ctx context.Context
......@@ -143,12 +126,12 @@ func TestGnmi_GetIntegration(t *testing.T) {
ctx: context.Background(),
params: paths[:1],
},
want: gnmiMessages["../test/proto/resp-interfaces-arista-ceos"],
want: gnmiMessages["../proto/resp-interfaces-arista-ceos"],
wantErr: false,
},
{
name: "destination unreachable",
fields: fields{opt: &GnmiTransportOptions{
fields: fields{opt: &nucleus.GnmiTransportOptions{
Config: gnmi.Config{
Addr: "203.0.113.10:6030",
},
......@@ -164,7 +147,7 @@ func TestGnmi_GetIntegration(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g, err := NewGnmiTransport(tt.fields.opt)
g, err := nucleus.NewGnmiTransport(tt.fields.opt)
if err != nil {
t.Error(err)
return
......@@ -186,7 +169,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
}
type fields struct {
opt *GnmiTransportOptions
opt *nucleus.GnmiTransportOptions
}
type args struct {
ctx context.Context
......@@ -201,7 +184,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
{
name: "default",
fields: fields{
opt: &GnmiTransportOptions{
opt: &nucleus.GnmiTransportOptions{
Config: opt.Config,
RespChan: make(chan *gpb.SubscribeResponse),
},
......@@ -217,7 +200,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
"/interfaces/interface/name",
"/system/config/hostname",
}),
Target: gnmiAddress,
Target: testAddress,
},
},
wantErr: false,
......@@ -225,7 +208,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
{
name: "wrong path",
fields: fields{
opt: &GnmiTransportOptions{
opt: &nucleus.GnmiTransportOptions{
Config: opt.Config,
RespChan: make(chan *gpb.SubscribeResponse),
},
......@@ -240,7 +223,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
"interfaces/interface/name",
"ystem/config/hostname",
}),
Target: gnmiAddress,
Target: testAddress,
},
},
wantErr: true,
......@@ -248,7 +231,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
{
name: "destination unreachable",
fields: fields{
opt: &GnmiTransportOptions{
opt: &nucleus.GnmiTransportOptions{
Config: gnmi.Config{
Addr: "203.0.113.10:6030",
},
......@@ -264,12 +247,12 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var wantErr = tt.wantErr
g, err := NewGnmiTransport(tt.fields.opt)
g, err := nucleus.NewGnmiTransport(tt.fields.opt)
if err != nil {
t.Error(err)
return
}
ctx := context.WithValue(context.Background(), CtxKeyOpts, tt.args.opts) //nolint
ctx := context.WithValue(context.Background(), nucleus.CtxKeyOpts, tt.args.opts) //nolint
ctx, cancel := context.WithCancel(ctx)
go func() {
subErr := g.Subscribe(ctx)
......@@ -293,7 +276,7 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
t.Skip("skipping integration test")
}
type fields struct {
opt *GnmiTransportOptions
opt *nucleus.GnmiTransportOptions
}
type args struct {
ctx context.Context
......@@ -309,26 +292,26 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
name: "supported models",
fields: fields{opt: opt},
args: args{ctx: context.Background()},
want: gnmiMessages["../test/proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedModels,
want: gnmiMessages["../proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedModels,
wantErr: false,
},
{
name: "supported encodings",
fields: fields{opt: opt},
args: args{ctx: context.Background()},
want: gnmiMessages["../test/proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedEncodings,
want: gnmiMessages["../proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).SupportedEncodings,
wantErr: false,
},
{
name: "gnmi version",
fields: fields{opt: opt},
args: args{ctx: context.Background()},
want: gnmiMessages["../test/proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).GNMIVersion,
want: gnmiMessages["../proto/cap-resp-arista-ceos"].(*gpb.CapabilityResponse).GNMIVersion,
wantErr: false,
},
{
name: "destination unreachable",
fields: fields{opt: &GnmiTransportOptions{
fields: fields{opt: &nucleus.GnmiTransportOptions{
Config: gnmi.Config{
Addr: "203.0.113.10:6030",
},
......@@ -341,7 +324,7 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g, err := NewGnmiTransport(tt.fields.opt)
g, err := nucleus.NewGnmiTransport(tt.fields.opt)
if err != nil {
t.Error(err)
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment