|
| 1 | +// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Mozilla Public License v2.0 |
| 3 | + |
| 4 | +package integrationtest |
| 5 | + |
| 6 | +import ( |
| 7 | + "fmt" |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/oracle/terraform-provider-oci/internal/acctest" |
| 11 | + "github.com/oracle/terraform-provider-oci/internal/utils" |
| 12 | + |
| 13 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 14 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| 15 | + "github.com/oracle/terraform-provider-oci/httpreplay" |
| 16 | +) |
| 17 | + |
| 18 | +var ( |
| 19 | + DatabaseAutonomousDatabasePeerDataSourceRepresentation = map[string]interface{}{ |
| 20 | + "autonomous_database_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_database_autonomous_database.test_autonomous_database.id}`}, |
| 21 | + } |
| 22 | + |
| 23 | + DatabaseAutonomousDatabaseRepresentation11 = map[string]interface{}{ |
| 24 | + "compartment_id": acctest.Representation{RepType: acctest.Required, Create: utils.GetEnvSettingWithBlankDefault("compartment_ocid")}, |
| 25 | + "cpu_core_count": acctest.Representation{RepType: acctest.Required, Create: `1`}, |
| 26 | + "data_storage_size_in_tbs": acctest.Representation{RepType: acctest.Required, Create: `1`}, |
| 27 | + "db_name": acctest.Representation{RepType: acctest.Required, Create: adbName}, |
| 28 | + "admin_password": acctest.Representation{RepType: acctest.Required, Create: `BEstrO0ng_#11`, Update: `BEstrO0ng_#12`}, |
| 29 | + "db_workload": acctest.Representation{RepType: acctest.Optional, Create: `OLTP`}, |
| 30 | + "character_set": acctest.Representation{RepType: acctest.Optional, Create: `AL32UTF8`}, |
| 31 | + "display_name": acctest.Representation{RepType: acctest.Optional, Create: `example_autonomous_database`, Update: `displayName2`}, |
| 32 | + "is_auto_scaling_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`}, |
| 33 | + "is_auto_scaling_for_storage_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`}, |
| 34 | + "is_dedicated": acctest.Representation{RepType: acctest.Optional, Create: `false`}, |
| 35 | + "is_mtls_connection_required": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`}, |
| 36 | + "autonomous_maintenance_schedule_type": acctest.Representation{RepType: acctest.Optional, Create: `REGULAR`}, |
| 37 | + "is_preview_version_with_service_terms_accepted": acctest.Representation{RepType: acctest.Optional, Create: `false`}, |
| 38 | + "customer_contacts": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousDatabaseCustomerContactsRepresentation}, |
| 39 | + "license_model": acctest.Representation{RepType: acctest.Optional, Create: `LICENSE_INCLUDED`}, |
| 40 | + "scheduled_operations": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousDatabaseScheduledOperationsRepresentation}, |
| 41 | + "whitelisted_ips": acctest.Representation{RepType: acctest.Optional, Create: []string{`1.1.1.1/28`}}, |
| 42 | + "operations_insights_status": acctest.Representation{RepType: acctest.Optional, Create: `NOT_ENABLED`, Update: `ENABLED`}, |
| 43 | + "timeouts": acctest.RepresentationGroup{RepType: acctest.Required, Group: autonomousDatabaseTimeoutsRepresentation}, |
| 44 | + "ncharacter_set": acctest.Representation{RepType: acctest.Optional, Create: `AL16UTF16`}, |
| 45 | + "state": acctest.Representation{RepType: acctest.Optional, Create: `AVAILABLE`}, |
| 46 | + } |
| 47 | +) |
| 48 | + |
| 49 | +func TestDatabaseAutonomousDatabasePeerResource_basic(t *testing.T) { |
| 50 | + datasourceName := "data.oci_database_autonomous_database_peers.test_autonomous_database_peers" |
| 51 | + |
| 52 | + httpreplay.SetScenario("TestDatabaseCrossRegionDisasterRecovery_basic") |
| 53 | + defer httpreplay.SaveScenario() |
| 54 | + |
| 55 | + provider := acctest.TestAccProvider |
| 56 | + config := acctest.ProviderTestConfig() |
| 57 | + compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") |
| 58 | + compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) |
| 59 | + |
| 60 | + resource.Test(t, resource.TestCase{ |
| 61 | + PreCheck: func() { acctest.TestAccPreCheck(t) }, |
| 62 | + Providers: map[string]*schema.Provider{ |
| 63 | + "oci": provider, |
| 64 | + }, |
| 65 | + Steps: []resource.TestStep{ |
| 66 | + { |
| 67 | + Config: config + |
| 68 | + acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", acctest.Required, acctest.Create, DatabaseAutonomousDatabaseRepresentation11) + |
| 69 | + acctest.GenerateDataSourceFromRepresentationMap("oci_database_autonomous_database_peers", "test_autonomous_database_peers", acctest.Required, acctest.Create, DatabaseAutonomousDatabasePeerDataSourceRepresentation) + |
| 70 | + compartmentIdVariableStr, |
| 71 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 72 | + resource.TestCheckResourceAttrSet(datasourceName, "autonomous_database_peer_collection.#"), |
| 73 | + resource.TestCheckResourceAttr(datasourceName, "autonomous_database_peer_collection.0.items.#", "0"), |
| 74 | + ), |
| 75 | + }, |
| 76 | + }, |
| 77 | + }) |
| 78 | +} |
0 commit comments