Skip to content
Snippets Groups Projects

Resolve "Isolate Integration Tests"

Merged Ghost User requested to merge 91-isolate-integration-tests into develop
1 file
+ 4
0
Compare changes
  • Side-by-side
  • Inline
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,
Loading