Skip to content
Snippets Groups Projects
Commit 1c4414fa authored by Malte Bauch's avatar Malte Bauch
Browse files

Merge branch 'develop' into thesis-mk

parents 8a0dbcf6 780fb28d
No related branches found
No related tags found
1 merge request!221Thesis mk
Pipeline #88913 failed
Showing with 613 additions and 296 deletions
...@@ -72,7 +72,6 @@ func Test_CommitConfirm(t *testing.T) { ...@@ -72,7 +72,6 @@ func Test_CommitConfirm(t *testing.T) {
return return
} }
log.Info(resp) log.Info(resp)
} }
func Test_AddDevice(t *testing.T) { func Test_AddDevice(t *testing.T) {
......
...@@ -5,11 +5,13 @@ import ( ...@@ -5,11 +5,13 @@ import (
"net" "net"
"os" "os"
"testing" "testing"
"time" "time"
cpb "code.fbi.h-da.de/danet/api/go/gosdn/core" cpb "code.fbi.h-da.de/danet/api/go/gosdn/core"
ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd" ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd"
tpb "code.fbi.h-da.de/danet/api/go/gosdn/transport" tpb "code.fbi.h-da.de/danet/api/go/gosdn/transport"
"code.fbi.h-da.de/danet/gosdn/config"
"code.fbi.h-da.de/danet/gosdn/mocks" "code.fbi.h-da.de/danet/gosdn/mocks"
nbi "code.fbi.h-da.de/danet/gosdn/northbound/server" nbi "code.fbi.h-da.de/danet/gosdn/northbound/server"
"code.fbi.h-da.de/danet/gosdn/nucleus" "code.fbi.h-da.de/danet/gosdn/nucleus"
...@@ -112,7 +114,6 @@ func bufDialer(context.Context, string) (net.Conn, error) { ...@@ -112,7 +114,6 @@ func bufDialer(context.Context, string) (net.Conn, error) {
return lis.Dial() return lis.Dial()
} }
const unreachable = "203.0.113.10:6030"
const testPath = "/system/config/hostname" const testPath = "/system/config/hostname"
var testAddress = "141.100.70.170:6030" var testAddress = "141.100.70.170:6030"
...@@ -129,14 +130,12 @@ func TestMain(m *testing.M) { ...@@ -129,14 +130,12 @@ func TestMain(m *testing.M) {
} }
func bootstrapIntegrationTest() { func bootstrapIntegrationTest() {
if os.Getenv("GOSDN_LOG") == "nolog" { log.SetLevel(config.LogLevel)
log.SetLevel(log.PanicLevel)
}
addr := os.Getenv("GOSDN_TEST_ENDPOINT") addr := os.Getenv("CEOS_TEST_ENDPOINT")
if addr != "" { if addr != "" {
testAddress = addr testAddress = addr
log.Infof("GOSDN_TEST_ENDPOINT set to %v", testAddress) log.Infof("CEOS_TEST_ENDPOINT set to %v", testAddress)
} }
api := os.Getenv("GOSDN_TEST_API_ENDPOINT") api := os.Getenv("GOSDN_TEST_API_ENDPOINT")
if api != "" { if api != "" {
......
variables:
DOCKER_TLS_CERTDIR: "/certs"
DOCKERFILE: Dockerfile
build-docker:
before_script:
- echo "override global before script"
stage: build
allow_failure: false
needs: []
tags:
- shell-builder
rules:
- if: $CI_COMMIT_BRANCH == "develop" && $CI_NIGHTLY == null
variables:
TAG: $CI_REGISTRY_IMAGE:develop
BUILDARGS: -race
- if: $CI_NIGHTLY == "develop"
variables:
TAG: $CI_REGISTRY_IMAGE:nightly-develop
BUILDARGS: -race
- if: $CI_NIGHTLY == "mainline"
variables:
TAG: $CI_REGISTRY_IMAGE:nightly
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
TAG: $CI_REGISTRY_IMAGE:merge-request
BUILDARGS: -race
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_NIGHTLY == null
variables:
TAG: $CI_REGISTRY_IMAGE:latest
- if: $CI_COMMIT_BRANCH == "thesis-mk"
variables:
TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
DOCKERFILE: Dockerfile.alpine
BUILDKIT: DOCKER_BUILDKIT=1
- if: '$CI_COMMIT_BRANCH'
variables:
TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
script:
- echo $DOCKERFILE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- DOCKER_BUILDKIT=1 docker build --build-arg GITLAB_USER=$GO_MODULES_USER --build-arg GITLAB_TOKEN=$GO_MODULES_ACCESS_TOKEN --build-arg BUILDARGS=$BUILDARGS -t $DOCKER_IMAGE_SHA --file $DOCKERFILE .
- docker push $DOCKER_IMAGE_SHA
- docker tag $DOCKER_IMAGE_SHA $TAG
- docker push $TAG
- DOCKER_BUILDKIT=1 docker build --target installer --build-arg GITLAB_USER=$GO_MODULES_USER --build-arg GITLAB_TOKEN=$GO_MODULES_ACCESS_TOKEN --build-arg BUILDARGS=$BUILDARGS -t ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID} --file $DOCKERFILE .
- docker push ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID}
sast:
variables:
SAST_ANALYZER_IMAGE_TAG: '2'
SAST_EXCLUDED_PATHS: spec, test, tests, tmp
SEARCH_MAX_DEPTH: '4'
include:
- template: Security/SAST.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
.integration-test: &integration-test
image: ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID}
stage: integration-test
needs:
- job: "containerlab:deploy:integration"
variables:
GOSDN_LOG: "nolog"
GOSDN_TEST_API_ENDPOINT: "141.100.70.178:${GOSDN_GRPC_PORT}"
GOSDN_TEST_ENDPOINT: "141.100.70.178:${CEOS1_PORT}"
GOSDN_TEST_USER: "admin"
GOSDN_TEST_PASSWORD: "admin"
rules:
- if: $CI_NIGHTLY
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
allow_failure: true
integration-test:nucleus:
<<: *integration-test
script:
- ${CI_PROJECT_DIR}/build/ci/scripts/wait-for-it.sh ${GOSDN_TEST_ENDPOINT} -s -t 180 -- echo "CEOS is up"
- cd ./test/integration
- go test -race -run TestGnmi_SetIntegration
- go test -race -run TestGnmi_GetIntegration
- go test -race -run TestGnmi_SubscribeIntegration
- go test -race -run TestGnmi_CapabilitiesIntegration
integration-test:api:
<<: *integration-test
variables:
K8S_OP: "getenv"
script:
- cd ./api
- go test -race -run TestApiIntegration
.test: &test
image: ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID}
stage: test
allow_failure: true
variables:
GOSDN_LOG: "nolog"
GOSDN_CHANGE_TIMEOUT: "100ms"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
- if: $CI_NIGHTLY
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
allow_failure: true
unit-test:
script:
- go test -short -race $(go list ./... | grep -v /forks/ | grep -v /mocks ) -coverprofile=coverage.out
after_script:
- go tool cover -func=coverage.out
<<: *test
controller-test:
image: golang:1.16
script:
- go test -race -run TestRun
<<: *test
#!/bin/bash
input=$1
#trailing_backspace=$2
hashed_value=$(echo $input | sha256sum | awk '{print $1}' )
decimal_value=$((16#$hashed_value))
decimal_value=${decimal_value/-/}
octet=$(((decimal_value % 255)))
echo -n $octet
\ No newline at end of file
...@@ -34,6 +34,7 @@ package cmd ...@@ -34,6 +34,7 @@ package cmd
import ( import (
"context" "context"
"os" "os"
"path/filepath"
"code.fbi.h-da.de/danet/gosdn" "code.fbi.h-da.de/danet/gosdn"
...@@ -80,16 +81,22 @@ func init() { ...@@ -80,16 +81,22 @@ func init() {
rootCmd.Flags().StringVar(&csbiOrchestrator, "csbi-orchestrator", "", "csbi orchestrator address") rootCmd.Flags().StringVar(&csbiOrchestrator, "csbi-orchestrator", "", "csbi orchestrator address")
} }
const (
configHome string = "./configs"
configName string = "gosdn"
configType string = "toml"
)
// initConfig reads in config file and ENV variables if set. // initConfig reads in config file and ENV variables if set.
func initConfig() { func initConfig() {
if cfgFile != "" { if cfgFile != "" {
// Use config file from the flag. // Use config file from the flag.
viper.SetConfigFile(cfgFile) viper.SetConfigFile(cfgFile)
} else { } else {
viper.AddConfigPath("./configs") viper.AddConfigPath(configHome)
viper.AddConfigPath("/usr/local/etc/gosdn/") viper.AddConfigPath("/usr/local/etc/gosdn/")
viper.SetConfigType("toml") viper.SetConfigType(configType)
viper.SetConfigName("gosdn") viper.SetConfigName(configName)
} }
viper.AutomaticEnv() // read in environment variables that match viper.AutomaticEnv() // read in environment variables that match
...@@ -97,6 +104,8 @@ func initConfig() { ...@@ -97,6 +104,8 @@ func initConfig() {
// If a config file is found, read it in. // If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil { if err := viper.ReadInConfig(); err == nil {
log.Debug("Using config file:", viper.ConfigFileUsed()) log.Debug("Using config file:", viper.ConfigFileUsed())
} else {
ensureViperConfigFileExists()
} }
if err := viper.BindPFlags(rootCmd.Flags()); err != nil { if err := viper.BindPFlags(rootCmd.Flags()); err != nil {
...@@ -122,3 +131,28 @@ func initConfig() { ...@@ -122,3 +131,28 @@ func initConfig() {
} }
log.WithFields(viper.AllSettings()).Debug("current viper config") log.WithFields(viper.AllSettings()).Debug("current viper config")
} }
func ensureFileSystemStoreExists(pathToStore string) error {
emptyString := []byte("")
err := os.WriteFile(pathToStore, emptyString, 0600)
if err != nil {
return err
}
return nil
}
func ensureViperConfigFileExists() {
// Viper will crash if you call 'WriteConfig()' and the file does
// not exists yet.
// Therefore we handle this case here.
// Inspired by //https://github.com/spf13/viper/issues/430#issuecomment-661945101
configPath := filepath.Join(configHome, configName+"."+configType)
if _, err := os.Stat(configPath); os.IsNotExist(err) {
err := ensureFileSystemStoreExists(configPath)
if err != nil {
panic(err)
}
}
}
package gosdn
import (
"github.com/google/uuid"
"github.com/spf13/viper"
)
// Config represents the nucleus configuration
type Config struct {
BasePndUUID uuid.UUID
BaseSouthBoundType int32
BaseSouthBoundUUID uuid.UUID
}
func getUUIDFromViper(viperKey string) (uuid.UUID, error) {
UUIDAsString := viper.GetString(viperKey)
if UUIDAsString == "" {
newUUID := uuid.New()
viper.Set(viperKey, newUUID.String())
viper.WriteConfig()
return newUUID, nil
}
parsedUUID, err := uuid.Parse(UUIDAsString)
if err != nil {
return uuid.Nil, err
}
return parsedUUID, nil
}
// InitializeConfig loads the configuration
func (c *Config) InitializeConfig() error {
var err error
basePNDUUIDKey := "basePNDUUID"
baseSouthBoundTypeKey := "baseSouthBoundType"
baseSouthBoundUUIDKey := "baseSouthBoundUUID"
basePNDUUID, err := getUUIDFromViper(basePNDUUIDKey)
if err != nil {
return err
}
c.BasePndUUID = basePNDUUID
baseSouthBoundUUID, err := getUUIDFromViper(baseSouthBoundUUIDKey)
if err != nil {
return err
}
c.BaseSouthBoundUUID = baseSouthBoundUUID
c.BaseSouthBoundType = viper.GetInt32("BaseSouthBoundType")
if c.BaseSouthBoundType != 0 {
viper.Set(baseSouthBoundTypeKey, 0)
viper.WriteConfig()
}
return nil
}
package config
import (
"os"
"time"
"github.com/google/uuid"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
const (
defaultTimeOutDuration10minutes = time.Minute * 10
basePNDUUIDKey = "basePNDUUID"
baseSouthBoundTypeKey = "baseSouthBoundType"
baseSouthBoundUUIDKey = "baseSouthBoundUUID"
changeTimeoutKey = "GOSDN_CHANGE_TIMEOUT"
)
// BasePndUUID is an uuid for the base PND
var BasePndUUID uuid.UUID
// BaseSouthBoundType is the type of the base SBI
var BaseSouthBoundType int32
// BaseSouthBoundUUID is an uuid for the base SBI
var BaseSouthBoundUUID uuid.UUID
// ChangeTimeout is the default timeout for a change
var ChangeTimeout time.Duration
// LogLevel ist the default log level
var LogLevel logrus.Level
// Init gets called on module import
func Init() {
InitializeConfig()
}
// InitializeConfig loads the configuration
func InitializeConfig() error {
var err error
basePNDUUIDFromViper, err := getUUIDFromViper(basePNDUUIDKey)
if err != nil {
return err
}
BasePndUUID = basePNDUUIDFromViper
baseSouthBoundUUIDFromViper, err := getUUIDFromViper(baseSouthBoundUUIDKey)
if err != nil {
return err
}
BaseSouthBoundUUID = baseSouthBoundUUIDFromViper
BaseSouthBoundType = viper.GetInt32(baseSouthBoundTypeKey)
if BaseSouthBoundType != 0 {
viper.Set(baseSouthBoundTypeKey, 0)
viper.WriteConfig()
}
err = setChangeTimeout()
if err != nil {
return err
}
setLogLevel()
return nil
}
func getUUIDFromViper(viperKey string) (uuid.UUID, error) {
UUIDAsString := viper.GetString(viperKey)
if UUIDAsString == "" {
newUUID := uuid.New()
viper.Set(viperKey, newUUID.String())
viper.WriteConfig()
return newUUID, nil
}
parsedUUID, err := uuid.Parse(UUIDAsString)
if err != nil {
return uuid.Nil, err
}
return parsedUUID, nil
}
func setChangeTimeout() error {
e := os.Getenv(changeTimeoutKey)
if e != "" {
changeTimeout, err := time.ParseDuration(e)
if err != nil {
log.Fatal(err)
}
ChangeTimeout = changeTimeout
} else {
ChangeTimeout = time.Minute * 10
}
return nil
}
func setLogLevel() {
if os.Getenv("GOSDN_LOG") == "nolog" {
LogLevel = logrus.PanicLevel
} else {
LogLevel = logrus.InfoLevel
}
}
package config
import (
"os"
"testing"
"time"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func TestInit(t *testing.T) {
viper.SetConfigFile("./config_test.toml")
viper.Set("baseSouthBoundType", 0)
viper.Set("baseSouthBoundUUID", "bf8160d4-4659-4a1b-98fd-f409a04111eb")
viper.Set("basePNDUUID", "bf8160d4-4659-4a1b-98fd-f409a04111ec")
viper.Set("GOSDN_CHANGE_TIMEOUT", "10m")
}
func TestUseExistingConfig(t *testing.T) {
TestInit(t)
err := InitializeConfig()
if err != nil {
t.Error(err)
return
}
if BasePndUUID.String() != "bf8160d4-4659-4a1b-98fd-f409a04111ec" {
t.Fatalf("BasePndUUID.String() is not bf8160d4-4659-4a1b-98fd-f409a04111ec. got=%s",
BasePndUUID.String())
}
if BaseSouthBoundUUID.String() != "bf8160d4-4659-4a1b-98fd-f409a04111eb" {
t.Fatalf("BaseSouthBoundUUID.String() is not bf8160d4-4659-4a1b-98fd-f409a04111eb. got=%s",
BaseSouthBoundUUID.String())
}
if BaseSouthBoundType != 0 {
t.Fatalf("BaseSouthBoundType is not 0. got=%d",
BaseSouthBoundType)
}
testChangeTimeout, _ := time.ParseDuration("10m")
defaultChangeTimeout := defaultTimeOutDuration10minutes
if defaultChangeTimeout != testChangeTimeout {
t.Fatalf("ChangeTimeout is not 10ms. got=%v",
ChangeTimeout)
}
if os.Getenv("GOSDN_LOG") == "nolog" {
if LogLevel != logrus.PanicLevel {
t.Fatalf("LogLevel is not %v. got=%v",
logrus.PanicLevel, LogLevel)
}
} else {
if LogLevel != logrus.InfoLevel {
t.Fatalf("LogLevel is not %v. got=%v",
logrus.InfoLevel, LogLevel)
}
}
}
package gosdn
import (
"testing"
"github.com/spf13/viper"
)
func Test_Init(t *testing.T) {
viper.SetConfigFile("./config_test.toml")
viper.Set("baseSouthBoundType", 0)
viper.Set("baseSouthBoundUUID", "bf8160d4-4659-4a1b-98fd-f409a04111eb")
viper.Set("basePNDUUID", "bf8160d4-4659-4a1b-98fd-f409a04111ec")
}
func Test_UseExistingConfig(t *testing.T) {
Test_Init(t)
testConfig := Config{}
err := testConfig.InitializeConfig()
if err != nil {
t.Error(err)
return
}
if testConfig.BasePndUUID.String() != "bf8160d4-4659-4a1b-98fd-f409a04111ec" {
t.Fatalf("testConfig.BasePndUUID.String() is not bf8160d4-4659-4a1b-98fd-f409a04111ec. got=%s",
testConfig.BasePndUUID.String())
}
if testConfig.BaseSouthBoundUUID.String() != "bf8160d4-4659-4a1b-98fd-f409a04111eb" {
t.Fatalf("testConfig.BaseSouthBoundUUID.String() is not bf8160d4-4659-4a1b-98fd-f409a04111eb. got=%s",
testConfig.BaseSouthBoundUUID.String())
}
if testConfig.BaseSouthBoundType != 0 {
t.Fatalf("testConfig.BaseSouthBoundType is not 0. got=%d",
testConfig.BaseSouthBoundType)
}
}
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
cpb "code.fbi.h-da.de/danet/api/go/gosdn/csbi" cpb "code.fbi.h-da.de/danet/api/go/gosdn/csbi"
ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd" ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd"
spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound" spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound"
"code.fbi.h-da.de/danet/gosdn/config"
"code.fbi.h-da.de/danet/gosdn/interfaces/southbound" "code.fbi.h-da.de/danet/gosdn/interfaces/southbound"
nbi "code.fbi.h-da.de/danet/gosdn/northbound/server" nbi "code.fbi.h-da.de/danet/gosdn/northbound/server"
"code.fbi.h-da.de/danet/gosdn/store" "code.fbi.h-da.de/danet/gosdn/store"
...@@ -61,13 +62,12 @@ func initialize() error { ...@@ -61,13 +62,12 @@ func initialize() error {
startHttpServer() startHttpServer()
coreLock.Unlock() coreLock.Unlock()
config := Config{}
err := config.InitializeConfig() err := config.InitializeConfig()
if err != nil { if err != nil {
return err return err
} }
return createSouthboundInterfaces(config) return createSouthboundInterfaces()
} }
func startGrpc() error { func startGrpc() error {
...@@ -90,18 +90,21 @@ func startGrpc() error { ...@@ -90,18 +90,21 @@ func startGrpc() error {
orchestrator := viper.GetString("csbi-orchestrator") orchestrator := viper.GetString("csbi-orchestrator")
conn, err := grpc.Dial(orchestrator, grpc.WithInsecure()) conn, err := grpc.Dial(orchestrator, grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
c.csbiClient = cpb.NewCsbiClient(conn) c.csbiClient = cpb.NewCsbiClient(conn)
return nil return nil
} }
// createSouthboundInterfaces initializes the controller with its supported SBIs // createSouthboundInterfaces initializes the controller with its supported SBIs
func createSouthboundInterfaces(config Config) error { func createSouthboundInterfaces() error {
sbi := nucleus.NewSBI(spb.Type(config.BaseSouthBoundType), config.BaseSouthBoundUUID) sbi := nucleus.NewSBI(spb.Type(config.BaseSouthBoundType), config.BaseSouthBoundUUID)
return createPrincipalNetworkDomain(sbi, config) return createPrincipalNetworkDomain(sbi)
} }
// createPrincipalNetworkDomain initializes the controller with an initial PND // createPrincipalNetworkDomain initializes the controller with an initial PND
func createPrincipalNetworkDomain(s southbound.SouthboundInterface, config Config) error { func createPrincipalNetworkDomain(s southbound.SouthboundInterface) error {
pnd, err := nucleus.NewPND("base", "gosdn base pnd", config.BasePndUUID, s, c.csbiClient, callback) pnd, err := nucleus.NewPND("base", "gosdn base pnd", config.BasePndUUID, s, c.csbiClient, callback)
if err != nil { if err != nil {
return err return err
......
module code.fbi.h-da.de/danet/gosdn module code.fbi.h-da.de/danet/gosdn
go 1.16 go 1.17
require ( require (
code.fbi.h-da.de/danet/api v0.2.5-0.20210722102157-e7e463162450 code.fbi.h-da.de/danet/api v0.2.5-0.20210722102157-e7e463162450
code.fbi.h-da.de/danet/forks/goarista v0.0.0-20210709163519-47ee8958ef40 code.fbi.h-da.de/danet/forks/goarista v0.0.0-20210709163519-47ee8958ef40
code.fbi.h-da.de/danet/forks/google v0.0.0-20210709163519-47ee8958ef40 code.fbi.h-da.de/danet/forks/google v0.0.0-20210709163519-47ee8958ef40
code.fbi.h-da.de/danet/yang-models v0.1.0 code.fbi.h-da.de/danet/yang-models v0.1.0
github.com/docker/docker v20.10.6+incompatible github.com/docker/docker v20.10.11+incompatible
github.com/google/uuid v1.2.0 github.com/google/uuid v1.2.0
github.com/openconfig/gnmi v0.0.0-20210707145734-c69a5df04b53 github.com/openconfig/gnmi v0.0.0-20210914185457-51254b657b7d
github.com/openconfig/goyang v0.2.9 github.com/openconfig/goyang v0.3.1
github.com/openconfig/ygot v0.12.0 github.com/openconfig/ygot v0.12.5
github.com/prometheus/client_golang v1.9.0 github.com/prometheus/client_golang v1.9.0
github.com/sirupsen/logrus v1.8.1 github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3 github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1 github.com/spf13/viper v1.9.0
github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
google.golang.org/grpc v1.39.0 google.golang.org/grpc v1.40.0
google.golang.org/protobuf v1.27.1 google.golang.org/protobuf v1.27.1
) )
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.18.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
gopkg.in/ini.v1 v1.64.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
This diff is collapsed.
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
) )
func Test_httpApi(t *testing.T) { func Test_httpApi(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
request string request string
......
...@@ -4,6 +4,8 @@ import ( ...@@ -4,6 +4,8 @@ import (
"os" "os"
"testing" "testing"
"code.fbi.h-da.de/danet/gosdn/config"
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
...@@ -17,10 +19,8 @@ var cuid uuid.UUID ...@@ -17,10 +19,8 @@ var cuid uuid.UUID
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
log.SetReportCaller(true) log.SetReportCaller(true)
log.SetLevel(config.LogLevel)
if os.Getenv("GOSDN_LOG") == "nolog" {
log.SetLevel(log.PanicLevel)
}
readTestUUIDs() readTestUUIDs()
os.Exit(m.Run()) os.Exit(m.Run())
} }
......
...@@ -350,13 +350,6 @@ func handleSetOnd(pnd networkdomain.NetworkDomain, req []*ppb.SetOnd) (*ppb.SetR ...@@ -350,13 +350,6 @@ func handleSetOnd(pnd networkdomain.NetworkDomain, req []*ppb.SetOnd) (*ppb.SetR
}, nil }, nil
} }
func handleSetSbi(pnd networkdomain.NetworkDomain, req []*ppb.SetSbi) (*ppb.SetResponse, error) {
return &ppb.SetResponse{
Timestamp: time.Now().UnixNano(),
Status: ppb.SetResponse_ERROR,
}, nil
}
func handleSetChange(pnd networkdomain.NetworkDomain, req []*ppb.SetChange) (*ppb.SetResponse, error) { func handleSetChange(pnd networkdomain.NetworkDomain, req []*ppb.SetChange) (*ppb.SetResponse, error) {
for _, r := range req { for _, r := range req {
cuid, err := uuid.Parse(r.Cuid) cuid, err := uuid.Parse(r.Cuid)
......
...@@ -132,7 +132,6 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, < ...@@ -132,7 +132,6 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
errChan <- err errChan <- err
} }
errChan <- fmt.Errorf("change %v timed out", ch.cuid) errChan <- fmt.Errorf("change %v timed out", ch.cuid)
break
case s := <-stateIn: case s := <-stateIn:
switch s { switch s {
case ppb.Change_COMMITTED: case ppb.Change_COMMITTED:
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"time" "time"
ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd" ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd"
"code.fbi.h-da.de/danet/gosdn/config"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/openconfig/ygot/exampleoc" "github.com/openconfig/ygot/exampleoc"
"github.com/openconfig/ygot/ygot" "github.com/openconfig/ygot/ygot"
...@@ -61,7 +62,7 @@ func TestChange_CommitRollback(t *testing.T) { ...@@ -61,7 +62,7 @@ func TestChange_CommitRollback(t *testing.T) {
if err := c.Commit(); (err != nil) != wantErr { if err := c.Commit(); (err != nil) != wantErr {
t.Errorf("Commit() error = %v, wantErr %v", err, wantErr) t.Errorf("Commit() error = %v, wantErr %v", err, wantErr)
} }
time.Sleep(time.Millisecond * 200) time.Sleep(config.ChangeTimeout)
}() }()
got := <-callback got := <-callback
if !reflect.DeepEqual(got, want) { if !reflect.DeepEqual(got, want) {
...@@ -103,7 +104,7 @@ func TestChange_CommitRollbackError(t *testing.T) { ...@@ -103,7 +104,7 @@ func TestChange_CommitRollbackError(t *testing.T) {
if err := c.Commit(); (err != nil) != wantErr { if err := c.Commit(); (err != nil) != wantErr {
t.Errorf("Commit() error = %v, wantErr %v", err, wantErr) t.Errorf("Commit() error = %v, wantErr %v", err, wantErr)
} }
time.Sleep(time.Millisecond * 200) time.Sleep(config.ChangeTimeout)
}() }()
got := <-c.errChan got := <-c.errChan
if !reflect.DeepEqual(got, want) { if !reflect.DeepEqual(got, want) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment