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;
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)
# 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)
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);
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()) {
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();
--- /dev/null
+// 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 <iostream>
+#include <fstream>
+#include <cstring>
+
+#include <Batch_Constants.hxx>
+#include <Batch_Job.hxx>
+#include <Batch_BatchManagerCatalog.hxx>
+#include <Batch_FactBatchManager.hxx>
+#include <Batch_BatchManager.hxx>
+
+#include "SimpleParser.hxx"
+
+#include <Test_config.h>
+
+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;
+ }
+}
// 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}"
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
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
--- /dev/null
+#!/bin/sh
+
+a=4
--- /dev/null
+#!/bin/sh
+
+b=3
--- /dev/null
+#!/bin/sh
+
+. ./seta.sh
+. ./setb.sh
+
+c=`expr $a "*" $b`
+
+echo "MYENVVAR = $MYENVVAR" > result.txt
+echo "c = $c" >> result.txt
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)
+++ /dev/null
-# 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)
+++ /dev/null
-// 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 <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Batch_Constants.hxx>
-#include <Batch_Job.hxx>
-#include <Batch_BatchManagerCatalog.hxx>
-#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-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;
- }
-}
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
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)
+++ /dev/null
-# 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)
+++ /dev/null
-// 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 <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Batch_Constants.hxx>
-#include <Batch_Job.hxx>
-#include <Batch_BatchManagerCatalog.hxx>
-#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-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;
- }
-}
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
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)
+++ /dev/null
-# 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)
+++ /dev/null
-// 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 <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Batch_Constants.hxx>
-#include <Batch_Job.hxx>
-#include <Batch_BatchManagerCatalog.hxx>
-#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-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;
- }
-}
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt