From 16022ef4171e7dccf2932ae6e8d451b51c93291c Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 20 Oct 2023 15:01:27 +0200 Subject: [PATCH] chore: Set up a single warehouse for the SDK integration tests (#2141) * WH: Prepare common warehouse for integration tests * WH: Use created warehouse in almost every test --- pkg/sdk/testint/alerts_integration_test.go | 45 +++++++------------ pkg/sdk/testint/comments_integration_test.go | 7 +-- .../context_functions_integration_test.go | 1 + .../conversion_functions_integration_test.go | 2 + .../testint/dynamic_table_integration_test.go | 10 ++--- .../external_tables_integration_test.go | 4 +- pkg/sdk/testint/grants_integration_test.go | 5 +-- pkg/sdk/testint/helpers_test.go | 8 ++-- pkg/sdk/testint/sessions_integration_test.go | 32 +++++++------ pkg/sdk/testint/setup_integration_test.go | 35 +++++++++++++-- pkg/sdk/testint/tasks_gen_integration_test.go | 7 +-- .../testint/warehouses_integration_test.go | 12 +++++ 12 files changed, 93 insertions(+), 75 deletions(-) diff --git a/pkg/sdk/testint/alerts_integration_test.go b/pkg/sdk/testint/alerts_integration_test.go index d12dbdf839..3d7c8ad6ce 100644 --- a/pkg/sdk/testint/alerts_integration_test.go +++ b/pkg/sdk/testint/alerts_integration_test.go @@ -14,13 +14,10 @@ func TestInt_AlertsShow(t *testing.T) { client := testClient(t) ctx := testContext(t) - testWarehouse, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - - alertTest, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse) + alertTest, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) t.Cleanup(alertCleanup) - alert2Test, alert2Cleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse) + alert2Test, alert2Cleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) t.Cleanup(alert2Cleanup) t.Run("without show options", func(t *testing.T) { @@ -85,9 +82,6 @@ func TestInt_AlertCreate(t *testing.T) { client := testClient(t) ctx := testContext(t) - testWarehouse, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - t.Run("test complete case", func(t *testing.T) { name := random.String() schedule := "USING CRON * * * * TUE,THU UTC" @@ -95,7 +89,7 @@ func TestInt_AlertCreate(t *testing.T) { action := "SELECT 1" comment := random.Comment() id := sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name) - err := client.Alerts.Create(ctx, id, testWarehouse.ID(), schedule, condition, action, &sdk.CreateAlertOptions{ + err := client.Alerts.Create(ctx, id, testWarehouse(t).ID(), schedule, condition, action, &sdk.CreateAlertOptions{ OrReplace: sdk.Bool(true), IfNotExists: sdk.Bool(false), Comment: sdk.String(comment), @@ -104,7 +98,7 @@ func TestInt_AlertCreate(t *testing.T) { alertDetails, err := client.Alerts.Describe(ctx, id) require.NoError(t, err) assert.Equal(t, name, alertDetails.Name) - assert.Equal(t, testWarehouse.Name, alertDetails.Warehouse) + assert.Equal(t, testWarehouse(t).Name, alertDetails.Warehouse) assert.Equal(t, schedule, alertDetails.Schedule) assert.Equal(t, comment, *alertDetails.Comment) assert.Equal(t, condition, alertDetails.Condition) @@ -131,7 +125,7 @@ func TestInt_AlertCreate(t *testing.T) { action := "SELECT 1" comment := random.Comment() id := sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name) - err := client.Alerts.Create(ctx, id, testWarehouse.ID(), schedule, condition, action, &sdk.CreateAlertOptions{ + err := client.Alerts.Create(ctx, id, testWarehouse(t).ID(), schedule, condition, action, &sdk.CreateAlertOptions{ OrReplace: sdk.Bool(false), IfNotExists: sdk.Bool(true), Comment: sdk.String(comment), @@ -140,7 +134,7 @@ func TestInt_AlertCreate(t *testing.T) { alertDetails, err := client.Alerts.Describe(ctx, id) require.NoError(t, err) assert.Equal(t, name, alertDetails.Name) - assert.Equal(t, testWarehouse.Name, alertDetails.Warehouse) + assert.Equal(t, testWarehouse(t).Name, alertDetails.Warehouse) assert.Equal(t, schedule, alertDetails.Schedule) assert.Equal(t, comment, *alertDetails.Comment) assert.Equal(t, condition, alertDetails.Condition) @@ -166,12 +160,12 @@ func TestInt_AlertCreate(t *testing.T) { condition := "SELECT 1" action := "SELECT 1" id := sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name) - err := client.Alerts.Create(ctx, id, testWarehouse.ID(), schedule, condition, action, nil) + err := client.Alerts.Create(ctx, id, testWarehouse(t).ID(), schedule, condition, action, nil) require.NoError(t, err) alertDetails, err := client.Alerts.Describe(ctx, id) require.NoError(t, err) assert.Equal(t, name, alertDetails.Name) - assert.Equal(t, testWarehouse.Name, alertDetails.Warehouse) + assert.Equal(t, testWarehouse(t).Name, alertDetails.Warehouse) assert.Equal(t, schedule, alertDetails.Schedule) assert.Equal(t, condition, alertDetails.Condition) assert.Equal(t, action, alertDetails.Action) @@ -204,12 +198,12 @@ func TestInt_AlertCreate(t *testing.T) { end ` id := sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name) - err := client.Alerts.Create(ctx, id, testWarehouse.ID(), schedule, condition, action, nil) + err := client.Alerts.Create(ctx, id, testWarehouse(t).ID(), schedule, condition, action, nil) require.NoError(t, err) alertDetails, err := client.Alerts.Describe(ctx, id) require.NoError(t, err) assert.Equal(t, name, alertDetails.Name) - assert.Equal(t, testWarehouse.Name, alertDetails.Warehouse) + assert.Equal(t, testWarehouse(t).Name, alertDetails.Warehouse) assert.Equal(t, schedule, alertDetails.Schedule) assert.Equal(t, condition, alertDetails.Condition) assert.Equal(t, strings.TrimSpace(action), alertDetails.Action) @@ -233,10 +227,7 @@ func TestInt_AlertDescribe(t *testing.T) { client := testClient(t) ctx := testContext(t) - warehouseTest, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - - alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), warehouseTest) + alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) t.Cleanup(alertCleanup) t.Run("when alert exists", func(t *testing.T) { @@ -256,11 +247,8 @@ func TestInt_AlertAlter(t *testing.T) { client := testClient(t) ctx := testContext(t) - warehouseTest, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - t.Run("when setting and unsetting a value", func(t *testing.T) { - alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), warehouseTest) + alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) t.Cleanup(alertCleanup) newSchedule := "USING CRON * * * * TUE,FRI GMT" @@ -286,7 +274,7 @@ func TestInt_AlertAlter(t *testing.T) { }) t.Run("when modifying condition and action", func(t *testing.T) { - alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), warehouseTest) + alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) t.Cleanup(alertCleanup) newCondition := "select * from DUAL where false" @@ -330,7 +318,7 @@ func TestInt_AlertAlter(t *testing.T) { }) t.Run("resume and then suspend", func(t *testing.T) { - alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), warehouseTest) + alert, alertCleanup := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) t.Cleanup(alertCleanup) alterOptions := &sdk.AlterAlertOptions{ @@ -375,11 +363,8 @@ func TestInt_AlertDrop(t *testing.T) { client := testClient(t) ctx := testContext(t) - warehouseTest, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - t.Run("when alert exists", func(t *testing.T) { - alert, _ := createAlert(t, client, testDb(t), testSchema(t), warehouseTest) + alert, _ := createAlert(t, client, testDb(t), testSchema(t), testWarehouse(t)) id := alert.ID() err := client.Alerts.Drop(ctx, id) require.NoError(t, err) diff --git a/pkg/sdk/testint/comments_integration_test.go b/pkg/sdk/testint/comments_integration_test.go index 6c5b29d0b5..18afc97d52 100644 --- a/pkg/sdk/testint/comments_integration_test.go +++ b/pkg/sdk/testint/comments_integration_test.go @@ -13,18 +13,15 @@ func TestInt_Comment(t *testing.T) { client := testClient(t) ctx := testContext(t) - testWarehouse, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - t.Run("set", func(t *testing.T) { comment := random.Comment() err := client.Comments.Set(ctx, &sdk.SetCommentOptions{ ObjectType: sdk.ObjectTypeWarehouse, - ObjectName: testWarehouse.ID(), + ObjectName: testWarehouse(t).ID(), Value: sdk.String(comment), }) require.NoError(t, err) - wh, err := client.Warehouses.ShowByID(ctx, testWarehouse.ID()) + wh, err := client.Warehouses.ShowByID(ctx, testWarehouse(t).ID()) require.NoError(t, err) assert.Equal(t, comment, wh.Comment) }) diff --git a/pkg/sdk/testint/context_functions_integration_test.go b/pkg/sdk/testint/context_functions_integration_test.go index aa5b130cc5..12906bae8c 100644 --- a/pkg/sdk/testint/context_functions_integration_test.go +++ b/pkg/sdk/testint/context_functions_integration_test.go @@ -81,6 +81,7 @@ func TestInt_CurrentWarehouse(t *testing.T) { client := testClient(t) ctx := testContext(t) + // new warehouse created on purpose warehouseTest, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) err := client.Sessions.UseWarehouse(ctx, warehouseTest.ID()) diff --git a/pkg/sdk/testint/conversion_functions_integration_test.go b/pkg/sdk/testint/conversion_functions_integration_test.go index 7192a94160..303e25e4bb 100644 --- a/pkg/sdk/testint/conversion_functions_integration_test.go +++ b/pkg/sdk/testint/conversion_functions_integration_test.go @@ -36,6 +36,7 @@ func TestInt_ToTimestampLTZ(t *testing.T) { }) require.NoError(t, err) }) + // new warehouse created on purpose warehouseTest, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) err = client.Sessions.UseWarehouse(ctx, warehouseTest.ID()) @@ -74,6 +75,7 @@ func TestInt_ToTimestampNTZ(t *testing.T) { }) require.NoError(t, err) }) + // new warehouse created on purpose warehouseTest, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) err = client.Sessions.UseWarehouse(ctx, warehouseTest.ID()) diff --git a/pkg/sdk/testint/dynamic_table_integration_test.go b/pkg/sdk/testint/dynamic_table_integration_test.go index cd8ec42227..0c6edea858 100644 --- a/pkg/sdk/testint/dynamic_table_integration_test.go +++ b/pkg/sdk/testint/dynamic_table_integration_test.go @@ -13,8 +13,6 @@ import ( func TestInt_DynamicTableCreateAndDrop(t *testing.T) { client := testClient(t) - warehouseTest, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) tableTest, tableCleanup := createTable(t, client, testDb(t), testSchema(t)) t.Cleanup(tableCleanup) @@ -26,7 +24,7 @@ func TestInt_DynamicTableCreateAndDrop(t *testing.T) { } query := "select id from " + tableTest.ID().FullyQualifiedName() comment := random.Comment() - err := client.DynamicTables.Create(ctx, sdk.NewCreateDynamicTableRequest(name, warehouseTest.ID(), targetLag, query).WithOrReplace(true).WithComment(&comment)) + err := client.DynamicTables.Create(ctx, sdk.NewCreateDynamicTableRequest(name, testWarehouse(t).ID(), targetLag, query).WithOrReplace(true).WithComment(&comment)) require.NoError(t, err) t.Cleanup(func() { err = client.DynamicTables.Drop(ctx, sdk.NewDropDynamicTableRequest(name)) @@ -38,7 +36,7 @@ func TestInt_DynamicTableCreateAndDrop(t *testing.T) { entity := entities[0] require.Equal(t, name.Name(), entity.Name) - require.Equal(t, warehouseTest.ID().Name(), entity.Warehouse) + require.Equal(t, testWarehouse(t).ID().Name(), entity.Warehouse) require.Equal(t, *targetLag.MaximumDuration, entity.TargetLag) }) @@ -49,7 +47,7 @@ func TestInt_DynamicTableCreateAndDrop(t *testing.T) { } query := "select id from " + tableTest.ID().FullyQualifiedName() comment := random.Comment() - err := client.DynamicTables.Create(ctx, sdk.NewCreateDynamicTableRequest(name, warehouseTest.ID(), targetLag, query).WithOrReplace(true).WithComment(&comment)) + err := client.DynamicTables.Create(ctx, sdk.NewCreateDynamicTableRequest(name, testWarehouse(t).ID(), targetLag, query).WithOrReplace(true).WithComment(&comment)) require.NoError(t, err) t.Cleanup(func() { err = client.DynamicTables.Drop(ctx, sdk.NewDropDynamicTableRequest(name)) @@ -61,7 +59,7 @@ func TestInt_DynamicTableCreateAndDrop(t *testing.T) { entity := entities[0] require.Equal(t, name.Name(), entity.Name) - require.Equal(t, warehouseTest.ID().Name(), entity.Warehouse) + require.Equal(t, testWarehouse(t).ID().Name(), entity.Warehouse) require.Equal(t, "DOWNSTREAM", entity.TargetLag) }) } diff --git a/pkg/sdk/testint/external_tables_integration_test.go b/pkg/sdk/testint/external_tables_integration_test.go index 13ef6d55ac..a3eb9e639b 100644 --- a/pkg/sdk/testint/external_tables_integration_test.go +++ b/pkg/sdk/testint/external_tables_integration_test.go @@ -99,10 +99,8 @@ func TestInt_ExternalTables(t *testing.T) { t.Run("Create: infer schema", func(t *testing.T) { fileFormat, _ := createFileFormat(t, client, testSchema(t).ID()) - warehouse, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - err := client.Sessions.UseWarehouse(ctx, warehouse.ID()) + err := client.Sessions.UseWarehouse(ctx, testWarehouse(t).ID()) require.NoError(t, err) name := random.AlphanumericN(32) diff --git a/pkg/sdk/testint/grants_integration_test.go b/pkg/sdk/testint/grants_integration_test.go index e550f1d791..a4c6cb7063 100644 --- a/pkg/sdk/testint/grants_integration_test.go +++ b/pkg/sdk/testint/grants_integration_test.go @@ -544,9 +544,6 @@ func TestInt_GrantOwnership(t *testing.T) { }) t.Run("on account level object to role", func(t *testing.T) { - warehouse, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - // role is deliberately created after warehouse, so that cleanup is done in reverse // because after ownership grant we lose privilege to drop object // with first dropping the role, we reacquire rights to do it - a little hacky trick @@ -557,7 +554,7 @@ func TestInt_GrantOwnership(t *testing.T) { on := sdk.OwnershipGrantOn{ Object: &sdk.Object{ ObjectType: sdk.ObjectTypeWarehouse, - Name: warehouse.ID(), + Name: testWarehouse(t).ID(), }, } to := sdk.OwnershipGrantTo{ diff --git a/pkg/sdk/testint/helpers_test.go b/pkg/sdk/testint/helpers_test.go index ce25e7f157..97bd3fbb44 100644 --- a/pkg/sdk/testint/helpers_test.go +++ b/pkg/sdk/testint/helpers_test.go @@ -66,12 +66,10 @@ func testClientFromProfile(t *testing.T, profile string) (*sdk.Client, error) { func useWarehouse(t *testing.T, client *sdk.Client, warehouseID sdk.AccountObjectIdentifier) func() { t.Helper() ctx := context.Background() - orgWarehouse, err := client.ContextFunctions.CurrentWarehouse(ctx) - require.NoError(t, err) - err = client.Sessions.UseWarehouse(ctx, warehouseID) + err := client.Sessions.UseWarehouse(ctx, warehouseID) require.NoError(t, err) return func() { - err := client.Sessions.UseWarehouse(ctx, sdk.NewAccountObjectIdentifier(orgWarehouse)) + err = client.Sessions.UseWarehouse(ctx, testWarehouse(t).ID()) require.NoError(t, err) } } @@ -137,6 +135,8 @@ func createWarehouseWithOptions(t *testing.T, client *sdk.Client, opts *sdk.Crea }, func() { err := client.Warehouses.Drop(ctx, id, nil) require.NoError(t, err) + err = client.Sessions.UseWarehouse(ctx, testWarehouse(t).ID()) + require.NoError(t, err) } } diff --git a/pkg/sdk/testint/sessions_integration_test.go b/pkg/sdk/testint/sessions_integration_test.go index fa7c283503..f14211fac4 100644 --- a/pkg/sdk/testint/sessions_integration_test.go +++ b/pkg/sdk/testint/sessions_integration_test.go @@ -99,23 +99,19 @@ func TestInt_ShowUserParameter(t *testing.T) { func TestInt_UseWarehouse(t *testing.T) { client := testClient(t) ctx := testContext(t) - originalWH, err := client.ContextFunctions.CurrentWarehouse(ctx) - require.NoError(t, err) + t.Cleanup(func() { - originalWHIdentifier := sdk.NewAccountObjectIdentifier(originalWH) - if !sdk.ValidObjectIdentifier(originalWHIdentifier) { - return - } - err := client.Sessions.UseWarehouse(ctx, originalWHIdentifier) + err := client.Sessions.UseWarehouse(ctx, testWarehouse(t).ID()) require.NoError(t, err) }) - warehouseTest, warehouseCleanup := createWarehouse(t, client) + // new warehouse created on purpose + warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) - err = client.Sessions.UseWarehouse(ctx, warehouseTest.ID()) + err := client.Sessions.UseWarehouse(ctx, warehouse.ID()) require.NoError(t, err) actual, err := client.ContextFunctions.CurrentWarehouse(ctx) require.NoError(t, err) - expected := warehouseTest.Name + expected := warehouse.Name assert.Equal(t, expected, actual) } @@ -127,11 +123,14 @@ func TestInt_UseDatabase(t *testing.T) { err := client.Sessions.UseSchema(ctx, testSchema(t).ID()) require.NoError(t, err) }) - err := client.Sessions.UseDatabase(ctx, testDb(t).ID()) + // new database created on purpose + database, databaseCleanup := createDatabase(t, client) + t.Cleanup(databaseCleanup) + err := client.Sessions.UseDatabase(ctx, database.ID()) require.NoError(t, err) actual, err := client.ContextFunctions.CurrentDatabase(ctx) require.NoError(t, err) - expected := testDb(t).Name + expected := database.Name assert.Equal(t, expected, actual) } @@ -143,10 +142,15 @@ func TestInt_UseSchema(t *testing.T) { err := client.Sessions.UseSchema(ctx, testSchema(t).ID()) require.NoError(t, err) }) - err := client.Sessions.UseSchema(ctx, testSchema(t).ID()) + // new database and schema created on purpose + database, databaseCleanup := createDatabase(t, client) + t.Cleanup(databaseCleanup) + schema, schemaCleanup := createSchema(t, client, database) + t.Cleanup(schemaCleanup) + err := client.Sessions.UseSchema(ctx, schema.ID()) require.NoError(t, err) actual, err := client.ContextFunctions.CurrentSchema(ctx) require.NoError(t, err) - expected := testSchema(t).Name + expected := schema.Name assert.Equal(t, expected, actual) } diff --git a/pkg/sdk/testint/setup_integration_test.go b/pkg/sdk/testint/setup_integration_test.go index 8a99eb484d..4508bfdbc9 100644 --- a/pkg/sdk/testint/setup_integration_test.go +++ b/pkg/sdk/testint/setup_integration_test.go @@ -51,10 +51,12 @@ type integrationTestContext struct { client *sdk.Client ctx context.Context - database *sdk.Database - databaseCleanup func() - schema *sdk.Schema - schemaCleanup func() + database *sdk.Database + databaseCleanup func() + schema *sdk.Schema + schemaCleanup func() + warehouse *sdk.Warehouse + warehouseCleanup func() } func (itc *integrationTestContext) initialize() error { @@ -81,6 +83,13 @@ func (itc *integrationTestContext) initialize() error { itc.schema = sc itc.schemaCleanup = scCleanup + wh, whCleanup, err := createWh(itc.client, itc.ctx) + if err != nil { + return err + } + itc.warehouse = wh + itc.warehouseCleanup = whCleanup + return nil } @@ -110,6 +119,19 @@ func createSc(client *sdk.Client, ctx context.Context, db *sdk.Database) (*sdk.S }, err } +func createWh(client *sdk.Client, ctx context.Context) (*sdk.Warehouse, func(), error) { + name := "int_test_wh_" + random.UUID() + id := sdk.NewAccountObjectIdentifier(name) + err := client.Warehouses.Create(ctx, id, nil) + if err != nil { + return nil, nil, err + } + warehouse, err := client.Warehouses.ShowByID(ctx, id) + return warehouse, func() { + _ = client.Warehouses.Drop(ctx, id, nil) + }, err +} + // timer measures time from invocation point to the end of method. // It's supposed to be used like: // @@ -140,3 +162,8 @@ func testSchema(t *testing.T) *sdk.Schema { t.Helper() return itc.schema } + +func testWarehouse(t *testing.T) *sdk.Warehouse { + t.Helper() + return itc.warehouse +} diff --git a/pkg/sdk/testint/tasks_gen_integration_test.go b/pkg/sdk/testint/tasks_gen_integration_test.go index d03415764f..f6dd6d9e5e 100644 --- a/pkg/sdk/testint/tasks_gen_integration_test.go +++ b/pkg/sdk/testint/tasks_gen_integration_test.go @@ -149,12 +149,9 @@ func TestInt_Tasks(t *testing.T) { }) t.Run("create task: almost complete case", func(t *testing.T) { - warehouse, warehouseCleanup := createWarehouse(t, client) - t.Cleanup(warehouseCleanup) - request := createTaskBasicRequest(t). WithOrReplace(sdk.Bool(true)). - WithWarehouse(sdk.NewCreateTaskWarehouseRequest().WithWarehouse(sdk.Pointer(warehouse.ID()))). + WithWarehouse(sdk.NewCreateTaskWarehouseRequest().WithWarehouse(sdk.Pointer(testWarehouse(t).ID()))). WithSchedule(sdk.String("10 MINUTE")). WithConfig(sdk.String(`$${"output_dir": "/temp/test_directory/", "learning_rate": 0.1}$$`)). WithAllowOverlappingExecution(sdk.Bool(true)). @@ -169,7 +166,7 @@ func TestInt_Tasks(t *testing.T) { task := createTaskWithRequest(t, request) - assertTaskWithOptions(t, task, id, "some comment", warehouse.Name, "10 MINUTE", `SYSTEM$STREAM_HAS_DATA('MYSTREAM')`, true, `{"output_dir": "/temp/test_directory/", "learning_rate": 0.1}`, nil) + assertTaskWithOptions(t, task, id, "some comment", testWarehouse(t).Name, "10 MINUTE", `SYSTEM$STREAM_HAS_DATA('MYSTREAM')`, true, `{"output_dir": "/temp/test_directory/", "learning_rate": 0.1}`, nil) }) t.Run("create task: with after", func(t *testing.T) { diff --git a/pkg/sdk/testint/warehouses_integration_test.go b/pkg/sdk/testint/warehouses_integration_test.go index e852bdd909..4b96d45283 100644 --- a/pkg/sdk/testint/warehouses_integration_test.go +++ b/pkg/sdk/testint/warehouses_integration_test.go @@ -13,6 +13,7 @@ func TestInt_WarehousesShow(t *testing.T) { client := testClient(t) ctx := testContext(t) + // new warehouses created on purpose testWarehouse, warehouseCleanup := createWarehouseWithOptions(t, client, &sdk.CreateWarehouseOptions{ WarehouseSize: &sdk.WarehouseSizeSmall, }) @@ -161,6 +162,7 @@ func TestInt_WarehouseDescribe(t *testing.T) { client := testClient(t) ctx := testContext(t) + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -246,6 +248,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("set", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -272,6 +275,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("rename", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) oldID := warehouse.ID() t.Cleanup(warehouseCleanup) @@ -299,6 +303,7 @@ func TestInt_WarehouseAlter(t *testing.T) { Comment: sdk.String("test comment"), MaxClusterCount: sdk.Int(10), } + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouseWithOptions(t, client, createOptions) t.Cleanup(warehouseCleanup) id := warehouse.ID() @@ -325,6 +330,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("suspend & resume", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -360,6 +366,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("resume without suspending", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -381,6 +388,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("abort all queries", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -427,6 +435,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("set tags", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -456,6 +465,7 @@ func TestInt_WarehouseAlter(t *testing.T) { }) t.Run("unset tags", func(t *testing.T) { + // new warehouse created on purpose warehouse, warehouseCleanup := createWarehouse(t, client) t.Cleanup(warehouseCleanup) @@ -507,6 +517,7 @@ func TestInt_WarehouseDrop(t *testing.T) { ctx := testContext(t) t.Run("when warehouse exists", func(t *testing.T) { + // new warehouse created on purpose warehouse, _ := createWarehouse(t, client) err := client.Warehouses.Drop(ctx, warehouse.ID(), nil) @@ -522,6 +533,7 @@ func TestInt_WarehouseDrop(t *testing.T) { }) t.Run("when warehouse exists and if exists is true", func(t *testing.T) { + // new warehouse created on purpose warehouse, _ := createWarehouse(t, client) dropOptions := &sdk.DropWarehouseOptions{IfExists: sdk.Bool(true)}