Ver código fonte

add gocql_debug to debug parts of the driver

Chris Bannister 10 anos atrás
pai
commit
e73d08a85b
4 arquivos alterados com 36 adições e 18 exclusões
  1. 5 0
      debug_off.go
  2. 5 0
      debug_on.go
  3. 8 0
      events.go
  4. 18 18
      integration.sh

+ 5 - 0
debug_off.go

@@ -0,0 +1,5 @@
+// +build !gocql_debug
+
+package gocql
+
+const debug = false

+ 5 - 0
debug_on.go

@@ -0,0 +1,5 @@
+// +build gocql_debug
+
+package gocql
+
+const debug = true

+ 8 - 0
events.go

@@ -111,6 +111,10 @@ func (s *Session) handleNodeEvent(frames []frame) {
 	}
 
 	for _, f := range events {
+		if debug {
+			log.Printf("gocql: dispatching event: %+v\n", f)
+		}
+
 		switch f.change {
 		case "NEW_NODE":
 			s.handleNewNode(f.host, f.port, true)
@@ -138,6 +142,10 @@ func (s *Session) handleEvent(framer *framer) {
 		return
 	}
 
+	if debug {
+		log.Printf("gocql: handling frame: %v\n", frame)
+	}
+
 	// TODO: handle medatadata events
 	switch f := frame.(type) {
 	case *schemaChangeKeyspace:

+ 18 - 18
integration.sh

@@ -14,27 +14,27 @@ function run_tests() {
 	local keypath="$(pwd)/testdata/pki"
 
 	local conf=(
-	    "client_encryption_options.enabled: true"
-	    "client_encryption_options.keystore: $keypath/.keystore"
-	    "client_encryption_options.keystore_password: cassandra"
-	    "client_encryption_options.require_client_auth: true"
-	    "client_encryption_options.truststore: $keypath/.truststore"
-	    "client_encryption_options.truststore_password: cassandra"
-	    "concurrent_reads: 2"
-	    "concurrent_writes: 2"
-	    "rpc_server_type: sync"
-	    "rpc_min_threads: 2"
-	    "rpc_max_threads: 2"
-	    "write_request_timeout_in_ms: 5000"
-	    "read_request_timeout_in_ms: 5000"
+		"client_encryption_options.enabled: true"
+		"client_encryption_options.keystore: $keypath/.keystore"
+		"client_encryption_options.keystore_password: cassandra"
+		"client_encryption_options.require_client_auth: true"
+		"client_encryption_options.truststore: $keypath/.truststore"
+		"client_encryption_options.truststore_password: cassandra"
+		"concurrent_reads: 2"
+		"concurrent_writes: 2"
+		"rpc_server_type: sync"
+		"rpc_min_threads: 2"
+		"rpc_max_threads: 2"
+		"write_request_timeout_in_ms: 5000"
+		"read_request_timeout_in_ms: 5000"
 	)
 
 	ccm remove test || true
 
 	ccm create test -v $version -n $clusterSize -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
-    ccm updateconf "${conf[@]}"
+	ccm updateconf "${conf[@]}"
 
-    if [ "$auth" = true ]
+	if [ "$auth" = true ]
 	then
 		ccm updateconf 'authenticator: PasswordAuthenticator' 'authorizer: CassandraAuthorizer'
 		rm -rf $HOME/.ccm/test/node1/data/system_auth
@@ -61,8 +61,8 @@ function run_tests() {
 
 	if [ "$auth" = true ]
 	then
-    	sleep 30s
-    	go test -v . -timeout 15s -run=TestAuthentication -tags integration -runssl -runauth -proto=$proto -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=1000ms
+		sleep 30s
+		go test -v . -timeout 15s -run=TestAuthentication -tags "integration gocql_debug" -runssl -runauth -proto=$proto -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=1000ms
 	else
 
 		go test -timeout 10m -tags integration -v -gocql.timeout=10s -runssl -proto=$proto -rf=3 -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=2000ms -compressor=snappy ./...
@@ -77,7 +77,7 @@ function run_tests() {
 			exit 1
 		fi
 
-		go test -timeout 10m -tags ccm -v -gocql.timeout=10s -runssl -proto=$proto -rf=3 -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=2000ms -compressor=snappy ./...
+		go test -timeout 10m -tags "ccm gocql_debug" -v -gocql.timeout=10s -runssl -proto=$proto -rf=3 -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=2000ms -compressor=snappy ./...
 	fi
 
 	ccm remove