Skip to content

Commit

Permalink
Disk Integration Tests (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
dehume authored Aug 24, 2023
1 parent 2602e49 commit 8d788bf
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/cluster_replica.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Read-Only:

- `availability_zone` (String)
- `cluster` (String)
- `disk` (Boolean)
- `id` (String)
- `name` (String)
- `size` (String)
1 change: 1 addition & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ resource "materialize_cluster" "example_cluster" {

### Optional

- `disk` (Boolean) **Private Preview**. Whether or not the replicas of the managed cluster are _disk-backed replicas_.
- `idle_arrangement_merge_effort` (Number) The amount of effort to exert compacting arrangements during idle periods. This is an unstable option! It may be changed or removed at any time.
- `introspection_debugging` (Boolean) Whether to introspect the gathering of the introspection data.
- `introspection_interval` (String) The interval at which to collect introspection data.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/cluster_replica.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "materialize_cluster_replica" "example_cluster_replica" {
### Optional

- `availability_zone` (String) The specific availability zone of the replica.
- `disk` (Boolean) **Private Preview**. Whether or not the replica is a _disk-backed replica_.
- `idle_arrangement_merge_effort` (Number) The amount of effort to exert compacting arrangements during idle periods. This is an unstable option! It may be changed or removed at any time.
- `introspection_debugging` (Boolean) Whether to introspect the gathering of the introspection data.
- `introspection_interval` (String) The interval at which to collect introspection data.
Expand Down
1 change: 1 addition & 0 deletions integration/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "materialize_cluster" "managed_cluster" {
introspection_interval = "1s"
introspection_debugging = true
idle_arrangement_merge_effort = 2
disk = true
}

data "materialize_cluster" "all" {}
Expand Down
1 change: 1 addition & 0 deletions integration/cluster_replica.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ resource "materialize_cluster_replica" "cluster_replica_2" {
introspection_interval = "2s"
introspection_debugging = true
idle_arrangement_merge_effort = 1
disk = true
}

resource "materialize_cluster_replica" "cluster_replica_source" {
Expand Down
2 changes: 2 additions & 0 deletions pkg/provider/acceptance_cluster_replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestAccClusterReplica_basic(t *testing.T) {
resource.TestCheckResourceAttr("materialize_cluster_replica.test", "size", "1"),
resource.TestCheckResourceAttr("materialize_cluster_replica.test", "introspection_interval", "1s"),
resource.TestCheckResourceAttr("materialize_cluster_replica.test", "introspection_debugging", "false"),
resource.TestCheckResourceAttr("materialize_cluster_replica.test", "disk", "true"),
resource.TestCheckNoResourceAttr("materialize_cluster_replica.test", "idle_arrangement_merge_effort"),
),
},
Expand Down Expand Up @@ -78,6 +79,7 @@ resource "materialize_cluster_replica" "test" {
cluster_name = materialize_cluster.test.name
name = "%[2]s"
size = "1"
disk = true
}
`, clusterName, clusterReplica)
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/provider/acceptance_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAccCluster_basic(t *testing.T) {
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: testAccClusterResource(roleName, clusterName, cluster2Name, roleName, "2-2", "1"),
Config: testAccClusterResource(roleName, clusterName, cluster2Name, roleName, "2-2", "1", "true"),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists("materialize_cluster.test"),
resource.TestCheckResourceAttr("materialize_cluster.test", "name", clusterName),
Expand All @@ -36,6 +36,7 @@ func TestAccCluster_basic(t *testing.T) {
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "ownership_role", "mz_system"),
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "replication_factor", "1"),
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "size", "2-2"),
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "disk", "true"),
),
},
{
Expand All @@ -60,10 +61,10 @@ func TestAccCluster_update(t *testing.T) {
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: testAccClusterResource(roleName, oldClusterName, cluster2Name, "mz_system", "2-1", "2"),
Config: testAccClusterResource(roleName, oldClusterName, cluster2Name, "mz_system", "2-1", "2", "false"),
},
{
Config: testAccClusterResource(roleName, newClusterName, cluster2Name, roleName, "2-2", "1"),
Config: testAccClusterResource(roleName, newClusterName, cluster2Name, roleName, "2-2", "1", "true"),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists("materialize_cluster.test"),
resource.TestCheckResourceAttr("materialize_cluster.test", "name", newClusterName),
Expand All @@ -77,6 +78,7 @@ func TestAccCluster_update(t *testing.T) {
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "ownership_role", "mz_system"),
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "replication_factor", "1"),
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "size", "2-2"),
resource.TestCheckResourceAttr("materialize_cluster.test_managed_cluster", "disk", "true"),
),
},
},
Expand All @@ -93,7 +95,7 @@ func TestAccCluster_disappears(t *testing.T) {
CheckDestroy: testAccCheckAllClusterDestroyed,
Steps: []resource.TestStep{
{
Config: testAccClusterResource(roleName, clusterName, cluster2Name, roleName, "2-2", "1"),
Config: testAccClusterResource(roleName, clusterName, cluster2Name, roleName, "2-2", "1", "true"),
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterExists("materialize_cluster.test"),
testAccCheckObjectDisappears(materialize.ObjectSchemaStruct{ObjectType: "CLUSTER", Name: clusterName}),
Expand All @@ -106,7 +108,7 @@ func TestAccCluster_disappears(t *testing.T) {
})
}

func testAccClusterResource(roleName, cluster1Name, cluster2Name, cluster2Owner, clusterSize, clusterReplicationFactor string) string {
func testAccClusterResource(roleName, cluster1Name, cluster2Name, cluster2Owner, clusterSize, clusterReplicationFactor, disk string) string {
return fmt.Sprintf(`
resource "materialize_role" "test" {
name = "%[1]s"
Expand All @@ -130,9 +132,10 @@ resource "materialize_cluster" "test_managed_cluster" {
introspection_interval = "1s"
introspection_debugging = true
idle_arrangement_merge_effort = 2
disk = %[7]s
}
`, roleName, cluster1Name, cluster2Name, cluster2Owner, clusterSize, clusterReplicationFactor)
`, roleName, cluster1Name, cluster2Name, cluster2Owner, clusterSize, clusterReplicationFactor, disk)
}

func testAccCheckClusterExists(name string) resource.TestCheckFunc {
Expand Down
2 changes: 2 additions & 0 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}

// TODO: Remove this once enable_connection_validation_syntax is enabled by default
_, err = db.Exec("ALTER SYSTEM SET enable_connection_validation_syntax = true;")
// TODO: Remove this once enable_disk_cluster_replicas is enabled by default
_, err = db.Exec("ALTER SYSTEM SET enable_disk_cluster_replicas TO true;")
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Expand Down

0 comments on commit 8d788bf

Please sign in to comment.