From 5a8eb541abc92dbdf0df5f324336658c49589184 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 1 Dec 2023 14:49:34 +0100 Subject: [PATCH] tests + versions updates (#211) * update mariadb default version * deprecate ElasticSearch * remove ES data source test * update deprecation message * update data source schema * Automated docs update --------- Co-authored-by: Dean Oren Co-authored-by: do87 --- .github/files/analyze-test-output/analyze.go | 6 +- docs/data-sources/elasticsearch_instance.md | 5 + docs/data-sources/logme_instance.md | 1 + docs/data-sources/mariadb_instance.md | 1 + docs/data-sources/opensearch_instance.md | 1 + docs/data-sources/postgres_instance.md | 1 + docs/data-sources/rabbitmq_instance.md | 1 + docs/data-sources/redis_instance.md | 1 + docs/resources/elasticsearch_instance.md | 5 + docs/resources/logme_instance.md | 1 + docs/resources/mariadb_instance.md | 1 + docs/resources/opensearch_instance.md | 1 + docs/resources/postgres_instance.md | 1 + docs/resources/rabbitmq_instance.md | 1 + docs/resources/redis_instance.md | 1 + .../data_source_elasticsearch_test.go | 77 ------------- .../instance/data_source_mariadb_test.go | 2 +- .../data-services/instance/schema.go | 11 +- .../instance/resource_elasticsearch_test.go | 104 ------------------ .../data-services/instance/schema.go | 11 +- 20 files changed, 46 insertions(+), 187 deletions(-) delete mode 100644 stackit/internal/data-sources/data-services/instance/data_source_elasticsearch_test.go delete mode 100644 stackit/internal/resources/data-services/instance/resource_elasticsearch_test.go diff --git a/.github/files/analyze-test-output/analyze.go b/.github/files/analyze-test-output/analyze.go index 61313451..a138c456 100644 --- a/.github/files/analyze-test-output/analyze.go +++ b/.github/files/analyze-test-output/analyze.go @@ -100,9 +100,9 @@ func main() { } func getDataServiceName(testName string) string { - if strings.Contains(testName, "ElasticSearch") { - return "elasticsearch-dsa" - } + // if strings.Contains(testName, "ElasticSearch") { + // return "elasticsearch-dsa" + // } if strings.Contains(testName, "LogMe") { return "logme-dsa" } diff --git a/docs/data-sources/elasticsearch_instance.md b/docs/data-sources/elasticsearch_instance.md index be53c2c8..ad2c760e 100644 --- a/docs/data-sources/elasticsearch_instance.md +++ b/docs/data-sources/elasticsearch_instance.md @@ -4,6 +4,8 @@ page_title: "stackit_elasticsearch_instance Data Source - stackit" subcategory: "" description: |- Data source for ElasticSearch instances + This resource is deprecated and will be removed in a future release. + Please use OpenSearch resource and data-source instead. -> Environment supportTo set a custom API base URL, set STACKITELASTICSEARCHBASEURL environment variable --- @@ -11,6 +13,9 @@ description: |- # stackit_elasticsearch_instance (Data Source) Data source for ElasticSearch instances +This resource is deprecated and will be removed in a future release. +Please use `OpenSearch` resource and data-source instead. +
diff --git a/docs/data-sources/logme_instance.md b/docs/data-sources/logme_instance.md index e1b2d015..bf1c31b1 100644 --- a/docs/data-sources/logme_instance.md +++ b/docs/data-sources/logme_instance.md @@ -12,6 +12,7 @@ description: |- Data source for LogMe instances +
-> __Environment support__To set a custom API base URL, set STACKIT_LOGME_BASEURL environment variable diff --git a/docs/data-sources/mariadb_instance.md b/docs/data-sources/mariadb_instance.md index 2531806f..96ef0fe5 100644 --- a/docs/data-sources/mariadb_instance.md +++ b/docs/data-sources/mariadb_instance.md @@ -12,6 +12,7 @@ description: |- Data source for MariaDB instances +
-> __Environment support__To set a custom API base URL, set STACKIT_MARIADB_BASEURL environment variable diff --git a/docs/data-sources/opensearch_instance.md b/docs/data-sources/opensearch_instance.md index a23cf335..d51a2785 100644 --- a/docs/data-sources/opensearch_instance.md +++ b/docs/data-sources/opensearch_instance.md @@ -12,6 +12,7 @@ description: |- Data source for Opensearch instances +
-> __Environment support__To set a custom API base URL, set STACKIT_REDIS_BASEURL environment variable diff --git a/docs/data-sources/postgres_instance.md b/docs/data-sources/postgres_instance.md index 50dc596b..3b376935 100644 --- a/docs/data-sources/postgres_instance.md +++ b/docs/data-sources/postgres_instance.md @@ -12,6 +12,7 @@ description: |- Data source for Postgres instances +
-> __Environment support__To set a custom API base URL, set STACKIT_POSTGRESQL_BASEURL environment variable diff --git a/docs/data-sources/rabbitmq_instance.md b/docs/data-sources/rabbitmq_instance.md index dc6864c7..be9d6239 100644 --- a/docs/data-sources/rabbitmq_instance.md +++ b/docs/data-sources/rabbitmq_instance.md @@ -12,6 +12,7 @@ description: |- Data source for RabbitMQ instances +
-> __Environment support__To set a custom API base URL, set STACKIT_RABBITMQ_BASEURL environment variable diff --git a/docs/data-sources/redis_instance.md b/docs/data-sources/redis_instance.md index 4ad60c22..12f109c3 100644 --- a/docs/data-sources/redis_instance.md +++ b/docs/data-sources/redis_instance.md @@ -12,6 +12,7 @@ description: |- Data source for Redis instances +
-> __Environment support__To set a custom API base URL, set STACKIT_REDIS_BASEURL environment variable diff --git a/docs/resources/elasticsearch_instance.md b/docs/resources/elasticsearch_instance.md index feaecd42..8b0e7238 100644 --- a/docs/resources/elasticsearch_instance.md +++ b/docs/resources/elasticsearch_instance.md @@ -4,6 +4,8 @@ page_title: "stackit_elasticsearch_instance Resource - stackit" subcategory: "" description: |- Manages ElasticSearch instances + This resource is deprecated and will be removed in a future release. + Please use the stackit_opensearch_instance resource instead. -> Environment supportTo set a custom API base URL, set STACKITELASTICSEARCHBASEURL environment variable --- @@ -11,6 +13,9 @@ description: |- # stackit_elasticsearch_instance (Resource) Manages ElasticSearch instances +This resource is deprecated and will be removed in a future release. +Please use the `stackit_opensearch_instance` resource instead. +
diff --git a/docs/resources/logme_instance.md b/docs/resources/logme_instance.md index 61ab839a..99a6f2d4 100644 --- a/docs/resources/logme_instance.md +++ b/docs/resources/logme_instance.md @@ -12,6 +12,7 @@ description: |- Manages LogMe instances +
-> __Environment support__To set a custom API base URL, set STACKIT_LOGME_BASEURL environment variable diff --git a/docs/resources/mariadb_instance.md b/docs/resources/mariadb_instance.md index 6b408091..985314e9 100644 --- a/docs/resources/mariadb_instance.md +++ b/docs/resources/mariadb_instance.md @@ -12,6 +12,7 @@ description: |- Manages MariaDB instances +
-> __Environment support__To set a custom API base URL, set STACKIT_MARIADB_BASEURL environment variable diff --git a/docs/resources/opensearch_instance.md b/docs/resources/opensearch_instance.md index c6e9444c..d49f1ea7 100644 --- a/docs/resources/opensearch_instance.md +++ b/docs/resources/opensearch_instance.md @@ -12,6 +12,7 @@ description: |- Manages Opensearch instances +
-> __Environment support__To set a custom API base URL, set STACKIT_REDIS_BASEURL environment variable diff --git a/docs/resources/postgres_instance.md b/docs/resources/postgres_instance.md index a99d3c13..415ff467 100644 --- a/docs/resources/postgres_instance.md +++ b/docs/resources/postgres_instance.md @@ -12,6 +12,7 @@ description: |- Manages Postgres instances +
-> __Environment support__To set a custom API base URL, set STACKIT_POSTGRESQL_BASEURL environment variable diff --git a/docs/resources/rabbitmq_instance.md b/docs/resources/rabbitmq_instance.md index 0a3ef50c..b8278872 100644 --- a/docs/resources/rabbitmq_instance.md +++ b/docs/resources/rabbitmq_instance.md @@ -12,6 +12,7 @@ description: |- Manages RabbitMQ instances +
-> __Environment support__To set a custom API base URL, set STACKIT_RABBITMQ_BASEURL environment variable diff --git a/docs/resources/redis_instance.md b/docs/resources/redis_instance.md index e10a3599..22db2d51 100644 --- a/docs/resources/redis_instance.md +++ b/docs/resources/redis_instance.md @@ -12,6 +12,7 @@ description: |- Manages Redis instances +
-> __Environment support__To set a custom API base URL, set STACKIT_REDIS_BASEURL environment variable diff --git a/stackit/internal/data-sources/data-services/instance/data_source_elasticsearch_test.go b/stackit/internal/data-sources/data-services/instance/data_source_elasticsearch_test.go deleted file mode 100644 index 2855cb59..00000000 --- a/stackit/internal/data-sources/data-services/instance/data_source_elasticsearch_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package instance_test - -import ( - "fmt" - "testing" - - "github.com/SchwarzIT/terraform-provider-stackit/stackit" - "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/common" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -const es_inst_run_this_test = false - -func TestAcc_DataSourceElasticSearchInstanceJob(t *testing.T) { - if !common.ShouldAccTestRun(es_inst_run_this_test) { - t.Skip() - return - } - - name := "odjtest-" + acctest.RandStringFromCharSet(7, acctest.CharSetAlpha) - plan := "stackit-elasticsearch-single-small" - planID := "a59cf7bb-ae64-4f63-8503-fca8c936bf0c" - version := "7" - - resource.ParallelTest(t, resource.TestCase{ - ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ - "stackit": providerserver.NewProtocol6WithError(stackit.New("test")()), - }, - Steps: []resource.TestStep{ - // check minimal configuration - { - Config: configElasticSearch(name, version, plan), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.stackit_elasticsearch_instance.example", "name", name), - resource.TestCheckResourceAttr("data.stackit_elasticsearch_instance.example", "project_id", common.GetAcceptanceTestsProjectID()), - resource.TestCheckResourceAttr("data.stackit_elasticsearch_instance.example", "version", version), - resource.TestCheckResourceAttr("data.stackit_elasticsearch_instance.example", "plan", plan), - resource.TestCheckResourceAttr("data.stackit_elasticsearch_instance.example", "plan_id", planID), - resource.TestCheckResourceAttrSet("data.stackit_elasticsearch_instance.example", "id"), - resource.TestCheckResourceAttrSet("data.stackit_elasticsearch_instance.example", "dashboard_url"), - resource.TestCheckResourceAttrSet("data.stackit_elasticsearch_instance.example", "cf_guid"), - resource.TestCheckResourceAttrSet("data.stackit_elasticsearch_instance.example", "cf_space_guid"), - resource.TestCheckTypeSetElemAttrPair("stackit_elasticsearch_instance.example", "id", "data.stackit_elasticsearch_instance.example", "id"), - ), - }, - }, - }) -} - -func configElasticSearch(name, version, plan string) string { - return fmt.Sprintf(` - resource "stackit_elasticsearch_instance" "example" { - name = "%s" - project_id = "%s" - version = "%s" - plan = "%s" - } - - - data "stackit_elasticsearch_instance" "example" { - depends_on = [stackit_elasticsearch_instance.example] - name = "%s" - project_id = "%s" - } - - `, - name, - common.GetAcceptanceTestsProjectID(), - version, - plan, - name, - common.GetAcceptanceTestsProjectID(), - ) -} diff --git a/stackit/internal/data-sources/data-services/instance/data_source_mariadb_test.go b/stackit/internal/data-sources/data-services/instance/data_source_mariadb_test.go index 0bda4c15..a872a754 100644 --- a/stackit/internal/data-sources/data-services/instance/data_source_mariadb_test.go +++ b/stackit/internal/data-sources/data-services/instance/data_source_mariadb_test.go @@ -23,7 +23,7 @@ func TestAcc_DataSourceMariaDBInstanceJob(t *testing.T) { name := "odjtest-" + acctest.RandStringFromCharSet(7, acctest.CharSetAlpha) plan := "stackit-mariadb-single-small" planID := "8fc9e236-6173-40dc-a79a-02aba46ba75a" - version := "10.4" + version := "10.6" resource.ParallelTest(t, resource.TestCase{ ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ diff --git a/stackit/internal/data-sources/data-services/instance/schema.go b/stackit/internal/data-sources/data-services/instance/schema.go index 91015c42..f83c53a7 100644 --- a/stackit/internal/data-sources/data-services/instance/schema.go +++ b/stackit/internal/data-sources/data-services/instance/schema.go @@ -32,10 +32,12 @@ type Instance struct { // Schema returns the terraform schema structure func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: fmt.Sprintf("Data source for %s instances\n%s", + MarkdownDescription: fmt.Sprintf("Data source for %s instances\n%s\n%s", d.service.Display(), + printDeprecation(d.service.Display()), common.EnvironmentInfo(d.urls), ), + DeprecationMessage: printDeprecation(d.service.Display()), Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "Specifies the resource ID", @@ -88,3 +90,10 @@ func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, r }, } } + +func printDeprecation(svc string) string { + if svc == "ElasticSearch" { + return "This resource is deprecated and will be removed in a future release.\nPlease use `OpenSearch` resource and data-source instead.\n" + } + return "" +} diff --git a/stackit/internal/resources/data-services/instance/resource_elasticsearch_test.go b/stackit/internal/resources/data-services/instance/resource_elasticsearch_test.go deleted file mode 100644 index b24e6638..00000000 --- a/stackit/internal/resources/data-services/instance/resource_elasticsearch_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package instance_test - -import ( - "errors" - "fmt" - "testing" - - "github.com/SchwarzIT/terraform-provider-stackit/stackit" - "github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/common" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -const es_inst_run_this_test = false - -func TestAcc_ResourceElasticSearchInstanceJob(t *testing.T) { - if !common.ShouldAccTestRun(es_inst_run_this_test) { - t.Skip() - return - } - - name := "odjtest-" + acctest.RandStringFromCharSet(7, acctest.CharSetAlpha) - plan1 := "stackit-elasticsearch-single-small" - planID1 := "a59cf7bb-ae64-4f63-8503-fca8c936bf0c" - plan2 := "stackit-elasticsearch-single-medium" - planID2 := "71d9918a-4361-432a-a307-1eb9353d257c" - version := "7" - - resource.ParallelTest(t, resource.TestCase{ - ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ - "stackit": providerserver.NewProtocol6WithError(stackit.New("test")()), - }, - Steps: []resource.TestStep{ - // check minimal configuration - { - Config: configInstElasticSearch(name, plan1, version), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "name", name), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "project_id", common.GetAcceptanceTestsProjectID()), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "version", version), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "plan", plan1), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "plan_id", planID1), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "id"), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "dashboard_url"), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "cf_guid"), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "cf_space_guid"), - ), - }, - // check update plan - { - Config: configInstElasticSearch(name, plan2, version), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "name", name), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "project_id", common.GetAcceptanceTestsProjectID()), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "version", version), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "plan", plan2), - resource.TestCheckResourceAttr("stackit_elasticsearch_instance.example", "plan_id", planID2), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "id"), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "dashboard_url"), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "cf_guid"), - resource.TestCheckResourceAttrSet("stackit_elasticsearch_instance.example", "cf_space_guid"), - ), - }, - // test import - { - ResourceName: "stackit_elasticsearch_instance.example", - ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_elasticsearch_instance.example"] - if !ok { - return "", errors.New("couldn't find resource stackit_elasticsearch_instance.example") - } - id, ok := r.Primary.Attributes["id"] - if !ok { - return "", errors.New("couldn't find attribute id") - } - - return fmt.Sprintf("%s,%s", common.GetAcceptanceTestsProjectID(), id), nil - }, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func configInstElasticSearch(name, plan, version string) string { - return fmt.Sprintf(` - resource "stackit_elasticsearch_instance" "example" { - name = "%s" - project_id = "%s" - version = "%s" - plan = "%s" - } - - `, - name, - common.GetAcceptanceTestsProjectID(), - version, - plan, - ) -} diff --git a/stackit/internal/resources/data-services/instance/schema.go b/stackit/internal/resources/data-services/instance/schema.go index d2e2d234..cf0e93f3 100644 --- a/stackit/internal/resources/data-services/instance/schema.go +++ b/stackit/internal/resources/data-services/instance/schema.go @@ -36,10 +36,12 @@ type Instance struct { // Schema returns the terraform schema structure func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: fmt.Sprintf("Manages %s instances\n%s", + MarkdownDescription: fmt.Sprintf("Manages %s instances\n%s\n%s", r.service.Display(), + printDeprecation(r.service.Display()), common.EnvironmentInfo(r.urls), ), + DeprecationMessage: printDeprecation(r.service.Display()), Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "Specifies the resource ID", @@ -114,3 +116,10 @@ func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp }, } } + +func printDeprecation(svc string) string { + if svc == "ElasticSearch" { + return "This resource is deprecated and will be removed in a future release.\nPlease use the `stackit_opensearch_instance` resource instead.\n" + } + return "" +}