-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Castilio dos Santos <[email protected]>
- Loading branch information
1 parent
6d9050c
commit 04458ba
Showing
7 changed files
with
145 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
) | ||
|
||
// Context returns a context with a deadline set to the test deadline - 1 min to ensure cleanup. | ||
// If the test deadline is not set, a deadline is set to Now + 24h to prevent the test from running indefinitely | ||
func Context(t *testing.T) (context.Context, context.CancelFunc) { | ||
deadline, ok := t.Deadline() | ||
if !ok { | ||
t.Log("Test deadline disabled, deadline set to Now + 24h to prevent test from running indefinitely") | ||
deadline = time.Now().Add(24 * time.Hour) | ||
Check failure on line 15 in test/e2e/framework/helpers/helpers.go GitHub Actions / Lint (linux, amd64)
Check failure on line 15 in test/e2e/framework/helpers/helpers.go GitHub Actions / Lint (linux, arm64)
Check failure on line 15 in test/e2e/framework/helpers/helpers.go GitHub Actions / Lint (windows, amd64)
|
||
} | ||
|
||
// Subtract a minute from the deadline to ensure we have time to cleanup | ||
deadline = deadline.Add(-time.Minute) | ||
|
||
return context.WithDeadline(context.Background(), deadline) | ||
} |
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,65 @@ | ||
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/helpers" | ||
"github.com/microsoft/retina/test/e2e/framework/types" | ||
jobs "github.com/microsoft/retina/test/e2e/jobs" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestE2ERetina_Scale(t *testing.T) { | ||
ctx, cancel := helpers.Context(t) | ||
defer cancel() | ||
|
||
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(locations)))) | ||
if err != nil { | ||
t.Fatalf("Failed to generate a secure random index: %v", err) | ||
} | ||
location = locations[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)) | ||
createTestInfra.Run(ctx) | ||
|
||
t.Cleanup(func() { | ||
_ = jobs.DeleteTestInfra(subID, clusterName, location).Run() | ||
}) | ||
|
||
// Install Retina | ||
installRetina := types.NewRunner(t, jobs.InstallRetina(kubeConfigFilePath, chartPath)) | ||
installRetina.Run(ctx) | ||
|
||
// TODO: Scale Cluster | ||
|
||
// TODO: equivalent of github.com/Azure/azure-container-networking/test/scale/test-scale.sh | ||
} |