resurrecting a minimal test infra - starting with linux node and application
[nepi.git] / test / resources / linux / node.py
index e7d44e1..02a2733 100755 (executable)
@@ -4,9 +4,8 @@
 #    Copyright (C) 2013 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,6 +23,7 @@ from nepi.util.sshfuncs import ProcStatus
 
 from test_utils import skipIfNotAlive, skipInteractive, create_node
 
+import shutil
 import os
 import time
 import tempfile
@@ -31,13 +31,13 @@ import unittest
 
 class LinuxNodeTestCase(unittest.TestCase):
     def setUp(self):
-        self.fedora_host = "nepi2.pl.sophia.inria.fr"
+        self.fedora_host = "fedora.pl.sophia.inria.fr"
         self.fedora_user = "inria_nepi"
 
-        self.ubuntu_host = "roseval.pl.sophia.inria.fr"
-        self.ubuntu_user = "alina"
+        self.ubuntu_host = "ubuntu.pl.sophia.inria.fr"
+        self.ubuntu_user = "inria_nepi"
         
-        self.target = "nepi5.pl.sophia.inria.fr"
+        self.target = "nepi.pl.sophia.inria.fr"
 
     @skipIfNotAlive
     def t_execute(self, host, user):
@@ -213,7 +213,6 @@ class LinuxNodeTestCase(unittest.TestCase):
 
         self.assertEquals(out.strip(), "")
 
-
     @skipIfNotAlive
     def t_xterm(self, host, user):
         node, ec = create_node(host, user)
@@ -286,6 +285,55 @@ main (void)
         
         self.assertEquals(out, "Hello, world!\n")
 
+    @skipIfNotAlive
+    def t_copy_files(self, host, user):
+        node, ec = create_node(host, user)
+
+        node.find_home()
+        app_home = os.path.join(node.exp_home, "my-app")
+        node.mkdir(app_home, clean = True)
+
+        # create some temp files and directories to copy
+        dirpath = tempfile.mkdtemp()
+        f = tempfile.NamedTemporaryFile(dir=dirpath, delete=False)
+        f.close()
+      
+        f1 = tempfile.NamedTemporaryFile(delete=False)
+        f1.close()
+        f1.name
+
+        source = [dirpath, f1.name]
+        destdir = "test"
+        node.mkdir(destdir, clean = True)
+        dest = "%s@%s:test" % (user, host)
+        node.copy(source, dest)
+
+        command = "ls %s" % destdir
+        
+        (out, err), proc = node.execute(command)
+
+        os.remove(f1.name)
+        shutil.rmtree(dirpath)
+
+        self.assertTrue(out.find(os.path.basename(dirpath)) > -1)
+        self.assertTrue(out.find(os.path.basename(f1.name)) > -1)
+
+        f2 = tempfile.NamedTemporaryFile(delete=False)
+        f2.close()
+        f2.name
+
+        node.mkdir(destdir, clean = True)
+        dest = "%s@%s:test" % (user, host)
+        node.copy(f2.name, dest)
+
+        command = "ls %s" % destdir
+        
+        (out, err), proc = node.execute(command)
+
+        os.remove(f2.name)
+        
+        self.assertTrue(out.find(os.path.basename(f2.name)) > -1)
+
     def test_execute_fedora(self):
         self.t_execute(self.fedora_host, self.fedora_user)
 
@@ -339,6 +387,11 @@ main (void)
         """ Interactive test. Should not run automatically """
         self.t_xterm(self.ubuntu_host, self.ubuntu_user)
 
+    def test_copy_files_fedora(self):
+        self.t_copy_files(self.fedora_host, self.fedora_user)
+
+    def test_copy_files_ubuntu(self):
+        self.t_copy_files(self.ubuntu_host, self.ubuntu_user)
 
 if __name__ == '__main__':
     unittest.main()