瀏覽代碼

Merge MASTER into cluster-ring-discovery

Ben Hood 11 年之前
父節點
當前提交
9b02df3de2
共有 5 個文件被更改,包括 42 次插入5 次删除
  1. 9 1
      README.md
  2. 24 1
      cassandra_test.go
  3. 1 0
      conn.go
  4. 1 1
      integration.sh
  5. 7 2
      wiki_test.go

+ 9 - 1
README.md

@@ -11,7 +11,15 @@ Project Website: http://gocql.github.io/<br>
 API documentation: http://godoc.org/github.com/gocql/gocql<br>
 Discussions: https://groups.google.com/forum/#!forum/gocql
 
-Supported Versions: Cassandra 1.2, 2.0, 2.1; Go 1.2, 1.3
+Supported Versions
+------------------
+
+The following matrix shows the versions of Go and Cassandra that are tested with the integration test suite as part of the CI build:
+
+Go/Cassandra | 1.2.18 | 2.0.9 | 2.1.0-RC5
+-------------| -------| ------| ---------
+1.2  | yes | yes | partial
+1.3  | yes | yes | partial
 
 Installation
 ------------

+ 24 - 1
cassandra_test.go

@@ -28,6 +28,7 @@ var (
 	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")
 	clusterHosts []string
 )
 
@@ -55,7 +56,7 @@ func createSession(tb testing.TB) *Session {
 	cluster.CQLVersion = *flagCQL
 	cluster.Timeout = 5 * time.Second
 	cluster.Consistency = Quorum
-	cluster.RetryPolicy.NumRetries = 2
+	cluster.RetryPolicy.NumRetries = *flagRetry
 
 	initOnce.Do(func() {
 		session, err := cluster.CreateSession()
@@ -833,6 +834,28 @@ func injectInvalidPreparedStatement(t *testing.T, session *Session, table string
 	return stmt, conn
 }
 
+func TestMissingSchemaPrepare(t *testing.T) {
+	s := createSession(t)
+	conn := s.Pool.Pick(nil)
+	defer s.Close()
+
+	insertQry := &Query{stmt: "INSERT INTO invalidschemaprep (val) VALUES (?)", values: []interface{}{5}, cons: s.cons,
+		session: s, pageSize: s.pageSize, trace: s.trace,
+		prefetch: s.prefetch, rt: s.cfg.RetryPolicy}
+
+	if err := conn.executeQuery(insertQry).err; err == nil {
+		t.Fatal("expected error, but got nil.")
+	}
+
+	if err := createTable(s, "CREATE TABLE invalidschemaprep (val int, PRIMARY KEY (val))"); err != nil {
+		t.Fatal("create table:", err)
+	}
+
+	if err := conn.executeQuery(insertQry).err; err != nil {
+		t.Fatal(err) // unconfigured columnfamily
+	}
+}
+
 func TestReprepareStatement(t *testing.T) {
 	session := createSession(t)
 	defer session.Close()

+ 1 - 0
conn.go

@@ -338,6 +338,7 @@ func (c *Conn) prepareStatement(stmt string, trace Tracer) (*QueryInfo, error) {
 		default:
 			flight.err = NewErrProtocol("Unknown type in response to prepare frame: %s", x)
 		}
+		err = flight.err
 	}
 
 	flight.wg.Done()

+ 1 - 1
integration.sh

@@ -6,7 +6,7 @@ function run_tests() {
 	local clusterSize=3
 	local version=$1
 
-	ccm create test -v $version -n $clusterSize -s -d --vnodes
+	ccm create test -v binary:$version -n 3 -s -d --vnodes
 	ccm status
 	ccm updateconf 'concurrent_reads: 8' 'concurrent_writes: 32' 'rpc_server_type: sync' 'rpc_min_threads: 2' 'rpc_max_threads: 8' 'write_request_timeout_in_ms: 5000' 'read_request_timeout_in_ms: 5000'
 

+ 7 - 2
wiki_test.go

@@ -58,7 +58,7 @@ func (w *WikiTest) CreateSchema() {
 	if err := w.session.Query(`DROP TABLE wiki_page`).Exec(); err != nil && err.Error() != "unconfigured columnfamily wiki_page" {
 		w.tb.Fatal("CreateSchema:", err)
 	}
-	if err := createTable(w.session, `CREATE TABLE wiki_page (
+	err := createTable(w.session, `CREATE TABLE wiki_page (
 			title       varchar,
 			revid       timeuuid,
 			body        varchar,
@@ -69,7 +69,12 @@ func (w *WikiTest) CreateSchema() {
 			tags        set<varchar>,
 			attachments map<varchar, blob>,
 			PRIMARY KEY (title, revid)
-		)`); err != nil {
+		)`)
+	if clusterSize > 1 {
+		// wait for table definition to propogate
+		time.Sleep(250 * time.Millisecond)
+	}
+	if err != nil {
 		w.tb.Fatal("CreateSchema:", err)
 	}
 }