Browse Source

Make a script to find an available port in the tests; added parallel test runner script

Yentl Van Tendeloo 9 years ago
parent
commit
6b99c13ac2
2 changed files with 46 additions and 3 deletions
  1. 24 3
      integration/utils.py
  2. 22 0
      run_tests_parallel.sh

+ 24 - 3
integration/utils.py

@@ -12,7 +12,28 @@ import signal
 import random
 import random
 
 
 username = "test_user"
 username = "test_user"
-parallel_push = False
+parallel_push = True
+
+ports = []
+
+def getFreePort():
+    while 1:
+        port = random.randint(10000, 20000)
+        ports.append(port)
+
+        exists = False
+        for p in ports:
+            if p == port:
+                if not exists:
+                    # We have hopefully found our own
+                    exists = True
+                else:
+                    # We seem to be the second entry, so chose another one
+                    p.remove(port)
+                    break
+        else:
+            # Didn't find a duplicate
+            return port
 
 
 def serialize(value):
 def serialize(value):
     if isinstance(value, str):
     if isinstance(value, str):
@@ -85,7 +106,7 @@ def run_file(files, parameters, expected, mode):
     import os.path
     import os.path
 
 
     time.sleep(0.01)
     time.sleep(0.01)
-    port = random.randint(10000, 10100)
+    port = getFreePort()
     address = "http://localhost:%i" % port
     address = "http://localhost:%i" % port
     try:
     try:
         # Run Modelverse server
         # Run Modelverse server
@@ -161,7 +182,7 @@ def run_file(files, parameters, expected, mode):
             pass
             pass
             
             
 def run_barebone(parameters, expected, interface="0", timeout=False, wait=False, link=None):
 def run_barebone(parameters, expected, interface="0", timeout=False, wait=False, link=None):
-    port = random.randint(10000, 10100)
+    port = getFreePort()
     address = "http://localhost:%i" % port
     address = "http://localhost:%i" % port
     try:
     try:
         # Run Modelverse server
         # Run Modelverse server

+ 22 - 0
run_tests_parallel.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+set -e
+
+./flush_compiler_caches.sh
+
+cd state
+py.test
+cd ..
+
+./generate_bootstrap.sh
+
+cd kernel
+py.test
+cd ..
+
+./flush_compiler_caches.sh
+
+cd interface/HUTN
+py.test
+cd ../..
+
+py.test integration -n 4