Newer
Older
package gosdn
import (
"context"
"os"
"testing"
"code.fbi.h-da.de/cocsn/gosdn/interfaces/device"
"code.fbi.h-da.de/cocsn/gosdn/interfaces/networkdomain"
"code.fbi.h-da.de/cocsn/gosdn/interfaces/southbound"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto"
"github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/mock"
pb "google.golang.org/protobuf/proto"
)
const apiEndpoint = "http://localhost:8080"
// UUIDs for test cases
var mdid uuid.UUID
var defaultSbiID uuid.UUID
var defaultPndID uuid.UUID
var cuid uuid.UUID
var sbi southbound.SouthboundInterface
var httpTestPND networkdomain.NetworkDomain
var args string
var argsNotFound string
var argsNotFoundGetDevice string
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var mockContext = mock.MatchedBy(func(ctx context.Context) bool { return true })
// TestMain bootstraps all tests. Humongous beast
// TODO: Move somewhere more sensible
func TestMain(m *testing.M) {
log.SetReportCaller(true)
if os.Getenv("GOSDN_LOG") == "nolog" {
log.SetLevel(log.PanicLevel)
}
gnmiMessages = map[string]pb.Message{
"./test/proto/cap-resp-arista-ceos": &gpb.CapabilityResponse{},
"./test/proto/req-full-node": &gpb.GetRequest{},
"./test/proto/req-full-node-arista-ceos": &gpb.GetRequest{},
"./test/proto/req-interfaces-arista-ceos": &gpb.GetRequest{},
"./test/proto/req-interfaces-interface-arista-ceos": &gpb.GetRequest{},
"./test/proto/req-interfaces-wildcard": &gpb.GetRequest{},
"./test/proto/resp-full-node": &gpb.GetResponse{},
"./test/proto/resp-full-node-arista-ceos": &gpb.GetResponse{},
"./test/proto/resp-interfaces-arista-ceos": &gpb.GetResponse{},
"./test/proto/resp-interfaces-interface-arista-ceos": &gpb.GetResponse{},
"./test/proto/resp-interfaces-wildcard": &gpb.GetResponse{},
"./test/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)
}
}
readTestUUIDs()
os.Exit(m.Run())
}
func readTestUUIDs() {
var err error
mdid, err = uuid.Parse("688a264e-5f85-40f8-bd13-afc42fcd5c7a")
defaultPndID, err = uuid.Parse("b4016412-eec5-45a1-aa29-f59915357bad")
cuid, err = uuid.Parse("3e8219b0-e926-400d-8660-217f2a25a7c6")
if err != nil {
log.Fatal(err)
}
}