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

Merge branch 'integration-test' into 'develop'

Integration test

See merge request cocsn/gosdn!112
parents f6a5e620 e7df554d
No related branches found
No related tags found
2 merge requests!112Integration test,!90Develop
Pipeline #66545 failed
...@@ -203,8 +203,10 @@ func (g *Gnmi) subscribe(ctx context.Context) error { ...@@ -203,8 +203,10 @@ func (g *Gnmi) subscribe(ctx context.Context) error {
go func() { go func() {
for { for {
resp := <-g.RespChan resp := <-g.RespChan
if err := gnmi.LogSubscribeResponse(resp); err != nil { if resp != nil {
log.Fatal(err) if err := gnmi.LogSubscribeResponse(resp); err != nil {
log.Fatal(err)
}
} }
} }
}() }()
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util" "code.fbi.h-da.de/cocsn/gosdn/nucleus/util"
"context" "context"
gpb "github.com/openconfig/gnmi/proto/gnmi" gpb "github.com/openconfig/gnmi/proto/gnmi"
"reflect"
"testing" "testing"
"time" "time"
) )
...@@ -95,15 +96,14 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { ...@@ -95,15 +96,14 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
Target: address, Target: address,
} }
ctx := context.WithValue(context.Background(), "opts", opts) ctx := context.WithValue(context.Background(), "opts", opts)
d := time.Now().Add(60 * time.Second)
ctx, cancel := context.WithDeadline(ctx, d)
defer cancel()
go func() { go func() {
if err := transport.Subscribe(ctx); err != nil { if err := transport.Subscribe(ctx); err != nil {
t.Error(err) t.Error(err)
} }
}() }()
time.Sleep(time.Second * 50) time.Sleep(time.Second * 30)
ctx.Done()
time.Sleep(time.Second * 5)
}) })
} }
...@@ -134,8 +134,8 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) { ...@@ -134,8 +134,8 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
if resp != v { if !reflect.DeepEqual(resp, v) {
t.Error("resp is nil") t.Errorf("Capabilities() = %v, want %v", resp, v)
} }
}) })
} }
......
...@@ -114,7 +114,8 @@ func TestOpenConfig_Schema(t *testing.T) { ...@@ -114,7 +114,8 @@ func TestOpenConfig_Schema(t *testing.T) {
schema: tt.fields.schema, schema: tt.fields.schema,
id: tt.fields.id, id: tt.fields.id,
} }
if got := oc.Schema(); !reflect.DeepEqual(got, tt.want) { got := oc.Schema().SchemaTree
if !reflect.DeepEqual(got, tt.want.SchemaTree) {
t.Errorf("Schema() = %v, want %v", got, tt.want) t.Errorf("Schema() = %v, want %v", got, tt.want)
} }
}) })
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"reflect" "reflect"
"sort"
"testing" "testing"
) )
...@@ -221,7 +222,14 @@ func Test_store_UUIDs(t *testing.T) { ...@@ -221,7 +222,14 @@ func Test_store_UUIDs(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if got := tt.s.UUIDs(); !reflect.DeepEqual(got, tt.want) { sort.Slice(tt.want, func(i, j int) bool {
return tt.want[i].String() < tt.want[j].String()
})
got := tt.s.UUIDs()
sort.Slice(got, func(i, j int) bool {
return got[i].String() < got[j].String()
})
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("UUIDs() = %v, want %v", got, tt.want) t.Errorf("UUIDs() = %v, want %v", got, tt.want)
} }
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment