From b1181527f69258d96329fcb065d90fb0323cb1ed Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Mon, 18 Mar 2024 10:27:25 +0200 Subject: [PATCH] Remove scale factor for auction/counter (#502) --- docs/resources/source_load_generator.md | 9 ++++----- .../materialize_source_load_generator/resource.tf | 3 +-- pkg/materialize/source_load_generator.go | 15 +-------------- pkg/materialize/source_load_generator_test.go | 6 ++---- .../acceptance_source_load_generator_test.go | 7 ------- pkg/resources/resource_source_load_generator.go | 15 ++++++++++++--- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/docs/resources/source_load_generator.md b/docs/resources/source_load_generator.md index 2d2bf195..ca546536 100644 --- a/docs/resources/source_load_generator.md +++ b/docs/resources/source_load_generator.md @@ -22,13 +22,12 @@ resource "materialize_source_load_generator" "example_source_load_generator" { counter_options { tick_interval = "500ms" - scale_factor = 0.01 } } # CREATE SOURCE schema.source_load_generator # FROM LOAD GENERATOR COUNTER -# (TICK INTERVAL '500ms' SCALE FACTOR 0.01); +# (TICK INTERVAL '500ms'); ``` @@ -65,7 +64,7 @@ resource "materialize_source_load_generator" "example_source_load_generator" { Optional: -- `scale_factor` (Number) The scale factor for the generator. Defaults to 0.01 (~ 10MB). +- `scale_factor` (Number, Deprecated) (Deprecated) The scale factor for the generator. Defaults to 0.01 (~ 10MB). - `tick_interval` (String) The interval at which the next datum should be emitted. Defaults to one second. @@ -75,7 +74,7 @@ Optional: Optional: - `max_cardinality` (Number) Causes the generator to delete old values to keep the collection at most a given size. Defaults to unlimited. -- `scale_factor` (Number) The scale factor for the generator. Defaults to 0.01 (~ 10MB). +- `scale_factor` (Number, Deprecated) (Deprecated) The scale factor for the generator. Defaults to 0.01 (~ 10MB). - `tick_interval` (String) The interval at which the next datum should be emitted. Defaults to one second. @@ -97,7 +96,7 @@ Optional: Optional: -- `scale_factor` (Number) The scale factor for the generator. Defaults to 0.01 (~ 10MB). +- `scale_factor` (Number, Deprecated) (Deprecated) The scale factor for the generator. Defaults to 0.01 (~ 10MB). - `tick_interval` (String) The interval at which the next datum should be emitted. Defaults to one second. diff --git a/examples/resources/materialize_source_load_generator/resource.tf b/examples/resources/materialize_source_load_generator/resource.tf index 279fc4f1..573c4491 100644 --- a/examples/resources/materialize_source_load_generator/resource.tf +++ b/examples/resources/materialize_source_load_generator/resource.tf @@ -7,10 +7,9 @@ resource "materialize_source_load_generator" "example_source_load_generator" { counter_options { tick_interval = "500ms" - scale_factor = 0.01 } } # CREATE SOURCE schema.source_load_generator # FROM LOAD GENERATOR COUNTER -# (TICK INTERVAL '500ms' SCALE FACTOR 0.01); +# (TICK INTERVAL '500ms'); diff --git a/pkg/materialize/source_load_generator.go b/pkg/materialize/source_load_generator.go index 0f8260a4..48701ab0 100644 --- a/pkg/materialize/source_load_generator.go +++ b/pkg/materialize/source_load_generator.go @@ -9,7 +9,6 @@ import ( type CounterOptions struct { TickInterval string - ScaleFactor float64 MaxCardinality int } @@ -20,10 +19,6 @@ func GetCounterOptionsStruct(v interface{}) CounterOptions { o.TickInterval = v.(string) } - if v, ok := u["scale_factor"]; ok { - o.ScaleFactor = v.(float64) - } - if v, ok := u["max_cardinality"]; ok { o.MaxCardinality = v.(int) } @@ -32,7 +27,6 @@ func GetCounterOptionsStruct(v interface{}) CounterOptions { type AuctionOptions struct { TickInterval string - ScaleFactor float64 } func GetAuctionOptionsStruct(v interface{}) AuctionOptions { @@ -42,15 +36,11 @@ func GetAuctionOptionsStruct(v interface{}) AuctionOptions { o.TickInterval = v.(string) } - if v, ok := u["scale_factor"]; ok { - o.ScaleFactor = v.(float64) - } return o } type MarketingOptions struct { TickInterval string - ScaleFactor float64 } func GetMarketingOptionsStruct(v interface{}) MarketingOptions { @@ -60,9 +50,6 @@ func GetMarketingOptionsStruct(v interface{}) MarketingOptions { o.TickInterval = v.(string) } - if v, ok := u["scale_factor"]; ok { - o.ScaleFactor = v.(float64) - } return o } @@ -162,7 +149,7 @@ func (b *SourceLoadgenBuilder) Create() error { } } - for _, t := range []float64{b.counterOptions.ScaleFactor, b.auctionOptions.ScaleFactor, b.marketingOptions.ScaleFactor, b.tpchOptions.ScaleFactor} { + for _, t := range []float64{b.tpchOptions.ScaleFactor} { if t != 0 { p = append(p, fmt.Sprintf(`SCALE FACTOR %.2f`, t)) } diff --git a/pkg/materialize/source_load_generator_test.go b/pkg/materialize/source_load_generator_test.go index f19bb3f7..f11fb16c 100644 --- a/pkg/materialize/source_load_generator_test.go +++ b/pkg/materialize/source_load_generator_test.go @@ -38,7 +38,7 @@ func TestSourceLoadgenAuctionCreate(t *testing.T) { mock.ExpectExec( `CREATE SOURCE "database"."schema"."source" FROM LOAD GENERATOR AUCTION - \(TICK INTERVAL '1s', SCALE FACTOR 0.01\) + \(TICK INTERVAL '1s'\) FOR ALL TABLES;`, ).WillReturnResult(sqlmock.NewResult(1, 1)) @@ -46,7 +46,6 @@ func TestSourceLoadgenAuctionCreate(t *testing.T) { b.LoadGeneratorType("AUCTION") b.AuctionOptions(AuctionOptions{ TickInterval: "1s", - ScaleFactor: 0.01, }) if err := b.Create(); err != nil { @@ -60,7 +59,7 @@ func TestSourceLoadgenMarketingCreate(t *testing.T) { mock.ExpectExec( `CREATE SOURCE "database"."schema"."source" FROM LOAD GENERATOR MARKETING - \(TICK INTERVAL '1s', SCALE FACTOR 0.01\) + \(TICK INTERVAL '1s'\) FOR ALL TABLES;`, ).WillReturnResult(sqlmock.NewResult(1, 1)) @@ -68,7 +67,6 @@ func TestSourceLoadgenMarketingCreate(t *testing.T) { b.LoadGeneratorType("MARKETING") b.MarketingOptions(MarketingOptions{ TickInterval: "1s", - ScaleFactor: 0.01, }) if err := b.Create(); err != nil { diff --git a/pkg/provider/acceptance_source_load_generator_test.go b/pkg/provider/acceptance_source_load_generator_test.go index 0482d452..aded6c64 100644 --- a/pkg/provider/acceptance_source_load_generator_test.go +++ b/pkg/provider/acceptance_source_load_generator_test.go @@ -33,7 +33,6 @@ func TestAccSourceLoadGeneratorCounter_basic(t *testing.T) { resource.TestCheckResourceAttr("materialize_source_load_generator.test", "cluster_name", roleName+"_cluster"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "load_generator_type", "COUNTER"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "counter_options.0.tick_interval", "1000ms"), - resource.TestCheckResourceAttr("materialize_source_load_generator.test", "counter_options.0.scale_factor", "0.1"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "counter_options.0.max_cardinality", "8"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "ownership_role", "mz_system"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsources.#", "0"), @@ -71,7 +70,6 @@ func TestAccSourceLoadGeneratorAuction_basic(t *testing.T) { resource.TestCheckResourceAttr("materialize_source_load_generator.test", "size", "3xsmall"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "load_generator_type", "AUCTION"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "auction_options.0.tick_interval", "1000ms"), - resource.TestCheckResourceAttr("materialize_source_load_generator.test", "auction_options.0.scale_factor", "0.1"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsource.#", "6"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsource.0.schema_name", "auction"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsource.0.database_name", "materialize"), @@ -104,7 +102,6 @@ func TestAccSourceLoadGeneratorMarketing_basic(t *testing.T) { resource.TestCheckResourceAttr("materialize_source_load_generator.test", "size", "3xsmall"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "load_generator_type", "MARKETING"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "marketing_options.0.tick_interval", "1000ms"), - resource.TestCheckResourceAttr("materialize_source_load_generator.test", "marketing_options.0.scale_factor", "0.1"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsource.#", "7"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsource.0.schema_name", "marketing"), resource.TestCheckResourceAttr("materialize_source_load_generator.test", "subsource.0.database_name", "materialize"), @@ -231,7 +228,6 @@ func testAccSourceLoadGeneratorResource(roleName, sourceName, source2Name, size, load_generator_type = "COUNTER" counter_options { tick_interval = "1000ms" - scale_factor = 0.1 max_cardinality = 8 } } @@ -243,7 +239,6 @@ func testAccSourceLoadGeneratorResource(roleName, sourceName, source2Name, size, load_generator_type = "COUNTER" counter_options { tick_interval = "1000ms" - scale_factor = 0.1 } ownership_role = "%[5]s" comment = "%[6]s" @@ -272,7 +267,6 @@ func testAccSourceLoadGeneratorAuctionResource(sourceName string) string { load_generator_type = "AUCTION" auction_options { tick_interval = "1000ms" - scale_factor = 0.1 } } `, sourceName) @@ -296,7 +290,6 @@ func testAccSourceLoadGeneratorMarketingResource(sourceName string) string { load_generator_type = "MARKETING" marketing_options { tick_interval = "1000ms" - scale_factor = 0.1 } } `, sourceName) diff --git a/pkg/resources/resource_source_load_generator.go b/pkg/resources/resource_source_load_generator.go index 9c6a4ea0..23f50906 100644 --- a/pkg/resources/resource_source_load_generator.go +++ b/pkg/resources/resource_source_load_generator.go @@ -28,6 +28,15 @@ var scale_factor = &schema.Schema{ ForceNew: true, } +var scale_factor_deprecated = &schema.Schema{ + Description: "(Deprecated) The scale factor for the generator. Defaults to 0.01 (~ 10MB).", + Deprecated: "Scale factor is deprecated and will be removed in a future release.", + Type: schema.TypeFloat, + Optional: true, + Default: 0.01, + ForceNew: true, +} + var sourceLoadgenSchema = map[string]*schema.Schema{ "name": ObjectNameSchema("source", true, false), "schema_name": SchemaNameSchema("source", false), @@ -49,7 +58,7 @@ var sourceLoadgenSchema = map[string]*schema.Schema{ Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "tick_interval": tick_interval, - "scale_factor": scale_factor, + "scale_factor": scale_factor_deprecated, "max_cardinality": { Description: "Causes the generator to delete old values to keep the collection at most a given size. Defaults to unlimited.", Type: schema.TypeInt, @@ -70,7 +79,7 @@ var sourceLoadgenSchema = map[string]*schema.Schema{ Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "tick_interval": tick_interval, - "scale_factor": scale_factor, + "scale_factor": scale_factor_deprecated, }, }, Optional: true, @@ -85,7 +94,7 @@ var sourceLoadgenSchema = map[string]*schema.Schema{ Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "tick_interval": tick_interval, - "scale_factor": scale_factor, + "scale_factor": scale_factor_deprecated, }, }, Optional: true,