-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prevent old simulation runs from piling up [POFSP-915] (#230)
* fix: prevent old simulation runs from piling up * changelog & release
- Loading branch information
Showing
5 changed files
with
85 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Cognite.Simulator.Tests/UtilsTests/SimulationRunUnitTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using CogniteSdk.Alpha; | ||
using Cognite.Simulator.Utils; | ||
using Xunit; | ||
using System; | ||
using Cognite.Extractor.Common; | ||
|
||
namespace Cognite.Simulator.Tests.UtilsTests; | ||
|
||
public class SimulationRunUnitTest { | ||
|
||
[Fact] | ||
public void TestRunReadinessTimeout (){ | ||
{ | ||
var input = new SimulationRunItem(new SimulationRun() { | ||
CreatedTime = DateTime.UtcNow.AddSeconds(-10).ToUnixTimeMilliseconds(), | ||
Status = SimulationRunStatus.ready, | ||
Id = 1, | ||
}); | ||
|
||
var ex = Assert.Throws<ConnectorException>(() => input.ValidateReadinessForExecution(1)); | ||
Assert.Equal("Simulation has timed out because it is older than 1 second(s)", ex.Message); | ||
} | ||
|
||
{ | ||
var input = new SimulationRunItem(new SimulationRun() { | ||
CreatedTime = 0, | ||
Status = SimulationRunStatus.ready, | ||
Id = 1, | ||
}); | ||
|
||
var ex = Assert.Throws<ConnectorException>(() => input.ValidateReadinessForExecution()); | ||
Assert.Equal("Simulation has timed out because it is older than 3600 second(s)", ex.Message); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void TestRunReadinessAlreadyRunning (){ | ||
var input = new SimulationRunItem(new SimulationRun() { | ||
CreatedTime = DateTime.UtcNow.ToUnixTimeMilliseconds(), | ||
Status = SimulationRunStatus.running, | ||
Id = 1, | ||
}); | ||
|
||
var ex = Assert.Throws<ConnectorException>(() => input.ValidateReadinessForExecution()); | ||
Assert.Equal("Simulation entered unrecoverable state and failed", ex.Message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0-beta-010 | ||
1.0.0-beta-011 |