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

azurerm_stream_analytics_job Removing requirement of optional properties #4190

Merged
merged 5 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 11 additions & 11 deletions azurerm/resource_arm_stream_analytics_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func resourceArmStreamAnalyticsJob() *schema.Resource {

"compatibility_level": {
Type: schema.TypeString,
Required: true,
Optional: true,
nexxai marked this conversation as resolved.
Show resolved Hide resolved
ValidateFunc: validation.StringInSlice([]string{
// values found in the other API the portal uses
string(streamanalytics.OneFullStopZero),
Expand All @@ -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,
// 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,
Required: true,
// portal allows for up to 9m 59s
Type: schema.TypeInt,
Optional: true,
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),
Expand All @@ -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),
Expand Down Expand Up @@ -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)
nexxai marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand All @@ -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),
nexxai marked this conversation as resolved.
Show resolved Hide resolved
EventsLateArrivalMaxDelayInSeconds: utils.Int32(int32(eventsLateArrivalMaxDelayInSeconds)),
EventsOutOfOrderMaxDelayInSeconds: utils.Int32(int32(eventsOutOfOrderMaxDelayInSeconds)),
EventsOutOfOrderPolicy: streamanalytics.EventsOutOfOrderPolicy(eventsOutOfOrderPolicy),
Expand Down
54 changes: 52 additions & 2 deletions azurerm/resource_arm_stream_analytics_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 = <<QUERY
SELECT *
INTO [YourOutputAlias]
FROM [YourInputAlias]
QUERY
}`, rInt, location, rInt)
}

func testAccAzureRMStreamAnalyticsJob_complete(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
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}"
compatibility_level = "1.0"
data_locale = "en-GB"
events_late_arrival_max_delay_in_seconds = 60
events_out_of_order_max_delay_in_seconds = 50
events_out_of_order_policy = "Adjust"
Expand Down Expand Up @@ -213,7 +264,6 @@ resource "azurerm_stream_analytics_job" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
compatibility_level = "1.1"
data_locale = "en-US"
events_late_arrival_max_delay_in_seconds = 10
events_out_of_order_max_delay_in_seconds = 20
events_out_of_order_policy = "Drop"
Expand Down
10 changes: 5 additions & 5 deletions website/docs/r/stream_analytics_job.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ The following arguments are supported:

-> **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`.

Expand Down