From 6e138367dce70f5359f2b152259b3d031ed097e3 Mon Sep 17 00:00:00 2001 From: nexxai Date: Thu, 29 Aug 2019 15:58:03 -0600 Subject: [PATCH 1/5] Removing requirement of optional properties --- azurerm/resource_arm_stream_analytics_job.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/azurerm/resource_arm_stream_analytics_job.go b/azurerm/resource_arm_stream_analytics_job.go index ef8c599be110..0f0445108941 100644 --- a/azurerm/resource_arm_stream_analytics_job.go +++ b/azurerm/resource_arm_stream_analytics_job.go @@ -42,7 +42,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "compatibility_level": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validation.StringInSlice([]string{ // values found in the other API the portal uses string(streamanalytics.OneFullStopZero), @@ -55,27 +55,27 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "data_locale": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validate.NoEmptyStrings, }, "events_late_arrival_max_delay_in_seconds": { Type: schema.TypeInt, - Required: true, + Optional: true, // portal allows for up to 20d 23h 59m 59s ValidateFunc: validation.IntBetween(-1, 1814399), }, "events_out_of_order_max_delay_in_seconds": { Type: schema.TypeInt, - Required: true, + Optional: true, // portal allows for up to 9m 59s ValidateFunc: validation.IntBetween(0, 599), }, "events_out_of_order_policy": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validation.StringInSlice([]string{ string(streamanalytics.Adjust), string(streamanalytics.Drop), @@ -84,7 +84,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "output_error_policy": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validation.StringInSlice([]string{ string(streamanalytics.OutputErrorPolicyDrop), string(streamanalytics.OutputErrorPolicyStop), @@ -93,13 +93,13 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "streaming_units": { Type: schema.TypeInt, - Required: true, + Optional: true, ValidateFunc: validate.StreamAnalyticsJobStreamingUnits, }, "transformation_query": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validate.NoEmptyStrings, }, From dd833fcc50d73ae31fa7ff952afa9bbd22ec7fd7 Mon Sep 17 00:00:00 2001 From: nexxai Date: Thu, 29 Aug 2019 16:02:40 -0600 Subject: [PATCH 2/5] make fmt --- azurerm/resource_arm_stream_analytics_job.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_stream_analytics_job.go b/azurerm/resource_arm_stream_analytics_job.go index 0f0445108941..4cdc96cd9dbd 100644 --- a/azurerm/resource_arm_stream_analytics_job.go +++ b/azurerm/resource_arm_stream_analytics_job.go @@ -93,13 +93,13 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "streaming_units": { Type: schema.TypeInt, - Optional: true, + Optional: true, ValidateFunc: validate.StreamAnalyticsJobStreamingUnits, }, "transformation_query": { Type: schema.TypeString, - Optional: true, + Optional: true, ValidateFunc: validate.NoEmptyStrings, }, From 0d28e77e70ecf1ea447095fa66dcd381bd21b076 Mon Sep 17 00:00:00 2001 From: nexxai Date: Fri, 30 Aug 2019 11:39:52 -0600 Subject: [PATCH 3/5] Refactored 'basic' test into 'basic' and 'complete'; updated docs --- azurerm/resource_arm_stream_analytics_job.go | 18 +++---- .../resource_arm_stream_analytics_job_test.go | 54 ++++++++++++++++++- .../docs/r/stream_analytics_job.html.markdown | 10 ++-- 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/azurerm/resource_arm_stream_analytics_job.go b/azurerm/resource_arm_stream_analytics_job.go index 4cdc96cd9dbd..0aad32ffd7df 100644 --- a/azurerm/resource_arm_stream_analytics_job.go +++ b/azurerm/resource_arm_stream_analytics_job.go @@ -60,16 +60,16 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { }, "events_late_arrival_max_delay_in_seconds": { - Type: schema.TypeInt, - Optional: true, // portal allows for up to 20d 23h 59m 59s + Type: schema.TypeInt, + Optional: true, ValidateFunc: validation.IntBetween(-1, 1814399), }, "events_out_of_order_max_delay_in_seconds": { - Type: schema.TypeInt, - Optional: true, // portal allows for up to 9m 59s + Type: schema.TypeInt, + Optional: true, ValidateFunc: validation.IntBetween(0, 599), }, @@ -93,13 +93,13 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "streaming_units": { Type: schema.TypeInt, - Optional: true, + Required: true, ValidateFunc: validate.StreamAnalyticsJobStreamingUnits, }, "transformation_query": { Type: schema.TypeString, - Optional: true, + Required: true, ValidateFunc: validate.NoEmptyStrings, }, @@ -137,7 +137,7 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte } compatibilityLevel := d.Get("compatibility_level").(string) - dataLocale := d.Get("data_locale").(string) + // dataLocale := d.Get("data_locale").(string) eventsLateArrivalMaxDelayInSeconds := d.Get("events_late_arrival_max_delay_in_seconds").(int) eventsOutOfOrderMaxDelayInSeconds := d.Get("events_out_of_order_max_delay_in_seconds").(int) eventsOutOfOrderPolicy := d.Get("events_out_of_order_policy").(string) @@ -163,8 +163,8 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte Sku: &streamanalytics.Sku{ Name: streamanalytics.Standard, }, - CompatibilityLevel: streamanalytics.CompatibilityLevel(compatibilityLevel), - DataLocale: utils.String(dataLocale), + CompatibilityLevel: streamanalytics.CompatibilityLevel(compatibilityLevel), + // DataLocale: utils.String(dataLocale), EventsLateArrivalMaxDelayInSeconds: utils.Int32(int32(eventsLateArrivalMaxDelayInSeconds)), EventsOutOfOrderMaxDelayInSeconds: utils.Int32(int32(eventsOutOfOrderMaxDelayInSeconds)), EventsOutOfOrderPolicy: streamanalytics.EventsOutOfOrderPolicy(eventsOutOfOrderPolicy), diff --git a/azurerm/resource_arm_stream_analytics_job_test.go b/azurerm/resource_arm_stream_analytics_job_test.go index 7f31bd4c5714..b3ad86ba4724 100644 --- a/azurerm/resource_arm_stream_analytics_job_test.go +++ b/azurerm/resource_arm_stream_analytics_job_test.go @@ -38,6 +38,33 @@ func TestAccAzureRMStreamAnalyticsJob_basic(t *testing.T) { }) } +func TestAccAzureRMStreamAnalyticsJob_complete(t *testing.T) { + resourceName := "azurerm_stream_analytics_job.test" + ri := tf.AccRandTimeInt() + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMStreamAnalyticsJobDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMStreamAnalyticsJob_complete(ri, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMStreamAnalyticsJobExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.environment", "Test"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAzureRMStreamAnalyticsJob_requiresImport(t *testing.T) { if features.ShouldResourcesBeImported() { t.Skip("Skipping since resources aren't required to be imported") @@ -155,12 +182,36 @@ resource "azurerm_resource_group" "test" { location = "%s" } +resource "azurerm_stream_analytics_job" "test" { + name = "acctestjob-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + streaming_units = 3 + + tags = { + environment = "Test" + } + + transformation_query = < **NOTE:** Support for Compatibility Level 1.2 is dependent on a new version of the Stream Analytics API, which [being tracked in this issue](https://github.com/Azure/azure-rest-api-specs/issues/5604). -* `data_locale` - (Required) Specifies the Data Locale of the Job, which [should be a supported .NET Culture](https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx). +* `data_locale` - (Optional) Specifies the Data Locale of the Job, which [should be a supported .NET Culture](https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx). -* `events_late_arrival_max_delay_in_seconds` - (Required) Specifies the maximum tolerable delay in seconds where events arriving late could be included. Supported range is `-1` (indefinite) to `1814399` (20d 23h 59m 59s). +* `events_late_arrival_max_delay_in_seconds` - (Optional) Specifies the maximum tolerable delay in seconds where events arriving late could be included. Supported range is `-1` (indefinite) to `1814399` (20d 23h 59m 59s). -* `events_out_of_order_max_delay_in_seconds` - (Required) Specifies the maximum tolerable delay in seconds where out-of-order events can be adjusted to be back in order. Supported range is `0` to `599` (9m 59s). +* `events_out_of_order_max_delay_in_seconds` - (Optional) Specifies the maximum tolerable delay in seconds where out-of-order events can be adjusted to be back in order. Supported range is `0` to `599` (9m 59s). -* `events_out_of_order_policy` - (Required) Specifies the policy which should be applied to events which arrive out of order in the input event stream. Possible values are `Adjust` and `Drop`. +* `events_out_of_order_policy` - (Optional) Specifies the policy which should be applied to events which arrive out of order in the input event stream. Possible values are `Adjust` and `Drop`. -* `output_error_policy` - (Required) Specifies the policy which should be applied to events which arrive at the output and cannot be written to the external storage due to being malformed (such as missing column values, column values of wrong type or size). Possible values are `Drop` and `Stop`. +* `output_error_policy` - (Optional) Specifies the policy which should be applied to events which arrive at the output and cannot be written to the external storage due to being malformed (such as missing column values, column values of wrong type or size). Possible values are `Drop` and `Stop`. * `streaming_units` - (Required) Specifies the number of streaming units that the streaming job uses. Supported values are `1`, `3`, `6` and multiples of `6` up to `120`. From c70160ac1c3e13e2852f92fb5b2dcf2428dddeb8 Mon Sep 17 00:00:00 2001 From: nexxai Date: Fri, 30 Aug 2019 14:23:47 -0600 Subject: [PATCH 4/5] Reverting updates; continuing next week --- azurerm/resource_arm_stream_analytics_job.go | 9 ++++++--- azurerm/resource_arm_stream_analytics_job_test.go | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_stream_analytics_job.go b/azurerm/resource_arm_stream_analytics_job.go index 0aad32ffd7df..01b2ff3a4194 100644 --- a/azurerm/resource_arm_stream_analytics_job.go +++ b/azurerm/resource_arm_stream_analytics_job.go @@ -43,6 +43,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "compatibility_level": { Type: schema.TypeString, Optional: true, + Computed: true, ValidateFunc: validation.StringInSlice([]string{ // values found in the other API the portal uses string(streamanalytics.OneFullStopZero), @@ -56,6 +57,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "data_locale": { Type: schema.TypeString, Optional: true, + Computed: true, ValidateFunc: validate.NoEmptyStrings, }, @@ -85,6 +87,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { "output_error_policy": { Type: schema.TypeString, Optional: true, + Computed: true, ValidateFunc: validation.StringInSlice([]string{ string(streamanalytics.OutputErrorPolicyDrop), string(streamanalytics.OutputErrorPolicyStop), @@ -137,7 +140,7 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte } compatibilityLevel := d.Get("compatibility_level").(string) - // dataLocale := d.Get("data_locale").(string) + dataLocale := d.Get("data_locale").(string) eventsLateArrivalMaxDelayInSeconds := d.Get("events_late_arrival_max_delay_in_seconds").(int) eventsOutOfOrderMaxDelayInSeconds := d.Get("events_out_of_order_max_delay_in_seconds").(int) eventsOutOfOrderPolicy := d.Get("events_out_of_order_policy").(string) @@ -163,8 +166,8 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte Sku: &streamanalytics.Sku{ Name: streamanalytics.Standard, }, - CompatibilityLevel: streamanalytics.CompatibilityLevel(compatibilityLevel), - // DataLocale: utils.String(dataLocale), + CompatibilityLevel: streamanalytics.CompatibilityLevel(compatibilityLevel), + DataLocale: utils.String(dataLocale), EventsLateArrivalMaxDelayInSeconds: utils.Int32(int32(eventsLateArrivalMaxDelayInSeconds)), EventsOutOfOrderMaxDelayInSeconds: utils.Int32(int32(eventsOutOfOrderMaxDelayInSeconds)), EventsOutOfOrderPolicy: streamanalytics.EventsOutOfOrderPolicy(eventsOutOfOrderPolicy), diff --git a/azurerm/resource_arm_stream_analytics_job_test.go b/azurerm/resource_arm_stream_analytics_job_test.go index b3ad86ba4724..ae1d74ab74ad 100644 --- a/azurerm/resource_arm_stream_analytics_job_test.go +++ b/azurerm/resource_arm_stream_analytics_job_test.go @@ -211,6 +211,7 @@ resource "azurerm_stream_analytics_job" "test" { name = "acctestjob-%d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" + data_locale = "en-GB" compatibility_level = "1.0" events_late_arrival_max_delay_in_seconds = 60 events_out_of_order_max_delay_in_seconds = 50 @@ -263,6 +264,7 @@ resource "azurerm_stream_analytics_job" "test" { name = "acctestjob-%d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" + data_locale = "en-GB" compatibility_level = "1.1" events_late_arrival_max_delay_in_seconds = 10 events_out_of_order_max_delay_in_seconds = 20 From e37e11689a3e56e65a5fd036bbe9b0362acf4d0c Mon Sep 17 00:00:00 2001 From: nexxai Date: Thu, 5 Sep 2019 14:48:36 -0600 Subject: [PATCH 5/5] Fixed default optional settings; tests are passing now --- azurerm/resource_arm_stream_analytics_job.go | 11 ++++++++--- azurerm/resource_arm_stream_analytics_job_test.go | 1 + website/docs/r/stream_analytics_job.html.markdown | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/azurerm/resource_arm_stream_analytics_job.go b/azurerm/resource_arm_stream_analytics_job.go index 01b2ff3a4194..6208ae85c2dd 100644 --- a/azurerm/resource_arm_stream_analytics_job.go +++ b/azurerm/resource_arm_stream_analytics_job.go @@ -66,6 +66,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(-1, 1814399), + Default: 5, }, "events_out_of_order_max_delay_in_seconds": { @@ -73,6 +74,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 599), + Default: 0, }, "events_out_of_order_policy": { @@ -82,16 +84,17 @@ func resourceArmStreamAnalyticsJob() *schema.Resource { string(streamanalytics.Adjust), string(streamanalytics.Drop), }, false), + Default: string(streamanalytics.Adjust), }, "output_error_policy": { Type: schema.TypeString, Optional: true, - Computed: true, ValidateFunc: validation.StringInSlice([]string{ string(streamanalytics.OutputErrorPolicyDrop), string(streamanalytics.OutputErrorPolicyStop), }, false), + Default: string(streamanalytics.OutputErrorPolicyDrop), }, "streaming_units": { @@ -140,7 +143,6 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte } compatibilityLevel := d.Get("compatibility_level").(string) - dataLocale := d.Get("data_locale").(string) eventsLateArrivalMaxDelayInSeconds := d.Get("events_late_arrival_max_delay_in_seconds").(int) eventsOutOfOrderMaxDelayInSeconds := d.Get("events_out_of_order_max_delay_in_seconds").(int) eventsOutOfOrderPolicy := d.Get("events_out_of_order_policy").(string) @@ -167,7 +169,6 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte Name: streamanalytics.Standard, }, CompatibilityLevel: streamanalytics.CompatibilityLevel(compatibilityLevel), - DataLocale: utils.String(dataLocale), EventsLateArrivalMaxDelayInSeconds: utils.Int32(int32(eventsLateArrivalMaxDelayInSeconds)), EventsOutOfOrderMaxDelayInSeconds: utils.Int32(int32(eventsOutOfOrderMaxDelayInSeconds)), EventsOutOfOrderPolicy: streamanalytics.EventsOutOfOrderPolicy(eventsOutOfOrderPolicy), @@ -176,6 +177,10 @@ func resourceArmStreamAnalyticsJobCreateUpdate(d *schema.ResourceData, meta inte Tags: tags.Expand(t), } + if dataLocale, ok := d.GetOk("data_locale"); ok { + props.StreamingJobProperties.DataLocale = utils.String(dataLocale.(string)) + } + if d.IsNewResource() { props.StreamingJobProperties.Transformation = &transformation diff --git a/azurerm/resource_arm_stream_analytics_job_test.go b/azurerm/resource_arm_stream_analytics_job_test.go index ae1d74ab74ad..70962e002b48 100644 --- a/azurerm/resource_arm_stream_analytics_job_test.go +++ b/azurerm/resource_arm_stream_analytics_job_test.go @@ -249,6 +249,7 @@ resource "azurerm_stream_analytics_job" "import" { output_error_policy = "${azurerm_stream_analytics_job.test.output_error_policy}" streaming_units = "${azurerm_stream_analytics_job.test.streaming_units}" transformation_query = "${azurerm_stream_analytics_job.test.transformation_query}" + tags = "${azurerm_stream_analytics_job.test.tags}" } `, template) } diff --git a/website/docs/r/stream_analytics_job.html.markdown b/website/docs/r/stream_analytics_job.html.markdown index 56acd4e15b61..9a0734702527 100644 --- a/website/docs/r/stream_analytics_job.html.markdown +++ b/website/docs/r/stream_analytics_job.html.markdown @@ -58,13 +58,13 @@ The following arguments are supported: * `data_locale` - (Optional) Specifies the Data Locale of the Job, which [should be a supported .NET Culture](https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx). -* `events_late_arrival_max_delay_in_seconds` - (Optional) Specifies the maximum tolerable delay in seconds where events arriving late could be included. Supported range is `-1` (indefinite) to `1814399` (20d 23h 59m 59s). +* `events_late_arrival_max_delay_in_seconds` - (Optional) Specifies the maximum tolerable delay in seconds where events arriving late could be included. Supported range is `-1` (indefinite) to `1814399` (20d 23h 59m 59s). Default is `0`. -* `events_out_of_order_max_delay_in_seconds` - (Optional) Specifies the maximum tolerable delay in seconds where out-of-order events can be adjusted to be back in order. Supported range is `0` to `599` (9m 59s). +* `events_out_of_order_max_delay_in_seconds` - (Optional) Specifies the maximum tolerable delay in seconds where out-of-order events can be adjusted to be back in order. Supported range is `0` to `599` (9m 59s). Default is `5`. -* `events_out_of_order_policy` - (Optional) Specifies the policy which should be applied to events which arrive out of order in the input event stream. Possible values are `Adjust` and `Drop`. +* `events_out_of_order_policy` - (Optional) Specifies the policy which should be applied to events which arrive out of order in the input event stream. Possible values are `Adjust` and `Drop`. Default is `Adjust`. -* `output_error_policy` - (Optional) Specifies the policy which should be applied to events which arrive at the output and cannot be written to the external storage due to being malformed (such as missing column values, column values of wrong type or size). Possible values are `Drop` and `Stop`. +* `output_error_policy` - (Optional) Specifies the policy which should be applied to events which arrive at the output and cannot be written to the external storage due to being malformed (such as missing column values, column values of wrong type or size). Possible values are `Drop` and `Stop`. Default is `Drop`. * `streaming_units` - (Required) Specifies the number of streaming units that the streaming job uses. Supported values are `1`, `3`, `6` and multiples of `6` up to `120`.