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
cfe1c094
Commit
cfe1c094
authored
2 years ago
by
Neil-Jocelyn Schark
Committed by
Fabian Seidl
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix Update for devices does not work as expected for file store system
See merge request
!325
parent
ef0cb25d
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!325
Fix Update for devices does not work as expected for file store system
,
!264
WIP: Develop
Pipeline
#103429
failed
2 years ago
Stage: build
Stage: test
Stage: analyze
Stage: integration-test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controller/nucleus/deviceFilesystemStore.go
+3
-2
3 additions, 2 deletions
controller/nucleus/deviceFilesystemStore.go
controller/nucleus/deviceFilesystemStore_test.go
+46
-3
46 additions, 3 deletions
controller/nucleus/deviceFilesystemStore_test.go
with
49 additions
and
5 deletions
controller/nucleus/deviceFilesystemStore.go
+
3
−
2
View file @
cfe1c094
...
...
@@ -125,7 +125,7 @@ func (s *FilesystemDeviceStore) Update(deviceToUpdate device.Device) error {
s
.
fileMutex
.
Lock
()
defer
s
.
fileMutex
.
Unlock
()
var
loadedDevice
device
.
LoadedDevice
loaded
DeviceToUpdate
,
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
]
=
loadedDevice
ToUpdate
err
=
s
.
writeAllDevicesToFile
(
devices
)
if
err
!=
nil
{
return
err
}
return
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
controller/nucleus/deviceFilesystemStore_test.go
+
46
−
3
View file @
cfe1c094
...
...
@@ -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
(
"Get
All
() = %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
)
}
}
...
...
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