Browse Source

Merge branch 'meganuke' of https://github.com/TechEmpower/FrameworkBenchmarks into meganuke

Lita Gratrix 10 years ago
parent
commit
cb1a876323

+ 9 - 1
deployment/vagrant-common/bootstrap.sh

@@ -74,6 +74,10 @@ if [ ! -e "~/.firstboot" ]; then
   echo $CLIENT_IP TFB-client   | sudo tee --append /etc/hosts
   echo $SERVER_IP TFB-server   | sudo tee --append /etc/hosts
 
+  # Add other users:
+  sudo useradd -m testrunner
+  sudo bash -c "echo 'testrunner ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/90-tfb-testrunner"
+
   # Update hostname to reflect our current role
   if [ "$ROLE" != "all" ]; then
     echo "Updating hostname"
@@ -112,8 +116,12 @@ if [ ! -e "~/.firstboot" ]; then
   echo "Setting up SSH access to localhost"
   ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa
   cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
+  sudo -u testrunner mkdir -p /home/testrunner/.ssh
+  sudo -u testrunner ssh-keygen -t rsa -N '' -f /home/testrunner/.ssh/id_rsa
+  sudo -u testrunner bash -c "cat /home/testrunner/.ssh/id_rsa.pub >> /home/testrunner/.ssh/authorized_keys"
+  sudo -u testrunner bash -c "cat /home/vagrant/.ssh/authorized_keys >> /home/testrunner/.ssh/authorized_keys"
   chmod 600 ~/.ssh/authorized_keys
-
+  sudo -u testrunner chmod 600 /home/testrunner/.ssh/authorized_keys
   # Enable remote SSH access if we are running production environment
   # Note : this are always copied from the local working copy using a
   #        file provisioner. While they exist in the git clone we just 

+ 2 - 2
deployment/vagrant-common/core.rb

@@ -96,10 +96,10 @@ def provider_virtualbox(config, role)
     vb.memory = ENV.fetch('TFB_VB_MEM', 2048)
     vb.cpus = ENV.fetch('TFB_VB_CPU', 2)
 
-    override.vm.synced_folder "../..", "/FrameworkBenchmarks"
+    override.vm.synced_folder "../..", "/FrameworkBenchmarks", mount_options: ['fmode=777', 'dmode=777']
 
     if role.eql? "all" or role.eql? "app"
       override.vm.network :forwarded_port, guest: 8080, host: 28080
     end
   end
-end
+end

+ 2 - 0
frameworks/Go/beego/setup.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/hello/hello.go
+
 # Where to find the go executable
 export PATH="$GOROOT/bin:$PATH"
 

+ 1 - 2
frameworks/Go/falcore/setup.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 
-
-#!/bin/bash
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/framework_benchmarks/falcore.go
 
 # Where to find the go executable
 export PATH="$GOROOT/bin:$PATH"

+ 1 - 4
frameworks/Go/gin/hello.go

@@ -149,10 +149,7 @@ func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())
 
 	dsn := "benchmarkdbuser:benchmarkdbpass@tcp(%s:3306)/hello_world"
-	dbhost := os.Getenv("TFB_DATABASE_HOST")
-	if dbhost == "" {
-		dbhost = "localhost"
-	}
+	dbhost := os.Getenv("DBHOST")
 
 	db, err := sql.Open("mysql", fmt.Sprintf(dsn, dbhost))
 	if err != nil {

+ 2 - 0
frameworks/Go/go/setup.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/hello/hello.go
+
 # Where to find the go executable
 export PATH="$GOROOT/bin:$PATH"
 

+ 2 - 0
frameworks/Go/gorail/setup.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/hello/hello.go
+
 # Where to find the go executable
 export PATH="$GOROOT/bin:$PATH"
 

+ 2 - 0
frameworks/Go/revel-jet/setup.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/benchmark/conf/app.conf
+
 # here te find the go executable
 export PATH="$GOROOT/bin:$PATH"
 

+ 2 - 0
frameworks/Go/revel-qbs/setup.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/benchmark/conf/app.conf
+
 # Where to find the go executable
 export PATH="$GOROOT/bin:$PATH"
 

+ 2 - 0
frameworks/Go/revel/setup.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+sed -i 's|tcp(.*:3306)|tcp('"${DBHOST}"':3306)|g' src/benchmark/conf/app.conf
+
 # Where to find the go executable
 export PATH="$GOROOT/bin:$PATH"
 

+ 2 - 1
frameworks/Haskell/snap/bash_profile.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
 
 export CABAL_HOME=/opt/cabal/1.20
-export HASKELL_HOME=/opt/ghc/7.8.3
+export HASKELL_HOME=/opt/ghc/7.8.3
+export LANG=en_US.UTF-8

+ 2 - 1
frameworks/Haskell/wai/bash_profile.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
 
 export CABAL_HOME=/opt/cabal/1.20
-export HASKELL_HOME=/opt/ghc/7.8.3
+export HASKELL_HOME=/opt/ghc/7.8.3
+export LANG=en_US.UTF-8

+ 2 - 1
frameworks/Haskell/yesod/bash_profile.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
 
 export CABAL_HOME=/opt/cabal/1.20
-export HASKELL_HOME=/opt/ghc/7.8.3
+export HASKELL_HOME=/opt/ghc/7.8.3
+export LANG=en_US.UTF-8

+ 1 - 1
frameworks/Python/bottle/app.py

@@ -20,7 +20,7 @@ if sys.version_info[0] == 3:
 _is_pypy = hasattr(sys, 'pypy_version_info')
 
 DBDRIVER = 'mysql+pymysql' if _is_pypy else 'mysql'
-DBHOSTNAME = os.environ.get('TFB_DATABASE_HOST', 'localhost')
+DBHOSTNAME = os.environ.get('DBHOST', 'localhost')
 DATABASE_URI = '%s://benchmarkdbuser:benchmarkdbpass@%s:3306/hello_world?charset=utf8' % (DBDRIVER, DBHOSTNAME)
 
 app = Bottle()

+ 1 - 1
frameworks/Python/django/hello/hello/settings.py

@@ -17,7 +17,7 @@ DATABASES = {
         'NAME': 'hello_world',           # Or path to database file if using sqlite3.
         'USER': 'benchmarkdbuser',       # Not used with sqlite3.
         'PASSWORD': 'benchmarkdbpass',   # Not used with sqlite3.
-        'HOST': os.environ.get('TFB_DATABASE_HOST', ''),  # Set to empty string for localhost. Not used with sqlite3.
+        'HOST': os.environ.get('DBHOST', ''),  # Set to empty string for localhost. Not used with sqlite3.
         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
         'CONN_MAX_AGE': 30,
     }

+ 1 - 1
frameworks/Python/flask/app.py

@@ -14,7 +14,7 @@ from sqlalchemy import create_engine
 if sys.version_info[0] == 3:
     xrange = range
 
-DBHOST = os.environ.get('TFB_DATABASE_HOST', 'localhost')
+DBHOST = os.environ.get('DBHOST', 'localhost')
 
 try:
     import MySQLdb

+ 1 - 1
frameworks/Python/pyramid/frameworkbenchmarks/models.py

@@ -11,7 +11,7 @@ from sqlalchemy.orm import sessionmaker
 from sqlalchemy.pool import QueuePool
 from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
 
-DBHOSTNAME = os.environ.get('TFB_DATABASE_HOST', 'localhost')
+DBHOSTNAME = os.environ.get('DBHOST', 'localhost')
 
 def get_conn():
     return psycopg2.connect(

+ 44 - 12
toolset/benchmark/benchmarker.py

@@ -539,15 +539,22 @@ class Benchmarker:
           time.sleep(10)
 
         if self.__is_port_bound(test.port):
-          self.__write_intermediate_results(test.name, "port " + str(test.port) + " is not available before start")
-          err.write(header("Error: Port %s is not available, cannot start %s" % (test.port, test.name)))
+          # This can happen sometimes - let's try again
+          self.__stop_test(out, err)
+          out.flush()
           err.flush()
-          print "Error: Unable to recover port, cannot start test"
-          return exit_with_code(1)
+          time.sleep(15)
+          if self.__is_port_bound(test.port):
+            # We gave it our all
+            self.__write_intermediate_results(test.name, "port " + str(test.port) + " is not available before start")
+            err.write(header("Error: Port %s is not available, cannot start %s" % (test.port, test.name)))
+            err.flush()
+            print "Error: Unable to recover port, cannot start test"
+            return exit_with_code(1)
 
         result = test.start(out, err)
         if result != 0: 
-          test.stop(out, err)
+          self.__stop_test(out, err)
           time.sleep(5)
           err.write( "ERROR: Problem starting {name}\n".format(name=test.name) )
           err.flush()
@@ -581,16 +588,23 @@ class Benchmarker:
         ##########################
         out.write(header("Stopping %s" % test.name))
         out.flush()
-        test.stop(out, err)
+        self.__stop_test(out, err)
         out.flush()
         err.flush()
-        time.sleep(5)
+        time.sleep(15)
 
         if self.__is_port_bound(test.port):
-          err.write(header("Error: Port %s was not released by stop %s" % (test.port, test.name)))
+          # This can happen sometimes - let's try again
+          self.__stop_test(out, err)
+          out.flush()
           err.flush()
-          self.__write_intermediate_results(test.name, "port " + str(test.port) + " was not released by stop")
-          return exit_with_code(1)
+          time.sleep(15)
+          if self.__is_port_bound(test.port):
+            # We gave it our all
+            self.__write_intermediate_results(test.name, "port " + str(test.port) + " was not released by stop")
+            err.write(header("Error: Port %s was not released by stop %s" % (test.port, test.name)))
+            err.flush()
+            return exit_with_code(1)
 
         out.write(header("Stopped %s" % test.name))
         out.flush()
@@ -613,7 +627,7 @@ class Benchmarker:
         traceback.print_exc(file=err)
         err.flush()
         try:
-          test.stop(out, err)
+          self.__stop_test(out, err)
         except (subprocess.CalledProcessError) as e:
           self.__write_intermediate_results(test.name,"<setup.py>#stop() raised an error")
           err.write(header("Subprocess Error: Test .stop() raised exception %s" % test.name))
@@ -625,7 +639,7 @@ class Benchmarker:
       # TODO - subprocess should not catch this exception!
       # Parent process should catch it and cleanup/exit
       except (KeyboardInterrupt) as e:
-        test.stop(out, err)
+        self.__stop_test(out, err)
         out.write(header("Cleaning up..."))
         out.flush()
         self.__finish()
@@ -639,6 +653,24 @@ class Benchmarker:
   # End __run_tests
   ############################################################
 
+  ############################################################
+  # __stop_test(benchmarker)
+  # Stops a running test
+  ############################################################
+  def __stop_test(self, out, err):
+
+    # Meganuke
+    try:
+      subprocess.check_call('sudo killall -s 9 -u %s' % self.runner_user, shell=True, stderr=err, stdout=out)
+      retcode = 0
+    except Exception:
+      retcode = 1
+
+    return retcode
+  ############################################################
+  # End __stop_test
+  ############################################################
+
   ############################################################
   # __is_port_bound
   # Check if the requested port is available. If it

+ 0 - 38
toolset/benchmark/framework_test.py

@@ -236,44 +236,6 @@ class FrameworkTest:
   # End start
   ############################################################
 
-  ############################################################
-  # stop(benchmarker)
-  # Stops the test using it's setup file
-  ############################################################
-  def stop(self, out, err):
-    # Load profile for this installation
-    profile="%s/bash_profile.sh" % self.directory
-    if not os.path.exists(profile):
-      logging.warning("Directory %s does not have a bash_profile.sh" % self.directory)
-      profile="$FWROOT/config/benchmark_profile"
-    
-    setup_util.replace_environ(config=profile, 
-              command='export TROOT=%s && export IROOT=%s' %
-              (self.directory, self.install_root))
-
-    # Run the module stop (inside parent of TROOT)
-    #     - we use the parent as a historical accident - a lot of tests
-    #       use subprocess's cwd argument already
-    previousDir = os.getcwd()
-    os.chdir(os.path.dirname(self.troot))
-
-    # Meganuke
-    try:
-      subprocess.check_call('sudo killall -s 9 -u %s' % self.benchmarker.runner_user, shell=True, stderr=err, stdout=out)
-      retcode = 0
-    except Exception:
-      retcode = 1
-
-    os.chdir(previousDir)
-
-    # Give processes sent a SIGTERM a moment to shut down gracefully
-    time.sleep(5)
-
-    return retcode
-  ############################################################
-  # End stop
-  ############################################################
-
   ############################################################
   # verify_urls
   # Verifys each of the URLs for this test. THis will sinply