diff --git a/src/cli/backup/exchange_integration_test.go b/src/cli/backup/exchange_integration_test.go index 106b74192..229078f85 100644 --- a/src/cli/backup/exchange_integration_test.go +++ b/src/cli/backup/exchange_integration_test.go @@ -50,13 +50,11 @@ type NoBackupExchangeIntegrationSuite struct { } func TestNoBackupExchangeIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIBackupTests) suite.Run(t, new(NoBackupExchangeIntegrationSuite)) } @@ -67,10 +65,7 @@ func (suite *NoBackupExchangeIntegrationSuite) SetupSuite() { defer flush() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) @@ -138,13 +133,11 @@ type BackupExchangeIntegrationSuite struct { } func TestBackupExchangeIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIBackupTests) suite.Run(t, new(BackupExchangeIntegrationSuite)) } @@ -155,10 +148,7 @@ func (suite *BackupExchangeIntegrationSuite) SetupSuite() { defer flush() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) @@ -234,23 +224,18 @@ type PreparedBackupExchangeIntegrationSuite struct { } func TestPreparedBackupExchangeIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIBackupTests) suite.Run(t, new(PreparedBackupExchangeIntegrationSuite)) } func (suite *PreparedBackupExchangeIntegrationSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) @@ -471,23 +456,18 @@ type BackupDeleteExchangeIntegrationSuite struct { } func TestBackupDeleteExchangeIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIBackupTests) suite.Run(t, new(BackupDeleteExchangeIntegrationSuite)) } func (suite *BackupDeleteExchangeIntegrationSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) diff --git a/src/cli/backup/onedrive_integration_test.go b/src/cli/backup/onedrive_integration_test.go index 05b93c9c6..961f836dd 100644 --- a/src/cli/backup/onedrive_integration_test.go +++ b/src/cli/backup/onedrive_integration_test.go @@ -40,13 +40,7 @@ type NoBackupOneDriveIntegrationSuite struct { } func TestNoBackupOneDriveIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( - tester.CorsoCITests, - tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests) suite.Run(t, new(NoBackupOneDriveIntegrationSuite)) } @@ -57,10 +51,7 @@ func (suite *NoBackupOneDriveIntegrationSuite) SetupSuite() { defer flush() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) @@ -128,23 +119,18 @@ type BackupDeleteOneDriveIntegrationSuite struct { } func TestBackupDeleteOneDriveIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIBackupTests) suite.Run(t, new(BackupDeleteOneDriveIntegrationSuite)) } func (suite *BackupDeleteOneDriveIntegrationSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) diff --git a/src/cli/backup/sharepoint_integration_test.go b/src/cli/backup/sharepoint_integration_test.go index 223504756..700f7fdff 100644 --- a/src/cli/backup/sharepoint_integration_test.go +++ b/src/cli/backup/sharepoint_integration_test.go @@ -40,13 +40,7 @@ type NoBackupSharePointIntegrationSuite struct { } func TestNoBackupSharePointIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( - tester.CorsoCITests, - tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests) suite.Run(t, new(NoBackupSharePointIntegrationSuite)) } @@ -57,10 +51,7 @@ func (suite *NoBackupSharePointIntegrationSuite) SetupSuite() { defer flush() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) @@ -128,23 +119,14 @@ type BackupDeleteSharePointIntegrationSuite struct { } func TestBackupDeleteSharePointIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( - tester.CorsoCITests, - tester.CorsoCLITests, - tester.CorsoCLIBackupTests, - ); err != nil { - t.Skip(err) - } + tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests) suite.Run(t, new(BackupDeleteSharePointIntegrationSuite)) } func (suite *BackupDeleteSharePointIntegrationSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // prepare common details suite.acct = tester.NewM365Account(t) diff --git a/src/cli/config/config_test.go b/src/cli/config/config_test.go index 0981dc7e1..8a0738bf9 100644 --- a/src/cli/config/config_test.go +++ b/src/cli/config/config_test.go @@ -187,21 +187,16 @@ type ConfigIntegrationSuite struct { } func TestConfigIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoCLIConfigTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIConfigTests) suite.Run(t, new(ConfigIntegrationSuite)) } func (suite *ConfigIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) } func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() { diff --git a/src/cli/repo/s3_integration_test.go b/src/cli/repo/s3_integration_test.go index db2ef9091..65e4e88bc 100644 --- a/src/cli/repo/s3_integration_test.go +++ b/src/cli/repo/s3_integration_test.go @@ -20,22 +20,17 @@ type S3IntegrationSuite struct { } func TestS3IntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIRepoTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIRepoTests) suite.Run(t, new(S3IntegrationSuite)) } func (suite *S3IntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) } func (suite *S3IntegrationSuite) TestInitS3Cmd() { diff --git a/src/cli/restore/exchange_integration_test.go b/src/cli/restore/exchange_integration_test.go index 6a441d17b..c8cd21570 100644 --- a/src/cli/restore/exchange_integration_test.go +++ b/src/cli/restore/exchange_integration_test.go @@ -42,13 +42,11 @@ type RestoreExchangeIntegrationSuite struct { } func TestRestoreExchangeIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoCLITests, - tester.CorsoCLIRestoreTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoCLIRestoreTests) suite.Run(t, new(RestoreExchangeIntegrationSuite)) } @@ -59,11 +57,7 @@ func (suite *RestoreExchangeIntegrationSuite) SetupSuite() { ctx, flush := tester.NewContext() defer flush() - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs, - ) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) // aggregate required details suite.acct = tester.NewM365Account(t) diff --git a/src/internal/connector/data_collections_test.go b/src/internal/connector/data_collections_test.go index 35e26f856..24629d5ad 100644 --- a/src/internal/connector/data_collections_test.go +++ b/src/internal/connector/data_collections_test.go @@ -28,12 +28,10 @@ type ConnectorDataCollectionIntegrationSuite struct { } func TestConnectorDataCollectionIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoConnectorDataCollectionTests, - ); err != nil { - t.Skip(err) - } + ) suite.Run(t, new(ConnectorDataCollectionIntegrationSuite)) } @@ -42,11 +40,12 @@ func (suite *ConnectorDataCollectionIntegrationSuite) SetupSuite() { ctx, flush := tester.NewContext() defer flush() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvVars(suite.T(), tester.M365AcctCredEnvs...) + suite.connector = loadConnector(ctx, suite.T(), AllResources) suite.user = tester.M365UserID(suite.T()) suite.site = tester.M365SiteID(suite.T()) + tester.LogTimeOfTest(suite.T()) } @@ -260,12 +259,10 @@ type ConnectorCreateSharePointCollectionIntegrationSuite struct { } func TestConnectorCreateSharePointCollectionIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoConnectorCreateSharePointCollectionTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoConnectorCreateSharePointCollectionTests) suite.Run(t, new(ConnectorCreateSharePointCollectionIntegrationSuite)) } @@ -274,10 +271,11 @@ func (suite *ConnectorCreateSharePointCollectionIntegrationSuite) SetupSuite() { ctx, flush := tester.NewContext() defer flush() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs) + suite.connector = loadConnector(ctx, suite.T(), Sites) suite.user = tester.M365UserID(suite.T()) + tester.LogTimeOfTest(suite.T()) } diff --git a/src/internal/connector/exchange/data_collections_test.go b/src/internal/connector/exchange/data_collections_test.go index 2fdc6b7d8..e8f09076d 100644 --- a/src/internal/connector/exchange/data_collections_test.go +++ b/src/internal/connector/exchange/data_collections_test.go @@ -209,19 +209,16 @@ type DataCollectionsIntegrationSuite struct { } func TestDataCollectionsIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoConnectorCreateExchangeCollectionTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoConnectorCreateExchangeCollectionTests) suite.Run(t, new(DataCollectionsIntegrationSuite)) } func (suite *DataCollectionsIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs) suite.user = tester.M365UserID(suite.T()) suite.site = tester.M365SiteID(suite.T()) diff --git a/src/internal/connector/exchange/exchange_service_test.go b/src/internal/connector/exchange/exchange_service_test.go index 353c326dc..c863de482 100644 --- a/src/internal/connector/exchange/exchange_service_test.go +++ b/src/internal/connector/exchange/exchange_service_test.go @@ -26,25 +26,20 @@ type ExchangeServiceSuite struct { } func TestExchangeServiceSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoGraphConnectorTests, - tester.CorsoGraphConnectorExchangeTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoGraphConnectorExchangeTests) suite.Run(t, new(ExchangeServiceSuite)) } func (suite *ExchangeServiceSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.M365AcctCredEnvs) a := tester.NewM365Account(t) - require.NoError(t, err) - m365, err := a.M365Config() require.NoError(t, err) diff --git a/src/internal/connector/exchange/folder_resolver_test.go b/src/internal/connector/exchange/folder_resolver_test.go index 23247d8be..95f2ee305 100644 --- a/src/internal/connector/exchange/folder_resolver_test.go +++ b/src/internal/connector/exchange/folder_resolver_test.go @@ -17,13 +17,11 @@ type CacheResolverSuite struct { } func TestCacheResolverIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoGraphConnectorTests, - tester.CorsoGraphConnectorExchangeTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoGraphConnectorExchangeTests) suite.Run(t, new(CacheResolverSuite)) } @@ -31,12 +29,9 @@ func TestCacheResolverIntegrationSuite(t *testing.T) { func (suite *CacheResolverSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.M365AcctCredEnvs) a := tester.NewM365Account(t) - require.NoError(t, err) - m365, err := a.M365Config() require.NoError(t, err) diff --git a/src/internal/connector/exchange/iterators_test.go b/src/internal/connector/exchange/iterators_test.go index e1a2cef0c..cf5c6115b 100644 --- a/src/internal/connector/exchange/iterators_test.go +++ b/src/internal/connector/exchange/iterators_test.go @@ -22,13 +22,11 @@ type ExchangeIteratorSuite struct { } func TestExchangeIteratorSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoGraphConnectorTests, - tester.CorsoGraphConnectorExchangeTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoGraphConnectorExchangeTests) suite.Run(t, new(ExchangeIteratorSuite)) } diff --git a/src/internal/connector/exchange/mail_folder_cache_test.go b/src/internal/connector/exchange/mail_folder_cache_test.go index b8a508d35..1d3c01e75 100644 --- a/src/internal/connector/exchange/mail_folder_cache_test.go +++ b/src/internal/connector/exchange/mail_folder_cache_test.go @@ -29,15 +29,22 @@ type MailFolderCacheIntegrationSuite struct { gs graph.Servicer } +func TestMailFolderCacheIntegrationSuite(t *testing.T) { + tester.RunOnAny( + t, + tester.CorsoCITests, + tester.CorsoGraphConnectorTests, + tester.CorsoGraphConnectorExchangeTests) + + suite.Run(t, new(MailFolderCacheIntegrationSuite)) +} + func (suite *MailFolderCacheIntegrationSuite) SetupSuite() { t := suite.T() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.M365AcctCredEnvs) a := tester.NewM365Account(t) - require.NoError(t, err) - m365, err := a.M365Config() require.NoError(t, err) @@ -47,18 +54,6 @@ func (suite *MailFolderCacheIntegrationSuite) SetupSuite() { suite.gs = service } -func TestMailFolderCacheIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( - tester.CorsoCITests, - tester.CorsoGraphConnectorTests, - tester.CorsoGraphConnectorExchangeTests, - ); err != nil { - t.Skip(err) - } - - suite.Run(t, new(MailFolderCacheIntegrationSuite)) -} - func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() { suite.T().Skipf("Test depends on hardcoded folder names. Skipping till that is fixed") diff --git a/src/internal/connector/graph_connector_test.go b/src/internal/connector/graph_connector_test.go index 47993dc37..c788ca07b 100644 --- a/src/internal/connector/graph_connector_test.go +++ b/src/internal/connector/graph_connector_test.go @@ -138,13 +138,11 @@ type GraphConnectorIntegrationSuite struct { } func TestGraphConnectorIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoGraphConnectorTests, - tester.CorsoGraphConnectorExchangeTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoGraphConnectorExchangeTests) suite.Run(t, new(GraphConnectorIntegrationSuite)) } @@ -153,10 +151,11 @@ func (suite *GraphConnectorIntegrationSuite) SetupSuite() { ctx, flush := tester.NewContext() defer flush() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs) + suite.connector = loadConnector(ctx, suite.T(), Users) suite.user = tester.M365UserID(suite.T()) + tester.LogTimeOfTest(suite.T()) } diff --git a/src/internal/connector/onedrive/drive_test.go b/src/internal/connector/onedrive/drive_test.go index 10934db26..34257a280 100644 --- a/src/internal/connector/onedrive/drive_test.go +++ b/src/internal/connector/onedrive/drive_test.go @@ -21,12 +21,10 @@ type OneDriveSuite struct { } func TestOneDriveDriveSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoOneDriveTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoOneDriveTests) suite.Run(t, new(OneDriveSuite)) } diff --git a/src/internal/connector/onedrive/item_test.go b/src/internal/connector/onedrive/item_test.go index 65425ac71..e423e65d9 100644 --- a/src/internal/connector/onedrive/item_test.go +++ b/src/internal/connector/onedrive/item_test.go @@ -35,13 +35,11 @@ func (suite *ItemIntegrationSuite) Adapter() *msgraphsdk.GraphRequestAdapter { } func TestItemIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoGraphConnectorTests, - tester.CorsoGraphConnectorOneDriveTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoGraphConnectorOneDriveTests) suite.Run(t, new(ItemIntegrationSuite)) } @@ -52,11 +50,9 @@ func (suite *ItemIntegrationSuite) SetupSuite() { ctx, flush := tester.NewContext() defer flush() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.M365AcctCredEnvs) a := tester.NewM365Account(t) - m365, err := a.M365Config() require.NoError(t, err) diff --git a/src/internal/connector/sharepoint/list_test.go b/src/internal/connector/sharepoint/list_test.go index cab1a190a..c798be368 100644 --- a/src/internal/connector/sharepoint/list_test.go +++ b/src/internal/connector/sharepoint/list_test.go @@ -26,13 +26,10 @@ func (suite *SharePointSuite) SetupSuite() { } func TestSharePointSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoGraphConnectorSharePointTests, - ); err != nil { - t.Skip(err) - } - + tester.CorsoGraphConnectorSharePointTests) suite.Run(t, new(SharePointSuite)) } diff --git a/src/internal/events/events_test.go b/src/internal/events/events_test.go index 8911c280a..80205d805 100644 --- a/src/internal/events/events_test.go +++ b/src/internal/events/events_test.go @@ -19,10 +19,7 @@ type EventsIntegrationSuite struct { } func TestMetricsIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoCITests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoCITests) suite.Run(t, new(EventsIntegrationSuite)) } diff --git a/src/internal/kopia/conn_test.go b/src/internal/kopia/conn_test.go index 4c8f48fbf..05ff5e110 100644 --- a/src/internal/kopia/conn_test.go +++ b/src/internal/kopia/conn_test.go @@ -59,19 +59,16 @@ type WrapperIntegrationSuite struct { } func TestWrapperIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoKopiaWrapperTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoKopiaWrapperTests) suite.Run(t, new(WrapperIntegrationSuite)) } func (suite *WrapperIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs) } func (suite *WrapperIntegrationSuite) TestRepoExistsError() { diff --git a/src/internal/kopia/model_store_test.go b/src/internal/kopia/model_store_test.go index 0847d2076..a984cd479 100644 --- a/src/internal/kopia/model_store_test.go +++ b/src/internal/kopia/model_store_test.go @@ -63,19 +63,16 @@ type ModelStoreIntegrationSuite struct { } func TestModelStoreIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoModelStoreTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoModelStoreTests) suite.Run(t, new(ModelStoreIntegrationSuite)) } func (suite *ModelStoreIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs) } func (suite *ModelStoreIntegrationSuite) SetupTest() { @@ -712,19 +709,16 @@ type ModelStoreRegressionSuite struct { } func TestModelStoreRegressionSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoModelStoreTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoModelStoreTests) suite.Run(t, new(ModelStoreRegressionSuite)) } func (suite *ModelStoreRegressionSuite) SetupSuite() { - _, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs) } // TODO(ashmrtn): Make a mock of whatever controls the handle to kopia so we can diff --git a/src/internal/kopia/wrapper_test.go b/src/internal/kopia/wrapper_test.go index 4027ec9f8..e650723b6 100644 --- a/src/internal/kopia/wrapper_test.go +++ b/src/internal/kopia/wrapper_test.go @@ -148,19 +148,16 @@ type KopiaIntegrationSuite struct { } func TestKopiaIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoKopiaWrapperTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoKopiaWrapperTests) suite.Run(t, new(KopiaIntegrationSuite)) } func (suite *KopiaIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs) tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory( testTenant, @@ -509,19 +506,16 @@ type KopiaSimpleRepoIntegrationSuite struct { } func TestKopiaSimpleRepoIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoKopiaWrapperTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoKopiaWrapperTests) suite.Run(t, new(KopiaSimpleRepoIntegrationSuite)) } func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs) tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory( testTenant, diff --git a/src/internal/operations/backup_integration_test.go b/src/internal/operations/backup_integration_test.go index 966365670..0b5ae12d1 100644 --- a/src/internal/operations/backup_integration_test.go +++ b/src/internal/operations/backup_integration_test.go @@ -437,22 +437,17 @@ type BackupOpIntegrationSuite struct { } func TestBackupOpIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, tester.CorsoOperationTests, - tester.CorsoOperationBackupTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoOperationBackupTests) suite.Run(t, new(BackupOpIntegrationSuite)) } func (suite *BackupOpIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) suite.user = tester.M365UserID(suite.T()) suite.site = tester.M365SiteID(suite.T()) diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index 5638a210c..8def6999c 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -133,12 +133,10 @@ type RestoreOpIntegrationSuite struct { } func TestRestoreOpIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoOperationTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoOperationTests) suite.Run(t, new(RestoreOpIntegrationSuite)) } @@ -147,8 +145,7 @@ func (suite *RestoreOpIntegrationSuite) SetupSuite() { ctx, flush := tester.NewContext() defer flush() - _, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs) t := suite.T() diff --git a/src/internal/streamstore/streamstore_test.go b/src/internal/streamstore/streamstore_test.go index 843a8ebe5..c3259606e 100644 --- a/src/internal/streamstore/streamstore_test.go +++ b/src/internal/streamstore/streamstore_test.go @@ -18,12 +18,7 @@ type StreamStoreIntegrationSuite struct { } func TestStreamStoreIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( - tester.CorsoCITests, - ); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoCITests) suite.Run(t, new(StreamStoreIntegrationSuite)) } diff --git a/src/internal/tester/envvars.go b/src/internal/tester/envvars.go deleted file mode 100644 index 9cf7b7fa1..000000000 --- a/src/internal/tester/envvars.go +++ /dev/null @@ -1,44 +0,0 @@ -package tester - -import ( - "errors" - "os" - - "golang.org/x/exp/maps" -) - -// GetRequiredEnvVars retrieves the provided env vars from the os. -// Retrieved values are populated into the resulting map. -// If any of the env values are zero length, returns an error. -func GetRequiredEnvVars(evs ...string) (map[string]string, error) { - vals := map[string]string{} - - for _, ev := range evs { - ge := os.Getenv(ev) - if len(ge) == 0 { - return nil, errors.New(ev + " env var required for test suite") - } - - vals[ev] = ge - } - - return vals, nil -} - -// GetRequiredEnvSls retrieves the provided env vars from the os. -// Retrieved values are populated into the resulting map. -// If any of the env values are zero length, returns an error. -func GetRequiredEnvSls(evs ...[]string) (map[string]string, error) { - vals := map[string]string{} - - for _, ev := range evs { - r, err := GetRequiredEnvVars(ev...) - if err != nil { - return nil, err - } - - maps.Copy(vals, r) - } - - return vals, nil -} diff --git a/src/internal/tester/envvars_test.go b/src/internal/tester/envvars_test.go deleted file mode 100644 index b5205bffa..000000000 --- a/src/internal/tester/envvars_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package tester - -import ( - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" -) - -type EnvvarsTestSuite struct { - suite.Suite -} - -func TestEnvvarsSuite(t *testing.T) { - suite.Run(t, new(EnvvarsTestSuite)) -} - -func (suite *EnvvarsTestSuite) TestRunOnAny() { - envVariable := "TEST_ENVVARS_SUITE" - os.Setenv(envVariable, "1") - - table := []struct { - name string - param string - function assert.ErrorAssertionFunc - }{ - { - name: "Valid Environment", - param: envVariable, - function: assert.NoError, - }, - { - name: "Invalid Environment", - param: "TEST_ENVVARS_SUITE_INVALID", - function: assert.Error, - }, - } - for _, test := range table { - suite.T().Run(test.name, func(t *testing.T) { - result := RunOnAny(test.param) - test.function(suite.T(), result) - }) - } - - os.Unsetenv(envVariable) -} diff --git a/src/internal/tester/integration_runners.go b/src/internal/tester/integration_runners.go index 536ddf13c..b1f3681ec 100644 --- a/src/internal/tester/integration_runners.go +++ b/src/internal/tester/integration_runners.go @@ -1,11 +1,13 @@ package tester import ( - "fmt" "os" "strings" "testing" "time" + + "github.com/stretchr/testify/require" + "golang.org/x/exp/maps" ) const ( @@ -40,19 +42,17 @@ const CorsoGraphConnectorTestSupportFile = "CORSO_TEST_SUPPORT_FILE" // an error if all of them are zero valued. Implication being: // if any of those env vars are truthy, you should run the // subsequent tests. -func RunOnAny(tests ...string) error { +func RunOnAny(t *testing.T, tests ...string) { var l int for _, test := range tests { l += len(os.Getenv(test)) } if l == 0 { - return fmt.Errorf( - "%s env vars are not flagged for testing", + t.Skipf( + "one or more env vars mus be flagged to run this test: %v", strings.Join(tests, ", ")) } - - return nil } // LogTimeOfTest logs the test name and the time that it was run. @@ -69,3 +69,33 @@ func LogTimeOfTest(t *testing.T) string { return now } + +// MustGetEnvVars retrieves the provided env vars from the os. +// Retrieved values are populated into the resulting map. +// If any of the env values are zero length, the test errors. +func MustGetEnvVars(t *testing.T, evs ...string) map[string]string { + vals := map[string]string{} + + for _, ev := range evs { + ge := os.Getenv(ev) + require.NotEmpty(t, ev, ev+" env var required for test suite") + + vals[ev] = ge + } + + return vals +} + +// MustGetEnvSls retrieves the provided env vars from the os. +// Retrieved values are populated into the resulting map. +// If any of the env values are zero length, the test errors. +func MustGetEnvSets(t *testing.T, evs ...[]string) map[string]string { + vals := map[string]string{} + + for _, ev := range evs { + r := MustGetEnvVars(t, ev...) + maps.Copy(vals, r) + } + + return vals +} diff --git a/src/pkg/repository/repository_load_test.go b/src/pkg/repository/repository_load_test.go index 3b4053a70..5647ead95 100644 --- a/src/pkg/repository/repository_load_test.go +++ b/src/pkg/repository/repository_load_test.go @@ -48,24 +48,23 @@ func singleUserSet(t *testing.T) []string { var loadCtx context.Context func TestMain(m *testing.M) { - ctx, logFlush := tester.NewContext() - loadCtx = ctx - flush := func() { - logFlush() + if len(os.Getenv(tester.CorsoLoadTests)) == 0 { + return } - if err := tester.RunOnAny(tester.CorsoLoadTests); err == nil { - if err := D.InitCollector(); err != nil { - fmt.Println("initializing load tests:", err) - os.Exit(1) - } + ctx, logFlush := tester.NewContext() + loadCtx = ctx - ctx, spanFlush := D.Start(ctx, "Load_Testing_Main") - loadCtx = ctx - flush = func() { - spanFlush() - logFlush() - } + if err := D.InitCollector(); err != nil { + fmt.Println("initializing load tests:", err) + os.Exit(1) + } + + ctx, spanFlush := D.Start(ctx, "Load_Testing_Main") + loadCtx = ctx + flush := func() { + spanFlush() + logFlush() } exitVal := m.Run() @@ -80,13 +79,12 @@ func TestMain(m *testing.M) { // ------------------------------------------------------------------------------------------------ func initM365Repo(t *testing.T) ( - context.Context, repository.Repository, account.Account, storage.Storage, + context.Context, + repository.Repository, + account.Account, + storage.Storage, ) { - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs, - ) - require.NoError(t, err) + tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) ctx, flush := tester.WithContext(loadCtx) defer flush() @@ -378,10 +376,7 @@ type RepositoryLoadTestExchangeSuite struct { } func TestRepositoryLoadTestExchangeSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoLoadTests) suite.Run(t, new(RepositoryLoadTestExchangeSuite)) } @@ -428,10 +423,7 @@ type RepositoryIndividualLoadTestExchangeSuite struct { } func TestRepositoryIndividualLoadTestExchangeSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoLoadTests) suite.Run(t, new(RepositoryIndividualLoadTestExchangeSuite)) } @@ -481,10 +473,7 @@ type RepositoryLoadTestOneDriveSuite struct { } func TestRepositoryLoadTestOneDriveSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoLoadTests) suite.Run(t, new(RepositoryLoadTestOneDriveSuite)) } @@ -528,10 +517,7 @@ type RepositoryIndividualLoadTestOneDriveSuite struct { } func TestRepositoryIndividualLoadTestOneDriveSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoLoadTests) suite.Run(t, new(RepositoryIndividualLoadTestOneDriveSuite)) } @@ -579,10 +565,7 @@ type RepositoryLoadTestSharePointSuite struct { } func TestRepositoryLoadTestSharePointSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoLoadTests) suite.Run(t, new(RepositoryLoadTestSharePointSuite)) } @@ -626,10 +609,7 @@ type RepositoryIndividualLoadTestSharePointSuite struct { } func TestRepositoryIndividualLoadTestSharePointSuite(t *testing.T) { - if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoLoadTests) suite.Run(t, new(RepositoryIndividualLoadTestOneDriveSuite)) } diff --git a/src/pkg/repository/repository_test.go b/src/pkg/repository/repository_test.go index eff7b0816..132e9f76f 100644 --- a/src/pkg/repository/repository_test.go +++ b/src/pkg/repository/repository_test.go @@ -96,22 +96,17 @@ type RepositoryIntegrationSuite struct { } func TestRepositoryIntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoRepositoryTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoRepositoryTests) suite.Run(t, new(RepositoryIntegrationSuite)) } // ensure all required env values are populated func (suite *RepositoryIntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) } func (suite *RepositoryIntegrationSuite) TestInitialize() { diff --git a/src/pkg/repository/repository_unexported_test.go b/src/pkg/repository/repository_unexported_test.go index 409955bde..8d06f259d 100644 --- a/src/pkg/repository/repository_unexported_test.go +++ b/src/pkg/repository/repository_unexported_test.go @@ -16,22 +16,17 @@ type RepositoryModelSuite struct { } func TestRepositoryModelSuite(t *testing.T) { - if err := tester.RunOnAny( + tester.RunOnAny( + t, tester.CorsoCITests, - tester.CorsoRepositoryTests, - ); err != nil { - t.Skip(err) - } + tester.CorsoRepositoryTests) suite.Run(t, new(RepositoryModelSuite)) } // ensure all required env values are populated func (suite *RepositoryModelSuite) SetupSuite() { - _, err := tester.GetRequiredEnvSls( - tester.AWSStorageCredEnvs, - tester.M365AcctCredEnvs) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs) } func (suite *RepositoryModelSuite) TestWriteGetModel() { diff --git a/src/pkg/services/m365/m365_test.go b/src/pkg/services/m365/m365_test.go index 8bea6f707..0441251d0 100644 --- a/src/pkg/services/m365/m365_test.go +++ b/src/pkg/services/m365/m365_test.go @@ -15,19 +15,12 @@ type M365IntegrationSuite struct { } func TestM365IntegrationSuite(t *testing.T) { - if err := tester.RunOnAny( - tester.CorsoCITests, - ); err != nil { - t.Skip(err) - } - + tester.RunOnAny(t, tester.CorsoCITests) suite.Run(t, new(M365IntegrationSuite)) } func (suite *M365IntegrationSuite) SetupSuite() { - _, err := tester.GetRequiredEnvSls( - tester.M365AcctCredEnvs) - require.NoError(suite.T(), err) + tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs) } func (suite *M365IntegrationSuite) TestUsers() {