-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #1672 Errors are not propagated on failed simulation run #1709
Conversation
var simulationRunResults = _simModelBatch.RunSimulation(); | ||
|
||
if (!simulationRunResults.Success) | ||
throw new OSPSuiteException(simulationRunResults.Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsuccessful run must be signaled by exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
var hasResults = simulationHasResults(_simModelSimulation); | ||
|
||
return new SimulationRunResults(success: hasResults, warnings: WarningsFrom(_simModelSimulation), results: getResults(), | ||
error: hasResults ? null : Error.SimulationDidNotProduceResults); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you create a method (something around the lines of...)
createSimulationResults(string errorFromException = null) {
var hasResults = simulationHasResults(_simModelSimulation);
var warnings = WarningsFrom(_simModelSimulation);
var error = errorFromException ?? (hasResults ? null : Error.SimulationDidNotProduceResults)
if(error==null){
return SimulationRunResults(success: true , warnings, results: getResults())
}
//error
return SimulationRunResults(false, warnings, error)
}
and call that in both instances?
var id = _ids.First(); | ||
var simulationBatch = Api.GetSimulationBatchFactory().Create(_simulation, _concurrentRunSimulationBatch.SimulationBatchOptions); | ||
|
||
The.Action(() => simulationBatch.Run(_simulationBatchRunValues.FirstOrDefault(v => v.Id == id))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum I don't get it. The action was called already in RunConcurrently
So i think this test should check that _results has en entry with success=false and an error
That tests here is a test for the _simulationBatch or sthg. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we can have the implementation only once for the returning of the results
Also the tests is not what I would except. I feel you are testing something else (this test is valid but for another sut)
} | ||
|
||
private bool simulationHasResults(Simulation simModelSimulation) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: This is ok to use the short hand syntax (see below)
private bool simulationHasResults(Simulation simModelSimulation) => simModelSimulation.AllValues.Any();
var warnings = WarningsFrom(_simModelSimulation); | ||
var error = errorFromException ?? (hasResults ? null : Error.SimulationDidNotProduceResults); | ||
if (error == null) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI Also. Not required when a single return
if(error ==null)
return xxx
[Observation] | ||
public void should_return_a_result_with_success_set_to_false() | ||
{ | ||
_results.All(x => x.Succeeded).ShouldBeFalse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test that now verifies that this flag is sometimes true? (e.g. can you set the parameter for one run instead as for all). Then one run should be success and the one where it fails should be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do now.
…ot cause the whole batch to fail
No description provided.