Skip to content

Commit

Permalink
Testing++ (Simulation.cpp)
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Aug 22, 2018
1 parent 653618f commit 6f6595b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/main.cpp
Expand Up @@ -12,7 +12,7 @@

int main(int argc, char **argv) {
// disable log
// xbt_log_control_set("root.thresh:critical");
xbt_log_control_set("root.thresh:critical");

// Example selective log enabling
// xbt_log_control_set("multicore_compute_service.thresh:info");
Expand Down
22 changes: 20 additions & 2 deletions test/simulation/SimpleSimulationTest.cpp
Expand Up @@ -252,6 +252,20 @@ class SimpleSimulationReadyTasksTestWMS : public wrench::WMS {
}
}

// For converage,
unsigned long num_cores = this->simulation->getNumCores();
if (num_cores != 2) {
throw std::runtime_error("Unexpected number of cores!");
}
double flop_rate = this->simulation->getFlopRate();
if (flop_rate != 1.0) {
throw std::runtime_error("Unexpected flop rate");
}
this->simulation->compute(1 / flop_rate);

std::map<std::string, std::vector<std::string>> clusters =
this->simulation->getHostnameListByCluster();

return 0;
}
};
Expand Down Expand Up @@ -286,7 +300,7 @@ void SimpleSimulationTest::do_getReadyTasksTest_test() {
ASSERT_NO_THROW(simulation->instantiatePlatform(platform_file_path));

// Get a hostname
std::string hostname = simulation->getHostnameList()[0];
std::string hostname = "DualCoreHost";

// Create a Storage Service
ASSERT_THROW(storage_service = simulation->add(
Expand All @@ -311,7 +325,7 @@ void SimpleSimulationTest::do_getReadyTasksTest_test() {
ASSERT_EQ(123, storage_service->getMessagePayloadValueAsDouble(wrench::SimpleStorageServiceMessagePayload::FILE_COPY_ANSWER_MESSAGE_PAYLOAD));

// Create a Cloud Service
std::vector<std::string> execution_hosts = {simulation->getHostnameList()[1]};
std::vector<std::string> execution_hosts = {"QuadCoreHost"};
ASSERT_NO_THROW(compute_service = simulation->add(
new wrench::CloudService(hostname, execution_hosts, 100.0,
{ {wrench::MultihostMulticoreComputeServiceProperty::SUPPORTS_PILOT_JOBS, "false"}})));
Expand All @@ -333,13 +347,17 @@ void SimpleSimulationTest::do_getReadyTasksTest_test() {
ASSERT_THROW(simulation->add((wrench::NetworkProximityService *) nullptr), std::invalid_argument);
ASSERT_THROW(simulation->add((wrench::FileRegistryService *) nullptr), std::invalid_argument);

// Try to stage a file without a file registry
ASSERT_THROW(simulation->stageFile(input_file, storage_service), std::runtime_error);

// Create a file registry
ASSERT_NO_THROW(simulation->add(new wrench::FileRegistryService(hostname)));

// Staging the input_file on the storage service
ASSERT_NO_THROW(simulation->stageFile(input_file, storage_service));

// Staging an invalid file on the storage service
ASSERT_THROW(simulation->stageFile(output_file1, storage_service), std::runtime_error);

// Won't work without a workflow!
ASSERT_THROW(simulation->launch(), std::runtime_error);
Expand Down

0 comments on commit 6f6595b

Please sign in to comment.