- typo
[oweals/gnunet.git] / src / integration-tests / test_integration_connect_on_restart.py.in
index 536ffd8868a8260f4d133d92edc758a16b6e5e16..3fe5756e6efc9f9602d799c84f103ba4654f0486 100755 (executable)
@@ -32,7 +32,6 @@ import subprocess
 import re
 import shutil
 import time
-import pexpect
 from gnunet_testing import Peer
 from gnunet_testing import Test
 from gnunet_testing import Check
@@ -46,16 +45,42 @@ testname = "test_integration_clique"
 verbose = True
 check_timeout = 180
 
+if os.name == "nt":
+  tmp = os.getenv ("TEMP")
+else:
+  tmp = "/tmp"
 
 def cleanup ():
-       if os.name == "nt":
-           shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_bootstrap_server"), True)
-           shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client"), True)
-           shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client_2"), True)
-       else:
-           shutil.rmtree ("/tmp/c_bootstrap_server/", True)
-           shutil.rmtree ("/tmp/c_no_nat_client/", True)
-           shutil.rmtree ("/tmp/c_no_nat_client_2/", True)
+    retries = 10
+    path = os.path.join (tmp, "c_bootstrap_server")  
+    test.p ("Removing " + path)      
+    while ((os.path.exists(path)) and (retries > 0)):
+        shutil.rmtree ((path), False)
+        time.sleep (1)
+        retries -= 1
+    if (os.path.exists(path)):
+        test.p ("Failed to remove " + path)
+    
+    retries = 10
+    path = os.path.join (tmp, "c_no_nat_client")  
+    test.p ("Removing " + path)      
+    while ((os.path.exists(path)) and (retries > 0)):
+        shutil.rmtree ((path), False)
+        time.sleep (1)
+        retries -= 1
+    if (os.path.exists(path)):
+        test.p ("Failed to remove " + path)
+    
+        retries = 10
+    path = os.path.join (tmp, "c_no_nat_client_2")  
+    test.p ("Removing " + path)      
+    while ((os.path.exists(path)) and (retries > 0)):
+        shutil.rmtree ((path), False)
+        time.sleep (1)
+        retries -= 1
+    if (os.path.exists(path)):
+        test.p ("Failed to remove " + path)
+    shutil.rmtree (os.path.join (tmp, "c_no_nat_client_2"), True)
 
 
 def success_cont (check):
@@ -82,13 +107,13 @@ def success_connect_cont (check):
        check = Check (test)
        check.add (StatisticsCondition (client, 'transport', '# peers connected',1))
        check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1))  
-       check.add (StatisticsCondition (client, 'core', '# entries in session map',1))
+       check.add (StatisticsCondition (client, 'core', '# peers connected',1))
        check.add (StatisticsCondition (client, 'topology', '# peers connected',1))
        check.add (StatisticsCondition (client, 'fs', '# peers connected',1))
        
        check.add (StatisticsCondition (client2, 'transport', '# peers connected',1))
        check.add (StatisticsCondition (client2, 'core', '# neighbour entries allocated',1))  
-       check.add (StatisticsCondition (client2, 'core', '# entries in session map',1))
+       check.add (StatisticsCondition (client2, 'core', '# peers connected',1))
        check.add (StatisticsCondition (client2, 'topology', '# peers connected',1))
        check.add (StatisticsCondition (client2, 'fs', '# peers connected',1))  
 
@@ -106,19 +131,19 @@ def check_connect ():
   check = Check (test)
   check.add (StatisticsCondition (client, 'transport', '# peers connected',2))
   check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',2))  
-  check.add (StatisticsCondition (client, 'core', '# entries in session map',2))
+  check.add (StatisticsCondition (client, 'core', '# peers connected',2))
   check.add (StatisticsCondition (client, 'topology', '# peers connected',2))
   check.add (StatisticsCondition (client, 'fs', '# peers connected',2))
 
   check.add (StatisticsCondition (client2, 'transport', '# peers connected',2))
   check.add (StatisticsCondition (client2, 'core', '# neighbour entries allocated',2))  
-  check.add (StatisticsCondition (client2, 'core', '# entries in session map',2))
+  check.add (StatisticsCondition (client2, 'core', '# peers connected',2))
   check.add (StatisticsCondition (client2, 'topology', '# peers connected',2))
   check.add (StatisticsCondition (client2, 'fs', '# peers connected',2))
   
   check.add (StatisticsCondition (server, 'transport', '# peers connected',2))
   check.add (StatisticsCondition (server, 'core', '# neighbour entries allocated',2))  
-  check.add (StatisticsCondition (server, 'core', '# entries in session map',2))
+  check.add (StatisticsCondition (server, 'core', '# peers connected',2))
   check.add (StatisticsCondition (server, 'topology', '# peers connected',2))
   check.add (StatisticsCondition (server, 'fs', '# peers connected',2))  
   
@@ -137,6 +162,7 @@ def run ():
        success = False
        
        test = Test ('test_integration_disconnect', verbose)
+       cleanup ()
        
        server = Peer(test, './confs/c_bootstrap_server.conf');
        server.start();