first step towards integrating http://svn.planet-lab.org/svn/tests/trunk/qaapi/qa...
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 18 Aug 2008 16:55:04 +0000 (16:55 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 18 Aug 2008 16:55:04 +0000 (16:55 +0000)
can run tests in the node's root context so far (vsys_launch.pl is hardwired)
tests in a slice to be implemented later on (is simpler)
also waiting for tony's answer as to the place to store these scripts on the long run

system/TestKey.py
system/TestNode.py
system/TestPlc.py
system/TestSlice.py
system/TestSsh.py

index 4df0b48..d1af805 100644 (file)
@@ -17,17 +17,17 @@ class TestKey:
     def privatepath(self):
         return "keys/%s.rsa"%(self.name())
 
-    def store_remote_key(self,hostname):
-        #Not tested yet, don't know if needed
-        pub=self.publicpath()
-        priv=self.privatepath()
-        utils.header("Storing key %s in %s into %s "%(self.name(),pub,hostname))
-        dir=os.path.dirname(pub)
-        self.test_ssh.run("mkdir %s"%dir)
-        self.test_ssh.run("cat %s >> %s"%(self.key_spec['key_fields']['key'],pub))
-        self.test_ssh.run("cat %s >> %s"%(self.key_spec['private'],priv))
-        self.test_ssh.run("chmod %s 0400"%priv)
-        self.test_ssh.run("chmod %s 0444"%pub)
+#Not tested yet, don't know if needed
+#    def store_remote_key(self,hostname):
+#        pub=self.publicpath()
+#        priv=self.privatepath()
+#        utils.header("Storing key %s in %s into %s "%(self.name(),pub,hostname))
+#        dir=os.path.dirname(pub)
+#        self.test_ssh.run("mkdir %s"%dir)
+#        self.test_ssh.run("cat %s >> %s"%(self.key_spec['key_fields']['key'],pub))
+#        self.test_ssh.run("cat %s >> %s"%(self.key_spec['private'],priv))
+#        self.test_ssh.run("chmod %s 0400"%priv)
+#        self.test_ssh.run("chmod %s 0444"%pub)
             
     def store_key(self):
         pub=self.publicpath()
index 7cc3602..f990e71 100644 (file)
@@ -1,4 +1,4 @@
-import os, sys, time, base64
+import sys, os, os.path, time, base64
 import xmlrpclib
 
 import utils
@@ -208,3 +208,27 @@ class TestNode:
     def clear_known_hosts (self):
         TestSsh(self.name()).clear_known_hosts()
         return True
+
+    def check_sanity_node_script (self,local_script):
+        # get the plc's keys for entering the node
+        vservername=self.test_plc.vservername
+        key = "keys/%(vservername)s.rsa"%locals()
+        # push the script on the node's root context
+        ssh_handle = TestSsh(self.name(),
+                             buildname=self.buildname(),
+                             key=key)
+        ssh_handle.copy_home(local_script)
+        if ssh_handle.run("./"+os.path.basename(local_script)) != 0:
+            print "WARNING: sanity check script %s FAILED"
+            # xxx - temporary : always return true for now
+            #return False
+        return True
+    
+    def check_sanity_node (self):
+        # locate the relevant scripts - xxx
+        scripts = [ 'tests/qaapi/qa/tests/node/vsys_launch.pl' ]
+        overall = True
+        for script in scripts:
+            if not self.check_sanity_node_script (script):
+                overall = False
+        return overall
index 590aab9..1deb7a7 100644 (file)
@@ -63,13 +63,13 @@ SEP='<sep>'
 class TestPlc:
 
     default_steps = ['uninstall','install','install_rpm', 
-                     'configure', 'start', SEP,
+                     'configure', 'start', 'fetch_keys', SEP,
                      'store_keys', 'clear_known_hosts', 'initscripts', SEP,
                      'sites', 'nodes', 'slices', 'nodegroups', SEP,
                      'init_node','bootcd', 'configure_qemu', 'export_qemu',
                      'kill_all_qemus', 'reinstall_node','start_node', SEP,
-                     'nodes_booted', 'nodes_ssh', 'check_slice',
-                     'check_initscripts', 'check_tcp', 'plcsh_stress_test', SEP,
+                     'nodes_booted', 'nodes_ssh', 'check_slice', 'check_initscripts', SEP,
+                     'check_sanity', 'check_tcp', 'plcsh_stress_test', SEP,
                      'force_gather_logs', 'force_kill_qemus', 'force_record_tracker','force_free_tracker' ]
     other_steps = [ 'stop_all_vservers','fresh_install', 'cache_rpm', 'stop', 'vs_start', SEP,
                     'clean_initscripts', 'clean_nodegroups','clean_all_sites', SEP,
@@ -361,7 +361,7 @@ class TestPlc:
         self.start_guest()
         return True
 
-    # could use a TestKey class
+    # stores the keys from the config for further use
     def store_keys(self):
         for key_spec in self.plc_spec['keys']:
                TestKey(self,key_spec).store_key()
@@ -370,6 +370,17 @@ class TestPlc:
     def clean_keys(self):
         utils.system("rm -rf %s/keys/"%os.path(sys.argv[0]))
 
+    # fetches the ssh keys in the plc's /etc/planetlab and stores them in keys/
+    # for later direct access to the nodes
+    def fetch_keys(self):
+        prefix = 'root_ssh_key'
+        vservername=self.vservername
+        for ext in [ 'pub', 'rsa' ] :
+            src="/vservers/%(vservername)s/etc/planetlab/%(prefix)s.%(ext)s"%locals()
+            dst="keys/%(vservername)s.%(ext)s"%locals()
+            self.run_in_guest_piped
+            self.test_ssh.fetch(src,dst)
+
     def sites (self):
         return self.do_sites()
     
@@ -596,6 +607,14 @@ class TestPlc:
     @node_mapper
     def export_qemu (self): pass
         
+    @node_mapper
+    def check_sanity_node (self): pass
+    @slice_mapper_options
+    def check_sanity_slice (self) : pass
+    
+    def check_sanity (self):
+        return self.check_sanity_node() and self.check_sanity_slice()
+
     def do_check_initscripts(self):
         overall = True
         for slice_spec in self.plc_spec['slices']:
index 3ec6cb7..fb8935f 100644 (file)
@@ -129,3 +129,7 @@ class TestSlice:
             time.sleep (period)
         # for an empty slice
         return True
+
+    def check_sanity_slice (self):
+        print 'TestSlice.check_sanity_slice (run scripts in slice): XXX todo'
+        return True
index f523843..6f11344 100644 (file)
@@ -140,6 +140,9 @@ class TestSsh:
         scp_command += "%s %s%s"%(local_file,dest,remote_file)
         return utils.system(scp_command)
 
+    def copy_home (self, local_file, recursive=False):
+        return self.copy_abs(local_file,os.path.basename(local_file),recursive)
+
     def fetch (self, remote_file, local_file, recursive=False):
         if self.is_local():
             command="cp "