Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gNMI Target
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
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
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
gNMI Target
Commits
34f4dcf4
Commit
34f4dcf4
authored
1 month ago
by
S.H.
Browse files
Options
Downloads
Patches
Plain Diff
Add benchmark measurements
parent
af732489
No related branches found
No related tags found
No related merge requests found
Pipeline
#270498
failed
1 month ago
Stage: build
Stage: analyze
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
benchmark/benchmark.go
+51
-0
51 additions, 0 deletions
benchmark/benchmark.go
internal/gnmiserver/server.go
+8
-2
8 additions, 2 deletions
internal/gnmiserver/server.go
with
59 additions
and
2 deletions
benchmark/benchmark.go
0 → 100644
+
51
−
0
View file @
34f4dcf4
package
rtdt_benchmark
import
(
"encoding/json"
"fmt"
"os"
"time"
)
type
Rtdt_Benchmark
struct
{
MneGnmiRcv
time
.
Time
MneGnmiSend
time
.
Time
}
var
CurrentBenchmark
Rtdt_Benchmark
func
AppendToJsonFile
(
r
*
Rtdt_Benchmark
)
{
var
benchmarks
[]
Rtdt_Benchmark
if
_
,
err
:=
os
.
Stat
(
"/etc/gnmi-target/mne_share/measure_mne.json"
);
err
==
nil
{
data
,
err
:=
os
.
ReadFile
(
"/etc/gnmi-target/mne_share/measure_mne.json"
)
if
err
!=
nil
{
fmt
.
Println
(
"Error reading file:"
,
err
)
return
}
if
len
(
data
)
>
0
{
err
=
json
.
Unmarshal
(
data
,
&
benchmarks
)
if
err
!=
nil
{
fmt
.
Println
(
"Error unmarshaling JSON:"
,
err
)
return
}
}
}
else
if
!
os
.
IsNotExist
(
err
)
{
fmt
.
Println
(
"Error checking file status:"
,
err
)
return
}
// Append the new benchmark
benchmarks
=
append
(
benchmarks
,
*
r
)
// Marshal and write back to file
outData
,
err
:=
json
.
MarshalIndent
(
benchmarks
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"Error marshaling JSON:"
,
err
)
return
}
err
=
os
.
WriteFile
(
"/etc/gnmi-target/mne_share/measure_mne.json"
,
outData
,
0644
)
if
err
!=
nil
{
fmt
.
Println
(
"Error writing to file:"
,
err
)
}
}
This diff is collapsed.
Click to expand it.
internal/gnmiserver/server.go
+
8
−
2
View file @
34f4dcf4
...
@@ -37,6 +37,7 @@ import (
...
@@ -37,6 +37,7 @@ import (
"github.com/openconfig/ygot/ytypes"
"github.com/openconfig/ygot/ytypes"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/proto"
rtdt_benchmark
"code.fbi.h-da.de/danet/gnmi-target/benchmark"
"code.fbi.h-da.de/danet/gnmi-target/handler"
"code.fbi.h-da.de/danet/gnmi-target/handler"
not
"code.fbi.h-da.de/danet/gnmi-target/internal/notifications"
not
"code.fbi.h-da.de/danet/gnmi-target/internal/notifications"
dpb
"github.com/golang/protobuf/protoc-gen-go/descriptor"
dpb
"github.com/golang/protobuf/protoc-gen-go/descriptor"
...
@@ -145,7 +146,7 @@ func (s *Server) callback(newConfig ygot.ValidatedGoStruct, existingConf ygot.Va
...
@@ -145,7 +146,7 @@ func (s *Server) callback(newConfig ygot.ValidatedGoStruct, existingConf ygot.Va
// TODO: This will be moved.
// TODO: This will be moved.
func
(
s
*
Server
)
PublishNotificationsToSubscribers
(
notifications
[]
*
gnmi
.
Notification
)
error
{
func
(
s
*
Server
)
PublishNotificationsToSubscribers
(
notifications
[]
*
gnmi
.
Notification
)
error
{
fmt
.
Println
(
"In PublishNotificationsToSubscribers()"
)
fmt
.
Println
(
"In PublishNotificationsToSubscribers()"
)
fmt
.
Println
(
"Notifications:"
,
notifications
)
fmt
.
Println
(
"Notifications:"
,
notifications
)
for
_
,
specificDiff
:=
range
notifications
{
for
_
,
specificDiff
:=
range
notifications
{
// First for gnmi Updates
// First for gnmi Updates
updates
:=
specificDiff
.
GetUpdate
()
updates
:=
specificDiff
.
GetUpdate
()
...
@@ -700,6 +701,8 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse,
...
@@ -700,6 +701,8 @@ func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse,
// Set implements the Set RPC in gNMI spec.
// Set implements the Set RPC in gNMI spec.
func
(
s
*
Server
)
Set
(
ctx
context
.
Context
,
req
*
pb
.
SetRequest
)
(
*
pb
.
SetResponse
,
error
)
{
func
(
s
*
Server
)
Set
(
ctx
context
.
Context
,
req
*
pb
.
SetRequest
)
(
*
pb
.
SetResponse
,
error
)
{
rtdt_benchmark
.
CurrentBenchmark
=
rtdt_benchmark
.
Rtdt_Benchmark
{}
rtdt_benchmark
.
CurrentBenchmark
.
MneGnmiRcv
=
time
.
Now
()
s
.
config
.
Lock
()
s
.
config
.
Lock
()
defer
s
.
config
.
Unlock
()
defer
s
.
config
.
Unlock
()
...
@@ -770,6 +773,7 @@ func (s *Server) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse,
...
@@ -770,6 +773,7 @@ func (s *Server) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse,
s
.
config
.
Data
=
rootStruct
s
.
config
.
Data
=
rootStruct
// notify subscribers about the changes
// notify subscribers about the changes
fmt
.
Println
(
"------------ In Set(): diff is:"
,
diff
)
err
=
s
.
PublishNotificationsToSubscribers
(
diff
)
err
=
s
.
PublishNotificationsToSubscribers
(
diff
)
if
err
!=
nil
{
if
err
!=
nil
{
msg
:=
fmt
.
Sprintf
(
"error while publishing config changes to subscribers: %v"
,
err
)
msg
:=
fmt
.
Sprintf
(
"error while publishing config changes to subscribers: %v"
,
err
)
...
@@ -777,10 +781,12 @@ func (s *Server) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse,
...
@@ -777,10 +781,12 @@ func (s *Server) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse,
return
nil
,
status
.
Error
(
codes
.
Internal
,
msg
)
return
nil
,
status
.
Error
(
codes
.
Internal
,
msg
)
}
}
rtdt_benchmark
.
CurrentBenchmark
.
MneGnmiSend
=
time
.
Now
()
rtdt_benchmark
.
AppendToJsonFile
(
&
rtdt_benchmark
.
CurrentBenchmark
)
return
&
pb
.
SetResponse
{
return
&
pb
.
SetResponse
{
Prefix
:
req
.
GetPrefix
(),
Prefix
:
req
.
GetPrefix
(),
Response
:
results
,
Response
:
results
,
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Timestamp
:
rtdt_benchmark
.
CurrentBenchmark
.
MneGnmiSend
.
UnixNano
(),
},
nil
},
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