Skip to content
Snippets Groups Projects
Commit a9dfa0f4 authored by André Sterba's avatar André Sterba
Browse files

Merge branch 'develop' into istaester/init-topology

parents fb85fc23 cb7ac689
Branches
No related tags found
5 merge requests!376Add additional example application hostname-checker,!349Northbound refactoring to implement NIB concept for devices,!343Add basic application framework and example application to show interaction between events an NBI,!339Create basic venv-manager for use with arista,!324Provide prototype implementation for topology handling
This commit is part of merge request !343. Comments created here will be created in the context of that merge request.
# tooling
build-tools/
**/build-tools/
artifacts/
# containerlab
......@@ -9,6 +9,9 @@ clab-gosdn_csbi_arista_base/
# non vimmers
.vscode/
# MacOS
.DS_Store
# test artifacts
coverage.out
report.xml
......@@ -18,10 +21,22 @@ controller/gosdn
cli/gosdnc
csbi/resources/csbi
# testing and configs
# controller
controller/configs/testing-gosdn.toml
controller/configs/development-gosdn.toml
controller/configs/containerlab-gosdn.toml
**/stores_testing
config/.gosdnc.toml
controller/config/*_test.toml
controller/configs/ci-testing-gosdn.toml
controller/stores_testing
controller/stores/**
controller/plugins
controller/config/.gosdnc.toml
controller/debug.test
controller/api/api_test.toml
controller/report.xml
controller/test/plugin/**/*.so
controller/nucleus/util/proto/*_test
controller/api/stores_testing/**
controller/northbound/server/stores_testing/**
controller/nucleus/stores_testing/**
controller/nucleus/**/gostructs.go
.vscode/
.vscode/launch.json
.DS_Store
documentation/design-documentation/
documentation/design/*.pdf
*.aux
*.bbl
*.blg
*.lof
*.log
*.out
.idea/gosdn.iml
.idea/modules.xml
.idea/vcs.xml
.idea/workspace.xml
restconf/bin/bin
test/.terraform.local/
configs/gosdn.toml
api/api_test.toml
debug.test
# developer tools
build-tools/
# test files
report.xml
test/plugin/**/*.so
nucleus/util/proto/*_test
# persistent data
**/stores/**
plugins
documentation/figures/~$goSDN-Net-Environment.drawio.dtmp
......@@ -41,7 +41,7 @@ controller-test: install-tools
ENVIRONMENT=testing ./$(TOOLS_DIR)/gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun
ci-unit-test: ci-install-tools
ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -coverprofile=coverage.out
ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -coverprofile=coverage.out -timeout 30m
ci-controller-test: ci-install-tools
ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun -coverprofile=coverage.out
......
basepnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
basesouthboundtype = 1
basesouthbounduuid = "bf8160d4-4659-4a1b-98fd-f409a04111eb"
databaseconnection = "test@test:test"
gosdn_change_timeout = "10m"
basepnduuid = "e3a04432-a5de-4c6a-9d06-cacc0a349b77"
basesouthboundtype = 1
basesouthbounduuid = "94f48ae8-6028-4da0-b495-4c554f886366"
......@@ -7,6 +7,7 @@ import (
"testing"
"time"
"code.fbi.h-da.de/danet/gosdn/controller/config"
"github.com/spf13/viper"
)
......@@ -16,7 +17,21 @@ const (
configType string = "toml"
)
func TestInit(t *testing.T) {
viper.SetConfigFile("./configs/ci-testing-gosdn.toml")
viper.Set("basePNDUUID", "3e58372e-b53d-41d8-a06e-4131810c8e70")
viper.Set("baseSouthBoundType", 1)
viper.Set("baseSouthBoundUUID", "73b30205-7ad9-48fb-8251-0dbef649ce01")
}
func TestRun(t *testing.T) {
TestInit(t)
err := config.InitializeConfig()
if err != nil {
t.Error(err)
return
}
type args struct {
request string
}
......
......@@ -125,7 +125,7 @@ func (s *FilesystemDeviceStore) Update(deviceToUpdate device.Device) error {
s.fileMutex.Lock()
defer s.fileMutex.Unlock()
var loadedDevice device.LoadedDevice
loadedDeviceToUpdate, err := store.TransformObjectToLoadedObject[device.Device, device.LoadedDevice](deviceToUpdate)
devices, err := s.readAllDevicesFromFile()
if err != nil {
......@@ -134,11 +134,12 @@ func (s *FilesystemDeviceStore) Update(deviceToUpdate device.Device) error {
for i, device := range devices {
if device.ID == deviceToUpdate.ID().String() {
devices[i] = loadedDevice
devices[i] = loadedDeviceToUpdate
err = s.writeAllDevicesToFile(devices)
if err != nil {
return err
}
return nil
}
}
......
......@@ -54,11 +54,12 @@ func TestAddDevice(t *testing.T) {
pndID, _ := uuid.Parse("b4016412-eec5-45a1-aa29-f59915357bad")
deviceID, _ := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
sbiID1, _ := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
trop := returnBasicTransportOption()
sbi1, _ := NewSBI(spb.Type_TYPE_OPENCONFIG, sbiID1)
deviceStore := NewDeviceStore(pndID)
device, _ := NewDevice("testdevice", deviceID, nil, sbi1)
device, _ := NewDevice("testdevice", deviceID, &trop, sbi1)
err := deviceStore.Add(device)
if err != nil {
......@@ -160,10 +161,52 @@ func TestGetDevice(t *testing.T) {
}
if returnDevice.ID != inputDevices[1].ID().String() {
t.Errorf("GetAll() = %v, want %v", returnDevice.ID, inputDevices[1].ID().String())
t.Errorf("Get() = %v, want %v", returnDevice.ID, inputDevices[1].ID().String())
}
if returnDevice.Name != inputDevices[1].Name() {
t.Errorf("GetAll() = %v, want %v", returnDevice.Name, inputDevices[1].Name())
t.Errorf("Get() = %v, want %v", returnDevice.Name, inputDevices[1].Name())
}
}
func TestUpdateDevice(t *testing.T) {
ensureDeviceFilesForTestAreRemoved()
defer ensureDeviceFilesForTestAreRemoved()
pndID, _ := uuid.Parse("b4016412-eec5-45a1-aa29-f59915357bad")
deviceID, _ := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
sbiID1, _ := uuid.Parse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
trop := returnBasicTransportOption()
updatedDeviceName := "testdevice2"
sbi1, _ := NewSBI(spb.Type_TYPE_OPENCONFIG, sbiID1)
deviceStore := NewDeviceStore(pndID)
device, _ := NewDevice("testdevice", deviceID, &trop, sbi1)
err := deviceStore.Add(device)
if err != nil {
t.Error(err)
}
device, _ = NewDevice(updatedDeviceName, deviceID, &trop, sbi1)
err = deviceStore.Update(device)
if err != nil {
t.Error(err)
}
returnDevice, err := deviceStore.Get(store.Query{ID: deviceID, Name: updatedDeviceName})
if err != nil {
t.Error(err)
}
if returnDevice.ID != deviceID.String() {
t.Errorf("Get() = %v, want %v", returnDevice.ID, deviceID.String())
}
if returnDevice.Name != updatedDeviceName {
t.Errorf("Get() = %v, want %v", returnDevice.Name, updatedDeviceName)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment