Skip to content
Snippets Groups Projects
Commit 850e9bf5 authored by S.H.'s avatar S.H.
Browse files

Refine benchmark mechanism

parent 0cf0389e
Branches
No related tags found
No related merge requests found
Pipeline #270206 failed
...@@ -7,17 +7,22 @@ import ( ...@@ -7,17 +7,22 @@ import (
"time" "time"
) )
// Benchmarking struct for testing propagation delay to twin
type Benchmark0 struct { type Benchmark0 struct {
StartTimeRealnet time.Time // Callback entered StartTimeRealnet time.Time // Callback entered
RmSendPathRequest time.Time // rtdt-manager sends change request
//CtlRcvPathRequest --> DO IN CONTROLLER: controller receives request
CtlSendPathResponse time.Time // time controller sends package back after processing, controller sends timestamp
RmReceivePathResponse time.Time // the change request is received in controller
SendChangeRequest time.Time // realnet sends change request RmSendCommitRequest time.Time // the commit is sent from realnet
ReceiveChangeRequest time.Time // the change reuest received in twin // CtlRcvCommitRequest --> IN CONTROLLER: ctrler receives the commit
ReceiveChangeResponse time.Time // the change request is received in twin // CtlSendGnmi --> IN CONTROLLER: apply change start
// GnmiReceive --> IN gnmi-target: receives apply change
SendCommitRequest time.Time // the commit is sent from realnet // GnmiSend --> IN gnmi-target: finished applying change
ReceiveCommitRequest time.Time // the commit is received in twin // CtlRcvGnmi --> IN CONTROLLER: received apply change
ReceiveCommitResponse time.Time // the response of the twin received in realnet CtlSendCommitResponse time.Time // IN CONTROLLER: sending back to rtdt-manager
//EndTime time.Time RmReceiveCommitResponse time.Time // commit response of the twin received in rtdt-manager
PropagationDelay time.Duration // calculated delay PropagationDelay time.Duration // calculated delay
} }
...@@ -25,7 +30,7 @@ type Benchmark0 struct { ...@@ -25,7 +30,7 @@ type Benchmark0 struct {
var Current Benchmark0 var Current Benchmark0
func (b *Benchmark0) GetDurations() { func (b *Benchmark0) GetDurations() {
startToSend := Diff(b.StartTimeRealnet, b.SendChangeRequest).Microseconds() startToSend := Diff(b.StartTimeRealnet, b.RmSendPathRequest).Microseconds()
fmt.Println("Start to Send:", startToSend) fmt.Println("Start to Send:", startToSend)
} }
...@@ -35,8 +40,8 @@ func Diff(start, end time.Time) time.Duration { ...@@ -35,8 +40,8 @@ func Diff(start, end time.Time) time.Duration {
} }
func (b *Benchmark0) Print() { func (b *Benchmark0) Print() {
fmt.Println("SendChangeRequest to ReceiveChangeRequest in us:", b.ReceiveChangeRequest.Sub(b.SendChangeRequest).Microseconds()) fmt.Println("SendChangeRequest to ReceiveChangeRequest in us:", b.CtlSendPathResponse.Sub(b.RmSendPathRequest).Microseconds())
fmt.Println("SendChangeRequest to ReceiveChangeResponse in us:", b.ReceiveChangeResponse.Sub(b.SendChangeRequest).Microseconds()) fmt.Println("ReceiveChangeRequest to ReceiveChangeResponse in us:", b.RmReceivePathResponse.Sub(b.CtlSendPathResponse).Microseconds())
fmt.Println("PropagationDelay in ms:", b.PropagationDelay.Milliseconds()) fmt.Println("PropagationDelay in ms:", b.PropagationDelay.Milliseconds())
} }
......
...@@ -216,14 +216,6 @@ func DeriveConfig(clabConfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, c ...@@ -216,14 +216,6 @@ func DeriveConfig(clabConfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, c
splitIPv4 := strings.Split(node.MgmtIPv4, ".") splitIPv4 := strings.Split(node.MgmtIPv4, ".")
splitIPv4[0], splitIPv4[1], splitIPv4[2] = subnetParts[0], subnetParts[1], subnetParts[2] splitIPv4[0], splitIPv4[1], splitIPv4[2] = subnetParts[0], subnetParts[1], subnetParts[2]
node.MgmtIPv4 = strings.Join(splitIPv4, ".") node.MgmtIPv4 = strings.Join(splitIPv4, ".")
// if strings.HasPrefix(name, "gosdn") {
// pluginRegistryAddress := fmt.Sprintf("clab-%s-plugin-registry:55057", clabConfig.Name)
// dbAddress := fmt.Sprintf("mongodb://root:example@clab-%s-mongodb:27017", clabConfig.Name)
// node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress)
// }
// Ports: host side needs to be incremented or there will be conflicts
// for now just use 5 as increment
for i, portBinding := range node.Ports { for i, portBinding := range node.Ports {
parts := strings.Split(portBinding, ":") parts := strings.Split(portBinding, ":")
if len(parts) == 3 { if len(parts) == 3 {
......
...@@ -114,6 +114,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon ...@@ -114,6 +114,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon
// newName := fmt.Sprintf("%s-%s", nodename, name) // newName := fmt.Sprintf("%s-%s", nodename, name)
if strings.HasPrefix(nodename, "gosdn") { if strings.HasPrefix(nodename, "gosdn") {
node.Binds = []string{"../../../../artifacts/ssl/gosdn:/app/ssl"} node.Binds = []string{"../../../../artifacts/ssl/gosdn:/app/ssl"}
if name != "realnet" {
node.Binds = append(node.Binds, "gosdn_share:/app/gosdn_share")
}
pluginRegistryAddress := fmt.Sprintf("%s:55057", pluginRegistryAddress) pluginRegistryAddress := fmt.Sprintf("%s:55057", pluginRegistryAddress)
dbAddress := fmt.Sprintf("mongodb://root:example@%s:27017", mongodbAddress) dbAddress := fmt.Sprintf("mongodb://root:example@%s:27017", mongodbAddress)
node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress) node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress)
...@@ -136,6 +139,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon ...@@ -136,6 +139,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon
fmt.Printf("ProduceClabConfig(): Warning: No MNE entry for node: %s\n", node.Name) fmt.Printf("ProduceClabConfig(): Warning: No MNE entry for node: %s\n", node.Name)
} }
if node.Name == "gnmi-target-switch0-test-twin" {
clabNode.Binds = append(clabNode.Binds, "mne_share:/etc/gnmi-target/mne_share") // place tests here
}
clabConfig.Topology.Nodes[node.Name] = *clabNode clabConfig.Topology.Nodes[node.Name] = *clabNode
} }
for _, link := range sdnConfig.Links { for _, link := range sdnConfig.Links {
...@@ -271,7 +277,7 @@ func (r *RtdtManager) RunBenchmark0(numTests int64) error { ...@@ -271,7 +277,7 @@ func (r *RtdtManager) RunBenchmark0(numTests int64) error {
if err != nil { if err != nil {
fmt.Printf("Encountered error: %v\n", err) fmt.Printf("Encountered error: %v\n", err)
} }
time.Sleep(time.Second * 1)
} }
r.benchmark0 = false r.benchmark0 = false
return nil return nil
...@@ -490,8 +496,8 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { ...@@ -490,8 +496,8 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) {
return return
} }
if r.benchmark0 { if r.benchmark0 {
benchmark.Current = benchmark.Benchmark0{} benchmark.Current = benchmark.Benchmark0{}
benchmark.Current.StartTimeRealnet = time.Now() benchmark.Current.StartTimeRealnet = time.Now()
} }
fmt.Println("--------------------------------") fmt.Println("--------------------------------")
fmt.Println("---------- MNE EVENT -----------") fmt.Println("---------- MNE EVENT -----------")
...@@ -499,12 +505,12 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { ...@@ -499,12 +505,12 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) {
fmt.Println("Event Type: ", event.Type) fmt.Println("Event Type: ", event.Type)
fmt.Println("PathsAndValuesMap: ", event.PathsAndValuesMap) fmt.Println("PathsAndValuesMap: ", event.PathsAndValuesMap)
fmt.Println("EntityID", event.EntityID) fmt.Println("EntityID", event.EntityID)
prefix := "/interfaces/interface[name=" // prefix := "/interfaces/interface[name="
prefixHostname := "/system/config/hostname" // prefixHostname := "/system/config/hostname"
//realnetClabData := r.realnet.GetClabData() //realnetClabData := r.realnet.GetClabData()
// for i, node := range realnetClabData.Topology.Nodes { // for i, node := range realnetClabData.Topology.Nodes {
// } // // }
suffixMTU := "]/config/mtu" // suffixMTU := "]/config/mtu"
// Select a twin // Select a twin
//TODO: This is where some selection process should happen to select the right twin based on the event //TODO: This is where some selection process should happen to select the right twin based on the event
...@@ -524,8 +530,8 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { ...@@ -524,8 +530,8 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) {
// First get hostname of realnet node // First get hostname of realnet node
realnetNode := r.realnet.GetSdnConfig().GetNodeByUUID(event.EntityID.String()) realnetNode := r.realnet.GetSdnConfig().GetNodeByUUID(event.EntityID.String())
// LINK UP/DOWN // LINK UP/DOWN
interfaceRegex := regexp.MustCompile(`/interfaces/interface\[name=([^]]+)]/state/oper-status`) //interfaceRegex := regexp.MustCompile(`/interfaces/interface\[name=([^]]+)]/state/oper-status`)
regexMatch := interfaceRegex.FindStringSubmatch(path) // regexMatch := interfaceRegex.FindStringSubmatch(path)
// Get the ID of parallel mne in twin network // Get the ID of parallel mne in twin network
// parallel nodes are nodes that have the same name in twin and realnet // parallel nodes are nodes that have the same name in twin and realnet
...@@ -536,45 +542,47 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { ...@@ -536,45 +542,47 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) {
} }
} }
var err error //var err error
twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0)
// Some explicitly supported paths // Some explicitly supported paths
// MTU Change // MTU Change
if strings.HasPrefix(path, prefix) && strings.HasSuffix(path, suffixMTU) { // if strings.HasPrefix(path, prefix) && strings.HasSuffix(path, suffixMTU) {
fmt.Println("--- CHANGE MTU TRIGGERED ---") // fmt.Println("--- CHANGE MTU TRIGGERED ---")
fmt.Println("Value of new MTU: ", value) // fmt.Println("Value of new MTU: ", value)
twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) // twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0)
// Set Hostname // // Set Hostname
} else if strings.HasPrefix(path, prefixHostname) { // } else if strings.HasPrefix(path, prefixHostname) {
// Hostname change // // Hostname change
fmt.Println("--- CHANGE HOSTNAME TRIGGERED ---") // fmt.Println("--- CHANGE HOSTNAME TRIGGERED ---")
for _, twin := range r.rtdt_twins { // for _, twin := range r.rtdt_twins {
if twin == nil { // if twin == nil {
fmt.Println("Encountered nil twin, skipping") // fmt.Println("Encountered nil twin, skipping")
continue // continue
} // }
fmt.Println("ENTERING SETGNMIPATH, value: ", value, "path:", path) // fmt.Println("ENTERING SETGNMIPATH, value: ", value, "path:", path)
err = twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) // err = twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0)
if err != nil { // if err != nil {
fmt.Println("Callback failed:", err) // fmt.Println("Callback failed:", err)
return // return
} // }
} // }
// Interface UP/Down // // Interface UP/Down
} else if regexMatch != nil && len(r.rtdt_twins) > 0 { // } else if regexMatch != nil && len(r.rtdt_twins) > 0 {
//
fmt.Println("Setting interface", regexMatch[1], "UP/DOWN") // fmt.Println("Setting interface", regexMatch[1], "UP/DOWN")
fmt.Printf("match: %v\n", regexMatch) // fmt.Printf("match: %v\n", regexMatch)
path := "/interfaces/interface[name=" + regexMatch[1] + "]/config/enabled" // path := "/interfaces/interface[name=" + regexMatch[1] + "]/config/enabled"
if value == "DOWN" { // if value == "DOWN" {
value = "false" // value = "false"
} else { // } else {
value = "true" // value = "true"
} // }
twin.SetGnmiPath(path, value, twinEntityID, false) // twin.SetGnmiPath(path, value, twinEntityID, false)
// CATCHALL // // CATCHALL
} else { // } else {
twin.SetGnmiPath(path, value, twinEntityID, false) // twin.SetGnmiPath(path, value, twinEntityID, false)
} // }
} }
twin.SyncBack = true twin.SyncBack = true
} }
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
gnmitargetygot "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/yang" gnmitargetygot "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/yang"
uuid "github.com/google/uuid" uuid "github.com/google/uuid"
gnmi "github.com/openconfig/gnmi/proto/gnmi" gnmi "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/ygot" "github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ytypes" "github.com/openconfig/ygot/ytypes"
"google.golang.org/grpc" "google.golang.org/grpc"
...@@ -48,6 +49,7 @@ type VEnv struct { ...@@ -48,6 +49,7 @@ type VEnv struct {
// This is an ugly way of temporarily ignoring events to avoid e.g. infinite sync loops: // This is an ugly way of temporarily ignoring events to avoid e.g. infinite sync loops:
SyncBack bool SyncBack bool
EventSystemStarted bool EventSystemStarted bool
RootSchema *yang.Entry
} }
// Accepts a yaml filename to deploy a container lab environment // Accepts a yaml filename to deploy a container lab environment
...@@ -112,6 +114,8 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi ...@@ -112,6 +114,8 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi
fmt.Printf("[%s] - Couldn't retrieve PND, retrying in 2 seconds..\n", name) fmt.Printf("[%s] - Couldn't retrieve PND, retrying in 2 seconds..\n", name)
time.Sleep(time.Second * 2) time.Sleep(time.Second * 2)
} }
// Put the schema here because it will be needed on every sync
schema, _ := gnmitargetygot.Schema()
// load topo into DB via API // load topo into DB via API
return &VEnv{ return &VEnv{
...@@ -124,6 +128,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi ...@@ -124,6 +128,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi
sdnConfig: sdnConfig, sdnConfig: sdnConfig,
containerRegistryURL: "registry.code.fbi.h-da.de/danet/gnmi-target/debian:interface-enabled-test", // TODO: Could let user choose containerRegistryURL: "registry.code.fbi.h-da.de/danet/gnmi-target/debian:interface-enabled-test", // TODO: Could let user choose
SyncBack: false, SyncBack: false,
RootSchema: schema.RootSchema(),
} }
} }
...@@ -317,9 +322,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { ...@@ -317,9 +322,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error {
return fmt.Errorf("Encountered error while trying to parse string path into gnmi path: %w", err) return fmt.Errorf("Encountered error while trying to parse string path into gnmi path: %w", err)
} }
//ytypes.GetOrCreateNode(gnmitargetygot.Schema(), ,gnmiPath) //ytypes.GetOrCreateNode(gnmitargetygot.Schema(), ,gnmiPath)
schema, nil := gnmitargetygot.Schema() _, entry, err := ytypes.GetOrCreateNode(v.RootSchema, &gnmitargetygot.Gnmitarget{}, gnmiPath)
rootSchema := schema.RootSchema()
_, entry, err := ytypes.GetOrCreateNode(rootSchema, &gnmitargetygot.Gnmitarget{}, gnmiPath)
if err != nil { if err != nil {
return fmt.Errorf("SetGnnmiPath Error: %w", err) return fmt.Errorf("SetGnnmiPath Error: %w", err)
} }
...@@ -341,7 +344,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { ...@@ -341,7 +344,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error {
pid := v.pnd.Id pid := v.pnd.Id
if save { if save {
benchmark.Current.SendChangeRequest = time.Now() benchmark.Current.RmSendPathRequest = time.Now()
} }
setPathListReq := &networkelement.SetPathListRequest{ setPathListReq := &networkelement.SetPathListRequest{
Timestamp: util.Now(), Timestamp: util.Now(),
...@@ -350,7 +353,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { ...@@ -350,7 +353,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error {
} }
setPathResponse, err := mneService.SetPathList(ctx, setPathListReq) setPathResponse, err := mneService.SetPathList(ctx, setPathListReq)
if save { if save {
benchmark.Current.ReceiveChangeResponse = time.Now() // TOA of response benchmark.Current.RmReceivePathResponse = time.Now() // TOA of response
} }
if err != nil { if err != nil {
fmt.Printf("Error: %v\n", err) fmt.Printf("Error: %v\n", err)
...@@ -371,7 +374,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { ...@@ -371,7 +374,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error {
} }
clResponse, err := mneService.SetChangeList(ctx, &setChangeListRequest) clResponse, err := mneService.SetChangeList(ctx, &setChangeListRequest)
if save { if save {
benchmark.Current.ReceiveCommitResponse = time.Now() benchmark.Current.RmReceiveCommitResponse = time.Now()
} }
if err != nil { if err != nil {
fmt.Println("Error, failed to commit changes:", err) fmt.Println("Error, failed to commit changes:", err)
...@@ -381,13 +384,13 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { ...@@ -381,13 +384,13 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error {
} }
if save { if save {
benchmark.Current.SendChangeRequest = time.Unix(0, setPathListReq.Timestamp) // send req in realnet benchmark.Current.RmSendPathRequest = time.Unix(0, setPathListReq.Timestamp) // send req in realnet
benchmark.Current.ReceiveChangeRequest = time.Unix(0, setPathResponse.Timestamp) // rcv in twin benchmark.Current.CtlSendPathResponse = time.Unix(0, setPathResponse.Timestamp) // rcv in twin
benchmark.Current.SendCommitRequest = time.Unix(0, setChangeListRequest.Timestamp) benchmark.Current.RmSendCommitRequest = time.Unix(0, setChangeListRequest.Timestamp)
benchmark.Current.ReceiveCommitResponse = time.Unix(0, clResponse.Timestamp) benchmark.Current.CtlSendCommitResponse = time.Unix(0, clResponse.Timestamp)
benchmark.Current.PropagationDelay = benchmark.Current.ReceiveCommitResponse.Sub(benchmark.Current.StartTimeRealnet) benchmark.Current.PropagationDelay = benchmark.Current.RmReceiveCommitResponse.Sub(benchmark.Current.StartTimeRealnet)
fmt.Println("---Measurement finished---") fmt.Println("---Measurement finished---")
benchmark.Current.Print() benchmark.Current.Print()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment