@@ -7,40 +7,95 @@ import (
77 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
88)
99
10- func TestCDC (t * testing.T ) {
11- // Disable this test by default until test works with non-prod clusters
12- checkRequiredTestVars (t , "ASTRA_TEST_CDC_TEST_ENABLED" )
10+ // https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html
11+ func TestAccAstraCDC (t * testing.T ) {
12+ resource .Test (t , resource.TestCase {
13+ PreCheck : func () { testAccPreCheck (t ) },
14+ Providers : testAccProviders ,
15+ Steps : []resource.TestStep {
16+ {
17+ Config : testAstraCDCConfig (),
18+ },
19+ },
20+ })
21+ }
22+
23+ func testAstraCDCConfig () string {
24+ return `
1325
26+ resource "astra_cdc" "cdc-1" {
27+ database_id = "de76e588-761f-4e74-afed-1d2092aaaa84"
28+ database_name = "terraform-cdc-test"
29+ keyspace = "ks1"
30+ table = "tbl1"
31+ topic_partitions = 3
32+ pulsar_cluster = "pulsar-gcp-useast1-staging"
33+ tenant_name = "terraform-tests1"
34+ }`
35+ }
36+
37+ func TestAstraCDCFull (t * testing.T ) {
38+ checkRequiredTestVars (t , "ASTRA_TEST_CDC_FULL_TEST_ENABLED" )
39+ streamingTenant := "terraform-cdc-test-" + randomString (6 )
1440 resource .Test (t , resource.TestCase {
1541 PreCheck : func () { testAccPreCheck (t ) },
1642 Providers : testAccProviders ,
1743 Steps : []resource.TestStep {
1844 {
19- Config : testAccCDCConfiguration ( ),
45+ Config : testAstraCDCConfigFull ( "GCP" , "us-east1" , streamingTenant ),
2046 },
2147 },
2248 })
2349}
2450
25- // https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html
26- func testAccCDCConfiguration () string {
51+ func testAstraCDCConfigFull (cloud_provider , region , streamingTenant string ) string {
2752 return fmt .Sprintf (`
28- resource "astra_streaming_tenant" "streaming_tenant-1" {
29- tenant_name = "terraformtest"
30- topic = "terraformtest"
31- region = "useast-4"
32- cloud_provider = "gcp"
33- 53+
54+ resource "astra_database" "database_1" {
55+ cloud_provider = "%s"
56+ regions = ["%s"]
57+ name = "terraform-cdc-test"
58+ keyspace = "ks1"
59+ deletion_protection = "false"
3460}
35- resource "astra_cdc" "cdc-1" {
36- depends_on = [ astra_streaming_tenant.streaming_tenant-1 ]
37- database_id = "5b70892f-e01a-4595-98e6-19ecc9985d50"
38- database_name = "sai_test"
39- table = "test"
40- keyspace = "sai_test"
41- topic_partitions = 3
42- tenant_name = astra_streaming_tenant.streaming_tenant-1.tenant_name
61+
62+ resource "astra_table" "table_1" {
63+ database_id = astra_database.database_1.id
64+ keyspace = astra_database.database_1.keyspace
65+ region = "%s"
66+ table = "cdctable1"
67+ clustering_columns = "a"
68+ partition_keys = "b"
69+ column_definitions = [
70+ {
71+ Name: "a"- Static: false
72+ TypeDefinition: "text"
73+ },
74+ {
75+ Name: "b"
76+ Static: false
77+ TypeDefinition: "text"
78+ }
79+ ]
4380}
4481
45- ` )
82+ resource "astra_streaming_tenant" "streaming_tenant_1" {
83+ tenant_name = "%s"
84+ cloud_provider = lower(astra_database.database_1.cloud_provider)
85+ region = astra_table.table_1.region
86+ 87+ deletion_protection = "false"
88+ }
89+
90+ resource "astra_cdc" "cdc-1" {
91+ depends_on = [ astra_database.database_1, astra_streaming_tenant.streaming_tenant_1 ]
92+ database_id = astra_database.database_1.id
93+ database_name = astra_database.database_1.name
94+ keyspace = astra_database.database_1.keyspace
95+ table = astra_table.table_1.table
96+ topic_partitions = 3
97+ tenant_name = astra_streaming_tenant.streaming_tenant_1.tenant_name
98+ pulsar_cluster = astra_streaming_tenant.streaming_tenant_1.cluster_name
99+ }` , cloud_provider , region , region , streamingTenant )
100+
46101}
0 commit comments