From 38b81b82cb8e069fd82ef3e864055482d8315c48 Mon Sep 17 00:00:00 2001 From: Chris Bannister Date: Thu, 2 Apr 2015 17:11:02 +0100 Subject: [PATCH] Add a flag to enable compression --- cassandra_test.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/cassandra_test.go b/cassandra_test.go index 9d5702222..b82a039e6 100644 --- a/cassandra_test.go +++ b/cassandra_test.go @@ -22,15 +22,16 @@ import ( ) var ( - flagCluster = flag.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples") - flagProto = flag.Int("proto", 2, "protcol version") - flagCQL = flag.String("cql", "3.0.0", "CQL version") - flagRF = flag.Int("rf", 1, "replication factor for test keyspace") - clusterSize = flag.Int("clusterSize", 1, "the expected size of the cluster") - flagRetry = flag.Int("retries", 5, "number of times to retry queries") - flagAutoWait = flag.Duration("autowait", 1000*time.Millisecond, "time to wait for autodiscovery to fill the hosts poll") - flagRunSslTest = flag.Bool("runssl", false, "Set to true to run ssl test") - clusterHosts []string + flagCluster = flag.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples") + flagProto = flag.Int("proto", 2, "protcol version") + flagCQL = flag.String("cql", "3.0.0", "CQL version") + flagRF = flag.Int("rf", 1, "replication factor for test keyspace") + clusterSize = flag.Int("clusterSize", 1, "the expected size of the cluster") + flagRetry = flag.Int("retries", 5, "number of times to retry queries") + flagAutoWait = flag.Duration("autowait", 1000*time.Millisecond, "time to wait for autodiscovery to fill the hosts poll") + flagRunSslTest = flag.Bool("runssl", false, "Set to true to run ssl test") + flagCompressTest = flag.String("compressor", "", "compressor to use") + clusterHosts []string ) func init() { @@ -71,6 +72,15 @@ func createCluster() *ClusterConfig { if *flagRetry > 0 { cluster.RetryPolicy = &SimpleRetryPolicy{NumRetries: *flagRetry} } + + switch *flagCompressTest { + case "snappy": + cluster.Compressor = &SnappyCompressor{} + case "": + default: + panic("invalid compressor: " + *flagCompressTest) + } + cluster = addSslOptions(cluster) return cluster }