From 373757208c6ec51240379aa7e7b5ae3746236457 Mon Sep 17 00:00:00 2001 From: henricasanova Date: Fri, 23 Feb 2018 11:35:22 -1000 Subject: [PATCH] A bit more coverage --- CMakeLists.txt | 2 +- test/simulation/BatchServiceTest.cpp | 1 + ...eComputeServiceResourceInformationTest.cpp | 72 ++++++++++++------- ...ulticoreComputeServiceTestStandardJobs.cpp | 11 +++ .../SimpleStorageServiceFunctionalTest.cpp | 1 + test/simulation/StandardJobExecutorTest.cpp | 1 + .../MessageConstructorTest.cpp | 0 7 files changed, 62 insertions(+), 26 deletions(-) rename test/{constructor_exceptions => simulation_message_constructors}/MessageConstructorTest.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b5065a95f..adfa9b911b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/test/simulation/BatchServiceTest.cpp b/test/simulation/BatchServiceTest.cpp index dc35608b96..b441297ef1 100644 --- a/test/simulation/BatchServiceTest.cpp +++ b/test/simulation/BatchServiceTest.cpp @@ -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"); diff --git a/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceResourceInformationTest.cpp b/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceResourceInformationTest.cpp index e91dc48d01..63d0cbab4e 100644 --- a/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceResourceInformationTest.cpp +++ b/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceResourceInformationTest.cpp @@ -95,16 +95,58 @@ class ResourceInformationTestWMS : public wrench::WMS { std::unique_ptr(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 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 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 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 @@ -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 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 @@ -132,28 +176,6 @@ class ResourceInformationTestWMS : public wrench::WMS { throw std::runtime_error("Unexpected workflow execution event!"); } - std::vector 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 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); @@ -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"); diff --git a/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceTestStandardJobs.cpp b/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceTestStandardJobs.cpp index fb403c78f8..4de02dfa0d 100644 --- a/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceTestStandardJobs.cpp +++ b/test/simulation/MultihostMulticoreComputeService/MultihostMulticoreComputeServiceTestStandardJobs.cpp @@ -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) { diff --git a/test/simulation/SimpleStorageService/SimpleStorageServiceFunctionalTest.cpp b/test/simulation/SimpleStorageService/SimpleStorageServiceFunctionalTest.cpp index d3665cfb67..11acccc6f9 100644 --- a/test/simulation/SimpleStorageService/SimpleStorageServiceFunctionalTest.cpp +++ b/test/simulation/SimpleStorageService/SimpleStorageServiceFunctionalTest.cpp @@ -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"); diff --git a/test/simulation/StandardJobExecutorTest.cpp b/test/simulation/StandardJobExecutorTest.cpp index 5fdda4697a..0440f164ad 100644 --- a/test/simulation/StandardJobExecutorTest.cpp +++ b/test/simulation/StandardJobExecutorTest.cpp @@ -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"); diff --git a/test/constructor_exceptions/MessageConstructorTest.cpp b/test/simulation_message_constructors/MessageConstructorTest.cpp similarity index 100% rename from test/constructor_exceptions/MessageConstructorTest.cpp rename to test/simulation_message_constructors/MessageConstructorTest.cpp