Skip to content

Commit

Permalink
Pull request #1301: remove mongodb enterprise tests
Browse files Browse the repository at this point in the history
Merge in CLOUD/terraform-provider-yandex-mirror from remove-mongodb-enterprise-tests to master

Squashed commit of the following:

commit 74257918d82068df78d880b09e198767571913b8
Author: Dmitry Zykov <dmitryzykov@yandex-team.ru>
Date:   Fri Jul 12 13:47:12 2024 +0300

    remove mongodb enterprise tests
  • Loading branch information
Dmitrii Zykov committed Jul 15, 2024
1 parent 698b314 commit ca4fda3
Showing 1 changed file with 0 additions and 235 deletions.
235 changes: 0 additions & 235 deletions yandex/resource_yandex_mdb_mongodb_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,241 +869,6 @@ func TestAccMDBMongoDBCluster_6_0(t *testing.T) {
})
}

func create6_0_enterpriseConfigData() map[string]interface{} {
return map[string]interface{}{
"Version": "6.0-enterprise",
"ClusterName": acctest.RandomWithPrefix("test-acc-tf-mongodb"),
"Environment": "PRESTABLE",
"Lables": map[string]string{"test_key": "test_value"},
"BackupWindow": map[string]int64{
"hours": 3,
"minutes": 4,
},
"Mongod": map[string]interface{}{
"AuditLog": map[string]interface{}{
"Filter": "{ \"atype\": { \"$in\": [ \"createCollection\", \"dropCollection\" ] } }",
},
"SetParameter": map[string]interface{}{
"AuditAuthorizationSuccess": true,
},
"Net": map[string]interface{}{
"MaxConnections": 1100,
},
"OperationProfiling": map[string]interface{}{
"Mode": "ALL",
"OpThreshold": 1000,
"OpSampleRate": 0.5,
},
"Storage": map[string]interface{}{
"WiredTiger": map[string]interface{}{
"Compressor": "ZLIB",
"PrefixCompression": false,
},
"Journal": map[string]interface{}{
"CommitInterval": 404,
},
},
},
"Databases": []string{"testdb"},
"Users": []*mongodb.UserSpec{
{
Name: "john",
Password: "password",
Permissions: []*mongodb.Permission{
{
DatabaseName: "testdb",
},
},
},
},
"ResourcesMongod": &mongodb.Resources{
ResourcePresetId: s2Micro16hdd.ResourcePresetId,
DiskSize: s2Micro16hdd.DiskSize >> 30,
DiskTypeId: s2Micro16hdd.DiskTypeId,
},
"Hosts": mongoHosts,
"SecurityGroupIds": []string{"${yandex_vpc_security_group.sg-x.id}"},
"MaintenanceWindow": map[string]interface{}{
"Type": "WEEKLY",
"Day": "FRI",
"Hour": 20,
},
"DeletionProtection": true,
}
}

// Test that a MongoDB Cluster can be created, updated and destroyed
func TestAccMDBMongoDBCluster_6_0_enterprise(t *testing.T) {
t.Parallel()

configData := create6_0_enterpriseConfigData()
clusterName := configData["ClusterName"].(string)
version := configData["Version"].(string)
auditLogFilter := ((configData["Mongod"].(map[string]interface{}))["AuditLog"].(map[string]interface{}))["Filter"].(string)

var testCluster mongodb.Cluster
folderID := getExampleFolderID()
newResources := mongodb.Resources{
ResourcePresetId: s2Small26hdd.ResourcePresetId,
DiskSize: toBytes(30),
DiskTypeId: s2Small26hdd.DiskTypeId,
}
fmt.Printf("%v", makeConfig(t, &configData, nil))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
CheckDestroy: resource.ComposeTestCheckFunc(
testAccCheckMDBMongoDBClusterDestroy,
testAccCheckVPCNetworkDestroy,
),
Steps: []resource.TestStep{
// Create
{
Config: makeConfig(t, &configData, nil),
Check: resource.ComposeTestCheckFunc(
testAccCheckMDBMongoDBClusterExists(mongodbResource, &testCluster, 2),
resource.TestCheckResourceAttr(mongodbResource, "name", clusterName),
resource.TestCheckResourceAttr(mongodbResource, "folder_id", folderID),
testAccCheckMDBMongoDBClusterHasRightVersion(&testCluster, version),
testAccCheckMDBMongoDBClusterHasMongodSpec(&testCluster, map[string]interface{}{
"Resources": &s2Micro16hdd,
"AuditLogFilter": auditLogFilter,
"AuditAuthorizationSuccess": true,
}),
testAccCheckMDBMongoDBClusterHasDatabases(mongodbResource, []string{"testdb"}),
testAccCheckMDBMongoDBClusterHasUsers(mongodbResource, map[string][]string{"john": {"testdb"}}),
testAccCheckMDBMongoDBClusterContainsLabel(&testCluster, "test_key", "test_value"),
testAccCheckCreatedAtAttr(mongodbResource),
resource.TestCheckResourceAttr(mongodbResource, "security_group_ids.#", "1"),
resource.TestCheckResourceAttr(mongodbResource, "maintenance_window.0.type", "WEEKLY"),
resource.TestCheckResourceAttr(mongodbResource, "maintenance_window.0.day", "FRI"),
resource.TestCheckResourceAttr(mongodbResource, "maintenance_window.0.hour", "20"),
resource.TestCheckResourceAttr(mongodbResource, "deletion_protection", "true"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.audit_log.0.filter", auditLogFilter),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.set_parameter.0.audit_authorization_success", "true"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.net.0.max_incoming_connections", "1100"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.operation_profiling.0.mode", "ALL"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.operation_profiling.0.slow_op_threshold", "1000"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.operation_profiling.0.slow_op_sample_rate", "0.5"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.storage.0.wired_tiger.0.block_compressor", "ZLIB"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.storage.0.wired_tiger.0.prefix_compression", "false"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.storage.0.journal.0.commit_interval", "404"),
resource.TestCheckNoResourceAttr(mongodbResource, "cluster_config.0.mongod.0.net.0.compressors"),
resource.TestCheckResourceAttr(mongodbResource, "host.0.assign_public_ip", "false"),
resource.TestCheckResourceAttr(mongodbResource, "host.1.assign_public_ip", "true"),
resource.TestCheckResourceAttr(mongodbResource, "host.0.host_parameters.#", "1"),
resource.TestCheckResourceAttr(mongodbResource, "host.1.host_parameters.#", "1"),
testAccCheckMDBMongoDBClusterHasHostParameters(mongodbResource, map[string]interface{}{"tags": map[string]string{}, "hidden": false, "priority": 1.0, "secondary_delay_secs": int64(0)}, 2),
),
},
mdbMongoDBClusterImportStep(),
{ // Uncheck deletion_protection
Config: makeConfig(t, &configData, &map[string]interface{}{
"DeletionProtection": false,
}),
Check: resource.ComposeTestCheckFunc(
testAccCheckMDBMongoDBClusterExists(mongodbResource, &testCluster, 2),
resource.TestCheckResourceAttr(mongodbResource, "deletion_protection", "false"),
),
},
mdbMongoDBClusterImportStep(),
{ // Update: remove filter and uncheck AuditAuthorizationSuccess
Config: makeConfig(t, &configData, &map[string]interface{}{
"Mongod": map[string]interface{}{
"AuditLog": map[string]interface{}{
"Filter": "{}",
},
"SetParameter": map[string]interface{}{
"AuditAuthorizationSuccess": false,
"EnableFlowControl": false,
"MinSnapshotHistoryWindowInSeconds": 300,
},
"Net": map[string]interface{}{
"MaxConnections": 1101,
"Compressors": []string{"\"SNAPPY\""},
},
"OperationProfiling": map[string]interface{}{
"Mode": "SLOW_OP",
"OpThreshold": 2000,
"OpSampleRate": 0.6,
},
"Storage": map[string]interface{}{
"WiredTiger": map[string]interface{}{
"Compressor": "SNAPPY",
"PrefixCompression": true,
},
"Journal": map[string]interface{}{
"CommitInterval": 407,
},
},
},
"ResourcesMongod": &mongodb.Resources{
ResourcePresetId: newResources.ResourcePresetId,
DiskSize: newResources.DiskSize >> 30,
DiskTypeId: newResources.DiskTypeId,
},
}),
Check: resource.ComposeTestCheckFunc(
testAccCheckMDBMongoDBClusterExists(mongodbResource, &testCluster, 2),
resource.TestCheckResourceAttr(mongodbResource, "name", clusterName),
resource.TestCheckResourceAttr(mongodbResource, "folder_id", folderID),
testAccCheckMDBMongoDBClusterHasRightVersion(&testCluster, version),
testAccCheckMDBMongoDBClusterHasMongodSpec(&testCluster, map[string]interface{}{
"Resources": &newResources,
"AuditLogFilter": "{}",
"AuditAuthorizationSuccess": false,
}),
testAccCheckMDBMongoDBClusterHasDatabases(mongodbResource, []string{"testdb"}),
testAccCheckMDBMongoDBClusterHasUsers(mongodbResource, map[string][]string{"john": {"testdb"}}),
testAccCheckMDBMongoDBClusterContainsLabel(&testCluster, "test_key", "test_value"),
testAccCheckCreatedAtAttr(mongodbResource),
resource.TestCheckResourceAttr(mongodbResource, "security_group_ids.#", "1"),
resource.TestCheckResourceAttr(mongodbResource, "maintenance_window.0.type", "WEEKLY"),
resource.TestCheckResourceAttr(mongodbResource, "maintenance_window.0.day", "FRI"),
resource.TestCheckResourceAttr(mongodbResource, "maintenance_window.0.hour", "20"),
resource.TestCheckResourceAttr(mongodbResource, "deletion_protection", "false"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.audit_log.0.filter", "{}"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.set_parameter.0.audit_authorization_success", "false"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.net.0.max_incoming_connections", "1101"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.operation_profiling.0.mode", "SLOW_OP"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.net.0.compressors.0", "SNAPPY"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.net.0.compressors.#", "1"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.operation_profiling.0.slow_op_sample_rate", "0.6"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.set_parameter.0.enable_flow_control", "false"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.set_parameter.0.min_snapshot_history_window_in_seconds", "300"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.storage.0.wired_tiger.0.prefix_compression", "true"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.operation_profiling.0.slow_op_threshold", "2000"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.storage.0.wired_tiger.0.block_compressor", "SNAPPY"),
resource.TestCheckResourceAttr(mongodbResource,
"cluster_config.0.mongod.0.storage.0.journal.0.commit_interval", "407"),
),
},
mdbMongoDBClusterImportStep(),
},
})
}

// minimal configs for creation mongodb cluster
func create6_0V1ConfigData() map[string]interface{} {
return map[string]interface{}{
Expand Down

0 comments on commit ca4fda3

Please sign in to comment.