Skip to content

Commit

Permalink
updates to the CLI experience (microsoft#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeligia authored Mar 26, 2022
1 parent 9f92cdf commit da6b68e
Show file tree
Hide file tree
Showing 130 changed files with 3,161 additions and 7,819 deletions.
4 changes: 2 additions & 2 deletions Coyote.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{458F6344-4ADE-475F-8A31-4DF3D01CF364}"
ProjectSection(SolutionItems) = preProject
Expand Down
4 changes: 2 additions & 2 deletions Samples/CloudMessaging/CloudMessaging.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raft", "Raft\Raft.csproj", "{64EA33E6-A1C1-4E8B-9CE0-E581E344EE49}"
EndProject
Expand Down
33 changes: 1 addition & 32 deletions Samples/CloudMessaging/Raft.Azure/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Management;
using Microsoft.Coyote.Actors;
using Microsoft.Coyote.Actors.Coverage;

namespace Microsoft.Coyote.Samples.CloudMessaging
{
Expand All @@ -22,7 +19,7 @@ namespace Microsoft.Coyote.Samples.CloudMessaging
/// in separate processes.
/// The presence of the --server-id and --client-process-id arguments makes
/// a server instance. The Client instance starts the number of servers specified
/// in the --num-servers argumenet.
/// in the --num-servers argument.
/// </summary>
public class Program
{
Expand All @@ -36,7 +33,6 @@ public class Program
private int ServerId = -1;
private int ClientProcessId = -1;
private readonly bool Debug = false;
private bool GraphIt = false;
private TaskCompletionSource<ClientResponseEvent> completed;

internal static void PrintUsage()
Expand All @@ -50,7 +46,6 @@ internal static void PrintUsage()
Console.WriteLine(" --connection-string your Azure Service Bus connection string");
Console.WriteLine(" --topic-name optional string for Service Bus Topic (default 'rafttopic')");
Console.WriteLine(" --num-servers number of servers to spawn");
Console.WriteLine(" --graph produce DGML graphs of the activity");
}

private bool ParseCommandLine(string[] args)
Expand Down Expand Up @@ -104,10 +99,6 @@ private bool ParseCommandLine(string[] args)
Task.Delay(10000).Wait();
break;

case "--graph":
this.GraphIt = true;
break;

case "--?":
case "--help":
case "-?":
Expand Down Expand Up @@ -183,13 +174,6 @@ await managementClient.CreateSubscriptionAsync(

IActorRuntime runtime = RuntimeFactory.Create(Configuration.Create().WithVerbosityEnabled());

if (this.GraphIt)
{
var graphBuilder = new ActorRuntimeLogGraphBuilder(false);
runtime.RegisterLog(graphBuilder);
_ = Task.Run(() => { PeriodicSaves(graphBuilder, subscriptionName); });
}

// We create a new Coyote actor runtime instance, and pass an optional configuration
// that increases the verbosity level to see the Coyote runtime log.
runtime.OnFailure += RuntimeOnFailure;
Expand All @@ -213,21 +197,6 @@ await managementClient.CreateSubscriptionAsync(
}
}

private static async void PeriodicSaves(ActorRuntimeLogGraphBuilder log, string baseName)
{
while (true)
{
await Task.Delay(10000);
Graph graph = log.SnapshotGraph(false);
string filename = baseName + ".dgml";
using (var stream = new StreamWriter(filename, false, Encoding.UTF8))
{
Console.WriteLine("############ saved " + filename + " ##########################################");
graph.WriteDgml(stream, true);
}
}
}

private async Task RunClient(IActorRuntime runtime, ActorId clusterManager, string subscriptionName)
{
CancellationTokenSource cancelSource = new CancellationTokenSource();
Expand Down
22 changes: 14 additions & 8 deletions Scripts/NuGet/Coyote.Test.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@
<dependencies>
<group targetFramework=".NET6.0">
<dependency id="Microsoft.Coyote" version="$version$"/>
<dependency id="Microsoft.ApplicationInsights.WindowsServer" version="2.14.0"/>
<dependency id="System.Configuration.ConfigurationManager" version="4.7.0"/>
<dependency id="Microsoft.ApplicationInsights" version="2.20.0"/>
<dependency id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0"/>
<dependency id="Mono.Cecil" version="0.11.4"/>
</group>
<group targetFramework=".NET5.0">
<dependency id="Microsoft.Coyote" version="$version$"/>
<dependency id="Microsoft.ApplicationInsights.WindowsServer" version="2.14.0"/>
<dependency id="System.Configuration.ConfigurationManager" version="4.7.0"/>
<dependency id="Microsoft.ApplicationInsights" version="2.20.0"/>
<dependency id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0"/>
<dependency id="Mono.Cecil" version="0.11.4"/>
</group>
<group targetFramework=".NETCoreApp3.1">
<dependency id="Microsoft.Coyote" version="$version$"/>
<dependency id="Microsoft.ApplicationInsights.WindowsServer" version="2.14.0"/>
<dependency id="System.Configuration.ConfigurationManager" version="4.7.0"/>
<dependency id="Microsoft.ApplicationInsights" version="2.20.0"/>
<dependency id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0"/>
<dependency id="Mono.Cecil" version="0.11.4"/>
<dependency id="System.Text.Json" version="6.0.0"/>
</group>
<group targetFramework=".NETFramework4.6.2">
<dependency id="Microsoft.Coyote" version="$version$"/>
<dependency id="Microsoft.ApplicationInsights.WindowsServer" version="2.14.0"/>
<dependency id="System.Configuration.ConfigurationManager" version="4.7.0"/>
<dependency id="Microsoft.ApplicationInsights" version="2.20.0"/>
<dependency id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0"/>
<dependency id="Mono.Cecil" version="0.11.4"/>
<dependency id="System.Text.Json" version="6.0.0"/>
</group>
</dependencies>
</metadata>
Expand Down
21 changes: 16 additions & 5 deletions Scripts/NuGet/Coyote.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@
<readme>docs\readme.md</readme>
<tags>asynchrony reliability tasks actors state-machines specifications testing</tags>
<dependencies>
<group targetFramework=".NET6.0" />
<group targetFramework=".NET5.0" />
<group targetFramework=".NETCoreApp3.1" />
<group targetFramework=".NETStandard2.0" />
<group targetFramework=".NETFramework4.6.2" />
<group targetFramework=".NET6.0">
<dependency id="System.Threading.Tasks.Extensions" version="4.5.4"/>
</group>
<group targetFramework=".NET5.0">
<dependency id="System.Threading.Tasks.Extensions" version="4.5.4"/>
</group>
<group targetFramework=".NETCoreApp3.1">
<dependency id="System.Threading.Tasks.Extensions" version="4.5.4"/>
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="System.Threading.Tasks.Extensions" version="4.5.4"/>
</group>
<group targetFramework=".NETFramework4.6.2">
<dependency id="System.Threading.Tasks.Extensions" version="4.5.4"/>
<dependency id="System.ValueTuple" version="4.5.0"/>
</group>
</dependencies>
</metadata>
<files>
Expand Down
2 changes: 1 addition & 1 deletion Scripts/test-cli-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else {

$help = (& "$PSScriptRoot/../temp/coyote" -?) -join '\n'

if (!$help.Contains("usage: Coyote command path")) {
if (!$help.Contains("coyote [command] [options]")) {
Write-Error "### Unexpected output from coyote command"
Write-Error $help
Exit 1
Expand Down
21 changes: 19 additions & 2 deletions Source/Core/Actors/ActorExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,11 @@ internal CoverageInfo BuildCoverageInfo()
var result = this.CoverageInfo;
if (result != null)
{
var builder = this.LogWriter.GetLogsOfType<ActorRuntimeLogGraphBuilder>().FirstOrDefault();
var builder = this.LogWriter.GetLogsOfType<ActorRuntimeLogGraphBuilder>()
.FirstOrDefault(builder => builder.CollapseInstances);
if (builder != null)
{
result.CoverageGraph = builder.SnapshotGraph(this.Configuration.IsDgmlBugGraph);
result.CoverageGraph = builder.SnapshotGraph(false);
}

var eventCoverage = this.LogWriter.GetLogsOfType<ActorRuntimeLogEventCoverage>().FirstOrDefault();
Expand All @@ -756,6 +757,22 @@ internal CoverageInfo BuildCoverageInfo()
return result;
}

/// <summary>
/// Returns the DGML graph of the current execution, if there is any.
/// </summary>
internal Graph GetExecutionGraph()
{
Graph result = null;
var builder = this.LogWriter.GetLogsOfType<ActorRuntimeLogGraphBuilder>()
.FirstOrDefault(builder => !builder.CollapseInstances);
if (builder != null)
{
result = builder.SnapshotGraph(true);
}

return result;
}

/// <summary>
/// Returns the program counter of the specified actor.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Actors/ActorId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Licensed under the MIT License.

using System;
#if !DEBUG
using System.Diagnostics;
#endif
using System.Globalization;
using System.Runtime.Serialization;

Expand Down
Loading

0 comments on commit da6b68e

Please sign in to comment.