add rolling data production to load test (#1339)

## Description

Adds production of 10 exchange items of each type, only for the load_test user, every time the load tests succeed.  Also migrates that user ID out to a secret value stored in github.

## Type of change

- [x] 🤖 Test

## Issue(s)

* #902

## Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2022-10-26 15:56:32 -06:00 committed by GitHub
parent 77c703cee9
commit 1bc3210c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 122 additions and 68 deletions

View File

@ -52,6 +52,7 @@ jobs:
AZURE_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} AZURE_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }} AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
CORSO_PASSPHRASE: ${{ secrets.INTEGRATION_TEST_CORSO_PASSPHRASE }} CORSO_PASSPHRASE: ${{ secrets.INTEGRATION_TEST_CORSO_PASSPHRASE }}
CORSO_M356_LOAD_TEST_USER_ID: ${{ secrets.CORSO_M356_LOAD_TEST_USER_ID }}
CORSO_LOAD_TESTS: true CORSO_LOAD_TESTS: true
run: | run: |
set -euo pipefail set -euo pipefail
@ -79,6 +80,37 @@ jobs:
if-no-files-found: error if-no-files-found: error
retention-days: 14 retention-days: 14
# currently, we're required to generate a unique folder for each factory
# production. Whenever possible, this should be reverted to increasing the
# item count of a single folder instead, to prevent overproduction of folders
# during restore.
- name: Set folder destination date
run: |
echo "NOW=$(date -u +"%Y-%m-%d_%H-%M-%S")" >> $GITHUB_ENV
# generate new entries to roll into the next load test
# only runs if the test was successful
- name: New Data Creation
working-directory: ./src/cmd/factory
env:
AZURE_CLIENT_ID: ${{ secrets.CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
CORSO_M356_LOAD_TEST_USER_ID: ${{ secrets.CORSO_M356_LOAD_TEST_USER_ID }}
run: |
go run . exchange emails \
--user ${{ env.CORSO_M356_LOAD_TEST_USER_ID }} \
--destination lt_${{ env.NOW }} \
--count 10
go run . exchange contacts \
--user ${{ env.CORSO_M356_LOAD_TEST_USER_ID }} \
--destination lt_${{ env.NOW }} \
--count 10
go run . exchange events \
--user ${{ env.CORSO_M356_LOAD_TEST_USER_ID }} \
--destination lt_${{ env.NOW }} \
--count 10
# cleanup folders produced by load test # cleanup folders produced by load test
- name: Restored Folder Purge - name: Restored Folder Purge
if: always() if: always()
@ -92,4 +124,3 @@ jobs:
go run ./cmd/purge/purge.go go run ./cmd/purge/purge.go
--user '*' --user '*'
--prefix ${{ env.DELETE_FOLDER_PREFIX }} --prefix ${{ env.DELETE_FOLDER_PREFIX }}

View File

@ -23,6 +23,7 @@ const (
TestCfgAzureTenantID = "azure_tenantid" TestCfgAzureTenantID = "azure_tenantid"
TestCfgUserID = "m365userid" TestCfgUserID = "m365userid"
TestCfgSecondaryUserID = "secondarym365userid" TestCfgSecondaryUserID = "secondarym365userid"
TestCfgLoadTestUserID = "loadttestm365userid"
TestCfgAccountProvider = "account_provider" TestCfgAccountProvider = "account_provider"
) )
@ -30,6 +31,7 @@ const (
const ( const (
EnvCorsoM365TestUserID = "CORSO_M356_TEST_USER_ID" EnvCorsoM365TestUserID = "CORSO_M356_TEST_USER_ID"
EnvCorsoSecondaryM365TestUserID = "CORSO_SECONDARY_M356_TEST_USER_ID" EnvCorsoSecondaryM365TestUserID = "CORSO_SECONDARY_M356_TEST_USER_ID"
EnvCorsoM365LoadTestUserID = "CORSO_M356_LOAD_TEST_USER_ID"
EnvCorsoTestConfigFilePath = "CORSO_TEST_CONFIG_FILE" EnvCorsoTestConfigFilePath = "CORSO_TEST_CONFIG_FILE"
) )
@ -119,6 +121,13 @@ func readTestConfig() (map[string]string, error) {
"lidiah@8qzvrj.onmicrosoft.com", "lidiah@8qzvrj.onmicrosoft.com",
//"lynner@8qzvrj.onmicrosoft.com", //"lynner@8qzvrj.onmicrosoft.com",
) )
fallbackTo(
testEnv,
TestCfgLoadTestUserID,
os.Getenv(EnvCorsoM365LoadTestUserID),
vpr.GetString(TestCfgLoadTestUserID),
"leeg@8qzvrj.onmicrosoft.com",
)
testEnv[EnvCorsoTestConfigFilePath] = os.Getenv(EnvCorsoTestConfigFilePath) testEnv[EnvCorsoTestConfigFilePath] = os.Getenv(EnvCorsoTestConfigFilePath)
testConfig = testEnv testConfig = testEnv

View File

@ -28,3 +28,15 @@ func SecondaryM365UserID(t *testing.T) string {
return cfg[TestCfgSecondaryUserID] return cfg[TestCfgSecondaryUserID]
} }
// LoadTestM365UserID returns an userID string representing the m365UserID
// described by either the env var CORSO_M356_LOAD_TEST_USER_ID, the
// corso_test.toml config file or the default value (in that order of priority).
// The default is a last-attempt fallback that will only work on alcion's
// testing org.
func LoadTestM365UserID(t *testing.T) string {
cfg, err := readTestConfig()
require.NoError(t, err, "retrieving load test m365 user id from test configuration")
return cfg[TestCfgLoadTestUserID]
}

View File

@ -22,7 +22,12 @@ import (
"github.com/alcionai/corso/src/pkg/storage" "github.com/alcionai/corso/src/pkg/storage"
) )
var alcUsers = []string{ func userSet(t *testing.T) []string {
// avoid adding the following users
// they are reserved for other purposes
// "LeeG@8qzvrj.onmicrosoft.com",
// "ntoja@8qzvrj.onmicrosoft.com",
return []string{
"AdeleV@8qzvrj.onmicrosoft.com", "AdeleV@8qzvrj.onmicrosoft.com",
"AlexW@8qzvrj.onmicrosoft.com", "AlexW@8qzvrj.onmicrosoft.com",
"ashmarks@8qzvrj.onmicrosoft.com", "ashmarks@8qzvrj.onmicrosoft.com",
@ -44,15 +49,12 @@ var alcUsers = []string{
"Rfinders@8qzvrj.onmicrosoft.com", "Rfinders@8qzvrj.onmicrosoft.com",
"vkarma@8qzvrj.onmicrosoft.com", "vkarma@8qzvrj.onmicrosoft.com",
"greg.sanders@8qzvrj.onmicrosoft.com", "greg.sanders@8qzvrj.onmicrosoft.com",
}
// avoid adding the following users
// they are reserved for other purposes
// "LeeG@8qzvrj.onmicrosoft.com",
// "ntoja@8qzvrj.onmicrosoft.com",
} }
var largeDatasetUser = []string{"LeeG@8qzvrj.onmicrosoft.com"} func singleUserSet(t *testing.T) []string {
return []string{tester.LoadTestM365UserID(t)}
}
func initM365Repo(t *testing.T) ( func initM365Repo(t *testing.T) (
context.Context, repository.Repository, account.Account, storage.Storage, context.Context, repository.Repository, account.Account, storage.Storage,
@ -88,12 +90,12 @@ func runLoadTest(
t *testing.T, t *testing.T,
ctx context.Context, ctx context.Context,
r repository.Repository, r repository.Repository,
service string, prefix, service string,
usersUnderTest []string, usersUnderTest []string,
bupSel, restSel selectors.Selector, bupSel, restSel selectors.Selector,
) { ) {
//revive:enable:context-as-argument //revive:enable:context-as-argument
t.Run("load_test_main", func(t *testing.T) { t.Run(prefix+"_load_test_main", func(t *testing.T) {
b, err := r.NewBackup(ctx, bupSel) b, err := r.NewBackup(ctx, bupSel)
require.NoError(t, err) require.NoError(t, err)
@ -349,6 +351,7 @@ type RepositoryLoadTestExchangeSuite struct {
repo repository.Repository repo repository.Repository
acct account.Account acct account.Account
st storage.Storage st storage.Storage
usersUnderTest []string
} }
func TestRepositoryLoadTestExchangeSuite(t *testing.T) { func TestRepositoryLoadTestExchangeSuite(t *testing.T) {
@ -363,6 +366,7 @@ func (suite *RepositoryLoadTestExchangeSuite) SetupSuite() {
t := suite.T() t := suite.T()
t.Parallel() t.Parallel()
suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t) suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t)
suite.usersUnderTest = userSet(t)
} }
func (suite *RepositoryLoadTestExchangeSuite) TeardownSuite() { func (suite *RepositoryLoadTestExchangeSuite) TeardownSuite() {
@ -373,20 +377,18 @@ func (suite *RepositoryLoadTestExchangeSuite) TestExchange() {
ctx, flush := tester.NewContext() ctx, flush := tester.NewContext()
defer flush() defer flush()
usersUnderTest := alcUsers
bsel := selectors.NewExchangeBackup() bsel := selectors.NewExchangeBackup()
bsel.Include(bsel.MailFolders(usersUnderTest, selectors.Any())) bsel.Include(bsel.MailFolders(suite.usersUnderTest, selectors.Any()))
bsel.Include(bsel.ContactFolders(usersUnderTest, selectors.Any())) bsel.Include(bsel.ContactFolders(suite.usersUnderTest, selectors.Any()))
bsel.Include(bsel.EventCalendars(usersUnderTest, selectors.Any())) bsel.Include(bsel.EventCalendars(suite.usersUnderTest, selectors.Any()))
sel := bsel.Selector sel := bsel.Selector
runLoadTest( runLoadTest(
suite.T(), suite.T(),
ctx, ctx,
suite.repo, suite.repo,
"exchange", "all_users", "exchange",
usersUnderTest, suite.usersUnderTest,
sel, sel, // same selection for backup and restore sel, sel, // same selection for backup and restore
) )
} }
@ -399,6 +401,7 @@ type RepositoryIndividualLoadTestExchangeSuite struct {
repo repository.Repository repo repository.Repository
acct account.Account acct account.Account
st storage.Storage st storage.Storage
usersUnderTest []string
} }
func TestRepositoryIndividualLoadTestExchangeSuite(t *testing.T) { func TestRepositoryIndividualLoadTestExchangeSuite(t *testing.T) {
@ -413,6 +416,7 @@ func (suite *RepositoryIndividualLoadTestExchangeSuite) SetupSuite() {
t := suite.T() t := suite.T()
t.Parallel() t.Parallel()
suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t) suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t)
suite.usersUnderTest = singleUserSet(t)
} }
func (suite *RepositoryIndividualLoadTestExchangeSuite) TeardownSuite() { func (suite *RepositoryIndividualLoadTestExchangeSuite) TeardownSuite() {
@ -423,20 +427,18 @@ func (suite *RepositoryIndividualLoadTestExchangeSuite) TestExchange() {
ctx, flush := tester.NewContext() ctx, flush := tester.NewContext()
defer flush() defer flush()
usersUnderTest := largeDatasetUser
bsel := selectors.NewExchangeBackup() bsel := selectors.NewExchangeBackup()
bsel.Include(bsel.MailFolders(usersUnderTest, selectors.Any())) bsel.Include(bsel.MailFolders(suite.usersUnderTest, selectors.Any()))
bsel.Include(bsel.ContactFolders(usersUnderTest, selectors.Any())) bsel.Include(bsel.ContactFolders(suite.usersUnderTest, selectors.Any()))
bsel.Include(bsel.EventCalendars(usersUnderTest, selectors.Any())) bsel.Include(bsel.EventCalendars(suite.usersUnderTest, selectors.Any()))
sel := bsel.Selector sel := bsel.Selector
runLoadTest( runLoadTest(
suite.T(), suite.T(),
ctx, ctx,
suite.repo, suite.repo,
"exchange", "single_user", "exchange",
usersUnderTest, suite.usersUnderTest,
sel, sel, // same selection for backup and restore sel, sel, // same selection for backup and restore
) )
} }
@ -451,6 +453,7 @@ type RepositoryLoadTestOneDriveSuite struct {
repo repository.Repository repo repository.Repository
acct account.Account acct account.Account
st storage.Storage st storage.Storage
usersUnderTest []string
} }
func TestRepositoryLoadTestOneDriveSuite(t *testing.T) { func TestRepositoryLoadTestOneDriveSuite(t *testing.T) {
@ -466,6 +469,7 @@ func (suite *RepositoryLoadTestOneDriveSuite) SetupSuite() {
t.Skip("temp issue-902-live") t.Skip("temp issue-902-live")
t.Parallel() t.Parallel()
suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t) suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t)
suite.usersUnderTest = userSet(t)
} }
func (suite *RepositoryLoadTestOneDriveSuite) TeardownSuite() { func (suite *RepositoryLoadTestOneDriveSuite) TeardownSuite() {
@ -476,18 +480,16 @@ func (suite *RepositoryLoadTestOneDriveSuite) TestOneDrive() {
ctx, flush := tester.NewContext() ctx, flush := tester.NewContext()
defer flush() defer flush()
usersUnderTest := alcUsers
bsel := selectors.NewOneDriveBackup() bsel := selectors.NewOneDriveBackup()
bsel.Include(bsel.Users(usersUnderTest)) bsel.Include(bsel.Users(suite.usersUnderTest))
sel := bsel.Selector sel := bsel.Selector
runLoadTest( runLoadTest(
suite.T(), suite.T(),
ctx, ctx,
suite.repo, suite.repo,
"one_drive", "all_users", "one_drive",
usersUnderTest, suite.usersUnderTest,
sel, sel, // same selection for backup and restore sel, sel, // same selection for backup and restore
) )
} }
@ -498,6 +500,7 @@ type RepositoryIndividualLoadTestOneDriveSuite struct {
repo repository.Repository repo repository.Repository
acct account.Account acct account.Account
st storage.Storage st storage.Storage
usersUnderTest []string
} }
func TestRepositoryIndividualLoadTestOneDriveSuite(t *testing.T) { func TestRepositoryIndividualLoadTestOneDriveSuite(t *testing.T) {
@ -513,6 +516,7 @@ func (suite *RepositoryIndividualLoadTestOneDriveSuite) SetupSuite() {
t.Skip("temp issue-902-live") t.Skip("temp issue-902-live")
t.Parallel() t.Parallel()
suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t) suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t)
suite.usersUnderTest = singleUserSet(t)
} }
func (suite *RepositoryIndividualLoadTestOneDriveSuite) TeardownSuite() { func (suite *RepositoryIndividualLoadTestOneDriveSuite) TeardownSuite() {
@ -523,18 +527,16 @@ func (suite *RepositoryIndividualLoadTestOneDriveSuite) TestOneDrive() {
ctx, flush := tester.NewContext() ctx, flush := tester.NewContext()
defer flush() defer flush()
usersUnderTest := largeDatasetUser
bsel := selectors.NewOneDriveBackup() bsel := selectors.NewOneDriveBackup()
bsel.Include(bsel.Users(usersUnderTest)) bsel.Include(bsel.Users(suite.usersUnderTest))
sel := bsel.Selector sel := bsel.Selector
runLoadTest( runLoadTest(
suite.T(), suite.T(),
ctx, ctx,
suite.repo, suite.repo,
"one_drive", "single_user", "one_drive",
usersUnderTest, suite.usersUnderTest,
sel, sel, // same selection for backup and restore sel, sel, // same selection for backup and restore
) )
} }