Skip to content

Commit

Permalink
installed NBench v1.2.0 and am trying to execute it via the runner (#18)
Browse files Browse the repository at this point in the history
* installed NBench v1.2.0 and am trying to execute it via the runner

* Added NBench v1.2.1

* Added timeouts to the Azure spec

* added expontential backoff for starting Azure table storage journal
  • Loading branch information
Aaronontheweb authored Jul 11, 2018
1 parent 274cf84 commit 6d0e5bd
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 71 deletions.
50 changes: 19 additions & 31 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,38 +119,26 @@ Target "RunTests" (fun _ ->
)

Target "NBench" <| fun _ ->
let nbenchTestPath = findToolInSubPath "NBench.Runner.exe" (toolsDir @@ "NBench.Runner*")
printfn "Using NBench.Runner: %s" nbenchTestPath

let nbenchTestAssemblies = !! "./src/Akka.Persistence.Azure.Tests.Performance/bin/Release/**/*Tests.Performance.dll" // doesn't support .NET Core at the moment

let runNBench assembly =
let includes = getBuildParam "include"
let excludes = getBuildParam "exclude"
let teamcityStr = (getBuildParam "teamcity")
let enableTeamCity =
match teamcityStr with
| null -> false
| "" -> false
| _ -> bool.Parse teamcityStr

let args = StringBuilder()
|> append assembly
|> append (sprintf "output-directory=\"%s\"" outputPerfTests)
|> append (sprintf "concurrent=\"%b\"" true)
|> append (sprintf "trace=\"%b\"" true)
|> append (sprintf "teamcity=\"%b\"" enableTeamCity)
|> appendIfNotNullOrEmpty includes "include="
|> appendIfNotNullOrEmpty excludes "include="
|> toText

let result = ExecProcess(fun info ->
info.FileName <- nbenchTestPath
info.WorkingDirectory <- (Path.GetDirectoryName (FullName nbenchTestPath))
info.Arguments <- args) (System.TimeSpan.FromMinutes 45.0) (* Reasonably long-running task. *)
if result <> 0 then failwithf "NBench.Runner failed. %s %s" nbenchTestPath args
let projects =
match (isWindows) with
| true -> !! "./src/**/*.Tests.Performance.csproj"
| _ -> !! "./src/**/*.Tests.Performance.csproj" // if you need to filter specs for Linux vs. Windows, do it here


let runSingleProject project =
let arguments =
match (hasTeamCity) with
| true -> (sprintf "nbench --nobuild --teamcity --concurrent true --trace true --output %s" (outputPerfTests))
| false -> (sprintf "nbench --nobuild --concurrent true --trace true --output %s" (outputPerfTests))

let result = ExecProcess(fun info ->
info.FileName <- "dotnet"
info.WorkingDirectory <- (Directory.GetParent project).FullName
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)

ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.DontFailBuild result

nbenchTestAssemblies |> Seq.iter runNBench
projects |> Seq.iter runSingleProject


//--------------------------------------------------------------------------------
Expand Down
15 changes: 0 additions & 15 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Param(
)

$FakeVersion = "4.61.2"
$NBenchVersion = "1.0.4"
$DotNetChannel = "LTS";
$DotNetVersion = "2.0.0";
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v$DotNetVersion/scripts/obtain/dotnet-install.ps1";
Expand Down Expand Up @@ -115,20 +114,6 @@ if (!(Test-Path $FakeExePath)) {
}
}

###########################################################################
# INSTALL NBench Runner
###########################################################################

# Make sure NBench Runner has been installed.
$NBenchDllPath = Join-Path $ToolPath "NBench.Runner/lib/net45/NBench.Runner.exe"
if (!(Test-Path $NBenchDllPath)) {
Write-Host "Installing NBench..."
Invoke-Expression "&`"$NugetPath`" install NBench.Runner -ExcludeVersion -Version $NBenchVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
if ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring NBench.Runner from NuGet."
}
}

###########################################################################
# Docfx
###########################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard1.6</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@


<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="NBench" Version="1.1.0" />
<PackageReference Include="NBench" Version="1.2.1" />
<DotNetCliToolReference Include="dotnet-nbench" Version="1.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class AzureJournalPerfSpecs
public const int PersistentActorCount = 200;
public const int PersistedMessageCount = 20;

public static readonly TimeSpan MaxTimeout = TimeSpan.FromMinutes(6);

public static Config JournalConfig()
{
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_CONNECTION_STR")))
Expand All @@ -44,11 +46,12 @@ public static Config JournalConfig(string connectionString)
TableName = "PerfTestTable" + TableVersionCounter.IncrementAndGet();

return ConfigurationFactory.ParseString(
@"akka.loglevel = DEBUG
@"akka.loglevel = INFO
akka.persistence.max-concurrent-recoveries = 25 # since Azure seems to have some trouble at 50
akka.persistence.journal.azure-table.class = ""Akka.Persistence.Azure.Journal.AzureTableStorageJournal, Akka.Persistence.Azure""
akka.persistence.journal.plugin = ""akka.persistence.journal.azure-table""
akka.persistence.journal.azure-table.connection-string=""" + connectionString + @"""
akka.persistence.journal.azure-table.verbose-logging = on")
akka.persistence.journal.azure-table.verbose-logging = off")
.WithFallback("akka.persistence.journal.azure-table.table-name=" + TableName);
}

Expand Down Expand Up @@ -99,7 +102,7 @@ public void BatchJournalWriteSpec(BenchmarkContext context)
for (int i = 0; i < PersistentActorCount; i++)
{
var task = _persistentActors[i]
.Ask<PersistentBenchmarkMsgs.Finished>(PersistentBenchmarkMsgs.Finish.Instance);
.Ask<PersistentBenchmarkMsgs.Finished>(PersistentBenchmarkMsgs.Finish.Instance, MaxTimeout);

finished[i] = task;
}
Expand Down
8 changes: 1 addition & 7 deletions src/Akka.Persistence.Azure/Akka.Persistence.Azure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@


<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard1.6</TargetFramework>
<Description>Akka.Persistence support for Windows Azure Table storage and Azure blob storage.</Description>
</PropertyGroup>


<ItemGroup>
<None Remove="reference.conf" />
</ItemGroup>


<ItemGroup>
<EmbeddedResource Include="reference.conf" />
</ItemGroup>
Expand Down
45 changes: 33 additions & 12 deletions src/Akka.Persistence.Azure/Journal/AzureTableStorageJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,46 @@ public AzureTableStorageJournal()
_serialization = new SerializationHelper(Context.System);
_storageAccount = CloudStorageAccount.Parse(_settings.ConnectionString);

_tableStorage = new Lazy<CloudTable>(() => InitCloudStorage().Result);
_tableStorage = new Lazy<CloudTable>(() => InitCloudStorage(5).Result);
}

public CloudTable Table => _tableStorage.Value;

private async Task<CloudTable> InitCloudStorage()
private static readonly Dictionary<int, TimeSpan> RetryInterval = new Dictionary<int, TimeSpan>()
{
var tableClient = _storageAccount.CreateCloudTableClient();
var tableRef = tableClient.GetTableReference(_settings.TableName);
var op = new OperationContext();
using (var cts = new CancellationTokenSource(_settings.ConnectTimeout))
{ 5, TimeSpan.FromMilliseconds(100) },
{ 4, TimeSpan.FromMilliseconds(500) },
{ 3, TimeSpan.FromMilliseconds(1000) },
{ 2, TimeSpan.FromMilliseconds(2000) },
{ 1, TimeSpan.FromMilliseconds(4000) },
{ 0, TimeSpan.FromMilliseconds(8000) },
};

private async Task<CloudTable> InitCloudStorage(int remainingTries)
{
try
{
if (await tableRef.CreateIfNotExistsAsync(new TableRequestOptions(), op, cts.Token))
_log.Info("Created Azure Cloud Table", _settings.TableName);
else
_log.Info("Successfully connected to existing table", _settings.TableName);
}
var tableClient = _storageAccount.CreateCloudTableClient();
var tableRef = tableClient.GetTableReference(_settings.TableName);
var op = new OperationContext();
using (var cts = new CancellationTokenSource(_settings.ConnectTimeout))
{
if (await tableRef.CreateIfNotExistsAsync(new TableRequestOptions(), op, cts.Token))
_log.Info("Created Azure Cloud Table", _settings.TableName);
else
_log.Info("Successfully connected to existing table", _settings.TableName);
}

return tableRef;
return tableRef;
}
catch (Exception ex)
{
_log.Error(ex, "[{0}] more tries to initialize table storage remaining...", remainingTries);
if (remainingTries == 0)
throw;
await Task.Delay(RetryInterval[remainingTries]);
return await InitCloudStorage(remainingTries - 1);
}
}

protected override void PreStart()
Expand Down

0 comments on commit 6d0e5bd

Please sign in to comment.