Skip to content

Commit

Permalink
test fix (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 2, 2019
1 parent 531b6eb commit 3793d50
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 59 deletions.
22 changes: 0 additions & 22 deletions include/wrench/workflow/execution_events/FailureCause.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,6 @@ namespace wrench {
};


/**
* @brief A "file cannot be found anywhere" failure cause
*/
class NoStorageServiceForFile : public FailureCause {

public:
/***********************/
/** \cond INTERNAL */
/***********************/
NoStorageServiceForFile(WorkflowFile *file);
/***********************/
/** \endcond */
/***********************/

WorkflowFile *getFile();
std::string toString();

private:
WorkflowFile *file;
};


/**
* @brief A "no scratch space" failure cause
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ namespace wrench {
if (work->file_locations.find(f) != work->file_locations.end()) {
files_to_read[f] = work->file_locations[f];
} else {
if (this->scratch_space == nullptr) {
WRENCH_INFO("DUCK!!");
if (this->scratch_space == nullptr) { // File should be in scratch, but there is no scratch
throw WorkflowExecutionException(
std::make_shared<FileNotFound>(f, FileLocation::SCRATCH));
}
files_to_read[f] = FileLocation::LOCATION(this->scratch_space, job->getName());
this->files_stored_in_scratch.insert(f);
Expand Down
25 changes: 1 addition & 24 deletions src/wrench/workflow/execution_events/FailureCause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ WRENCH_LOG_NEW_DEFAULT_CATEGORY(falure_cause, "Log category for FailureCause");

namespace wrench {

/**
* @brief Constructor
* @param file: the file that could not be found on any storage service
*/
NoStorageServiceForFile::NoStorageServiceForFile(WorkflowFile *file) {
this->file = file;
}

/**
* @brief Constructor
Expand All @@ -42,24 +35,8 @@ namespace wrench {
* @return the message
*/
std::string NoScratchSpace::toString() {
return error;
}

/**
* @brief Getter
* @return the file
*/
WorkflowFile *NoStorageServiceForFile::getFile() {
return this->file;
}
return error;}

/**
* @brief Get the human-readable failure message
* @return the message
*/
std::string NoStorageServiceForFile::toString() {
return "No Storage Service location is specified for file " + this->file->getID();
}

/**
* @brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,10 +1266,12 @@ class ExecutionWithPrePostCopiesNoTaskNoCleanupTestWMS : public wrench::WMS {
}

// Test file locations
if (!this->test->storage_service2->lookupFile(this->test->input_file, nullptr)) {
if (not wrench::StorageService::lookupFile(this->test->input_file,
wrench::FileLocation::LOCATION(this->test->storage_service2))) {
throw std::runtime_error("Input file should be on Storage Service #2");
}
if (!this->test->storage_service3->lookupFile(this->test->input_file, nullptr)) {
if (not wrench::StorageService::lookupFile(this->test->input_file,
wrench::FileLocation::LOCATION(this->test->storage_service3))) {
throw std::runtime_error("Input file should be on Storage Service #3");
}

Expand Down Expand Up @@ -1392,7 +1394,8 @@ class ExecutionWithPreNoPostCopiesNoTaskCleanupTestWMS : public wrench::WMS {
}

// Test file locations
if (this->test->storage_service2->lookupFile(this->test->input_file, nullptr)) {
if (wrench::StorageService::lookupFile(this->test->input_file,
wrench::FileLocation::LOCATION(this->test->storage_service2))) {
throw std::runtime_error("Input file should not be on Storage Service #2");
}

Expand Down Expand Up @@ -1489,11 +1492,11 @@ class ExecutionWithMissingFileTestWMS : public wrench::WMS {
// Create a job manager
auto job_manager = this->createJobManager();

// Remove the staged file!
wrench::StorageService::deleteFile(test->input_file,
wrench::FileLocation::LOCATION(test->storage_service1));
// // Remove the staged file!
// wrench::StorageService::deleteFile(test->input_file,
// wrench::FileLocation::LOCATION(test->storage_service1));

// Create a job
// Create a job (that doesn't say where the file should come from!)
wrench::StandardJob *job = job_manager->createStandardJob({test->task},
{},
{},
Expand All @@ -1506,11 +1509,11 @@ class ExecutionWithMissingFileTestWMS : public wrench::WMS {
std::shared_ptr<wrench::WorkflowExecutionEvent> event = this->getWorkflow()->waitForNextExecutionEvent();
auto real_event = std::dynamic_pointer_cast<wrench::StandardJobFailedEvent>(event);
if (real_event) {
auto cause = std::dynamic_pointer_cast<wrench::NoStorageServiceForFile>(real_event->failure_cause);
auto cause = std::dynamic_pointer_cast<wrench::FileNotFound>(real_event->failure_cause);
if (not cause) {
throw std::runtime_error(
"Got an Standard Job Failure as expected, but unexpected failure cause: " +
real_event->failure_cause->toString() + " (expected: NoStorageServiceForFile");
real_event->failure_cause->toString() + " (expected: FileNotFound");
}
std::string error_msg = cause->toString();
if (cause->getFile() != test->input_file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,10 @@ class BareMetalComputeServiceShutdownStorageServiceBeforeJobIsSubmittedTestWMS :
}
auto real_event = std::dynamic_pointer_cast<wrench::StandardJobFailedEvent>(event);
if (real_event) {
auto cause = std::dynamic_pointer_cast<wrench::NoStorageServiceForFile>(real_event->failure_cause);
auto cause = std::dynamic_pointer_cast<wrench::FileNotFound>(real_event->failure_cause);
if (not cause) {
throw std::runtime_error("Got the expected job failure but unexpected failure cause: " +
real_event->failure_cause->toString() + " (expected: NoStorageServiceForFile)");
real_event->failure_cause->toString() + " (expected: FileNotFound)");
}
if (cause->getFile() != this->test->input_file) {
throw std::runtime_error(
Expand Down

0 comments on commit 3793d50

Please sign in to comment.