Skip to content

Commit

Permalink
Merge pull request kubernetes#1592 from Nordix/netperf-msmt-testscript
Browse files Browse the repository at this point in the history
Adding network performance measurement testcases. (Test script addition)
  • Loading branch information
k8s-ci-robot authored Mar 25, 2021
2 parents abecfdd + 3b9d5c3 commit 8866b93
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ package network
import (
"context"
"fmt"
"math"
"sync"
"time"

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
Expand Down Expand Up @@ -101,7 +103,7 @@ type networkPerformanceMeasurement struct {
numberOfServers int
numberOfClients int
podRatioType string
testDuration int
testDuration time.Duration
protocol string

// workerPodInfo stores list of podData for every worker node.
Expand Down Expand Up @@ -261,6 +263,8 @@ func (npm *networkPerformanceMeasurement) storeWorkerPods() error {
}

func (npm *networkPerformanceMeasurement) gather() (measurement.Summary, error) {
npm.waitForMetricsFromPods()

close(npm.stopCh)
npm.cleanupCluster()

Expand Down Expand Up @@ -363,7 +367,6 @@ func (npm *networkPerformanceMeasurement) calculateMetricDataValue(dataElem *mea
dataElem.Data[perc95] = percentile.percentile95
klog.Info("Aggregate Metric value: ", aggregatePodPairMetrics)
}
klog.Infof("Response received from: %v pods", len(npm.metricVal))
}

func (npm *networkPerformanceMeasurement) createResultSummary() testResultSummary {
Expand Down Expand Up @@ -396,3 +399,19 @@ func (npm *networkPerformanceMeasurement) getMetricData(data *testResultSummary,
data.DataItems = append(data.DataItems, metricDataItem)
klog.V(3).Infof("TestResultSummary: %v", data)
}

func (npm *networkPerformanceMeasurement) waitForMetricsFromPods() {
bufferTime := time.Duration(math.Max(10, float64(npm.numberOfClients)*0.1)) * time.Second
timeout := initialDelayForTestExecution + npm.testDuration + bufferTime
interval := 2 * time.Second
if err := wait.Poll(interval, timeout, npm.checkResponseReceivedFromPods); err != nil {
// TODO: Log pod names from which response is not received.
klog.Errorf("Failed to receive response from %v pods", npm.numberOfClients-len(npm.metricVal))
}
}

func (npm *networkPerformanceMeasurement) checkResponseReceivedFromPods() (bool, error) {
npm.metricLock.Lock()
defer npm.metricLock.Unlock()
return len(npm.metricVal) == npm.numberOfClients, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

func (npm *networkPerformanceMeasurement) validate(config *measurement.Config) error {
var err error
if npm.testDuration, err = util.GetInt(config.Params, "duration"); err != nil {
if npm.testDuration, err = util.GetDuration(config.Params, "duration"); err != nil {
return err
}
if npm.protocol, err = util.GetString(config.Params, "protocol"); err != nil {
Expand Down Expand Up @@ -82,7 +82,7 @@ func (npm *networkPerformanceMeasurement) populateTemplate(podPair podPair, inde
"clientPodIP": podPair.sourcePodIP,
"serverPodIP": podPair.destinationPodIP,
"protocol": npm.protocol,
"duration": npm.testDuration,
"duration": npm.testDuration.Seconds(),
"clientStartTimestamp": npm.startTimeStampForTestExecution,
"numberOfClients": 1,
}
Expand Down
2 changes: 2 additions & 0 deletions clusterloader2/testing/network/1_1_ratio_override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CL2_NUMBER_OF_SERVERS: 1
CL2_NUMBER_OF_CLIENTS: 1
2 changes: 2 additions & 0 deletions clusterloader2/testing/network/50_50_ratio_override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CL2_NUMBER_OF_SERVERS: 50
CL2_NUMBER_OF_CLIENTS: 50
23 changes: 23 additions & 0 deletions clusterloader2/testing/network/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{$PROTOCOL := .CL2_PROTOCOL}}
{{$NUMBER_OF_SERVERS := .CL2_NUMBER_OF_SERVERS}}
{{$NUMBER_OF_CLIENTS := .CL2_NUMBER_OF_CLIENTS}}

name: Network Performance
automanagedNamespaces: 1
steps:
- name: Start network performance measurement
measurements:
- Identifier: NetworkPerformanceMetrics
Method: NetworkPerformanceMetrics
Params:
action: start
duration: 10s
protocol: {{$PROTOCOL}}
numberOfServers: {{$NUMBER_OF_SERVERS}}
numberOfClients: {{$NUMBER_OF_CLIENTS}}
- name: Gather network performance measurement
measurements:
- Identifier: NetworkPerformanceMetrics
Method: NetworkPerformanceMetrics
Params:
action: gather
1 change: 1 addition & 0 deletions clusterloader2/testing/network/http_protocol_override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CL2_PROTOCOL: HTTP
30 changes: 30 additions & 0 deletions clusterloader2/testing/network/suite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- identifier: tcp-1:1
configPath: testing/network/config.yaml
overridePaths:
- testing/network/tcp_protocol_override.yaml
- testing/network/1_1_ratio_override.yaml
- identifier: udp-1:1
configPath: testing/network/config.yaml
overridePaths:
- testing/network/udp_protocol_override.yaml
- testing/network/1_1_ratio_override.yaml
- identifier: http-1:1
configPath: testing/network/config.yaml
overridePaths:
- testing/network/http_protocol_override.yaml
- testing/network/1_1_ratio_override.yaml
- identifier: tcp-50:50
configPath: testing/network/config.yaml
overridePaths:
- testing/network/tcp_protocol_override.yaml
- testing/network/50_50_ratio_override.yaml
- identifier: udp-50:50
configPath: testing/network/config.yaml
overridePaths:
- testing/network/udp_protocol_override.yaml
- testing/network/50_50_ratio_override.yaml
- identifier: http-50:50
configPath: testing/network/config.yaml
overridePaths:
- testing/network/http_protocol_override.yaml
- testing/network/50_50_ratio_override.yaml
1 change: 1 addition & 0 deletions clusterloader2/testing/network/tcp_protocol_override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CL2_PROTOCOL: TCP
1 change: 1 addition & 0 deletions clusterloader2/testing/network/udp_protocol_override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CL2_PROTOCOL: UDP

0 comments on commit 8866b93

Please sign in to comment.