diff --git a/.github/workflows/load_test.yml b/.github/workflows/load_test.yml new file mode 100644 index 000000000..8d0ab1544 --- /dev/null +++ b/.github/workflows/load_test.yml @@ -0,0 +1,61 @@ +name: Nightly Load Testing +on: + schedule: + # every day at 01:59 (01:59am) UTC + - cron: "59 1 * * *" + +permissions: + # required to retrieve AWS credentials + id-token: write + contents: read + +Load-Tests: + environment: Testing + runs-on: ubuntu-latest + defaults: + run: + working-directory: src + steps: + - uses: actions/checkout@v3 + + - name: Setup Golang with cache + uses: magnetikonline/action-golang-cache@v3 + with: + go-version-file: src/go.mod + + # Install gotestfmt + - name: Set up gotestfmt + run: go install github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest + + # AWS creds + - name: Configure AWS credentials from Test account + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: arn:aws:iam::951767375776:role/corso-testing-role + role-session-name: integration-testing + aws-region: us-east-1 + + # run the tests + - name: Integration Tests + env: + CORSO_LOAD_TESTS: true + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + CORSO_PASSPHRASE: ${{ secrets.INTEGRATION_TEST_CORSO_PASSPHRASE }} + TENANT_ID: ${{ secrets.TENANT_ID }} + run: | + set -euo pipefail + go test \ + -json \ + -v \ + -count=1 \ + --timeout 12h \ + ./... 2>&1 | tee /tmp/gotest.log | gotestfmt -hide successful-tests + + # Upload the original go test log as an artifact for later review. + - name: Upload test log + uses: actions/upload-artifact@v2 + with: + name: test-log + path: /tmp/gotest.log + if-no-files-found: error \ No newline at end of file diff --git a/src/internal/tester/integration_runners.go b/src/internal/tester/integration_runners.go index c2781d6ee..f9a194f4b 100644 --- a/src/internal/tester/integration_runners.go +++ b/src/internal/tester/integration_runners.go @@ -9,6 +9,7 @@ import ( ) const ( + CorsoLoadTests = "CORSO_LOAD_TESTS" CorsoCITests = "CORSO_CI_TESTS" CorsoCLIBackupTests = "CORSO_COMMAND_LINE_BACKUP_TESTS" CorsoCLIConfigTests = "CORSO_COMMAND_LINE_CONFIG_TESTS" diff --git a/src/pkg/repository/repository_load_test.go b/src/pkg/repository/repository_load_test.go new file mode 100644 index 000000000..6904813f7 --- /dev/null +++ b/src/pkg/repository/repository_load_test.go @@ -0,0 +1,147 @@ +package repository_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/alcionai/corso/src/internal/tester" + "github.com/alcionai/corso/src/pkg/account" + "github.com/alcionai/corso/src/pkg/control" + "github.com/alcionai/corso/src/pkg/logger" + "github.com/alcionai/corso/src/pkg/repository" + "github.com/alcionai/corso/src/pkg/storage" +) + +func initM365Repo(t *testing.T) ( + context.Context, *repository.Repository, account.Account, storage.Storage, +) { + _, err := tester.GetRequiredEnvSls( + tester.AWSStorageCredEnvs, + tester.M365AcctCredEnvs, + ) + require.NoError(t, err) + + ctx := tester.NewContext() + st := tester.NewPrefixedS3Storage(t) + ac := tester.NewM365Account(t) + opts := control.Options{ + DisableMetrics: true, + FailFast: true, + } + + repo, err := repository.Initialize(ctx, ac, st, opts) + require.NoError(t, err) + + return ctx, repo, ac, st +} + +// ------------------------------------------------------------------------------------------------ +// Exchange +// ------------------------------------------------------------------------------------------------ + +type RepositoryLoadTestExchangeSuite struct { + suite.Suite + ctx context.Context + repo *repository.Repository + acct account.Account + st storage.Storage +} + +func TestRepositoryLoadTestExchangeSuite(t *testing.T) { + if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { + t.Skip(err) + } + + suite.Run(t, new(RepositoryLoadTestExchangeSuite)) +} + +func (suite *RepositoryLoadTestExchangeSuite) SetupSuite() { + t := suite.T() + suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t) +} + +func (suite *RepositoryLoadTestExchangeSuite) TeardownSuite() { + suite.repo.Close(suite.ctx) +} + +func (suite *RepositoryLoadTestExchangeSuite) SetupTest() { + suite.ctx, _ = logger.SeedLevel(context.Background(), logger.Development) +} + +func (suite *RepositoryLoadTestExchangeSuite) TeardownTest() { + logger.Flush(suite.ctx) +} + +func (suite *RepositoryLoadTestExchangeSuite) TestExchange() { + // var ( + // t = suite.T() + // ctx = context.Background() + // ) + + // t.parallel() + + // backup + + // list + + // details + + // restore +} + +// ------------------------------------------------------------------------------------------------ +// OneDrive +// ------------------------------------------------------------------------------------------------ + +type RepositoryLoadTestOneDriveSuite struct { + suite.Suite + ctx context.Context + repo *repository.Repository + acct account.Account + st storage.Storage +} + +func TestRepositoryLoadTestOneDriveSuite(t *testing.T) { + if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { + t.Skip(err) + } + + suite.Run(t, new(RepositoryLoadTestOneDriveSuite)) +} + +func (suite *RepositoryLoadTestOneDriveSuite) SetupSuite() { + t := suite.T() + suite.ctx, suite.repo, suite.acct, suite.st = initM365Repo(t) +} + +func (suite *RepositoryLoadTestOneDriveSuite) TeardownSuite() { + suite.repo.Close(suite.ctx) +} + +func (suite *RepositoryLoadTestOneDriveSuite) SetupTest() { + suite.ctx, _ = logger.SeedLevel(context.Background(), logger.Development) +} + +func (suite *RepositoryLoadTestOneDriveSuite) TeardownTest() { + logger.Flush(suite.ctx) +} + +func (suite *RepositoryLoadTestOneDriveSuite) TestExchange() { + // var ( + // t = suite.T() + // ctx = context.Background() + // ) + + // t.parallel() + + // backup + + // list + + // details + + // restore +}