Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
59e00686
Commit
59e00686
authored
2 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
Linter pleasing
parent
f54028e1
No related branches found
No related tags found
1 merge request
!401
Change the current gosdn plugin implementation from Go's internal plugin system to hashicorp's go-plugins
Pipeline
#135497
failed
2 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
controller/nucleus/initialise_test.go
+33
-36
33 additions, 36 deletions
controller/nucleus/initialise_test.go
with
33 additions
and
36 deletions
controller/nucleus/initialise_test.go
+
33
−
36
View file @
59e00686
...
@@ -2,11 +2,9 @@ package nucleus
...
@@ -2,11 +2,9 @@ package nucleus
import
(
import
(
"context"
"context"
"io/fs"
"os"
"os"
"path/filepath"
"path/filepath"
"testing"
"testing"
"time"
eventservice
"code.fbi.h-da.de/danet/gosdn/controller/eventService"
eventservice
"code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement"
...
@@ -188,7 +186,6 @@ func newPnd() (*pndImplementation, error) {
...
@@ -188,7 +186,6 @@ func newPnd() (*pndImplementation, error) {
err
:=
pluginService
.
Add
(
mockPlugin
)
err
:=
pluginService
.
Add
(
mockPlugin
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
deviceService
:=
NewNetworkElementService
(
deviceService
:=
NewNetworkElementService
(
deviceStore
,
deviceStore
,
...
@@ -208,42 +205,42 @@ func newPnd() (*pndImplementation, error) {
...
@@ -208,42 +205,42 @@ func newPnd() (*pndImplementation, error) {
// removeTestGoStructs removes the plugins created during running the test in the current directory based on their name consisting of a uuid
// removeTestGoStructs removes the plugins created during running the test in the current directory based on their name consisting of a uuid
// and the time since they`ve been created.
// and the time since they`ve been created.
func
removeTestGoStructs
()
{
//
func removeTestGoStructs() {
currentDirectory
:=
"./"
//
currentDirectory := "./"
// pattern to match plugin uuid used as dir name
//
// pattern to match plugin uuid used as dir name
pattern
:=
"*-*-*-*-*"
//
pattern := "*-*-*-*-*"
// max time passed since creation in seconds
//
// max time passed since creation in seconds
var
seconds
int64
=
10
//
var seconds int64 = 10
//
// get all available files
//
// get all available files
dirs
,
err
:=
os
.
ReadDir
(
currentDirectory
)
//
dirs, err := os.ReadDir(currentDirectory)
if
err
!=
nil
{
//
if err != nil {
log
.
Info
(
err
)
//
log.Info(err)
}
//
}
//
for
_
,
dir
:=
range
dirs
{
//
for _, dir := range dirs {
if
!
dir
.
IsDir
()
{
//
if !dir.IsDir() {
continue
//
continue
}
else
if
found
,
_
:=
filepath
.
Match
(
pattern
,
dir
.
Name
());
found
&&
isDirYoungerThanSeconds
(
dir
.
Name
(),
seconds
)
{
//
} else if found, _ := filepath.Match(pattern, dir.Name()); found && isDirYoungerThanSeconds(dir.Name(), seconds) {
log
.
Infof
(
"removing: %v"
,
dir
.
Name
())
//
log.Infof("removing: %v", dir.Name())
err
=
os
.
RemoveAll
(
dir
.
Name
())
//
err = os.RemoveAll(dir.Name())
if
err
!=
nil
{
//
if err != nil {
log
.
Info
(
err
)
//
log.Info(err)
}
//
}
}
//
}
}
//
}
}
//
}
// isDirYoungerThanSeconds returns true if the provided dir is younger than the given amount in seconds
// isDirYoungerThanSeconds returns true if the provided dir is younger than the given amount in seconds
// and therefore was created as part of the test suite.
// and therefore was created as part of the test suite.
func
isDirYoungerThanSeconds
(
dirName
string
,
seconds
int64
)
bool
{
//
func isDirYoungerThanSeconds(dirName string, seconds int64) bool {
fileInfo
,
err
:=
os
.
Stat
(
dirName
)
//
fileInfo, err := os.Stat(dirName)
if
err
!=
nil
{
//
if err != nil {
log
.
Info
(
err
)
//
log.Info(err)
}
//
}
//
return
fs
.
FileInfo
.
ModTime
(
fileInfo
)
.
Unix
()
>
(
time
.
Now
()
.
Unix
()
-
seconds
)
//
return fs.FileInfo.ModTime(fileInfo).Unix() > (time.Now().Unix() - seconds)
}
//
}
func
ensureStoreFileForTestsIsRemoved
(
storeName
string
)
{
func
ensureStoreFileForTestsIsRemoved
(
storeName
string
)
{
if
err
:=
store
.
EnsureFilesystemStorePathExists
(
storeName
);
err
!=
nil
{
if
err
:=
store
.
EnsureFilesystemStorePathExists
(
storeName
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment