Skip to content

Commit

Permalink
A bit more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Feb 23, 2018
1 parent 35b4fdc commit 3737572
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -183,7 +183,7 @@ set(SOURCE_FILES
# test files
set(TEST_FILES
test/main.cpp
test/constructor_exceptions/MessageConstructorTest.cpp
test/simulation_message_constructors/MessageConstructorTest.cpp
test/workflow/WorkflowTest.cpp
test/workflow/WorkflowFileTest.cpp
test/workflow/WorkflowTaskTest.cpp
Expand Down
1 change: 1 addition & 0 deletions test/simulation/BatchServiceTest.cpp
Expand Up @@ -1528,6 +1528,7 @@ class StandardJobInsidePilotJobTimeoutSubmissionTestWMS : public wrench::WMS {
throw std::runtime_error("Got a job failure event, but the failure cause seems wrong");
}
wrench::ServiceIsDown *real_cause = (wrench::ServiceIsDown *) (event->failure_cause.get());
std::string error_msg = real_cause->toString();
if (real_cause->getService() != this->test->compute_service) {
std::runtime_error(
"Got the correct failure even, a correct cause type, but the cause points to the wrong service");
Expand Down
Expand Up @@ -95,16 +95,58 @@ class ResourceInformationTestWMS : public wrench::WMS {
std::unique_ptr<wrench::JobManager>(new wrench::JobManager(this->workflow));

// Ask questions about resources

// Get number of Hosts
unsigned long num_hosts;

num_hosts = this->test->compute_service1->getNumHosts();
if (num_hosts != 2) {
throw std::runtime_error("getNumHosts() should return 2 for compute service #1");
}

num_hosts = this->test->compute_service2->getNumHosts();
if (num_hosts != 2) {
throw std::runtime_error("getNumHosts() should return 2 for compute service #2");
}


// Get number of Cores
std::vector<unsigned long> num_cores;

num_cores = this->test->compute_service1->getNumCores();
if ((num_cores.size() != 2) or (num_cores[0] != 4) or (num_cores[1] != 4)) {
throw std::runtime_error("getHostNumCores() should return {4,4} for compute service #1");
throw std::runtime_error("getNumCores() should return {4,4} for compute service #1");
}

num_cores = this->test->compute_service2->getNumCores();
if ((num_cores.size() != 2) or (num_cores[0] != 8) or (num_cores[1] != 8)) {
throw std::runtime_error("getHostNumCores() should return {8,8} for compute service #1");
throw std::runtime_error("getNumCores() should return {8,8} for compute service #1");
}

// Get Ram capacities
std::vector<double> ram_capacities;

ram_capacities = this->test->compute_service1->getMemoryCapacity();
std::sort(ram_capacities.begin(), ram_capacities.end());
if ((ram_capacities.size() != 2) or
(fabs(ram_capacities[0] - 1024) > EPSILON) or
(fabs(ram_capacities[1] - 2048) > EPSILON)) {
throw std::runtime_error("getMemoryCapacity() should return {1024,2048} or {2048,1024} for compute service #1");
}

// Get Core flop rates
std::vector<double> core_flop_rates = this->test->compute_service1->getCoreFlopRate();
std::sort(core_flop_rates.begin(), core_flop_rates.end());
if ((core_flop_rates.size() != 2) or
(fabs(core_flop_rates[0] - 1.0) > EPSILON) or
(fabs(core_flop_rates[1] - 1e+10) > EPSILON)) {
throw std::runtime_error("getCoreFlopRate() should return {1,10} or {10,1} for compute service #1");

}

// Get the TTL
if (this->test->compute_service1->getTTL() < DBL_MAX) {
throw std::runtime_error("getTTL() should return +inf for compute service #1");
}

// Create a job that will use cores on compute service #1
Expand All @@ -118,6 +160,8 @@ class ResourceInformationTestWMS : public wrench::WMS {
job_manager->submitJob(job, this->test->compute_service1);

wrench::Simulation::sleep(1.0);

// Get number of idle cores
std::vector<unsigned long> num_idle_cores = this->test->compute_service1->getNumIdleCores();
std::sort(num_idle_cores.begin(), num_idle_cores.end());
if ((num_idle_cores.size() != 2) or
Expand All @@ -132,28 +176,6 @@ class ResourceInformationTestWMS : public wrench::WMS {
throw std::runtime_error("Unexpected workflow execution event!");
}

std::vector<double> ram_capacities;

ram_capacities = this->test->compute_service1->getMemoryCapacity();
std::sort(ram_capacities.begin(), ram_capacities.end());
if ((ram_capacities.size() != 2) or
(fabs(ram_capacities[0] - 1024) > EPSILON) or
(fabs(ram_capacities[1] - 2048) > EPSILON)) {
throw std::runtime_error("getMemoryCapacity() should return {1024,2048} or {2048,1024} for compute service #1");
}

std::vector<double> core_flop_rates = this->test->compute_service1->getCoreFlopRate();
std::sort(core_flop_rates.begin(), core_flop_rates.end());
if ((core_flop_rates.size() != 2) or
(fabs(core_flop_rates[0] - 1.0) > EPSILON) or
(fabs(core_flop_rates[1] - 1e+10) > EPSILON)) {
throw std::runtime_error("getCoreFlopRate() should return {1,10} or {10,1} for compute service #1");

}

if (this->test->compute_service1->getTTL() < DBL_MAX) {
throw std::runtime_error("getTTL() should return +inf for compute service #1");
}

workflow->removeTask(t1);
workflow->removeTask(t2);
Expand All @@ -172,7 +194,7 @@ TEST_F(MultihostMulticoreComputeServiceTestResourceInformation, ResourceInformat
void MultihostMulticoreComputeServiceTestResourceInformation::do_ResourceInformation_test() {

// Create and initialize a simulation
wrench::Simulation *simulation = new wrench::Simulation();
auto simulation = new wrench::Simulation();
int argc = 1;
char **argv = (char **) calloc(1, sizeof(char *));
argv[0] = strdup("one_task_test");
Expand Down
Expand Up @@ -159,6 +159,17 @@ class MulticoreComputeServiceUnsupportedJobTypeTestWMS : public wrench::WMS {
if (e.getCause()->getCauseType() != wrench::FailureCause::JOB_TYPE_NOT_SUPPORTED) {
throw std::runtime_error("Didn't get the expected exception");
}
wrench::JobTypeNotSupported *real_cause = (wrench::JobTypeNotSupported *)e.getCause().get();
if (real_cause->getJob() != two_task_job) {
throw std::runtime_error(
"Got the expected exception and failure cause, but the failure cause does not point to the right job");
}
if (real_cause->getComputeService() != this->test->compute_service) {
throw std::runtime_error(
"Got the expected exception and failure cause, but the failure cause does not point to the right compute service");
}
std::string error_msg = real_cause->toString();

success = false;
}
if (success) {
Expand Down
Expand Up @@ -747,6 +747,7 @@ class SimpleStorageServiceSynchronousFileCopyFailuresTestWMS : public wrench::WM
}
// Check Exception details
wrench::StorageServiceNotEnoughSpace *real_cause = (wrench::StorageServiceNotEnoughSpace *) e.getCause().get();
std::string error_msg = real_cause->toString();
if (real_cause->getFile() != this->test->file_500) {
throw std::runtime_error(
"Got the expected 'not enough space' exception, but the failure cause does not point to the correct file");
Expand Down
1 change: 1 addition & 0 deletions test/simulation/StandardJobExecutorTest.cpp
Expand Up @@ -735,6 +735,7 @@ class OneSingleCoreTaskMissingFileTestWMS : public wrench::WMS {
}

wrench::FileNotFound *real_cause = (wrench::FileNotFound *) msg->cause.get();
std::string error_msg = real_cause->toString();
if (real_cause->getFile() != workflow->getFileById("input_file")) {
throw std::runtime_error(
"Got the expected 'file not found' exception, but the failure cause does not point to the correct file");
Expand Down

0 comments on commit 3737572

Please sign in to comment.