Skip to content

Commit

Permalink
Merge branch 'main' into Resource-Grants
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Hume committed Jun 15, 2023
2 parents b01b2be + c6e6d61 commit 794cfb0
Show file tree
Hide file tree
Showing 35 changed files with 1,322 additions and 65 deletions.
7 changes: 4 additions & 3 deletions docs/resources/source_load_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ resource "materialize_source_load_generator" "example_source_load_generator" {
schema_name = "schema"
size = "3xsmall"
load_generator_type = "COUNTER"
counter_options {
load_generator_type = "COUNTER"
tick_interval = "500ms"
scale_factor = 0.01
tick_interval = "500ms"
scale_factor = 0.01
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ resource "materialize_source_load_generator" "example_source_load_generator" {
schema_name = "schema"
size = "3xsmall"

load_generator_type = "COUNTER"

counter_options {
load_generator_type = "COUNTER"
tick_interval = "500ms"
scale_factor = 0.01
tick_interval = "500ms"
scale_factor = 0.01
}
}

# CREATE SOURCE schema.source_load_generator
# FROM LOAD GENERATOR COUNTER
# (TICK INTERVAL '500ms' SCALE FACTOR 0.01)
# WITH (SIZE = '3xsmall');
# WITH (SIZE = '3xsmall');
105 changes: 105 additions & 0 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/materialize/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func (s *Sink) QualifiedName() string {
return QualifiedName(s.DatabaseName, s.SchemaName, s.SinkName)
}

func (b *Sink) Rename(newConnectionName string) error {
func (b *Sink) Rename(newName string) error {
old := b.QualifiedName()
new := QualifiedName(b.DatabaseName, b.SchemaName, newConnectionName)
new := QualifiedName(newName)
return b.ddl.rename(old, new)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/materialize/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *Source) QualifiedName() string {

func (b *Source) Rename(newConnectionName string) error {
old := b.QualifiedName()
new := QualifiedName(b.DatabaseName, b.SchemaName, newConnectionName)
new := QualifiedName(newConnectionName)
return b.ddl.rename(old, new)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/materialize/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (b *TableBuilder) Create() error {
}

func (b *TableBuilder) Rename(newName string) error {
n := QualifiedName(b.databaseName, b.schemaName, newName)
n := QualifiedName(newName)
return b.ddl.rename(b.QualifiedName(), n)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/materialize/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestTableCreate(t *testing.T) {
func TestTableRename(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(
`ALTER TABLE "database"."schema"."table" RENAME TO "database"."schema"."new_table";`,
`ALTER TABLE "database"."schema"."table" RENAME TO "new_table";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

if err := NewTableBuilder(db, "table", "schema", "database").Rename("new_table"); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/materialize/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (b *ViewBuilder) Create() error {
}

func (b *ViewBuilder) Rename(newName string) error {
n := QualifiedName(b.databaseName, b.schemaName, newName)
n := QualifiedName(newName)
return b.ddl.rename(b.QualifiedName(), n)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/materialize/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestViewCreate(t *testing.T) {
func TestViewRename(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(
`ALTER VIEW "database"."schema"."view" RENAME TO "database"."schema"."new_view";`,
`ALTER VIEW "database"."schema"."view" RENAME TO "new_view";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

if err := NewViewBuilder(db, "view", "schema", "database").Rename("new_view"); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/acceptance_cluster_replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
)

func TestAccClusterReplica_basic(t *testing.T) {
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
replicaName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
replicaName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -36,8 +36,8 @@ func TestAccClusterReplica_basic(t *testing.T) {
}

func TestAccClusterReplica_disappears(t *testing.T) {
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
replicaName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
replicaName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/acceptance_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestAccCluster_basic(t *testing.T) {
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -30,7 +30,7 @@ func TestAccCluster_basic(t *testing.T) {
}

func TestAccCluster_disappears(t *testing.T) {
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
clusterName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestAccConnConfluentSchemaRegistry_basic(t *testing.T) {
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -35,7 +35,7 @@ func TestAccConnConfluentSchemaRegistry_basic(t *testing.T) {
}

func TestAccConnConfluentSchemaRegistry_update(t *testing.T) {
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)
connectionName := fmt.Sprintf("old_%s", slug)
newConnectionName := fmt.Sprintf("new_%s", slug)
resource.Test(t, resource.TestCase{
Expand All @@ -61,7 +61,7 @@ func TestAccConnConfluentSchemaRegistry_update(t *testing.T) {
}

func TestAccConnConfluentSchemaRegistry_disappears(t *testing.T) {
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
6 changes: 3 additions & 3 deletions pkg/provider/acceptance_connection_kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestAccConnKafka_basic(t *testing.T) {
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -36,7 +36,7 @@ func TestAccConnKafka_basic(t *testing.T) {
}

func TestAccConnKafka_update(t *testing.T) {
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)
connectionName := fmt.Sprintf("old_%s", slug)
newConnectionName := fmt.Sprintf("new_%s", slug)
resource.Test(t, resource.TestCase{
Expand All @@ -62,7 +62,7 @@ func TestAccConnKafka_update(t *testing.T) {
}

func TestAccConnKafka_disappears(t *testing.T) {
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
16 changes: 8 additions & 8 deletions pkg/provider/acceptance_connection_postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

func TestAccConnPostgres_basic(t *testing.T) {
secretName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
secretName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down Expand Up @@ -42,8 +42,8 @@ func TestAccConnPostgres_basic(t *testing.T) {
}

func TestAccConnPostgres_update(t *testing.T) {
secretName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
secretName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)
connectionName := fmt.Sprintf("old_%s", slug)
newConnectionName := fmt.Sprintf("new_%s", slug)
resource.Test(t, resource.TestCase{
Expand All @@ -69,8 +69,8 @@ func TestAccConnPostgres_update(t *testing.T) {
}

func TestAccConnPostgres_disappears(t *testing.T) {
secretName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
secretName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -94,7 +94,7 @@ resource "materialize_secret" "postgres_password" {
name = "%s"
value = "c2VjcmV0Cg=="
}
resource "materialize_connection_postgres" "test" {
name = "%s"
host = "postgres"
Expand All @@ -108,7 +108,7 @@ resource "materialize_connection_postgres" "test" {
database_name = materialize_secret.postgres_password.database_name
}
database = "postgres"
}
}
`, secret, name)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/provider/acceptance_connection_ssh_tunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestAccConnSshTunnel_basic(t *testing.T) {
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -37,7 +37,7 @@ func TestAccConnSshTunnel_basic(t *testing.T) {
}

func TestAccConnSshTunnel_update(t *testing.T) {
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
slug := acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)
connectionName := fmt.Sprintf("old_%s", slug)
newConnectionName := fmt.Sprintf("new_%s", slug)
resource.Test(t, resource.TestCase{
Expand All @@ -63,7 +63,7 @@ func TestAccConnSshTunnel_update(t *testing.T) {
}

func TestAccConnSshTunnel_disappears(t *testing.T) {
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
connectionName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/acceptance_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestAccDatabase_basic(t *testing.T) {
databaseName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
databaseName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -31,7 +31,7 @@ func TestAccDatabase_basic(t *testing.T) {
}

func TestAccDatabase_disappears(t *testing.T) {
databaseName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
databaseName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/acceptance_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
)

func TestAccIndex_basic(t *testing.T) {
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
indexName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
indexName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down Expand Up @@ -41,8 +41,8 @@ func TestAccIndex_basic(t *testing.T) {
}

func TestAccIndex_disappears(t *testing.T) {
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
indexName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
indexName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
12 changes: 10 additions & 2 deletions pkg/provider/acceptance_materialized_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestAccMaterializedView_basic(t *testing.T) {
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand All @@ -24,6 +24,10 @@ func TestAccMaterializedView_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckMaterializedViewExists("materialize_materialized_view.test"),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "name", viewName),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "schema_name", "public"),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "database_name", "materialize"),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "qualified_sql_name", fmt.Sprintf(`"materialize"."public"."%s"`, viewName)),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "statement", fmt.Sprintf(`SELECT 1 AS id`)),
),
},
},
Expand All @@ -46,14 +50,18 @@ func TestAccMaterializedView_update(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckMaterializedViewExists("materialize_materialized_view.test"),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "name", newViewName),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "schema_name", "public"),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "database_name", "materialize"),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "qualified_sql_name", fmt.Sprintf(`"materialize"."public"."%s"`, newViewName)),
resource.TestCheckResourceAttr("materialize_materialized_view.test", "statement", fmt.Sprintf(`SELECT 1 AS id`)),
),
},
},
})
}

func TestAccMaterializedView_disappears(t *testing.T) {
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
viewName := acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Expand Down
Loading

0 comments on commit 794cfb0

Please sign in to comment.