+ @skipIfNotAlive
+ def t_exitcode_ok(self, host, user):
+ command = "echo 'OK!'"
+
+ 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)
+
+ (out, err), proc = node.run_and_wait(command, app_home,
+ shfile = "cmd.sh",
+ pidfile = "pid",
+ ecodefile = "exitcode",
+ stdout = "stdout",
+ stderr = "stderr",
+ raise_on_error = True)
+
+ # get the pid of the process
+ ecode = node.exitcode(app_home)
+ self.assertEquals(ecode, ExitCode.OK)
+
+ @skipIfNotAlive
+ def t_exitcode_kill(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)
+
+ # Upload command that will not finish
+ command = "ping localhost"
+ shfile = os.path.join(app_home, "cmd.sh")
+ (out, err), proc = node.upload_command(command,
+ shfile = shfile,
+ ecodefile = "exitcode")
+
+ (out, err), proc = node.run(command, app_home,
+ pidfile = "pidfile",
+ stdout = "stdout",
+ stderr = "stderr")
+
+ # Just wait to make sure the ping started
+ time.sleep(5)
+
+ # The process is still running, so no retfile has been created yet
+ ecode = node.exitcode(app_home)
+ self.assertEquals(ecode, ExitCode.FILENOTFOUND)
+
+ (out, err), proc = node.check_errors(app_home)
+ self.assertEquals(err, "")
+
+ # Now kill the app
+ pid, ppid = node.getpid(app_home)
+ node.kill(pid, ppid)
+
+ (out, err), proc = node.check_errors(app_home)
+ self.assertEquals(err, "")
+
+ @skipIfNotAlive
+ def t_exitcode_error(self, host, user):
+ # Try to execute a command that doesn't exist
+ command = "unexistent-command"
+
+ 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)
+
+ (out, err), proc = node.run_and_wait(command, app_home,
+ shfile = "cmd.sh",
+ pidfile = "pid",
+ ecodefile = "exitcode",
+ stdout = "stdout",
+ stderr = "stderr",
+ raise_on_error = False)
+
+ # get the pid of the process
+ ecode = node.exitcode(app_home)
+
+ # bash erro 127 - command not found
+ self.assertEquals(ecode, 127)
+
+ (out, err), proc = node.check_errors(app_home)
+
+ self.assertTrue(err.find("cmd.sh: line 1: unexistent-command: command not found") > -1)
+
+ @skipIfNotAlive
+ def t_install(self, host, user):
+ node, ec = create_node(host, user)
+
+ node.find_home()
+ (out, err), proc = node.mkdir(node.node_home, clean = True)
+ self.assertEquals(err, "")
+
+ (out, err), proc = node.install_packages("gcc", node.node_home)
+ self.assertEquals(err, "")
+
+ (out, err), proc = node.remove_packages("gcc", node.node_home)
+ self.assertEquals(err, "")
+
+ (out, err), proc = node.rmdir(node.exp_home)
+ self.assertEquals(err, "")
+
+ @skipIfNotAlive
+ def t_clean(self, host, user):
+ node, ec = create_node(host, user)
+
+ node.find_home()
+ node.mkdir(node.lib_dir)
+ node.mkdir(node.node_home)
+
+ command1 = " [ -d %s ] && echo 'Found'" % node.lib_dir
+ (out, err), proc = node.execute(command1)
+
+ self.assertEquals(out.strip(), "Found")
+
+ command2 = " [ -d %s ] && echo 'Found'" % node.node_home
+ (out, err), proc = node.execute(command2)
+
+ self.assertEquals(out.strip(), "Found")
+
+ node.clean_experiment()
+
+ (out, err), proc = node.execute(command2)