diff --git a/cmd/gemini/root.go b/cmd/gemini/root.go index d76ded49..63b55aa4 100644 --- a/cmd/gemini/root.go +++ b/cmd/gemini/root.go @@ -63,6 +63,7 @@ var ( outFileArg string concurrency uint64 seed uint64 + schemaSeed uint64 dropSchema bool verbose bool mode string @@ -110,7 +111,7 @@ func interactive() bool { return !nonInteractive } -func readSchema(confFile string, schemaConfig typedef.SchemaConfig) (*typedef.Schema, error) { +func readSchema(confFile string) (*typedef.Schema, error) { byteValue, err := os.ReadFile(confFile) if err != nil { return nil, err @@ -124,7 +125,7 @@ func readSchema(confFile string, schemaConfig typedef.SchemaConfig) (*typedef.Sc } schemaBuilder := builders.NewSchemaBuilder() - schemaBuilder.Keyspace(shm.Keyspace).Config(schemaConfig) + schemaBuilder.Keyspace(shm.Keyspace) for t, tbl := range shm.Tables { shm.Tables[t].LinkIndexAndColumns() schemaBuilder.Table(tbl) @@ -145,6 +146,8 @@ func run(_ *cobra.Command, _ []string) error { globalStatus := status.NewGlobalStatus(1000) defer utils.IgnoreError(logger.Sync) + rand.Seed(seed) + cons, err := gocql.ParseConsistencyWrapper(consistency) if err != nil { logger.Error("Unable parse consistency, error=%s. Falling back on Quorum", zap.Error(err)) @@ -193,12 +196,12 @@ func run(_ *cobra.Command, _ []string) error { } var schema *typedef.Schema if len(schemaFile) > 0 { - schema, err = readSchema(schemaFile, schemaConfig) + schema, err = readSchema(schemaFile) if err != nil { return errors.Wrap(err, "cannot create schema") } } else { - schema = generators.GenSchema(schemaConfig, seed) + schema = generators.GenSchema(schemaConfig, schemaSeed) } jsonSchema, _ := json.MarshalIndent(schema, "", " ") @@ -279,9 +282,8 @@ func run(_ *cobra.Command, _ []string) error { if warmup > 0 && !stopFlag.IsHardOrSoft() { jobsList := jobs.ListFromMode(jobs.WarmupMode, warmup, concurrency) - if err = jobsList.Run(ctx, schema, schemaConfig, st, pump, gens, globalStatus, logger, seed, stop.NewFlag("warmup"), failFast, verbose); err != nil { + if err = jobsList.Run(ctx, schema, schemaConfig, st, pump, gens, globalStatus, logger, seed, stopFlag.CreateChild("warmup"), failFast, verbose); err != nil { logger.Error("warmup encountered an error", zap.Error(err)) - stopFlag.SetHard(true) } } @@ -380,8 +382,8 @@ func createClusters( return testCluster, nil } oracleCluster := gocql.NewCluster(oracleClusterHost...) - oracleCluster.Timeout = requestTimeout - oracleCluster.ConnectTimeout = connectTimeout + testCluster.Timeout = requestTimeout + testCluster.ConnectTimeout = connectTimeout oracleCluster.RetryPolicy = retryPolicy oracleCluster.Consistency = consistency oracleCluster.PoolConfig.HostSelectionPolicy = oracleHostSelectionPolicy @@ -467,7 +469,8 @@ func init() { rootCmd.Flags().StringVarP(&schemaFile, "schema", "", "", "Schema JSON config file") rootCmd.Flags().StringVarP(&mode, "mode", "m", jobs.MixedMode, "Query operation mode. Mode options: write, read, mixed (default)") rootCmd.Flags().Uint64VarP(&concurrency, "concurrency", "c", 10, "Number of threads per table to run concurrently") - rootCmd.Flags().Uint64VarP(&seed, "seed", "s", 1, "PRNG seed value") + rootCmd.Flags().Uint64VarP(&seed, "seed", "s", 1, "Statement seed value") + rootCmd.Flags().Uint64VarP(&schemaSeed, "schema-seed", "", 1, "Schema seed value") rootCmd.Flags().BoolVarP(&dropSchema, "drop-schema", "d", false, "Drop schema before starting tests run") rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Verbose output during test run") rootCmd.Flags().BoolVarP(&failFast, "fail-fast", "f", false, "Stop on the first failure") @@ -534,8 +537,8 @@ func init() { func printSetup() error { tw := new(tabwriter.Writer) tw.Init(os.Stdout, 0, 8, 2, '\t', tabwriter.AlignRight) - rand.Seed(seed) fmt.Fprintf(tw, "Seed:\t%d\n", seed) + fmt.Fprintf(tw, "Schema seed:\t%d\n", schemaSeed) fmt.Fprintf(tw, "Maximum duration:\t%s\n", duration) fmt.Fprintf(tw, "Warmup duration:\t%s\n", warmup) fmt.Fprintf(tw, "Concurrency:\t%d\n", concurrency)