소스 검색

Use ccm to bing up a cluster of nodes for integration testing

Chris Bannister 11 년 전
부모
커밋
65892d3cdb
2개의 변경된 파일21개의 추가작업 그리고 41개의 파일을 삭제
  1. 11 1
      .travis.yml
  2. 10 40
      integration.sh

+ 11 - 1
.travis.yml

@@ -1,15 +1,25 @@
 language: go
 
+env:
+  - CASS=1.2.18
+  - CASS=2.0.9
+
 go:
   - 1.2
   - 1.3
   - tip
 
 before_script:
+  - sudo apt-get install -y libjna-java python-pip
+  - sudo pip install cql PyYAML
   - go get code.google.com/p/go.tools/cmd/vet
+  - git clone https://github.com/pcmanus/ccm.git
+  - pushd ccm
+  - sudo ./setup.py install
+  - popd
 
 script:
-  - bash integration.sh
+  - bash integration.sh $CASS
   - go vet .
 
 notifications:

+ 10 - 40
integration.sh

@@ -2,50 +2,20 @@
 
 set -e
 
-PID_FILE=cassandra.pid
-STARTUP_LOG=startup.log
-ARCHIVE_BASE_URL=http://archive.apache.org/dist/cassandra
+function run_tests() {
+	local version=$1
+	ccm create test -v $version -n 3 -s --debug
 
-for v in 1.2.18 2.0.9
-do
-	TARBALL=apache-cassandra-$v-bin.tar.gz
-	CASSANDRA_DIR=apache-cassandra-$v
+	ccm status
 
-	curl -L -O $ARCHIVE_BASE_URL/$v/$TARBALL
-	
-	if [ ! -f $CASSANDRA_DIR/bin/cassandra ]
-	then
-   		tar xzf $TARBALL
-	fi
-	
-	CASSANDRA_LOG_DIR=`pwd`/v${v}/log/cassandra
-	CASSANDRA_LOG=$CASSANDRA_LOG_DIR/system.log
-
-	mkdir -p $CASSANDRA_LOG_DIR
-	: >$CASSANDRA_LOG  # create an empty log file
-	
-	sed -i -e 's?/var?'`pwd`/v${v}'?' $CASSANDRA_DIR/conf/cassandra.yaml
-	sed -i -e 's?/var?'`pwd`/v${v}'?' $CASSANDRA_DIR/conf/log4j-server.properties
-
-	echo "Booting Cassandra ${v}, waiting for CQL listener to start ...."
-
-	$CASSANDRA_DIR/bin/cassandra -p $PID_FILE &> $STARTUP_LOG
-
-	{ tail -n +1 -f $CASSANDRA_LOG & } | sed -n '/Starting listening for CQL clients/q'
-	
-	PID=$(<"$PID_FILE")
-
-	echo "Cassandra ${v} running (PID ${PID}), about to run test suite ...."
-
-	if [[ $v == 1.2.* ]]
-		then
+	if [[ $v == 1.2.* ]]; then
 		go test -v ./... -proto 1
 	else
 		go test -v ./...
 	fi
 
-	echo "Test suite passed against Cassandra ${v}, killing server instance (PID ${PID})"
-	
-	kill -9 $PID
-	rm $PID_FILE
-done
+	ccm stop --not-gently test
+	ccm remove test
+}
+
+run_tests $1