-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Task resource v1 readiness #3113
feat: Task resource v1 readiness #3113
Conversation
Integration tests failure for 28bf6a5cb6a95fa2d9cb42a558710bb4ad08ee58 |
Integration tests failure for 62adccb771be11faeea226dd4b4b4c29fcea2833 |
func (t *TaskResourceAssert) HasAfterIds(ids ...sdk.SchemaObjectIdentifier) *TaskResourceAssert { | ||
t.AddAssertion(assert.ValueSet("after.#", strconv.FormatInt(int64(len(ids)), 10))) | ||
for i, id := range ids { | ||
t.AddAssertion(assert.ValueSet(fmt.Sprintf("after.%d", i), id.FullyQualifiedName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order shouldn't matter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHouldn't because the assertion does not have InOrder in name or because Snowflake ordering for alter in non-deterministic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but that should be resolved in newly added TODO for asserts to generate or create a helper for creating asserts for list with non-deterministic order. Right now, this one work (despite being reliant on order) and I would leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's at least add InOrder suffix to the name of the function then (may be added in the next PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we discussed this in one of the previous PRs. Snowflake does not guarantee item order, so in general we should compare ID collections, not one by one. For cases where the order matters, we should add a comment about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in: For now, renamed to have InOrder suffix, the limitation of order was added to assert improvements some time ago (it should be in main or in this pr.)
pkg/acceptance/bettertestspoc/assert/resourceassert/task_resource_ext.go
Outdated
Show resolved
Hide resolved
pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go
Show resolved
Hide resolved
pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go
Show resolved
Hide resolved
pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go
Show resolved
Hide resolved
HasSuspendTaskAfterNumFailuresString("2"), | ||
resourceshowoutputassert.TaskShowOutput(t, rootTaskModel.ResourceReference()). | ||
HasSchedule(schedule). | ||
// HasTaskRelations(sdk.TaskRelations{FinalizerTask: &finalizerTaskId}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about these comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm missed them somehow. Uncommented + added asserts to the rest of the steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left TODO for the next pr to analyze this more in-depth. For now, I don't see why it's not there. I'll take a look if that's a mapping or Snowflake issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a short analysis, It seems like a bug in Snowflake. For now, I removed this assert and added an entry in our doc about Snowflake improvements. I'll fill it later.
expectedTaskConfig := strings.ReplaceAll(taskConfig, "$", "") | ||
taskConfigVariableValue := "$" + taskConfig | ||
comment := random.Comment() | ||
condition := `SYSTEM$STREAM_HAS_DATA('MYSTREAM')` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have some test cases for different spaces and new lines for fields with SQL statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, in upcoming tests I also wanted to add tests for different kinds of things in as
body. I'll link this comment in the desc and apply when testing other as
options.
HasConfig(expectedTaskConfig). | ||
HasBudget(""). | ||
HasTaskRelations(sdk.TaskRelations{}), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls add a test case with external changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test cases for Finalize and After fields, added TODO for next pr to see what also could be tested
pkg/acceptance/bettertestspoc/assert/objectassert/task_snowflake_gen.go
Outdated
Show resolved
Hide resolved
pkg/acceptance/bettertestspoc/assert/objectparametersassert/task_parameters_snowflake_gen.go
Show resolved
Hide resolved
func (t *TaskResourceAssert) HasAfterIds(ids ...sdk.SchemaObjectIdentifier) *TaskResourceAssert { | ||
t.AddAssertion(assert.ValueSet("after.#", strconv.FormatInt(int64(len(ids)), 10))) | ||
for i, id := range ids { | ||
t.AddAssertion(assert.ValueSet(fmt.Sprintf("after.%d", i), id.FullyQualifiedName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHouldn't because the assertion does not have InOrder in name or because Snowflake ordering for alter in non-deterministic?
pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go
Show resolved
Hide resolved
pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go
Show resolved
Hide resolved
HasConfig(expectedTaskConfig). | ||
HasBudget(""). | ||
HasTaskRelations(sdk.TaskRelations{}), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
# Conflicts: # pkg/acceptance/bettertestspoc/README.md # pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go # pkg/sdk/sweepers_test.go
Integration tests failure for 80ca12e07e4e1b0fa5a0d6a8245c017496fa00cd |
Integration tests failure for f0514bcb9d530e9f9afcb89bac43b56a59d69254 |
Integration tests failure for ee9583dfa93da2a748b9003843edc1fa844742f4 |
@@ -147,6 +145,7 @@ func TaskToSchema(task *sdk.Task) map[string]any { | |||
taskSchema["config"] = task.Config | |||
taskSchema["budget"] = task.Budget | |||
taskSchema["last_suspended_reason"] = task.LastSuspendedReason | |||
// This is manually edited, please don't re-generate this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (next PR): please keep this changes after regenerating the file
# Conflicts: # pkg/acceptance/bettertestspoc/README.md # pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go
012fb18
Integration tests failure for 012fb1835c3fceb166f9b81f159e7e09a9af61de |
Integration tests failure for 90d70469b3b6fadb123d943875b92dac69d6c261 |
- [x] Apply comments from #3086 - [x] Check if more helper functions from user resource could be used in task resource. - [ ] Apply comments from #3113 - [x] Cron #3113 (comment) - [ ] Resource logic #3113 (comment) - [ ] Refactor SDK suspend root logic for tasks (and overall suspend logic in SDK/resource) #3113 (comment) - [ ] Move some of the logic to SDK (if possible) - [ ] #3170 (comment) - [ ] Refactor task resuming in task resource (most likely with the use of defer) because currently, there may be cases that error can cause tasks to be not resumed. - [ ] Tests - [ ] External changes - #3113 (comment) - [ ] Add more complicated DAG structures to show the resource can handle more complex structures - [ ] Calling (`as` field) - #3113 (comment) - [ ] For showing how the DAG of tasks could be owned by a role other than the one created with Terraform (also with less privileges, only to run the task). - [ ] Check in one acceptance test why finalizer task in show_output is not set (is that Snowflake or mapping error). - [ ] Data source - [ ] Examples, documentation, and migration guide - [ ] Keep manually changed files after regeneration #3113 (comment) - [ ] Make config without $$ escapes needed - [ ] Support session paramters - [ ] Analyze non-deterministic test cases - [ ] Check test tasks_gen_integration_test.go:937 (and see why it's non deterministic). - [ ] Re-generate and list all the issues with asserts and models
## Changes - Fixed the need to enclose `config` with $$ - Added full datasource support with tests - Documentation and examples (v1 candidates; added for resource and datasource) - Migration guide (now only for datasource) - Extracted schema for regular `in` filtering - Describe wasn't added on purpose, because it seems to mirror values from what we get from the SHOW command (can also add it, but for now it doesn't provide any benefits) ## List from previous prs - [ ] Apply comments #3170 - [ ] Apply comments from #3113 - [x] Cron #3113 (comment) - [ ] Resource logic #3113 (comment) - [ ] Refactor SDK suspend root logic for tasks (and overall suspend logic in SDK/resource) #3113 (comment) - [ ] Move some of the logic to SDK (if possible) - [ ] #3170 (comment) - [ ] Refactor task resuming in task resource (most likely with the use of defer) because currently, there may be cases that error can cause tasks to be not resumed. - [ ] Tests - [ ] External changes - #3113 (comment) - [ ] Add more complicated DAG structures to show the resource can handle more complex structures - [ ] Calling (`as` field) - #3113 (comment) - [ ] For showing how the DAG of tasks could be owned by a role other than the one created with Terraform (also with less privileges, only to run the task). - [x] Check in one acceptance test why finalizer task in show_output is not set (is that Snowflake or mapping error). - [x] Data source - [ ] Examples, documentation, and migration guide - [ ] Keep manually changed files after regeneration #3113 (comment) - [x] Make config without $$ escapes needed - [ ] Support session paramters - [ ] Analyze non-deterministic test cases - [ ] Check test tasks_gen_integration_test.go:937 (and see why it's non deterministic). - [ ] Re-generate and list all the issues with asserts and models
- [x] Apply comments from #3113 - [x] Cron #3113 (comment) - [x] Resource logic #3113 (comment) - [x] Refactor SDK suspend root logic for tasks (and overall suspend logic in SDK/resource) #3113 (comment) - [x] Tests - [x] External changes - #3113 (comment) - [x] Add more complicated DAG structures to show the resource can handle more complex structures - [x] Calling (`as` field) - #3113 (comment) - [x] Check in one acceptance test why the finalizer task in show_output is not set (is that Snowflake or mapping error). - [x] Data source - [x] Examples, documentation, and migration guide - [x] Keep manually changed files after regeneration #3113 (comment) - [x] Make config without $$ escapes needed - [x] Support session parameters (I think it's already done, but check https://docs.snowflake.com/en/sql-reference/parameters#label-session-parameters) - [x] Refactor task resuming in task resource (most likely with the use of defer) because currently, there may be cases that error can cause tasks to be not resumed. - [x] Analyze non-deterministic test cases (All tests seem to be deterministic, only object_parameter resource tests are causing the AllParameters test to fail) - [x] Check test tasks_gen_integration_test.go:937 (and see why it's non-deterministic). - [x] Move some of the logic to SDK (if possible) - [x] #3170 (comment) - [x] Apply comments #3170 - [ ] Re-generate and list all the issues with asserts and models
Changes
Next prs
as
field) - feat: Task resource v1 readiness #3113 (comment)References