From: barate Date: Wed, 16 Jan 2013 15:56:06 +0000 (+0000) Subject: Fix remote directories in file transfer and merge some tests X-Git-Url: http://git.salome-platform.org/gitweb/?p=tools%2Flibbatch.git;a=commitdiff_plain;h=daf0abdaeae60faff7191e0e29aebb7a1bea92ad Fix remote directories in file transfer and merge some tests --- diff --git a/src/Core/Batch_BatchManager.cxx b/src/Core/Batch_BatchManager.cxx index 2585f7f..1af2bec 100644 --- a/src/Core/Batch_BatchManager.cxx +++ b/src/Core/Batch_BatchManager.cxx @@ -236,8 +236,12 @@ namespace Batch { for (Vit=V.begin() ; Vit!=V.end() ; Vit++) { CoupleType cpt = *static_cast< CoupleType * >(*Vit); Couple inputFile = cpt; + string remotePath = inputFile.getRemote(); + if (!Utils::isAbsolutePath(remotePath)) { + remotePath = params[WORKDIR].str() + "/" + remotePath; + } status = _protocol.copyFile(inputFile.getLocal(), "", "", - inputFile.getRemote(), _hostname, _username); + remotePath, _hostname, _username); if (status) { std::ostringstream oss; oss << "Cannot copy file " << inputFile.getLocal() << " on host " << _hostname; @@ -267,11 +271,15 @@ namespace Batch { for(Vit=V.begin(); Vit!=V.end(); Vit++) { CoupleType cpt = *static_cast< CoupleType * >(*Vit); Couple outputFile = cpt; + string remotePath = outputFile.getRemote(); + if (!Utils::isAbsolutePath(remotePath)) { + remotePath = params[WORKDIR].str() + "/" + remotePath; + } string localPath = outputFile.getLocal(); if (!Utils::isAbsolutePath(localPath)) { localPath = directory + "/" + localPath; } - status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username, + status = _protocol.copyFile(remotePath, _hostname, _username, localPath, "", ""); if (status) { // Try to get what we can (logs files) diff --git a/src/Core/Test/CMakeLists.txt b/src/Core/Test/CMakeLists.txt index a2e81cc..b2244cb 100644 --- a/src/Core/Test/CMakeLists.txt +++ b/src/Core/Test/CMakeLists.txt @@ -29,13 +29,18 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_config.h.in ${CMAKE_CURRENT_BINA # Set the include directories include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/src/Core) # Build SimpleParser library add_library (SimpleParser STATIC SimpleParser.cxx) -# Build the test program +# Build the test program for SimpleParser add_executable(Test_SimpleParser Test_SimpleParser.cxx) target_link_libraries(Test_SimpleParser SimpleParser) # Add the test itself ADD_TEST(SimpleParser Test_SimpleParser) + +# Build the test program for the batch managers +add_executable(Test_BatchManager Test_BatchManager.cxx) +target_link_libraries(Test_BatchManager batch SimpleParser) diff --git a/src/Core/Test/SimpleParser.cxx b/src/Core/Test/SimpleParser.cxx index f20eb27..ac6a135 100644 --- a/src/Core/Test/SimpleParser.cxx +++ b/src/Core/Test/SimpleParser.cxx @@ -128,6 +128,12 @@ const string & SimpleParser::getValue(const string & key) const throw(ParserExce return iter->second; } +const string & SimpleParser::getTestValue(const string & bmType, const string & key) const throw(ParserException) +{ + string fullkey = string("TEST_") + bmType + "_" + key; + return getValue(fullkey); +} + int SimpleParser::getValueAsInt(const string & key) const throw(ParserException) { const string & valueStr = getValue(key); @@ -140,6 +146,12 @@ int SimpleParser::getValueAsInt(const string & key) const throw(ParserException) return res; } +int SimpleParser::getTestValueAsInt(const string & bmType, const string & key) const throw(ParserException) +{ + string fullkey = string("TEST_") + bmType + "_" + key; + return getValueAsInt(fullkey); +} + ostream & operator <<(ostream & os, const SimpleParser & parser) throw() { if (parser._configmap.empty()) { diff --git a/src/Core/Test/SimpleParser.hxx b/src/Core/Test/SimpleParser.hxx index cccee1f..309799c 100644 --- a/src/Core/Test/SimpleParser.hxx +++ b/src/Core/Test/SimpleParser.hxx @@ -54,7 +54,9 @@ public: void parse(const std::string & filename) throw(ParserException); void parseTestConfigFile() throw(ParserException); const std::string & getValue(const std::string & key) const throw(ParserException); + const std::string & getTestValue(const std::string & bmType, const std::string & key) const throw(ParserException); int getValueAsInt(const std::string & key) const throw(ParserException); + int getTestValueAsInt(const std::string & bmType, const std::string & key) const throw(ParserException); friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) throw(); diff --git a/src/Core/Test/Test_BatchManager.cxx b/src/Core/Test/Test_BatchManager.cxx new file mode 100644 index 0000000..2bac0b3 --- /dev/null +++ b/src/Core/Test/Test_BatchManager.cxx @@ -0,0 +1,172 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * Test_BatchManager.cxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : Jan 2013 + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "SimpleParser.hxx" + +#include + +using namespace std; +using namespace Batch; + +void print_usage() +{ + cout << "usage: Test_BatchManager BATCH_MANAGER PROTOCOL" << endl; + cout << " BATCH_MANAGER \"CCC\", \"LL\", \"LOCAL\", \"LSF\", \"PBS\", " << + "\"SGE\", \"SLURM\" or \"VISHNU\"" << endl; + cout << " PROTOCOL \"SH\", \"SSH\" or \"RSH\"" << endl; +} + +int main(int argc, char** argv) +{ + // Parse argument + if (argc != 3) { + print_usage(); + return 1; + } + const char * bmType = argv[1]; + CommunicationProtocolType protocol; + if (strcmp(argv[2], "SSH") == 0) + protocol = SSH; + else if (strcmp(argv[2], "RSH") == 0) + protocol = RSH; + else if (strcmp(argv[2], "SH") == 0) + protocol = SH; + else { + print_usage(); + return 1; + } + + cout << "*******************************************************************************************" << endl; + cout << "This program tests the batch submission of a job using the batch manager \"" << bmType << "\"" << endl; + cout << "and the communication protocol \"" << argv[2] << "\"." << endl; + if (protocol == RSH || protocol == SSH) { + cout << "Passwordless authentication must be used for this test to pass." << endl; + if (protocol == SSH) { + cout << "This can be configured with ssh-agent for instance." << endl; + } else if (protocol == RSH) { + cout << "This can be configured with the .rhosts file." << endl; + } + } + cout << "*******************************************************************************************" << endl; + + // eventually remove any previous result + remove("resultdir/seconddirname/result.txt"); + + try { + // Get the catalog and the BatchManager factory + BatchManagerCatalog& cata = BatchManagerCatalog::getInstance(); + FactBatchManager * fbm = cata(bmType); + + // Parse the test configuration file + SimpleParser parser; + parser.parseTestConfigFile(); + const string & workdir = parser.getTestValue(bmType, "WORKDIR"); + const string & host = parser.getTestValue(bmType, "HOST"); + const string & user = parser.getTestValue(bmType, "USER"); + int timeout = parser.getTestValueAsInt(bmType, "TIMEOUT"); + + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p[EXECUTABLE] = string(CMAKE_CURRENT_SOURCE_DIR) + "/test-script.sh"; + p[NAME] = string("Test ") + bmType + " " + argv[2]; + p[WORKDIR] = workdir; + p[INFILE] = Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/seta.sh", "seta.sh"); + p[INFILE] += Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/setb.sh", "setb.sh"); + p[OUTFILE] = Couple("result.txt", "result.txt"); + p[NBPROC] = 1; + p[MAXWALLTIME] = 1; + p[MAXRAMSIZE] = 50; + job.setParametre(p); + // ... and its environment + Environnement e; + e["MYENVVAR"] = "MYVALUE"; + job.setEnvironnement(e); + cout << job << endl; + + // Create the BatchManager + BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = bm->waitForJobEnd(jobid, timeout); + + if (state == FINISHED) { + cout << "Job " << jobid.__repr__() << " is done" << endl; + bm->importOutputFiles(job, "resultdir/seconddirname"); + } else if (state == FAILED) { + cerr << "Job " << jobid.__repr__() << " finished in error" << endl; + bm->importOutputFiles(job, "resultdir/seconddirname"); + return 1; + } else { + cerr << "Timeout while executing job" << endl; + return 1; + } + + } catch (const GenericException & e) { + cerr << "Error: " << e << endl; + return 1; + } catch (const ParserException & e) { + cerr << "Parser error: " << e.what() << endl; + return 1; + } + + // test the result file + try { + SimpleParser resultParser; + resultParser.parse("resultdir/seconddirname/result.txt"); + cout << "Result:" << endl << resultParser; + const string & envvar = resultParser.getValue("MYENVVAR"); + int result = resultParser.getValueAsInt("c"); + if (envvar == "MYVALUE" && result == 12) { + cout << "OK, Expected result found." << endl; + return 0; + } else { + cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; + return 1; + } + } catch (const ParserException & e) { + cerr << "Parser error on result file: " << e.what() << endl; + return 1; + } +} diff --git a/src/Core/Test/Test_config.h.in b/src/Core/Test/Test_config.h.in index 8e5ab00..a116412 100644 --- a/src/Core/Test/Test_config.h.in +++ b/src/Core/Test/Test_config.h.in @@ -20,4 +20,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +/* Environment variable containing the path of the test configuration file */ #define TEST_CONFIG_FILE_ENV_VAR "${TEST_CONFIG_FILE_ENV_VAR}" + +/* Current source directory */ +#define CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/src/Core/Test/batchtest.conf b/src/Core/Test/batchtest.conf index 2d30ca9..9deb2de 100644 --- a/src/Core/Test/batchtest.conf +++ b/src/Core/Test/batchtest.conf @@ -21,11 +21,6 @@ TEST_LOCAL_SSH_WORK_DIR = "/tmp" # Work directory for SSH Batch tes TEST_LOCAL_SSH_TIMEOUT = 10 # Execution timeout (in seconds) for local SSH Batch test TEST_LOCAL_SSH_FINALIZATION_TIME = 5 # Finalization time (in seconds) for local SSH Batch test -TEST_PBS_HOST = "localhost" # PBS server host -TEST_PBS_USER = "username" # Login for the PBS server -TEST_PBS_QUEUE = "queuename" # Queue to submit test job on PBS server -TEST_PBS_TIMEOUT = 120 # Execution timeout (in seconds) for PBS Batch test - TEST_EPBS_HOST = "localhost" # PBS server host TEST_EPBS_USER = "username" # Login for the PBS server TEST_EPBS_HOMEDIR = "/home/username" # Home directory on PBS server @@ -39,12 +34,17 @@ TEST_ELL_QUEUE = "classname" # Class for the test job test job TEST_ELL_JOBTYPE = "serial" # Job type for LoadLeveler TEST_ELL_TIMEOUT = 120 # Execution timeout (in seconds) for LoadLeveler Batch test -TEST_ESLURM_HOST = "localhost" # Slurm server host -TEST_ESLURM_USER = "username" # Login for the Slurm server -TEST_ESLURM_HOMEDIR = "/home/username" # Home directory on Slurm server -TEST_ESLURM_TIMEOUT = 120 # Execution timeout (in seconds) for Slurm Batch test +TEST_LSF_HOST = "localhost" # LSF server host +TEST_LSF_USER = "username" # Login for the LSF server +TEST_LSF_WORKDIR = "/home/username/wrk" # Work directory on LSF server +TEST_LSF_TIMEOUT = 120 # Execution timeout (in seconds) for LSF Batch test + +TEST_SLURM_HOST = "localhost" # Slurm server host +TEST_SLURM_USER = "username" # Login for the Slurm server +TEST_SLURM_WORKDIR = "/home/username/wrk" # Work directory on Slurm server +TEST_SLURM_TIMEOUT = 120 # Execution timeout (in seconds) for Slurm Batch test -TEST_EVISHNU_HOST = "localhost" # Machine ID of the target cluster -TEST_EVISHNU_USER = "username" # Vishnu login (unused) -TEST_EVISHNU_HOMEDIR = "/home/username" # Home directory on the target cluster -TEST_EVISHNU_TIMEOUT = 120 # Execution timeout (in seconds) for Vishnu Batch test +TEST_VISHNU_HOST = "localhost" # Machine ID of the target cluster +TEST_VISHNU_USER = "username" # Vishnu login (unused) +TEST_VISHNU_WORKDIR = "/home/username/wrk" # Work directory on the target cluster +TEST_VISHNU_TIMEOUT = 120 # Execution timeout (in seconds) for Vishnu Batch test diff --git a/src/Core/Test/seta.sh b/src/Core/Test/seta.sh new file mode 100644 index 0000000..42d1e38 --- /dev/null +++ b/src/Core/Test/seta.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +a=4 diff --git a/src/Core/Test/setb.sh b/src/Core/Test/setb.sh new file mode 100644 index 0000000..8969060 --- /dev/null +++ b/src/Core/Test/setb.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +b=3 diff --git a/src/Core/Test/test-script.sh b/src/Core/Test/test-script.sh new file mode 100755 index 0000000..1d56247 --- /dev/null +++ b/src/Core/Test/test-script.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. ./seta.sh +. ./setb.sh + +c=`expr $a "*" $b` + +echo "MYENVVAR = $MYENVVAR" > result.txt +echo "c = $c" >> result.txt diff --git a/src/LSF/CMakeLists.txt b/src/LSF/CMakeLists.txt index 107d8f9..7a1d7f5 100644 --- a/src/LSF/CMakeLists.txt +++ b/src/LSF/CMakeLists.txt @@ -27,6 +27,6 @@ SET(CLASS_LIST LSF/Batch_BatchManager_eLSF APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) -IF (TEST_ENABLED) - add_subdirectory(Test) -ENDIF (TEST_ENABLED) +IF (TEST_ENABLED AND HAS_SSH) + ADD_TEST(LSF_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LSF SSH) +ENDIF (TEST_ENABLED AND HAS_SSH) diff --git a/src/LSF/Test/CMakeLists.txt b/src/LSF/Test/CMakeLists.txt deleted file mode 100644 index 2794feb..0000000 --- a/src/LSF/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Just copy the test scripts to the binary dir -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY) - -# set the include directories -include_directories(${CMAKE_SOURCE_DIR}/src/Core) -include_directories(${CMAKE_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eLSF Test_eLSF.cxx) -target_link_libraries(Test_eLSF batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eLSF_SSH Test_eLSF SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eLSF_RSH Test_eLSF RSH) -#ENDIF (HAS_RSH) diff --git a/src/LSF/Test/Test_eLSF.cxx b/src/LSF/Test/Test_eLSF.cxx deleted file mode 100644 index 98aa060..0000000 --- a/src/LSF/Test/Test_eLSF.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_eLSF.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : September 2011 - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -void print_usage() -{ - cout << "usage: Test_eLSF PROTOCOL" << endl; - cout << " PROTOCOL \"SSH\" or \"RSH\"" << endl; -} - -int main(int argc, char** argv) -{ - // Parse argument - if (argc != 2) { - print_usage(); - return 1; - } - CommunicationProtocolType protocol; - if (strcmp(argv[1], "SSH") == 0) - protocol = SSH; - else if (strcmp(argv[1], "RSH") == 0) - protocol = RSH; - else { - print_usage(); - return 1; - } - - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on LSF emulation. Passwordless" << endl; - cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl; - cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_ELSF_HOMEDIR"); - const string & host = parser.getValue("TEST_ELSF_HOST"); - const string & user = parser.getValue("TEST_ELSF_USER"); - int timeout = parser.getValueAsInt("TEST_ELSF_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = string("Test_eLSF_") + argv[1]; - p[WORKDIR] = homedir + "/tmp/Batch"; - p[INFILE] = Couple("seta.sh", "tmp/Batch/seta.sh"); - p[INFILE] += Couple("setb.sh", "tmp/Batch/setb.sh"); - p[OUTFILE] = Couple("result.txt", "tmp/Batch/result.txt"); - p[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 128; - p[HOMEDIR] = homedir; - p[EXCLUSIVE] = true; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager * fbm = c("LSF"); - BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else if (state == FAILED) { - cerr << "Job " << jobid.__repr__() << " finished in error" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - return 1; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/LSF/Test/seta.sh b/src/LSF/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/LSF/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/LSF/Test/setb.sh b/src/LSF/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/LSF/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/LSF/Test/test-script.sh b/src/LSF/Test/test-script.sh deleted file mode 100755 index 1d56247..0000000 --- a/src/LSF/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -. ./seta.sh -. ./setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt diff --git a/src/Slurm/CMakeLists.txt b/src/Slurm/CMakeLists.txt index 5a1c432..175559a 100644 --- a/src/Slurm/CMakeLists.txt +++ b/src/Slurm/CMakeLists.txt @@ -27,6 +27,6 @@ SET(CLASS_LIST Slurm/Batch_BatchManager_eSlurm APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) -IF (TEST_ENABLED) - add_subdirectory(Test) -ENDIF (TEST_ENABLED) +IF (TEST_ENABLED AND HAS_SSH) + ADD_TEST(SLURM_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager SLURM SSH) +ENDIF (TEST_ENABLED AND HAS_SSH) diff --git a/src/Slurm/Test/CMakeLists.txt b/src/Slurm/Test/CMakeLists.txt deleted file mode 100644 index be028f6..0000000 --- a/src/Slurm/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Just copy the test scripts to the binary dir -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY) - -# set the include directories -include_directories(${CMAKE_SOURCE_DIR}/src/Core) -include_directories(${CMAKE_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eSlurm Test_eSlurm.cxx) -target_link_libraries(Test_eSlurm batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eSlurm_SSH Test_eSlurm SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eSlurm_RSH Test_eSlurm RSH) -#ENDIF (HAS_RSH) diff --git a/src/Slurm/Test/Test_eSlurm.cxx b/src/Slurm/Test/Test_eSlurm.cxx deleted file mode 100644 index 41e2e46..0000000 --- a/src/Slurm/Test/Test_eSlurm.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_eSlurm.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : May 2011 - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -void print_usage() -{ - cout << "usage: Test_eSlurm PROTOCOL" << endl; - cout << " PROTOCOL \"SSH\" or \"RSH\"" << endl; -} - -int main(int argc, char** argv) -{ - // Parse argument - if (argc != 2) { - print_usage(); - return 1; - } - CommunicationProtocolType protocol; - if (strcmp(argv[1], "SSH") == 0) - protocol = SSH; - else if (strcmp(argv[1], "RSH") == 0) - protocol = RSH; - else { - print_usage(); - return 1; - } - - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on Slurm emulation. Passwordless" << endl; - cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl; - cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_ESLURM_HOMEDIR"); - const string & host = parser.getValue("TEST_ESLURM_HOST"); - const string & user = parser.getValue("TEST_ESLURM_USER"); - int timeout = parser.getValueAsInt("TEST_ESLURM_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = string("Test eSLURM ") + argv[1]; - p[WORKDIR] = homedir + "/tmp/Batch"; - p[INFILE] = Couple("seta.sh", "tmp/Batch/seta.sh"); - p[INFILE] += Couple("setb.sh", "tmp/Batch/setb.sh"); - p[OUTFILE] = Couple("result.txt", "tmp/Batch/result.txt"); - p[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 50; - p[HOMEDIR] = homedir; - p[EXCLUSIVE] = true; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager * fbm = c("SLURM"); - BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else if (state == FAILED) { - cerr << "Job " << jobid.__repr__() << " finished in error" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - return 1; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/Slurm/Test/seta.sh b/src/Slurm/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/Slurm/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/Slurm/Test/setb.sh b/src/Slurm/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/Slurm/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Slurm/Test/test-script.sh b/src/Slurm/Test/test-script.sh deleted file mode 100755 index 1d56247..0000000 --- a/src/Slurm/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -. ./seta.sh -. ./setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt diff --git a/src/Vishnu/CMakeLists.txt b/src/Vishnu/CMakeLists.txt index 31ab7a2..1a0d084 100644 --- a/src/Vishnu/CMakeLists.txt +++ b/src/Vishnu/CMakeLists.txt @@ -28,5 +28,5 @@ SET(CLASS_LIST Vishnu/Batch_BatchManager_eVishnu APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) IF (TEST_ENABLED) - add_subdirectory(Test) + ADD_TEST(VISHNU ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager VISHNU SH) ENDIF (TEST_ENABLED) diff --git a/src/Vishnu/Test/CMakeLists.txt b/src/Vishnu/Test/CMakeLists.txt deleted file mode 100644 index 9e66fb2..0000000 --- a/src/Vishnu/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Just copy the test scripts to the binary dir -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY) - -# set the include directories -include_directories(${CMAKE_SOURCE_DIR}/src/Core) -include_directories(${CMAKE_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eVishnu Test_eVishnu.cxx) -target_link_libraries(Test_eVishnu batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eVishnu_SSH Test_eVishnu SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eVishnu_RSH Test_eVishnu RSH) -#ENDIF (HAS_RSH) diff --git a/src/Vishnu/Test/Test_eVishnu.cxx b/src/Vishnu/Test/Test_eVishnu.cxx deleted file mode 100644 index 0ef9d12..0000000 --- a/src/Vishnu/Test/Test_eVishnu.cxx +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_eVishnu.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : June 2011 - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -int main(int argc, char** argv) -{ - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on Vishnu commands." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_EVISHNU_HOMEDIR"); - const string & host = parser.getValue("TEST_EVISHNU_HOST"); - const string & user = parser.getValue("TEST_EVISHNU_USER"); - int timeout = parser.getValueAsInt("TEST_EVISHNU_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = "Test_eVISHNU"; - p[WORKDIR] = homedir + "/tmp/Batch"; - p[INFILE] = Couple("seta.sh", "seta.sh"); - p[INFILE] += Couple("setb.sh", "setb.sh"); - p[OUTFILE] = Couple("result.txt", "result.txt"); - p[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 50; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager * fbm = c("VISHNU"); - BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), SH); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else if (state == FAILED) { - cerr << "Job " << jobid.__repr__() << " finished in error" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - return 1; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/Vishnu/Test/seta.sh b/src/Vishnu/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/Vishnu/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/Vishnu/Test/setb.sh b/src/Vishnu/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/Vishnu/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Vishnu/Test/test-script.sh b/src/Vishnu/Test/test-script.sh deleted file mode 100755 index 1d56247..0000000 --- a/src/Vishnu/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -. ./seta.sh -. ./setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt