Skip to content
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

Remove schedule block from monitorv2 #151

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/data-sources/monitor_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,8 @@ Read-Only:

Read-Only:

- `interval` (Block List) Should be used to run explicit ad-hoc queries. (see [below for nested schema](#nestedblock--scheduling--interval))
- `transform` (Block List) Should be used to defer scheduling to the transformer and evaluate when data becomes available. (see [below for nested schema](#nestedblock--scheduling--transform))

<a id="nestedblock--scheduling--interval"></a>
### Nested Schema for `scheduling.interval`

Read-Only:

- `interval` (String) How often the monitor should attempt to run.
- `randomize` (String) A maximum +/- to apply to the interval to avoid things like harmonics and work stacking up in parallel.


<a id="nestedblock--scheduling--transform"></a>
### Nested Schema for `scheduling.transform`

Expand Down
10 changes: 0 additions & 10 deletions docs/resources/monitor_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,8 @@ Optional:

Optional:

- `interval` (Block List, Max: 1) Should be used to run explicit ad-hoc queries. (see [below for nested schema](#nestedblock--scheduling--interval))
- `transform` (Block List, Max: 1) Should be used to defer scheduling to the transformer and evaluate when data becomes available. (see [below for nested schema](#nestedblock--scheduling--transform))

<a id="nestedblock--scheduling--interval"></a>
### Nested Schema for `scheduling.interval`

Required:

- `interval` (String) How often the monitor should attempt to run.
- `randomize` (String) A maximum +/- to apply to the interval to avoid things like harmonics and work stacking up in parallel.


<a id="nestedblock--scheduling--transform"></a>
### Nested Schema for `scheduling.transform`

Expand Down
20 changes: 0 additions & 20 deletions observe/data_source_monitor_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,6 @@ func dataSourceMonitorV2() *schema.Resource {
Description: descriptions.Get("monitorv2", "schema", "scheduling", "description"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"interval": { // MonitorV2IntervalScheduleInput
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: descriptions.Get("monitorv2", "schema", "scheduling", "interval", "description"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"interval": { // Duration!
Type: schema.TypeString,
Computed: true,
Description: descriptions.Get("monitorv2", "schema", "scheduling", "interval", "interval"),
},
"randomize": { // Duration!
Type: schema.TypeString,
Computed: true,
Description: descriptions.Get("monitorv2", "schema", "scheduling", "interval", "randomize"),
},
},
},
},
"transform": { // MonitorV2TransformScheduleInput
Type: schema.TypeList,
Optional: true,
Expand Down
31 changes: 11 additions & 20 deletions observe/data_source_monitor_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestAccObserveGetIDMonitorV2CountData(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -47,9 +46,8 @@ func TestAccObserveGetIDMonitorV2CountData(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
}
Expand All @@ -66,16 +64,14 @@ func TestAccObserveGetIDMonitorV2CountData(t *testing.T) {
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.level", "informational"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.count.0.compare_values.0.compare_fn", "greater"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.count.0.compare_values.0.value_int64.0", "0"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.interval.0.interval", "15m0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.interval.0.randomize", "0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.transform.0.freshness_goal", "15m0s"),
),
},
},
})
}

func TestAccObserveGetIDMonitorV2Threshold(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -107,9 +103,8 @@ func TestAccObserveGetIDMonitorV2Threshold(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
}
Expand All @@ -128,16 +123,14 @@ func TestAccObserveGetIDMonitorV2Threshold(t *testing.T) {
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.threshold.0.compare_values.0.value_int64.0", "0"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.threshold.0.value_column_name", "temp_number"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.threshold.0.aggregation", "all_of"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.interval.0.interval", "15m0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.interval.0.randomize", "0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.transform.0.freshness_goal", "15m0s"),
),
},
},
})
}

func TestAccObserveGetIDMonitorV2Promote(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -150,7 +143,7 @@ func TestAccObserveGetIDMonitorV2Promote(t *testing.T) {
workspace = data.observe_workspace.default.oid
rule_kind = "promote"
name = "%[1]s"
lookback_time = "10s"
lookback_time = "0s"
inputs = {
"test" = observe_datastream.test.dataset
}
Expand All @@ -174,9 +167,8 @@ func TestAccObserveGetIDMonitorV2Promote(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
}
Expand All @@ -188,14 +180,13 @@ func TestAccObserveGetIDMonitorV2Promote(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.observe_monitor_v2.lookup", "workspace"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "name", randomPrefix),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "lookback_time", "10s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "lookback_time", "0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rule_kind", "promote"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.level", "informational"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.promote.0.compare_columns.0.compare_values.0.compare_fn", "greater"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.promote.0.compare_columns.0.compare_values.0.value_int64.0", "1"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "rules.0.promote.0.compare_columns.0.column.0.column_path.0.name", "temp_number"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.interval.0.interval", "15m0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.interval.0.randomize", "0s"),
resource.TestCheckResourceAttr("data.observe_monitor_v2.lookup", "scheduling.0.transform.0.freshness_goal", "15m0s"),
),
},
},
Expand Down
34 changes: 4 additions & 30 deletions observe/resource_monitor_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,37 +216,11 @@ func resourceMonitorV2() *schema.Resource {
Description: descriptions.Get("monitorv2", "schema", "scheduling", "description"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"interval": { // MonitorV2IntervalScheduleInput
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ExactlyOneOf: []string{"scheduling.0.interval", "scheduling.0.transform"},
Description: descriptions.Get("monitorv2", "schema", "scheduling", "interval", "description"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"interval": { // Duration!
Type: schema.TypeString,
Required: true,
ValidateDiagFunc: validateTimeDuration,
DiffSuppressFunc: diffSuppressTimeDurationZeroDistinctFromEmpty,
Description: descriptions.Get("monitorv2", "schema", "scheduling", "interval", "interval"),
},
"randomize": { // Duration!
Type: schema.TypeString,
Required: true,
ValidateDiagFunc: validateTimeDuration,
DiffSuppressFunc: diffSuppressTimeDurationZeroDistinctFromEmpty,
Description: descriptions.Get("monitorv2", "schema", "scheduling", "interval", "randomize"),
},
},
},
},
"transform": { // MonitorV2TransformScheduleInput
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ExactlyOneOf: []string{"scheduling.0.interval", "scheduling.0.transform"},
Description: descriptions.Get("monitorv2", "schema", "scheduling", "transform", "description"),
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: descriptions.Get("monitorv2", "schema", "scheduling", "transform", "description"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"freshness_goal": { // Duration!
Expand Down
18 changes: 6 additions & 12 deletions observe/resource_monitor_v2_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestAccObserveMonitorV2ActionEmail(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -47,9 +46,8 @@ func TestAccObserveMonitorV2ActionEmail(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
actions {
Expand Down Expand Up @@ -95,7 +93,6 @@ func TestAccObserveMonitorV2ActionEmail(t *testing.T) {
}

func TestAccObserveMonitorV2ActionWebhook(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -133,9 +130,8 @@ func TestAccObserveMonitorV2ActionWebhook(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
actions {
Expand Down Expand Up @@ -181,7 +177,6 @@ func TestAccObserveMonitorV2ActionWebhook(t *testing.T) {
}

func TestAccObserveMonitorV2MultipleActionsEmail(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -219,9 +214,8 @@ func TestAccObserveMonitorV2MultipleActionsEmail(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
actions {
Expand Down
31 changes: 11 additions & 20 deletions observe/resource_monitor_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
var monitorV2ConfigPreamble = configPreamble + datastreamConfigPreamble

func TestAccObserveMonitorV2Count(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -49,9 +48,8 @@ func TestAccObserveMonitorV2Count(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal= "15m"
}
}
}
Expand All @@ -64,16 +62,14 @@ func TestAccObserveMonitorV2Count(t *testing.T) {
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.level", "informational"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.count.0.compare_values.0.compare_fn", "greater"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.count.0.compare_values.0.value_int64.0", "0"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.interval.0.interval", "15m0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.interval.0.randomize", "0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.transform.0.freshness_goal", "15m0s"),
),
},
},
})
}

func TestAccObserveMonitorV2Threshold(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -105,9 +101,8 @@ func TestAccObserveMonitorV2Threshold(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal = "15m"
}
}
}
Expand All @@ -122,16 +117,14 @@ func TestAccObserveMonitorV2Threshold(t *testing.T) {
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.threshold.0.compare_values.0.value_int64.0", "0"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.threshold.0.value_column_name", "temp_number"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.threshold.0.aggregation", "all_of"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.interval.0.interval", "15m0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.interval.0.randomize", "0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.transform.0.freshness_goal", "15m0s"),
),
},
},
})
}

func TestAccObserveMonitorV2Promote(t *testing.T) {
t.Skip("Skipping until monitorv2 resource fixed to match upstream")
randomPrefix := acctest.RandomWithPrefix("tf")

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -144,7 +137,7 @@ func TestAccObserveMonitorV2Promote(t *testing.T) {
workspace = data.observe_workspace.default.oid
rule_kind = "promote"
name = "%[1]s"
lookback_time = "10s"
lookback_time = "0s"
inputs = {
"test" = observe_datastream.test.dataset
}
Expand All @@ -168,24 +161,22 @@ func TestAccObserveMonitorV2Promote(t *testing.T) {
}
}
scheduling {
interval {
interval = "15m"
randomize = "0"
transform {
freshness_goal= "15m"
}
}
}
`, randomPrefix),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("observe_monitor_v2.first", "workspace"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "name", randomPrefix),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "lookback_time", "10s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "lookback_time", "0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rule_kind", "promote"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.level", "informational"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.promote.0.compare_columns.0.compare_values.0.compare_fn", "greater"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.promote.0.compare_columns.0.compare_values.0.value_int64.0", "1"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "rules.0.promote.0.compare_columns.0.column.0.column_path.0.name", "temp_number"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.interval.0.interval", "15m0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.interval.0.randomize", "0s"),
resource.TestCheckResourceAttr("observe_monitor_v2.first", "scheduling.0.transform.0.freshness_goal", "15m0s"),
),
},
},
Expand Down
Loading