Replaying schedule file programmatically? #392
Replies: 8 comments
-
Hey @ankushdesai, we will put out a new version soon that will include an API that allows you to do this. It will look like this: // For replaying a bug and single stepping
Configuration configuration = Configuration.Create();
configuration.WithVerbosityEnabled(true);
// update the path to the schedule file.
configuration.WithReplayStrategy("AfterNewUpdate.schedule");
TestingEngine engine = TestingEngine.Create(configuration, (Action<IActorRuntime>)function.start);
engine.Run();
string bug = engine.TestReport.BugReports.FirstOrDefault();
if (bug != null)
{
Console.WriteLine(bug);
} The following API: ITestingEngine engine = TestingEngineFactory.CreateReplayEngine(configuration, (Action<IActorRuntime>)function.start); is replaced by: TestingEngine engine = TestingEngine.Create(configuration, (Action<IActorRuntime>)function.start); That is already available. What is missing is: configuration.WithReplayStrategy("AfterNewUpdate.schedule"); |
Beta Was this translation helpful? Give feedback.
-
Thanks @pdeligia, looking forward to it! |
Beta Was this translation helpful? Give feedback.
-
@ankushdesai v1.0.4 is out, so this should work now, but let me know if it doesn't! |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @pdeligia, will try it out and get back to you. |
Beta Was this translation helpful? Give feedback.
-
I am able to use this feature now, thanks for all the help! |
Beta Was this translation helpful? Give feedback.
-
@pdeligia There seems to be some problem with the usage of the new API.
It throws the following exception when passed any string as input:
Can you please help? |
Beta Was this translation helpful? Give feedback.
-
@ankushdesai actually you need to pass the contents of the file to this API, rather than the file itself :) Sorry if this was confusing! We plan to write some documentation page on how to use the programmatic test API and will clarify there. You could do something like: File.WriteAllText("xx.schedule", reproducableTrace);
configuration.WithReplayStrategy(reproducableTrace); But there is another way, that works if in the same test you already run the non-replay testing engine! You could do something like: // Test to find a bug.
Configuration testConfiguration = Configuration.Create(); // assign more options
TestingEngine testingEngine = TestingEngine.Create(testConfiguration, (Action<IActorRuntime>)function.start);
engine.Run();
string bug = testingEngine.TestReport.BugReports.FirstOrDefault();
if (testingEngine.TestReport.NumOfFoundBugs > 0)
{
Configuration replayConfiguration = Configuration.Create().WithReplayStrategy(testingEngine.ReproducableTrace);
TestingEngine replayEngine = TestingEngine.Create(replayConfiguration, (Action<IActorRuntime>)function.start);
replayEngine.Run();
} Basically, in the next version, we will expose two currently internal APIs (only set during testing, not replay): string TestingEngine.ReadableTrace;
string TestingEngine.ReproducableTrace; The first gives you the contents of the human readable trace (which are normally dump inside the schedule Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
@pdeligia You rock! Thanks for the quick help. The above thing works. |
Beta Was this translation helpful? Give feedback.
-
How do we the following in latest version of Coyote:
coyote replay with -break command doesn't work on all platforms and the above thing is very useful. Can you please re-enable it?
Beta Was this translation helpful? Give feedback.
All reactions