Skip to content

Commit

Permalink
feat(root): introduce --schema-seed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kropachev committed Jul 7, 2023
1 parent a32c7b7 commit 674400b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/gemini/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var (
outFileArg string
concurrency uint64
seed uint64
schemaSeed uint64
dropSchema bool
verbose bool
mode string
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -198,7 +201,7 @@ func run(_ *cobra.Command, _ []string) error {
return errors.Wrap(err, "cannot create schema")
}
} else {
schema = generators.GenSchema(schemaConfig, seed)
schema = generators.GenSchema(schemaConfig, schemaSeed)
}

jsonSchema, _ := json.MarshalIndent(schema, "", " ")
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 674400b

Please sign in to comment.