add load tester suite (#2809)

#### Does this PR need a docs update or release note?

- [x]  No

#### Type of change

- [x] 🧹 Tech Debt/Cleanup

#### Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2023-03-16 17:04:35 -06:00 committed by GitHub
parent 4515d3a4b2
commit 26bf24c77e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 125 additions and 48 deletions

View File

@ -86,6 +86,32 @@ type e2eSuite struct {
suite.Suite
}
// ---------------------------------------------------------------------------
// Load
// ---------------------------------------------------------------------------
func NewLoadSuite(
t *testing.T,
envSets [][]string,
runOnAnyEnv ...string,
) *loadSuite {
RunOnAny(
t,
append(
[]string{CorsoLoadTests},
runOnAnyEnv...,
)...,
)
MustGetEnvSets(t, envSets...)
return new(loadSuite)
}
type loadSuite struct {
suite.Suite
}
// ---------------------------------------------------------------------------
// Run Condition Checkers
// ---------------------------------------------------------------------------

View File

@ -58,3 +58,20 @@ func (suite *TesterE2ESuite) SetupSuite() {
func (suite *TesterE2ESuite) TestE2ESuite() {
require.True(suite.T(), suite.called)
}
type TesterLoadSuite struct {
tester.Suite
called bool
}
func TestTesterLoadSuite(t *testing.T) {
suite.Run(t, &TesterLoadSuite{Suite: tester.NewLoadSuite(t, nil)})
}
func (suite *TesterLoadSuite) SetupSuite() {
suite.called = true
}
func (suite *TesterLoadSuite) TestE2ESuite() {
require.True(suite.T(), suite.called)
}

View File

@ -385,14 +385,24 @@ func normalizeCategorySet(t *testing.T, cats map[string]struct{}) []string {
return sl
}
/* ================================================
* A note on load test setup:
* Even though most of the code here is boiler-
* plate and could be easily compressed into a
* test matrix, we want to keep the suites separate
* to maximize parallelism. Due to how testify's
* suites work, we can only run in parallel at the
* level of the suite, not within each test.
* ================================================ */
// ------------------------------------------------------------------------------------------------
// Exchange
// ------------------------------------------------------------------------------------------------
// multiple users
type RepositoryLoadTestExchangeSuite struct {
suite.Suite
type LoadExchangeSuite struct {
tester.Suite
ctx context.Context
repo repository.Repository
acct account.Account //lint:ignore U1000 future test use
@ -400,23 +410,27 @@ type RepositoryLoadTestExchangeSuite struct {
usersUnderTest []string
}
func TestRepositoryLoadTestExchangeSuite(t *testing.T) {
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryLoadTestExchangeSuite))
func TestLoadExchangeSuite(t *testing.T) {
suite.Run(t, &LoadExchangeSuite{
Suite: tester.NewLoadSuite(
t,
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
),
})
}
func (suite *RepositoryLoadTestExchangeSuite) SetupSuite() {
func (suite *LoadExchangeSuite) SetupSuite() {
t := suite.T()
t.Parallel()
suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t)
suite.usersUnderTest = orgUserSet(t)
}
func (suite *RepositoryLoadTestExchangeSuite) TeardownSuite() {
func (suite *LoadExchangeSuite) TeardownSuite() {
suite.repo.Close(suite.ctx)
}
func (suite *RepositoryLoadTestExchangeSuite) TestExchange() {
func (suite *LoadExchangeSuite) TestExchange() {
ctx, flush := tester.WithContext(suite.ctx)
defer flush()
@ -439,8 +453,8 @@ func (suite *RepositoryLoadTestExchangeSuite) TestExchange() {
// single user, lots of data
type RepositoryIndividualLoadTestExchangeSuite struct {
suite.Suite
type IndividualLoadExchangeSuite struct {
tester.Suite
ctx context.Context
repo repository.Repository
acct account.Account //lint:ignore U1000 future test use
@ -448,12 +462,16 @@ type RepositoryIndividualLoadTestExchangeSuite struct {
usersUnderTest []string
}
func TestRepositoryIndividualLoadTestExchangeSuite(t *testing.T) {
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryIndividualLoadTestExchangeSuite))
func TestIndividualLoadExchangeSuite(t *testing.T) {
suite.Run(t, &IndividualLoadExchangeSuite{
Suite: tester.NewLoadSuite(
t,
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
),
})
}
func (suite *RepositoryIndividualLoadTestExchangeSuite) SetupSuite() {
func (suite *IndividualLoadExchangeSuite) SetupSuite() {
t := suite.T()
t.Skip("individual user exchange suite tests are on hold until token expiry gets resolved")
t.Parallel()
@ -461,11 +479,11 @@ func (suite *RepositoryIndividualLoadTestExchangeSuite) SetupSuite() {
suite.usersUnderTest = singleUserSet(t)
}
func (suite *RepositoryIndividualLoadTestExchangeSuite) TeardownSuite() {
func (suite *IndividualLoadExchangeSuite) TeardownSuite() {
suite.repo.Close(suite.ctx)
}
func (suite *RepositoryIndividualLoadTestExchangeSuite) TestExchange() {
func (suite *IndividualLoadExchangeSuite) TestExchange() {
ctx, flush := tester.WithContext(suite.ctx)
defer flush()
@ -490,8 +508,8 @@ func (suite *RepositoryIndividualLoadTestExchangeSuite) TestExchange() {
// OneDrive
// ------------------------------------------------------------------------------------------------
type RepositoryLoadTestOneDriveSuite struct {
suite.Suite
type LoadOneDriveSuite struct {
tester.Suite
ctx context.Context
repo repository.Repository
acct account.Account //lint:ignore U1000 future test use
@ -499,12 +517,16 @@ type RepositoryLoadTestOneDriveSuite struct {
usersUnderTest []string
}
func TestRepositoryLoadTestOneDriveSuite(t *testing.T) {
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryLoadTestOneDriveSuite))
func TestLoadOneDriveSuite(t *testing.T) {
suite.Run(t, &LoadOneDriveSuite{
Suite: tester.NewLoadSuite(
t,
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
),
})
}
func (suite *RepositoryLoadTestOneDriveSuite) SetupSuite() {
func (suite *LoadOneDriveSuite) SetupSuite() {
t := suite.T()
t.Skip("not running onedrive load tests atm")
t.Parallel()
@ -512,11 +534,11 @@ func (suite *RepositoryLoadTestOneDriveSuite) SetupSuite() {
suite.usersUnderTest = orgUserSet(t)
}
func (suite *RepositoryLoadTestOneDriveSuite) TeardownSuite() {
func (suite *LoadOneDriveSuite) TeardownSuite() {
suite.repo.Close(suite.ctx)
}
func (suite *RepositoryLoadTestOneDriveSuite) TestOneDrive() {
func (suite *LoadOneDriveSuite) TestOneDrive() {
ctx, flush := tester.WithContext(suite.ctx)
defer flush()
@ -535,8 +557,8 @@ func (suite *RepositoryLoadTestOneDriveSuite) TestOneDrive() {
)
}
type RepositoryIndividualLoadTestOneDriveSuite struct {
suite.Suite
type IndividualLoadOneDriveSuite struct {
tester.Suite
ctx context.Context
repo repository.Repository
acct account.Account //lint:ignore U1000 future test use
@ -544,23 +566,27 @@ type RepositoryIndividualLoadTestOneDriveSuite struct {
usersUnderTest []string
}
func TestRepositoryIndividualLoadTestOneDriveSuite(t *testing.T) {
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryIndividualLoadTestOneDriveSuite))
func TestIndividualLoadOneDriveSuite(t *testing.T) {
suite.Run(t, &IndividualLoadOneDriveSuite{
Suite: tester.NewLoadSuite(
t,
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
),
})
}
func (suite *RepositoryIndividualLoadTestOneDriveSuite) SetupSuite() {
func (suite *IndividualLoadOneDriveSuite) SetupSuite() {
t := suite.T()
t.Parallel()
suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t)
suite.usersUnderTest = singleUserSet(t)
}
func (suite *RepositoryIndividualLoadTestOneDriveSuite) TeardownSuite() {
func (suite *IndividualLoadOneDriveSuite) TeardownSuite() {
suite.repo.Close(suite.ctx)
}
func (suite *RepositoryIndividualLoadTestOneDriveSuite) TestOneDrive() {
func (suite *IndividualLoadOneDriveSuite) TestOneDrive() {
ctx, flush := tester.WithContext(suite.ctx)
defer flush()
@ -583,8 +609,8 @@ func (suite *RepositoryIndividualLoadTestOneDriveSuite) TestOneDrive() {
// SharePoint
// ------------------------------------------------------------------------------------------------
type RepositoryLoadTestSharePointSuite struct {
suite.Suite
type LoadSharePointSuite struct {
tester.Suite
ctx context.Context
repo repository.Repository
acct account.Account //lint:ignore U1000 future test use
@ -592,12 +618,16 @@ type RepositoryLoadTestSharePointSuite struct {
sitesUnderTest []string
}
func TestRepositoryLoadTestSharePointSuite(t *testing.T) {
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryLoadTestSharePointSuite))
func TestLoadSharePointSuite(t *testing.T) {
suite.Run(t, &LoadSharePointSuite{
Suite: tester.NewLoadSuite(
t,
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
),
})
}
func (suite *RepositoryLoadTestSharePointSuite) SetupSuite() {
func (suite *LoadSharePointSuite) SetupSuite() {
t := suite.T()
t.Skip("not running sharepoint load tests atm")
t.Parallel()
@ -605,11 +635,11 @@ func (suite *RepositoryLoadTestSharePointSuite) SetupSuite() {
suite.sitesUnderTest = orgSiteSet(t)
}
func (suite *RepositoryLoadTestSharePointSuite) TeardownSuite() {
func (suite *LoadSharePointSuite) TeardownSuite() {
suite.repo.Close(suite.ctx)
}
func (suite *RepositoryLoadTestSharePointSuite) TestSharePoint() {
func (suite *LoadSharePointSuite) TestSharePoint() {
ctx, flush := tester.WithContext(suite.ctx)
defer flush()
@ -628,8 +658,8 @@ func (suite *RepositoryLoadTestSharePointSuite) TestSharePoint() {
)
}
type RepositoryIndividualLoadTestSharePointSuite struct {
suite.Suite
type IndividualLoadSharePointSuite struct {
tester.Suite
ctx context.Context
repo repository.Repository
acct account.Account //lint:ignore U1000 future test use
@ -637,12 +667,16 @@ type RepositoryIndividualLoadTestSharePointSuite struct {
sitesUnderTest []string
}
func TestRepositoryIndividualLoadTestSharePointSuite(t *testing.T) {
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryIndividualLoadTestOneDriveSuite))
func TestIndividualLoadSharePointSuite(t *testing.T) {
suite.Run(t, &IndividualLoadSharePointSuite{
Suite: tester.NewLoadSuite(
t,
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
),
})
}
func (suite *RepositoryIndividualLoadTestSharePointSuite) SetupSuite() {
func (suite *IndividualLoadSharePointSuite) SetupSuite() {
t := suite.T()
t.Skip("not running sharepoint load tests atm")
t.Parallel()
@ -650,11 +684,11 @@ func (suite *RepositoryIndividualLoadTestSharePointSuite) SetupSuite() {
suite.sitesUnderTest = singleSiteSet(t)
}
func (suite *RepositoryIndividualLoadTestSharePointSuite) TeardownSuite() {
func (suite *IndividualLoadSharePointSuite) TeardownSuite() {
suite.repo.Close(suite.ctx)
}
func (suite *RepositoryIndividualLoadTestSharePointSuite) TestSharePoint() {
func (suite *IndividualLoadSharePointSuite) TestSharePoint() {
ctx, flush := tester.WithContext(suite.ctx)
defer flush()