diff --git a/main.go b/main.go index 6fff4fa..9f184e6 100644 --- a/main.go +++ b/main.go @@ -65,6 +65,7 @@ var ( password string mode string + workload string latencyType string maxErrorsAtRow int maxErrors int @@ -105,6 +106,7 @@ var ( hdrLatencyUnits string hdrLatencySigFig int validateData bool + skipTruncateTable bool ) func Query(session *gocql.Session, request string) { @@ -128,10 +130,16 @@ func PrepareDatabase(session *gocql.Session, replicationFactor int) { } if validateData { + if workload == "sequential" && skipTruncateTable { + log.Printf("Skip truncating of the '" + tableName + "' table") + return + } switch mode { case "write": + log.Printf("Truncating the '" + tableName + "' table") Query(session, "TRUNCATE TABLE "+keyspaceName+"."+tableName) case "counter_update": + log.Printf("Truncating the '" + counterTableName + "' table") Query(session, "TRUNCATE TABLE "+keyspaceName+"."+counterTableName) } } @@ -246,7 +254,6 @@ func getRetryPolicy() *gocql.ExponentialBackoffRetryPolicy { func main() { var ( - workload string consistencyLevel string replicationFactor int @@ -315,6 +322,9 @@ func main() { flag.StringVar(&hdrLatencyUnits, "hdr-latency-units", "ns", "ns (nano seconds), us (microseconds), ms (milliseconds)") flag.IntVar(&hdrLatencySigFig, "hdr-latency-sig", 3, "significant figures of the hdr histogram, number from 1 to 5 (default: 3)") + flag.BoolVar( + &skipTruncateTable, "skip-truncate-table", false, + "Skip truncation of a table before running 'write' or 'counter_update' stress commands if workload is 'sequential'") flag.BoolVar(&validateData, "validate-data", false, "write meaningful data and validate while reading") var startTimestamp int64