-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(tests): add network perf tests for Retina #772
Open
ritwikranjan
wants to merge
9
commits into
microsoft:main
Choose a base branch
from
ritwikranjan:chore/add-perf-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db7bc59
chore/tests: add network perf tests for Retina
ritwikranjan a10c8e5
Merge branch 'main' into chore/add-perf-tests
ritwikranjan 8d90d10
address PR comments and update perf-tests dependency
ritwikranjan a3e3455
Merge branch 'microsoft:main' into chore/add-perf-tests
ritwikranjan 34b158a
fix: remove go.mod version bump
ritwikranjan 0432003
fix: downgrading the accidently upgraded k8s modules
ritwikranjan 4de9504
fix: address PR comments
ritwikranjan 333fad2
Merge branch 'main' into chore/add-perf-tests
ritwikranjan 1d1da2c
fixed stuff after merge from main
ritwikranjan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,7 @@ bin/ | |
|
||
image-metadata-*.json | ||
*packetmonitorsupport*/ | ||
*.pem | ||
*results*.json | ||
netperf-*.json | ||
netperf-*.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package retina | ||
|
||
import ( | ||
"crypto/rand" | ||
"math/big" | ||
"os" | ||
"os/user" | ||
"path/filepath" | ||
"strconv" | ||
"testing" | ||
"time" | ||
|
||
"github.com/microsoft/retina/test/e2e/common" | ||
"github.com/microsoft/retina/test/e2e/framework/types" | ||
jobs "github.com/microsoft/retina/test/e2e/jobs" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// This test creates a new k8s cluster runs some network performance tests | ||
// saves the data as benchmark information and then installs retina and runs the performance tests | ||
// to compare the results and publishes a json with regression information. | ||
func TestE2EPerfRetina(t *testing.T) { | ||
curuser, err := user.Current() | ||
require.NoError(t, err) | ||
|
||
clusterName := curuser.Username + common.NetObsRGtag + strconv.FormatInt(time.Now().Unix(), 10) | ||
|
||
subID := os.Getenv("AZURE_SUBSCRIPTION_ID") | ||
require.NotEmpty(t, subID) | ||
|
||
location := os.Getenv("AZURE_LOCATION") | ||
if location == "" { | ||
var nBig *big.Int | ||
nBig, err = rand.Int(rand.Reader, big.NewInt(int64(len(common.AzureLocations)))) | ||
if err != nil { | ||
t.Fatalf("Failed to generate a secure random index: %v", err) | ||
} | ||
location = common.AzureLocations[nBig.Int64()] | ||
} | ||
|
||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
|
||
// Get to root of the repo by going up two directories | ||
rootDir := filepath.Dir(filepath.Dir(cwd)) | ||
|
||
chartPath := filepath.Join(rootDir, "deploy", "legacy", "manifests", "controller", "helm", "retina") | ||
kubeConfigFilePath := filepath.Join(rootDir, "test", "e2e", "test.pem") | ||
|
||
// CreateTestInfra | ||
createTestInfra := types.NewRunner(t, jobs.CreateTestInfra(subID, clusterName, location, kubeConfigFilePath, true)) | ||
createTestInfra.Run() | ||
|
||
t.Cleanup(func() { | ||
err := jobs.DeleteTestInfra(subID, clusterName, location).Run() | ||
if err != nil { | ||
t.Logf("Failed to delete test infrastructure: %v", err) | ||
} | ||
}) | ||
|
||
// Gather benchmark results then install retina and run the performance tests | ||
runner := types.NewRunner(t, jobs.RunPerfTest(kubeConfigFilePath, chartPath)) | ||
runner.Run() | ||
} |
88 changes: 88 additions & 0 deletions
88
test/e2e/scenarios/perf/get-network-performance-measures.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package perf | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"k8s.io/perf-tests/network/benchmarks/netperf/lib" | ||
) | ||
|
||
type GetNetworkPerformanceMeasures struct { | ||
ResultTag string | ||
KubeConfigFilePath string | ||
JsonOutputFile string | ||
} | ||
|
||
func (v *GetNetworkPerformanceMeasures) Prevalidate() error { | ||
return nil | ||
} | ||
|
||
func (v *GetNetworkPerformanceMeasures) Run() error { | ||
results, err := lib.PerformTests(lib.TestParams{ | ||
Iterations: 1, | ||
Image: "ghcr.io/azure/nptest:latest", // We would use the versioned image once we make a release in Azure/perf-tests | ||
TestNamespace: "netperf", | ||
TestFrom: 13, | ||
TestTo: 17, | ||
JsonOutput: true, | ||
Tag: v.ResultTag, | ||
KubeConfig: v.KubeConfigFilePath, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to get network performance measures: %v", err) | ||
} | ||
sourceJsonOutputFile := results[0].JsonResultFile | ||
err = moveFile(sourceJsonOutputFile, v.JsonOutputFile) | ||
if err != nil { | ||
return fmt.Errorf("failed to copy json output file: %v", err) | ||
} | ||
return nil | ||
} | ||
|
||
func (v *GetNetworkPerformanceMeasures) Stop() error { | ||
return nil | ||
} | ||
|
||
func moveFile(src, dst string) error { | ||
err := copyFile(src, dst) | ||
if err != nil { | ||
return fmt.Errorf("failed to move file: %v", err) | ||
} | ||
|
||
err = os.Remove(src) | ||
if err != nil { | ||
fmt.Printf("warning: failed to delete source file %s: %v\n", src, err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func copyFile(src, dst string) error { | ||
sourceFile, err := os.Open(src) | ||
if err != nil { | ||
return fmt.Errorf("failed to open source file: %v", err) | ||
} | ||
defer sourceFile.Close() | ||
|
||
// Create the destination file | ||
destinationFile, err := os.Create(dst) | ||
if err != nil { | ||
return fmt.Errorf("failed to create destination file: %v", err) | ||
} | ||
defer destinationFile.Close() | ||
|
||
// Copy the contents from source to destination | ||
_, err = io.Copy(destinationFile, sourceFile) | ||
if err != nil { | ||
return fmt.Errorf("failed to copy file: %v", err) | ||
} | ||
|
||
// Flush the destination file to ensure all data is written | ||
err = destinationFile.Sync() | ||
if err != nil { | ||
return fmt.Errorf("failed to sync destination file: %v", err) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we actually testing here? What assertions of behavior are being made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test basically generating regression data and not asserting anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that be the case, we should just create another binary artifact that runs these perf tests. The testing framework is just getting in the way since it wasn't designed for this purpose.