diff --git a/selectel/dbaas.go b/selectel/dbaas.go index d6383f7c..b2391b9b 100644 --- a/selectel/dbaas.go +++ b/selectel/dbaas.go @@ -30,6 +30,13 @@ const ( nl1DBaaSV1Endpoint = "https://nl-1.dbaas.selcloud.ru/v1" ) +const ( + postgreSQLDatastoreType = "postgresql" + mySQLDatastoreType = "mysql" + mySQLNativeDatastoreType = "mysql_native" + redisDatastoreType = "redis" +) + func getDBaaSV1Endpoint(region string) (endpoint string) { switch region { case ru1Region: @@ -425,6 +432,7 @@ func containeDatastoreType(expectedTypes []string, datastoreType string) bool { return true } } + return false } @@ -435,6 +443,7 @@ func buildDatastoreTypeErrorMEssage(expectedDatastoreTypeEngines []string, datas } else { baseMessage = "Provided datastore type must have an engine " } + return baseMessage + strings.Join(expectedDatastoreTypeEngines, ", ") + " for this resource. But provided type is " + datastoreTypeEngine } diff --git a/selectel/import_selectel_dbaas_mysql_datastore_v1_test.go b/selectel/import_selectel_dbaas_mysql_datastore_v1_test.go index ada10f38..02ee0184 100644 --- a/selectel/import_selectel_dbaas_mysql_datastore_v1_test.go +++ b/selectel/import_selectel_dbaas_mysql_datastore_v1_test.go @@ -12,7 +12,7 @@ func TestAccDBaaSMySQLDatastoreV1ImportBasic(t *testing.T) { projectName := acctest.RandomWithPrefix("tf-acc") datastoreName := acctest.RandomWithPrefix("tf-acc-ds") nodeCount := 1 - datastoreTypeEngine := "mysql" + datastoreTypeEngine := mySQLDatastoreType resource.Test(t, resource.TestCase{ PreCheck: func() { testAccSelectelPreCheck(t) }, @@ -37,7 +37,7 @@ func TestAccDBaaSMySQLNativeDatastoreV1ImportBasic(t *testing.T) { projectName := acctest.RandomWithPrefix("tf-acc") datastoreName := acctest.RandomWithPrefix("tf-acc-ds") nodeCount := 1 - datastoreTypeEngine := "mysql_native" + datastoreTypeEngine := mySQLNativeDatastoreType resource.Test(t, resource.TestCase{ PreCheck: func() { testAccSelectelPreCheck(t) }, diff --git a/selectel/resource_selectel_dbaas_mysql_database_v1_test.go b/selectel/resource_selectel_dbaas_mysql_database_v1_test.go index 90aeb89a..8975f120 100644 --- a/selectel/resource_selectel_dbaas_mysql_database_v1_test.go +++ b/selectel/resource_selectel_dbaas_mysql_database_v1_test.go @@ -20,7 +20,7 @@ func TestAccDBaaSMySQLDatabaseV1Basic(t *testing.T) { datastoreName := acctest.RandomWithPrefix("tf-acc-ds") databaseName := RandomWithPrefix("tf_acc_db") nodeCount := 1 - datastoreTypeEngine := "mysql" + datastoreTypeEngine := mySQLDatastoreType resource.Test(t, resource.TestCase{ PreCheck: func() { testAccSelectelPreCheck(t) }, @@ -50,7 +50,7 @@ func TestAccDBaaSMySQLNativeDatabaseV1Basic(t *testing.T) { datastoreName := acctest.RandomWithPrefix("tf-acc-ds") databaseName := RandomWithPrefix("tf_acc_db") nodeCount := 1 - datastoreTypeEngine := "mysql_native" + datastoreTypeEngine := mySQLNativeDatastoreType resource.Test(t, resource.TestCase{ PreCheck: func() { testAccSelectelPreCheck(t) }, diff --git a/selectel/resource_selectel_dbaas_mysql_datastore_v1.go b/selectel/resource_selectel_dbaas_mysql_datastore_v1.go index 7dbd1a0a..60873020 100644 --- a/selectel/resource_selectel_dbaas_mysql_datastore_v1.go +++ b/selectel/resource_selectel_dbaas_mysql_datastore_v1.go @@ -181,7 +181,7 @@ func resourceDBaaSMySQLDatastoreV1Create(ctx context.Context, d *schema.Resource } typeID := d.Get("type_id").(string) - diagErr = validateDatastoreType(ctx, []string{"mysql", "mysql_native"}, typeID, dbaasClient) + diagErr = validateDatastoreType(ctx, []string{mySQLDatastoreType, mySQLNativeDatastoreType}, typeID, dbaasClient) if diagErr != nil { return diagErr } diff --git a/selectel/resource_selectel_dbaas_mysql_datastore_v1_test.go b/selectel/resource_selectel_dbaas_mysql_datastore_v1_test.go index 1010cdae..4ecd1a0f 100644 --- a/selectel/resource_selectel_dbaas_mysql_datastore_v1_test.go +++ b/selectel/resource_selectel_dbaas_mysql_datastore_v1_test.go @@ -11,6 +11,39 @@ import ( "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/projects" ) +type Flavor struct { + vcpus int + ram int + disk int +} + +type MySQLConfig struct { + innodbChecksumAlgorithm string + autoIncrementOffset int + autocommit bool +} + +func getCheckSteps(project projects.Project, dbaasDatastore dbaas.Datastore, datastoreName string, nodeCount, firewallRulesLen int, flavor Flavor, config MySQLConfig) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), + testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", datastoreName), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(flavor.vcpus)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(flavor.ram)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(flavor.disk)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", config.innodbChecksumAlgorithm), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(config.autoIncrementOffset)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", strconv.FormatBool(config.autocommit)), + resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", strconv.Itoa(firewallRulesLen)), + resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), + resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), + ) +} + func TestAccDBaaSMySQLDatastoreV1Basic(t *testing.T) { var ( dbaasDatastore dbaas.Datastore @@ -20,7 +53,7 @@ func TestAccDBaaSMySQLDatastoreV1Basic(t *testing.T) { projectName := acctest.RandomWithPrefix("tf-acc") datastoreName := acctest.RandomWithPrefix("tf-acc-ds") nodeCount := 1 - datastoreTypeEngine := "mysql" + datastoreTypeEngine := mySQLDatastoreType updatedDatastoreName := acctest.RandomWithPrefix("tf-acc-ds-updated") @@ -31,106 +64,23 @@ func TestAccDBaaSMySQLDatastoreV1Basic(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccDBaaSMySQLDatastoreV1Basic(projectName, datastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", datastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(4096)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, datastoreName, nodeCount, 0, Flavor{2, 4096, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1UpdateName(projectName, updatedDatastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(4096)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, nodeCount, 0, Flavor{2, 4096, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1UpdateFirewall(projectName, updatedDatastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(4096)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", "2"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, nodeCount, 2, Flavor{2, 4096, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1Resize(projectName, updatedDatastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(8192)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", "2"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, nodeCount, 2, Flavor{2, 8192, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1UpdateConfig(projectName, updatedDatastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(8192)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(4)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", "2"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, nodeCount, 2, Flavor{2, 8192, 32}, MySQLConfig{"strict_innodb", 4, true}), }, }, }) @@ -145,7 +95,7 @@ func TestAccDBaaSMySQLNativeDatastoreV1Basic(t *testing.T) { projectName := acctest.RandomWithPrefix("tf-acc") datastoreName := acctest.RandomWithPrefix("tf-acc-ds") nodeCount := 1 - datastoreTypeEngine := "mysql_native" + datastoreTypeEngine := mySQLNativeDatastoreType resizeNodeCount := 2 updatedDatastoreName := acctest.RandomWithPrefix("tf-acc-ds-updated") @@ -157,106 +107,23 @@ func TestAccDBaaSMySQLNativeDatastoreV1Basic(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccDBaaSMySQLDatastoreV1Basic(projectName, datastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", datastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(4096)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, datastoreName, nodeCount, 0, Flavor{2, 4096, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1UpdateName(projectName, updatedDatastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(4096)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, nodeCount, 0, Flavor{2, 4096, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1UpdateFirewall(projectName, updatedDatastoreName, datastoreTypeEngine, nodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(nodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(4096)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", "2"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, nodeCount, 2, Flavor{2, 4096, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1Resize(projectName, updatedDatastoreName, datastoreTypeEngine, resizeNodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(resizeNodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(8192)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "false"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", "2"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, resizeNodeCount, 2, Flavor{2, 8192, 32}, MySQLConfig{"strict_innodb", 2, false}), }, { Config: testAccDBaaSMySQLDatastoreV1UpdateConfig(projectName, updatedDatastoreName, datastoreTypeEngine, resizeNodeCount), - Check: resource.ComposeTestCheckFunc( - testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project), - testAccCheckDBaaSDatastoreV1Exists("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", &dbaasDatastore), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "name", updatedDatastoreName), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "region", "ru-3"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "node_count", strconv.Itoa(resizeNodeCount)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "enabled", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "status", string(dbaas.StatusActive)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.vcpus", strconv.Itoa(2)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.ram", strconv.Itoa(8192)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "flavor.0.disk", strconv.Itoa(32)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.innodb_checksum_algorithm", "strict_innodb"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.auto_increment_offset", strconv.Itoa(4)), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "config.autocommit", "true"), - resource.TestCheckResourceAttr("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "firewall.0.ips.#", "2"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.master"), - resource.TestCheckResourceAttrSet("selectel_dbaas_mysql_datastore_v1.datastore_tf_acc_test_1", "connections.MASTER"), - ), + Check: getCheckSteps(project, dbaasDatastore, updatedDatastoreName, resizeNodeCount, 2, Flavor{2, 8192, 32}, MySQLConfig{"strict_innodb", 4, true}), }, }, }) diff --git a/selectel/resource_selectel_dbaas_postgresql_datastore_v1.go b/selectel/resource_selectel_dbaas_postgresql_datastore_v1.go index 8de32b41..8b5ef359 100644 --- a/selectel/resource_selectel_dbaas_postgresql_datastore_v1.go +++ b/selectel/resource_selectel_dbaas_postgresql_datastore_v1.go @@ -205,7 +205,7 @@ func resourceDBaaSPostgreSQLDatastoreV1Create(ctx context.Context, d *schema.Res } typeID := d.Get("type_id").(string) - diagErr = validateDatastoreType(ctx, []string{"postgresql"}, typeID, dbaasClient) + diagErr = validateDatastoreType(ctx, []string{postgreSQLDatastoreType}, typeID, dbaasClient) if diagErr != nil { return diagErr } diff --git a/selectel/resource_selectel_dbaas_redis_datastore_v1.go b/selectel/resource_selectel_dbaas_redis_datastore_v1.go index 9ba3ebe6..18a4a2d5 100644 --- a/selectel/resource_selectel_dbaas_redis_datastore_v1.go +++ b/selectel/resource_selectel_dbaas_redis_datastore_v1.go @@ -173,7 +173,7 @@ func resourceDBaaSRedisDatastoreV1Create(ctx context.Context, d *schema.Resource flavorID, flavorIDOk := d.GetOk("flavor_id") typeID := d.Get("type_id").(string) - diagErr = validateDatastoreType(ctx, []string{"redis"}, typeID, dbaasClient) + diagErr = validateDatastoreType(ctx, []string{redisDatastoreType}, typeID, dbaasClient) if diagErr != nil { return diagErr }