From 07ab2476f47c8da966c0ebe5435499f18bfa554a Mon Sep 17 00:00:00 2001 From: Alok Kumar Singh Date: Sat, 9 Nov 2024 23:34:45 +0530 Subject: [PATCH] Minor fixes Signed-off-by: Alok Kumar Singh --- pkg/cassandra/config/config.go | 2 +- pkg/cassandra/config/schema.go | 21 +++++++++++---------- scripts/cassandra-integration-test.sh | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pkg/cassandra/config/config.go b/pkg/cassandra/config/config.go index 670dda16006..067ad17c364 100644 --- a/pkg/cassandra/config/config.go +++ b/pkg/cassandra/config/config.go @@ -104,7 +104,7 @@ func DefaultConfiguration() Configuration { DependenciesTTL: 172800, ReplicationFactor: 1, CasVersion: 4, - CompactionWindow: "", + CompactionWindow: "1m", }, Connection: Connection{ Servers: []string{"127.0.0.1"}, diff --git a/pkg/cassandra/config/schema.go b/pkg/cassandra/config/schema.go index 46d4b7a992d..d3afb747655 100644 --- a/pkg/cassandra/config/schema.go +++ b/pkg/cassandra/config/schema.go @@ -7,6 +7,7 @@ import ( "bytes" "embed" "fmt" + "regexp" "strconv" "text/template" @@ -67,22 +68,22 @@ func applyDefaults(params *TemplateParams) { // Applies defaults for the configs and contructs other optional parameters from it func constructTemplateParams(cfg Schema) (TemplateParams, error) { params := TemplateParams{ - Schema: Schema{}, + Schema: cfg, } applyDefaults(¶ms) params.Replication = fmt.Sprintf("{'class': 'NetworkTopologyStrategy', 'replication_factor': '%v' }", params.ReplicationFactor) - if cfg.CompactionWindow != "" { + if params.CompactionWindow != "" { var err error - // isMatch, err := regexp.MatchString("[0-9]+[mhd]", params.CompactionWindow) - // if err != nil { - // return TemplateParams{}, err - // } - - // if !isMatch { - // return TemplateParams{}, fmt.Errorf("invalid compaction window size format: %s. Please use numeric value followed by 'm' for minutes, 'h' for hours, or 'd' for days", cfg.CompactionWindow) - // } + isMatch, err := regexp.MatchString("[0-9]+[mhd]", params.CompactionWindow) + if err != nil { + return TemplateParams{}, err + } + + if !isMatch { + return TemplateParams{}, fmt.Errorf("invalid compaction window size format: %s. Please use numeric value followed by 'm' for minutes, 'h' for hours, or 'd' for days", cfg.CompactionWindow) + } params.CompactionWindowSize, err = strconv.Atoi(params.CompactionWindow[0 : len(params.CompactionWindow)-1]) if err != nil { diff --git a/scripts/cassandra-integration-test.sh b/scripts/cassandra-integration-test.sh index 6dc972e510f..d9994fa41b7 100755 --- a/scripts/cassandra-integration-test.sh +++ b/scripts/cassandra-integration-test.sh @@ -89,6 +89,8 @@ run_integration_test() { apply_schema "$schema_version" "$archiveKeyspace" fi + read -n 1 + if [ "${jaegerVersion}" = "v1" ]; then STORAGE=cassandra make storage-integration-test elif [ "${jaegerVersion}" == "v2" ]; then