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

bugfix: azurerm_stream_analytics_output_eventhub does not set the output format #3318

Merged
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
1 change: 1 addition & 0 deletions azurerm/helpers/azure/stream_analytics_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func ExpandStreamAnalyticsOutputSerialization(input []interface{}) (streamanalyt
Type: streamanalytics.TypeJSON,
JSONSerializationProperties: &streamanalytics.JSONSerializationProperties{
Encoding: streamanalytics.Encoding(encoding),
Format: streamanalytics.JSONOutputSerializationFormat(format),
},
}, nil
}
Expand Down
61 changes: 61 additions & 0 deletions azurerm/resource_arm_stream_analytics_output_eventhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestAccAzureRMStreamAnalyticsOutputEventHub_avro(t *testing.T) {
Config: testAccAzureRMStreamAnalyticsOutputEventHub_avro(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStreamAnalyticsOutputEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "serialization.0.type", "Avro"),
),
},
{
Expand Down Expand Up @@ -53,6 +54,9 @@ func TestAccAzureRMStreamAnalyticsOutputEventHub_csv(t *testing.T) {
Config: testAccAzureRMStreamAnalyticsOutputEventHub_csv(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStreamAnalyticsOutputEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "serialization.0.type", "Csv"),
resource.TestCheckResourceAttr(resourceName, "serialization.0.field_delimiter", ","),
resource.TestCheckResourceAttr(resourceName, "serialization.0.encoding", "UTF8"),
),
},
{
Expand Down Expand Up @@ -82,6 +86,39 @@ func TestAccAzureRMStreamAnalyticsOutputEventHub_json(t *testing.T) {
Config: testAccAzureRMStreamAnalyticsOutputEventHub_json(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStreamAnalyticsOutputEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "serialization.0.format", "LineSeparated"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// not returned from the API
"shared_access_policy_key",
},
},
},
})
}

func TestAccAzureRMStreamAnalyticsOutputEventHub_jsonArrayFormat(t *testing.T) {
resourceName := "azurerm_stream_analytics_output_eventhub.test"
ri := tf.AccRandTimeInt()
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMStreamAnalyticsOutputEventHubDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMStreamAnalyticsOutputEventHub_jsonArrayFormat(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStreamAnalyticsOutputEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "serialization.0.format", "Array"),
resource.TestCheckResourceAttr(resourceName, "serialization.0.type", "Json"),
resource.TestCheckResourceAttr(resourceName, "serialization.0.encoding", "UTF8"),
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add some checks here:

resource.TestCheckResourceAttr(resourceName, "serialization.0.format", "Array"),

and for the rest of the serialization block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done here and for all other types of serialization

},
{
Expand Down Expand Up @@ -117,6 +154,7 @@ func TestAccAzureRMStreamAnalyticsOutputEventHub_update(t *testing.T) {
Config: testAccAzureRMStreamAnalyticsOutputEventHub_updated(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStreamAnalyticsOutputEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "serialization.0.type", "Avro"),
),
},
{
Expand Down Expand Up @@ -280,6 +318,29 @@ resource "azurerm_stream_analytics_output_eventhub" "test" {
`, template, rInt)
}

func testAccAzureRMStreamAnalyticsOutputEventHub_jsonArrayFormat(rInt int, location string) string {
template := testAccAzureRMStreamAnalyticsOutputEventHub_template(rInt, location)
return fmt.Sprintf(`
%s

resource "azurerm_stream_analytics_output_eventhub" "test" {
name = "acctestinput-%d"
stream_analytics_job_name = "${azurerm_stream_analytics_job.test.name}"
resource_group_name = "${azurerm_stream_analytics_job.test.resource_group_name}"
eventhub_name = "${azurerm_eventhub.test.name}"
servicebus_namespace = "${azurerm_eventhub_namespace.test.name}"
shared_access_policy_key = "${azurerm_eventhub_namespace.test.default_primary_key}"
shared_access_policy_name = "RootManageSharedAccessKey"

serialization {
type = "Json"
encoding = "UTF8"
format = "Array"
}
}
`, template, rInt)
}

func testAccAzureRMStreamAnalyticsOutputEventHub_updated(rInt int, location string) string {
template := testAccAzureRMStreamAnalyticsOutputEventHub_template(rInt, location)
return fmt.Sprintf(`
Expand Down