From 29f5556f9975b3d3cad1c8a245e2bfc8d4b856d4 Mon Sep 17 00:00:00 2001 From: Janki Chhatbar Date: Tue, 4 May 2021 20:59:14 +0530 Subject: [PATCH] Add context to benchmark commands Closes: #1311 Signed-off-by: Janki Chhatbar --- pkg/subctl/benchmark/latency.go | 22 +++++++++++++--------- pkg/subctl/benchmark/throughput.go | 18 +++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pkg/subctl/benchmark/latency.go b/pkg/subctl/benchmark/latency.go index 6c0dca1a4..87fb9a8e8 100644 --- a/pkg/subctl/benchmark/latency.go +++ b/pkg/subctl/benchmark/latency.go @@ -48,9 +48,13 @@ func StartLatencyTests(intraCluster bool) { f = initFramework("latency") + clusterAName := framework.TestContext.ClusterIDs[framework.ClusterA] + if !intraCluster { + clusterBName := framework.TestContext.ClusterIDs[framework.ClusterB] + if framework.TestContext.GlobalnetEnabled { - By("Latency test is not supported with Globalnet enabled, skipping the test...") + fmt.Println("Latency test is not supported with Globalnet enabled, skipping the test...") cleanupFramework(f) return } @@ -62,12 +66,14 @@ func StartLatencyTests(intraCluster bool) { ClientPodScheduling: framework.GatewayNode, } - framework.By("Performing latency tests from Gateway pod to Gateway pod") + fmt.Printf("Performing latency tests from Gateway pod on cluster %q to Gateway pod on cluster %q\n", + clusterAName, clusterBName) runLatencyTest(f, latencyTestParams) latencyTestParams.ServerPodScheduling = framework.NonGatewayNode latencyTestParams.ClientPodScheduling = framework.NonGatewayNode - framework.By("Performing latency tests from Non-Gateway pod to Non-Gateway pod") + fmt.Printf("Performing latency tests from Non-Gateway pod on cluster %q to Non-Gateway pod on cluster %q\n", + clusterAName, clusterBName) runLatencyTest(f, latencyTestParams) } else { latencyTestIntraClusterParams := benchmarkTestParams{ @@ -76,9 +82,7 @@ func StartLatencyTests(intraCluster bool) { ServerPodScheduling: framework.GatewayNode, ClientPodScheduling: framework.NonGatewayNode, } - - clusterAName := framework.TestContext.ClusterIDs[framework.ClusterA] - framework.By(fmt.Sprintf("Performing latency tests from Non-Gateway pod to Gateway pod on cluster %q", clusterAName)) + fmt.Printf("Performing latency tests from Non-Gateway pod to Gateway pod on cluster %q\n", clusterAName) runLatencyTest(f, latencyTestIntraClusterParams) } @@ -91,7 +95,7 @@ func runLatencyTest(f *framework.Framework, testParams benchmarkTestParams) { var connectionTimeout uint = 5 var connectionAttempts uint = 1 - framework.By(fmt.Sprintf("Creating a Nettest Server Pod on %q", clusterBName)) + By(fmt.Sprintf("Creating a Nettest Server Pod on %q", clusterBName)) nettestServerPod := f.NewNetworkPod(&framework.NetworkPodConfig{ Type: framework.LatencyServerPod, Cluster: testParams.ServerCluster, @@ -115,10 +119,10 @@ func runLatencyTest(f *framework.Framework, testParams benchmarkTestParams) { ConnectionAttempts: connectionAttempts, }) - framework.By(fmt.Sprintf("Nettest Client Pod %q was created on cluster %q, node %q; connect to server pod ip %q", + By(fmt.Sprintf("Nettest Client Pod %q was created on cluster %q, node %q; connect to server pod ip %q", nettestClientPod.Pod.Name, clusterAName, nettestClientPod.Pod.Spec.NodeName, remoteIP)) - framework.By(fmt.Sprintf("Waiting for the client pod %q to exit, returning what client sent", nettestClientPod.Pod.Name)) + By(fmt.Sprintf("Waiting for the client pod %q to exit, returning what client sent", nettestClientPod.Pod.Name)) nettestClientPod.AwaitFinishVerbose(Verbose) nettestClientPod.CheckSuccessfulFinish() latencyHeaders := strings.Split(nettestClientPod.TerminationMessage, "\n")[1] diff --git a/pkg/subctl/benchmark/throughput.go b/pkg/subctl/benchmark/throughput.go index a7120ef92..adfbebf22 100644 --- a/pkg/subctl/benchmark/throughput.go +++ b/pkg/subctl/benchmark/throughput.go @@ -53,15 +53,15 @@ func StartThroughputTests(intraCluster bool) { } clusterBName := framework.TestContext.ClusterIDs[framework.ClusterB] - framework.By(fmt.Sprintf("Performing throughput tests from Gateway pod on cluster %q to Gateway pod on cluster %q", - clusterAName, clusterBName)) + fmt.Printf("Performing throughput tests from Gateway pod on cluster %q to Gateway pod on cluster %q\n", + clusterAName, clusterBName) runThroughputTest(f, testParams) testParams.ServerPodScheduling = framework.NonGatewayNode testParams.ClientPodScheduling = framework.NonGatewayNode - framework.By(fmt.Sprintf("Performing throughput tests from Non-Gateway pod on cluster %q to Non-Gateway pod on cluster %q", - clusterAName, clusterBName)) + fmt.Printf("Performing throughput tests from Non-Gateway pod on cluster %q to Non-Gateway pod on cluster %q\n", + clusterAName, clusterBName) runThroughputTest(f, testParams) } else { testIntraClusterParams := benchmarkTestParams{ @@ -71,7 +71,7 @@ func StartThroughputTests(intraCluster bool) { ClientPodScheduling: framework.NonGatewayNode, } - framework.By(fmt.Sprintf("Performing throughput tests from Non-Gateway pod to Gateway pod on cluster %q", clusterAName)) + fmt.Printf("Performing throughput tests from Non-Gateway pod to Gateway pod on cluster %q\n", clusterAName) runThroughputTest(f, testIntraClusterParams) } @@ -106,7 +106,7 @@ func runThroughputTest(f *framework.Framework, testParams benchmarkTestParams) { var connectionAttempts uint = 2 var iperf3Port = 5201 - framework.By(fmt.Sprintf("Creating a Nettest Server Pod on %q", serverClusterName)) + By(fmt.Sprintf("Creating a Nettest Server Pod on %q", serverClusterName)) nettestServerPod := f.NewNetworkPod(&framework.NetworkPodConfig{ Type: framework.ThroughputServerPod, Cluster: testParams.ServerCluster, @@ -118,7 +118,7 @@ func runThroughputTest(f *framework.Framework, testParams benchmarkTestParams) { podsClusterB := framework.KubeClients[testParams.ServerCluster].CoreV1().Pods(f.Namespace) p1, _ := podsClusterB.Get(context.TODO(), nettestServerPod.Pod.Name, metav1.GetOptions{}) - framework.By(fmt.Sprintf("Nettest Server Pod %q was created on node %q", nettestServerPod.Pod.Name, nettestServerPod.Pod.Spec.NodeName)) + By(fmt.Sprintf("Nettest Server Pod %q was created on node %q", nettestServerPod.Pod.Name, nettestServerPod.Pod.Spec.NodeName)) remoteIP := p1.Status.PodIP @@ -144,10 +144,10 @@ func runThroughputTest(f *framework.Framework, testParams benchmarkTestParams) { Port: iperf3Port, }) - framework.By(fmt.Sprintf("Nettest Client Pod %q was created on cluster %q, node %q; connect to server pod ip %q", + By(fmt.Sprintf("Nettest Client Pod %q was created on cluster %q, node %q; connect to server pod ip %q", nettestClientPod.Pod.Name, clientClusterName, nettestClientPod.Pod.Spec.NodeName, remoteIP)) - framework.By(fmt.Sprintf("Waiting for the client pod %q to exit, returning what client sent", nettestClientPod.Pod.Name)) + By(fmt.Sprintf("Waiting for the client pod %q to exit, returning what client sent", nettestClientPod.Pod.Name)) nettestClientPod.AwaitFinishVerbose(Verbose) nettestClientPod.CheckSuccessfulFinish() fmt.Println(nettestClientPod.TerminationMessage)