Browse Source

Merge pull request #1082 from marko-asplund/servlet3-cass

Travis: Add Cassandra. Also fixes servlet3-cass
Hamilton Turner 11 years ago
parent
commit
6a4f6532b3

+ 1 - 0
config/cassandra/cleanup-keyspace.cql

@@ -0,0 +1 @@
+DROP KEYSPACE tfb;

+ 0 - 2
config/cassandra/create-keyspace.cql

@@ -1,6 +1,4 @@
 
-DROP KEYSPACE tfb;
-
 CREATE KEYSPACE tfb WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1 };
 USE tfb;
 

+ 3 - 2
frameworks/Java/servlet3-cass/benchmark_config

@@ -23,11 +23,12 @@
     "raw": {
       "setup_file": "setup",
       "db_url": "/servlet3-cass/db",
-      "query_url": "/servlet3-cass/db?queries=",
+      "query_url": "/servlet3-cass/queries?queries=",
+      "update_url": "/servlet3-cass/updates?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
-      "database": "Apache Cassandra",
+      "database": "Cassandra",
       "framework": "servlet3-cass",
       "language": "Java",
       "orm": "Raw",

+ 3 - 1
frameworks/Java/servlet3-cass/setup.py

@@ -16,7 +16,9 @@ def start(args, logfile, errfile):
       subprocess.check_call("C:\\Java\\resin\\bin\\start.bat", shell=True, stderr=errfile, stdout=logfile)
       return 0
     subprocess.check_call("rm -rf $RESIN_HOME/webapps/*", shell=True, stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp servlet3-cass/target/servlet3-cass.war $RESIN_HOME/webapps/", shell=True, stderr=errfile, stdout=logfile)
+    subprocess.check_call("cp servlet3-cass/target/servlet3-cass.war $RESIN_HOME/webapps/", shell=True, stderr=errfile, stdout=logfile)    
+#    subprocess.call("echo checking connection to TFB DB host: "+args.database_host, shell=True, stderr=errfile, stdout=logfile)
+#    subprocess.call("for i in 1 2 3 4 5; do nc -vz "+args.database_host+" 9160  && echo 'C* ok' && break || echo 'waiting for C*'; sleep 2; if [ $i -eq '5' ]; then echo 'ERROR: failed to connect to Cassandra'; fi; done", shell=True, stderr=errfile, stdout=logfile)
     subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True, stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:

+ 19 - 1
toolset/run-ci.py

@@ -195,8 +195,9 @@ class CIRunnner:
     validtests = [t for t in osvalidtests if t.database.lower() == "mysql"
                   or t.database.lower() == "postgres"
                   or t.database.lower() == "mongodb"
+                  or t.database.lower() == "cassandra"
                   or t.database.lower() == "none"]
-    log.info("Found %s usable tests (%s valid for linux, %s valid for linux and {mysql,postgres,mongodb,none}) in directory '%s'", 
+    log.info("Found %s usable tests (%s valid for linux, %s valid for linux and {mysql,postgres,mongodb,cassandra,none}) in directory '%s'", 
       len(dirtests), len(osvalidtests), len(validtests), '$FWROOT/frameworks/' + testdir)
     if len(validtests) == 0:
       log.critical("Found no test that is possible to run in Travis-CI! Aborting!")
@@ -314,11 +315,17 @@ class CIRunnner:
     until timeout 15s sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10; do echo 'Waiting for apt-key' ; done
     echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
 
+    # Add Apache Cassandra repository
+    until timeout 15s sudo apt-key adv --keyserver pgp.mit.edu --recv 4BD736A82B5C1B00; do echo 'Waiting for apt-key' ; done
+    sudo apt-add-repository  'deb http://www.apache.org/dist/cassandra/debian 20x main'
+
     sudo apt-get -q update
     
     # MongoDB takes a good 30-45 seconds to turn on, so install it first
     sudo apt-get -q install mongodb-org
 
+    sudo apt-get install -o Dpkg::Options::="--force-confnew" cassandra
+
     sudo apt-get -q install openssh-server
 
     # Run as travis user (who already has passwordless sudo)
@@ -332,14 +339,25 @@ class CIRunnner:
     # =======================================================
 
     # Add data to mysql
+    echo "Populating MySQL DB data"
     mysql -uroot < config/create.sql
 
     # Setup Postgres
+    echo "Setting up Postgres database"
     psql --version
     sudo useradd benchmarkdbuser -p benchmarkdbpass
     sudo -u postgres psql template1 < config/create-postgres-database.sql
     sudo -u benchmarkdbuser psql hello_world < config/create-postgres.sql
 
+    # Setup Apache Cassandra
+    echo "Setting up Apache Cassandra database"
+    until nc -z localhost 9160 ; do echo Waiting for Cassandra; sleep 1; done
+    cat config/cassandra/cleanup-keyspace.cql | sudo cqlsh
+    python config/cassandra/db-data-gen.py > config/cassandra/tfb-data.cql
+    sudo cqlsh -f config/cassandra/create-keyspace.cql
+    sudo cqlsh -f config/cassandra/tfb-data.cql
+
+    echo "Setting up MongDB database"
     # Setup MongoDB (see install above)
     mongod --version
     until nc -z localhost 27017 ; do echo Waiting for MongoDB; sleep 1; done

+ 11 - 4
toolset/setup/linux/installer.py

@@ -148,6 +148,7 @@ class Installer:
     ##############################
     # MySQL
     ##############################
+    echo "Setting up MySQL database"
     sudo sh -c "echo mysql-server mysql-server/root_password_again select secret | debconf-set-selections"
     sudo sh -c "echo mysql-server mysql-server/root_password select secret | debconf-set-selections"
 
@@ -175,6 +176,7 @@ class Installer:
     ##############################
     # Postgres
     ##############################
+    echo "Setting up Postgres database"
     sudo -u postgres psql template1 < create-postgres-database.sql
     sudo -u benchmarkdbuser psql hello_world < create-postgres.sql
     rm create-postgres-database.sql create-postgres.sql
@@ -192,6 +194,7 @@ class Installer:
     ##############################
     # MongoDB
     ##############################
+    echo "Setting up MongoDB database"
     sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
     echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
     sudo apt-get -y update
@@ -213,6 +216,7 @@ class Installer:
     ##############################
     # Apache Cassandra
     ##############################
+    echo "Setting up Apache Cassandra database"
     sudo apt-get install -qqy openjdk-7-jdk
     export CASS_V=2.0.7
     wget -nv http://archive.apache.org/dist/cassandra/$CASS_V/apache-cassandra-$CASS_V-bin.tar.gz
@@ -227,16 +231,19 @@ class Installer:
     
     mv cassandra/cassandra.yaml apache-cassandra-$CASS_V/conf
     mv cassandra/log4j-server.properties apache-cassandra-$CASS_V/conf
-    nohup apache-cassandra-$CASS_V/bin/cassandra > cassandra.log
+    nohup apache-cassandra-$CASS_V/bin/cassandra -p c.pid > cassandra.log
 
-    sleep 20
-    cat cassandra/create-keyspace.cql | apache-cassandra-$CASS_V/bin/cqlsh {database_host}
-    python cassandra/db-data-gen.py | apache-cassandra-$CASS_V/bin/cqlsh {database_host}
+    until nc -z {database_host} 9160 ; do echo Waiting for Cassandra; sleep 1; done
+    cat cassandra/cleanup-keyspace.cql | apache-cassandra-$CASS_V/bin/cqlsh {database_host}
+    python cassandra/db-data-gen.py > cassandra/tfb-data.cql
+    apache-cassandra-$CASS_V/bin/cqlsh -f cassandra/create-keyspace.cql {database_host}
+    apache-cassandra-$CASS_V/bin/cqlsh -f cassandra/tfb-data.cql {database_host}
     rm -rf apache-cassandra-*-bin.tar.gz cassandra
 
     ##############################
     # Redis
     ##############################
+    echo "Setting up Redis database"
     sudo service redis-server stop
     # NOTE: This will cause errors on Ubuntu 12.04, as apt installs 
     # an older version of redis