|
| 1 | +package provider |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 8 | +) |
| 9 | + |
| 10 | +func TestAstraCDCv3(t *testing.T) { |
| 11 | + checkRequiredTestVars(t, "ASTRA_TEST_CDC_V3_TEST_ENABLED") |
| 12 | + streamingTenant := "terraform-cdcv3-test-" + randomString(4) |
| 13 | + resource.Test(t, resource.TestCase{ |
| 14 | + PreCheck: func() { testAccPreCheck(t) }, |
| 15 | + Providers: testAccProviders, |
| 16 | + Steps: []resource.TestStep{ |
| 17 | + { |
| 18 | + Config: testAstraCDCv3Config("GCP", "us-east1", streamingTenant), |
| 19 | + }, |
| 20 | + }, |
| 21 | + }) |
| 22 | +} |
| 23 | + |
| 24 | +func testAstraCDCv3Config(cloud_provider, region, streamingTenant string) string { |
| 25 | + return fmt.Sprintf(` |
| 26 | +
|
| 27 | +resource "astra_database" "database_1" { |
| 28 | + cloud_provider = "%s" |
| 29 | + regions = ["%s"] |
| 30 | + name = "terraform-cdc-test" |
| 31 | + keyspace = "ks1" |
| 32 | + deletion_protection = "false" |
| 33 | +} |
| 34 | +
|
| 35 | +resource "astra_table" "table_1" { |
| 36 | + database_id = astra_database.database_1.id |
| 37 | + keyspace = astra_database.database_1.keyspace |
| 38 | + region = astra_database.database_1.region[0] |
| 39 | + table = "cdctable1" |
| 40 | + clustering_columns = "a" |
| 41 | + partition_keys = "b" |
| 42 | + column_definitions = [ |
| 43 | + { |
| 44 | + Name: "a" |
| 45 | + Static: false |
| 46 | + TypeDefinition: "text" |
| 47 | + }, |
| 48 | + { |
| 49 | + Name: "b" |
| 50 | + Static: false |
| 51 | + TypeDefinition: "text" |
| 52 | + } |
| 53 | + ] |
| 54 | +} |
| 55 | +
|
| 56 | +resource "astra_table" "table_2" { |
| 57 | + database_id = astra_database.database_1.id |
| 58 | + keyspace = astra_database.database_1.keyspace |
| 59 | + region = astra_database.database_1.region[0] |
| 60 | + table = "cdctable2" |
| 61 | + clustering_columns = "a" |
| 62 | + partition_keys = "b" |
| 63 | + column_definitions = [ |
| 64 | + { |
| 65 | + Name: "a" |
| 66 | + Static: false |
| 67 | + TypeDefinition: "text" |
| 68 | + }, |
| 69 | + { |
| 70 | + Name: "b" |
| 71 | + Static: false |
| 72 | + TypeDefinition: "text" |
| 73 | + } |
| 74 | + ] |
| 75 | +} |
| 76 | +
|
| 77 | +resource "astra_streaming_tenant" "tenant_1" { |
| 78 | + cluster_name = "pulsar-gcp-useast1" |
| 79 | + tenant_name = "%s" |
| 80 | + |
| 81 | + deletion_protection = "false" |
| 82 | +} |
| 83 | +
|
| 84 | + resource "astra_cdc_v3" "cdc_1" { |
| 85 | + depends_on = [ astra_database.database_1, astra_streaming_tenant.streaming_tenant_1 ] |
| 86 | + database_id = astra_database.database_1.id |
| 87 | + database_name = astra_database.database_1.name |
| 88 | + tables = [ |
| 89 | + { |
| 90 | + keyspace = "ks1" |
| 91 | + table = "table1" |
| 92 | + }, |
| 93 | + { |
| 94 | + keyspace = "ks1" |
| 95 | + table = "table2" |
| 96 | + }, |
| 97 | + ] |
| 98 | + regions = [ |
| 99 | + { |
| 100 | + region = "us-east1" |
| 101 | + datacenter_id = "${astra_database.example.id}-1" |
| 102 | + streaming_cluster = astra_streaming_tenant.tenant_1.cluster_name |
| 103 | + streaming_tenant = astra_streaming_tenant.tenant_1.tenant_name |
| 104 | + }, |
| 105 | + ] |
| 106 | +
|
| 107 | +}`, cloud_provider, region, streamingTenant) |
| 108 | + |
| 109 | +} |
0 commit comments