-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "BatchTest.hxx"
#include "Launcher.hxx"
+#include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Date.hxx>
-#include <Batch/Batch_MpiImpl.hxx>
+#include <libbatch/MpiImpl.hxx>
#endif
#include "utilities.h"
#ifdef WIN32
# include <io.h>
#endif
-BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr)
+BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr)
{
#ifdef WITH_LIBBATCH
_batch_descr = batch_descr;
// Getting date
- Batch::Date date = Batch::Date(time(0));
- _date = date.str();
- int lend = _date.size() ;
- int i = 0 ;
- while (i < lend)
- {
- if (_date[i] == '/' || _date[i] == '-' || _date[i] == ':' )
- {
- _date[i] = '_' ;
- }
- i++ ;
- }
-
+ const size_t BUFSIZE = 32;
+ char date[BUFSIZE];
+ time_t curtime = time(NULL);
+ strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
+
// Creating test temporary file
- _test_filename = "/tmp/";
- _test_filename += _date + "_test_cluster_file_";
- _test_filename += _batch_descr.hostname.in();
- _base_filename = _date + "_test_cluster_file_" + _batch_descr.hostname.in();
+ _base_filename = std::string(date) + "_test_cluster_file_" + _batch_descr.hostname.in();
+ _test_filename = Kernel_Utils::GetTmpDir() + _base_filename;
#endif
}
BatchTest::test()
{
bool rtn = false;
- INFOS(std::endl
+ INFOS(std::endl
<< "--- Testing batch Machine :" << std::endl
<< "--- Name : " << _batch_descr.hostname << std::endl
<< "--- hostname : " << _batch_descr.hostname << std::endl
<< "--- Submit mpi job : " << result_jobsubmit_mpi << std::endl
<< "--- Application : " << result_appli << std::endl
);
-
- if (result_connection == "OK" &&
+
+ if (result_connection == "OK" &&
result_filecopy == "OK" &&
result_getresult == "OK" &&
result_jobsubmit_simple == "OK" &&
result_jobsubmit_mpi == "OK" &&
result_appli == "OK")
rtn = true;
-
+
return rtn;
}
return result;
}
- // Writing into the tempory file
+ // Writing into the temporary file
command = "echo Hello > " + _test_filename;
status = system(command.c_str());
if(status) {
std::ostringstream oss;
oss << status;
- result += "Error in creating tempory file ! status = ";
+ result += "Error in creating temporary file ! status = ";
result += oss.str();
return result;
}
command = "scp";
if(protocol == "rsh")
command = "rcp";
- command += " " + username + "@" + hostname + ":" + home
+ command += " " + username + "@" + hostname + ":" + home
+ "/" + _base_filename + " " + _test_filename + "_copy";
// Test
result += oss.str();
return result;
}
-
+
// Compare files
std::ifstream src_file(_test_filename.c_str());
if (!src_file)
return result;
}
-std::string
-BatchTest::test_jobsubmit_simple()
+std::string
+BatchTest::test_jobsubmit_simple()
{
int status;
std::string home;
result = "OK";
return result;
}
+ if (batch_type == "oar")
+ {
+ INFOS("test_jobsubmit_simple not yet implemented for oar... return OK");
+ result = "OK";
+ return result;
+ }
+ if (batch_type == "coorm")
+ {
+ INFOS("test_jobsubmit_simple not yet implemented for coorm... return OK");
+ result = "OK";
+ return result;
+ }
if (batch_type != "pbs")
{
result += "Batch type unknown ! : " + batch_type;
}
std::getline(file_job, jobid);
file_job.close();
-
+
// Wait the end of the job
command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
bool stop = false;
- while (!stop)
+ while (!stop)
{
status = system(command.c_str());
if(status && status != 153 && status != 256*153)
command = "scp";
if(protocol == "rsh")
command = "rcp";
- command += " "
+ command += " "
+ username + "@" + hostname + ":" + home + "/" + _date + "_simple* /tmp";
status = system(command.c_str());
if(status) {
result += oss.str();
return result;
}
-
+
// Test results
std::string normal_input;
std::string file_normal_name = "/tmp/" + _date + "_simple_output.log";
file_normal.close();
if (normal_input != "Bonjour")
{
- result += "error from simple ouput file ! waiting for Bonjour and get : " + normal_input;
+ result += "error from simple output file ! waiting for Bonjour and get : " + normal_input;
return result;
}
std::string error_input;
return result;
}
-std::string
-BatchTest::test_jobsubmit_mpi()
+std::string
+BatchTest::test_jobsubmit_mpi()
{
#ifdef WITH_LIBBATCH
int status;
mpiImpl = new MpiImpl_MPICH2();
else if(mpi_type == "openmpi")
mpiImpl = new MpiImpl_OPENMPI();
+ else if(mpi_type == "ompi")
+ mpiImpl = new MpiImpl_OMPI();
else if(mpi_type == "slurmmpi")
mpiImpl = new MpiImpl_SLURM();
else
}
std::getline(file_job, jobid);
file_job.close();
-
+
// Wait the end of the job
command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
bool stop = false;
- while (!stop)
+ while (!stop)
{
status = system(command.c_str());
if(status && status != 153 && status != 256*153)
command = "scp";
if(protocol == "rsh")
command = "rcp";
- command += " "
+ command += " "
+ username + "@" + hostname + ":" + home + "/" + _date + "_mpi* /tmp";
status = system(command.c_str());
if(status) {
result += oss.str();
return result;
}
-
+
// Test results
std::string normal_input;
std::string file_normal_name = "/tmp/" + _date + "_mpi_output.log";
file_normal.close();
if (!test_ok)
{
- result += "error from mpi ouput file ! waiting for HELLO MPI please watch /tmp/" + _date + "_mpi_output.log file";
+ result += "error from mpi output file ! waiting for HELLO MPI please watch /tmp/" + _date + "_mpi_output.log file";
return result;
}
result = "OK";
- return result;
+ return result;
#else
throw LauncherException("Method BatchTest::test_jobsubmit_mpi is not available "
"(libBatch was not present at compilation time)");
#endif
}
-std::string
+std::string
BatchTest::test_appli()
{
int status;
std::string username = _batch_descr.username.in();
std::string protocol = _batch_descr.protocol.in();
std::string applipath = _batch_descr.applipath.in();
-
+
// Getting home directory
std::string rst = get_home(&home);
if(rst != "") {
std::ofstream file_appli;
file_appli.open(_test_file_appli.c_str(), std::ofstream::out);
file_appli << "#!/bin/bash\n"
- << "if [ -f " << applipath << "/runAppli ]\n"
+ << "if [ -f " << applipath << "/salome ]\n"
<< "then\n"
<< " echo OK\n"
<< "else\n"
}
// Launch test
- command = protocol + " " + username + "@" + hostname
- + " sh " + home + "/" + _base_filename + "_appli_test > "
+ command = protocol + " " + username + "@" + hostname
+ + " sh " + home + "/" + _base_filename + "_appli_test > "
+ _test_filename + "_appli_test_result";
status = system(command.c_str());
}
std::getline(file_appli_result, rst_appli);
file_appli_result.close();
-
+
if (rst_appli != "OK")
{
result += "Error checking application on remote host ! result = " + rst;
std::string protocol = _batch_descr.protocol.in();
std::string file_home_name = _test_filename + "_home";
- command = protocol + " " + username + "@" + hostname + " 'echo $HOME' > " + file_home_name;
+ command = protocol + " " + username + "@" + hostname + " 'echo $HOME' > " + file_home_name;
status = system(command.c_str());
if(status) {
std::ostringstream oss;