-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add retina mode support for perf-test and abstract common e2e s…
…etups (#1244) # Description This pull request includes several changes to the end-to-end (E2E) testing framework for the retina project. The main update is addition of running perf tests in advanced mode for Retina. The other updates involve the addition of new utility functions, refactoring of existing code for better modularity, and improvements to the performance testing workflow. ### New Utility Functions: * Added `RetinaChartPath`, `RetinaAdvancedProfilePath`, and `KubeConfigFilePath` functions to dynamically generate file paths. (`test/e2e/common/common.go`) ### Refactoring: * Moved the `CreateAzureTempK8sInfra` function to a new file `azure_temp_infra_setup.go` to modularize infrastructure setup. (`test/e2e/infra/azure_temp_infra_setup.go`) * Removed redundant code and simplified the `TestE2ERetina` and `TestE2EPerfRetina` functions by using new utility functions and the `CreateAzureTempK8sInfra` function. (`test/e2e/retina_e2e_test.go`, `test/e2e/retina_perf_test.go`) [[1]](diffhunk://#diff-66cf931d4cbc2a8832e1fcb70af2838ef6913eedb0294d0666fec1aa6787999bL24-R46) [[2]](diffhunk://#diff-4c195fe24e6f8e7cfb68381dd2d389ca275dc11282f0dfe785526a503dae509eL6-R62) ### Performance Testing: * Moved the performance test logic to a new file `perf.go` and added support for running tests in different retina modes (basic, advanced). (`test/e2e/jobs/perf.go`) * Updated the `PublishPerfResults` function to include the retina mode in telemetry data. (`test/e2e/scenarios/perf/publish-perf-results.go`) ### Code Cleanup: * Removed unused imports and redundant code blocks from various files to improve readability and maintainability. (`test/e2e/jobs/jobs.go`, `test/e2e/scale_test.go`) [[1]](diffhunk://#diff-96a5238dd492978468cfd659ceca6877583744425053d5f2ebbf9a62ae47e535L16) [[2]](diffhunk://#diff-cb7aaaca572345df6e4fbb0f6d5e54f8f392870192227f9746a244e095dcdaa8L52-R56) These changes collectively enhance the modularity, readability, and functionality of the E2E testing framework, making it easier to maintain and extend in the future. ## Checklist - [X] I have read the [contributing documentation](https://retina.sh/docs/contributing). - [X] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [X] I have correctly attributed the author(s) of the code. - [X] I have tested the changes locally. - [X] I have followed the project's style guidelines. - [] I have updated the documentation, if necessary. - [] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed I have tested the relevant changes locally and have verified that it works as nintended. ## Additional Notes Add any additional notes or context about the pull request here. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project.
- Loading branch information
1 parent
8928514
commit 8fb1c57
Showing
9 changed files
with
217 additions
and
143 deletions.
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
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,49 @@ | ||
package infra | ||
|
||
import ( | ||
"context" | ||
"crypto/rand" | ||
"math/big" | ||
"os" | ||
"testing" | ||
|
||
"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" | ||
) | ||
|
||
func CreateAzureTempK8sInfra(ctx context.Context, t *testing.T, rootDir string) string { | ||
kubeConfigFilePath := common.KubeConfigFilePath(rootDir) | ||
clusterName := common.ClusterNameForE2ETest(t) | ||
|
||
subID := os.Getenv("AZURE_SUBSCRIPTION_ID") | ||
require.NotEmpty(t, subID, "AZURE_SUBSCRIPTION_ID environment variable must be set") | ||
|
||
location := os.Getenv("AZURE_LOCATION") | ||
if location == "" { | ||
nBig, err := rand.Int(rand.Reader, big.NewInt(int64(len(common.AzureLocations)))) | ||
if err != nil { | ||
t.Fatal("Failed to generate a secure random index", err) | ||
} | ||
location = common.AzureLocations[nBig.Int64()] | ||
} | ||
|
||
rg := os.Getenv("AZURE_RESOURCE_GROUP") | ||
if rg == "" { | ||
// Use the cluster name as the resource group name by default. | ||
rg = clusterName | ||
} | ||
|
||
// CreateTestInfra | ||
createTestInfra := types.NewRunner(t, jobs.CreateTestInfra(subID, rg, clusterName, location, kubeConfigFilePath, *common.CreateInfra)) | ||
createTestInfra.Run(ctx) | ||
|
||
t.Cleanup(func() { | ||
err := jobs.DeleteTestInfra(subID, rg, location, *common.DeleteInfra).Run() | ||
if err != nil { | ||
t.Logf("Failed to delete test infrastructure: %v", err) | ||
} | ||
}) | ||
return kubeConfigFilePath | ||
} |
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,73 @@ | ||
package retina | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/microsoft/retina/test/e2e/framework/generic" | ||
"github.com/microsoft/retina/test/e2e/framework/kubernetes" | ||
"github.com/microsoft/retina/test/e2e/framework/types" | ||
"github.com/microsoft/retina/test/e2e/scenarios/perf" | ||
) | ||
|
||
func RunPerfTest(kubeConfigFilePath, chartPath, advancedValuePath, retinaMode string) *types.Job { | ||
job := types.NewJob("Run performance tests") | ||
|
||
benchmarkFile := fmt.Sprintf("netperf-benchmark-%s.json", time.Now().Format("20060102150405")) | ||
resultFile := fmt.Sprintf("netperf-result-%s.json", time.Now().Format("20060102150405")) | ||
regressionFile := fmt.Sprintf("netperf-regression-%s.json", time.Now().Format("20060102150405")) | ||
|
||
job.AddStep(&perf.GetNetworkPerformanceMeasures{ | ||
KubeConfigFilePath: kubeConfigFilePath, | ||
ResultTag: "no-retina", | ||
JsonOutputFile: benchmarkFile, | ||
}, &types.StepOptions{ | ||
SkipSavingParametersToJob: true, | ||
}) | ||
|
||
job.AddStep(&kubernetes.InstallHelmChart{ | ||
Namespace: "kube-system", | ||
ReleaseName: "retina", | ||
KubeConfigFilePath: kubeConfigFilePath, | ||
ChartPath: chartPath, | ||
TagEnv: generic.DefaultTagEnv, | ||
}, nil) | ||
|
||
if retinaMode == "advanced" { | ||
job.AddStep(&kubernetes.UpgradeRetinaHelmChart{ | ||
Namespace: "kube-system", | ||
ReleaseName: "retina", | ||
KubeConfigFilePath: kubeConfigFilePath, | ||
ChartPath: chartPath, | ||
ValuesFile: advancedValuePath, | ||
TagEnv: generic.DefaultTagEnv, | ||
}, &types.StepOptions{ | ||
SkipSavingParametersToJob: true, | ||
}) | ||
} | ||
|
||
job.AddStep(&perf.GetNetworkPerformanceMeasures{ | ||
KubeConfigFilePath: kubeConfigFilePath, | ||
ResultTag: "retina", | ||
JsonOutputFile: resultFile, | ||
}, &types.StepOptions{ | ||
SkipSavingParametersToJob: true, | ||
}) | ||
|
||
job.AddStep(&perf.GetNetworkRegressionResults{ | ||
BaseResultsFile: benchmarkFile, | ||
NewResultsFile: resultFile, | ||
RegressionResultsFile: regressionFile, | ||
}, &types.StepOptions{ | ||
SkipSavingParametersToJob: true, | ||
}) | ||
|
||
job.AddStep(&perf.PublishPerfResults{ | ||
ResultsFile: regressionFile, | ||
RetinaMode: retinaMode, | ||
}, &types.StepOptions{ | ||
SkipSavingParametersToJob: true, | ||
}) | ||
|
||
return job | ||
} |
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
Oops, something went wrong.