From 11febd407e60c2fe6b51201327257e4bda25abe5 Mon Sep 17 00:00:00 2001 From: Oguz Kilcan Date: Wed, 26 May 2021 18:35:28 +0200 Subject: [PATCH] Enable support for Apache Spark 3 on `azurerm_synapse_spark_pool` --- .../synapse/synapse_spark_pool_resource.go | 1 + .../synapse_spark_pool_resource_test.go | 55 +++++++++++++++++-- .../docs/r/synapse_spark_pool.html.markdown | 2 +- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/azurerm/internal/services/synapse/synapse_spark_pool_resource.go b/azurerm/internal/services/synapse/synapse_spark_pool_resource.go index 17fdcccdb728..265389c23003 100644 --- a/azurerm/internal/services/synapse/synapse_spark_pool_resource.go +++ b/azurerm/internal/services/synapse/synapse_spark_pool_resource.go @@ -150,6 +150,7 @@ func resourceSynapseSparkPool() *pluginsdk.Resource { Default: "2.4", ValidateFunc: validation.StringInSlice([]string{ "2.4", + "3.0", }, false), }, diff --git a/azurerm/internal/services/synapse/synapse_spark_pool_resource_test.go b/azurerm/internal/services/synapse/synapse_spark_pool_resource_test.go index 04902c893367..7e1b16b40d5c 100644 --- a/azurerm/internal/services/synapse/synapse_spark_pool_resource_test.go +++ b/azurerm/internal/services/synapse/synapse_spark_pool_resource_test.go @@ -52,7 +52,7 @@ func TestAccSynapseSparkPool_complete(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.complete(data), + Config: r.complete(data, "2.4"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -75,7 +75,52 @@ func TestAccSynapseSparkPool_update(t *testing.T) { }, data.ImportStep("spark_events_folder", "spark_log_folder"), { - Config: r.complete(data), + Config: r.complete(data, "2.4"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("spark_events_folder", "spark_log_folder"), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("spark_events_folder", "spark_log_folder"), + }) +} + +func TestAccSynapseSpark3Pool_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_synapse_spark_pool", "test") + r := SynapseSparkPoolResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data, "3.0"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + // not returned by service + data.ImportStep("spark_events_folder", "spark_log_folder"), + }) +} + +func TestAccSynapseSpark3Pool_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_synapse_spark_pool", "test") + r := SynapseSparkPoolResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("spark_events_folder", "spark_log_folder"), + { + Config: r.complete(data, "3.0"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -138,7 +183,7 @@ resource "azurerm_synapse_spark_pool" "import" { `, config) } -func (r SynapseSparkPoolResource) complete(data acceptance.TestData) string { +func (r SynapseSparkPoolResource) complete(data acceptance.TestData, sparkVersion string) string { template := r.template(data) return fmt.Sprintf(` %s @@ -168,13 +213,13 @@ EOF spark_log_folder = "/logs" spark_events_folder = "/events" - spark_version = "2.4" + spark_version = "%s" tags = { ENV = "Test" } } -`, template, data.RandomString) +`, template, data.RandomString, sparkVersion) } func (r SynapseSparkPoolResource) template(data acceptance.TestData) string { diff --git a/website/docs/r/synapse_spark_pool.html.markdown b/website/docs/r/synapse_spark_pool.html.markdown index cb105f73e542..0b998568619f 100644 --- a/website/docs/r/synapse_spark_pool.html.markdown +++ b/website/docs/r/synapse_spark_pool.html.markdown @@ -87,7 +87,7 @@ The following arguments are supported: * `spark_events_folder` - (Optional) The Spark events folder. Defaults to `/events`. -* `spark_version` - (Optional) The Apache Spark version. Possible value is `2.4`. Defaults to `2.4`. +* `spark_version` - (Optional) The Apache Spark version. Possible values are `2.4` and `3.0`. Defaults to `2.4`. * `tags` - (Optional) A mapping of tags which should be assigned to the Synapse Spark Pool.