Skip to content

Commit

Permalink
added session metadata and indexes for steps (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlenaKostash authored Oct 3, 2024
1 parent a2f7467 commit ab58779
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion benchmarks/TimescaleBenchmark/TimescaleBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="AutoBogus" Version="2.13.1" />
<PackageReference Include="NBomber" Version="5.7.0" />
<PackageReference Include="NBomber" Version="5.8.0-beta.4" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="RepoDb.PostgreSql" Version="1.13.1" />
<PackageReference Include="RepoDb.PostgreSql.BulkOperations" Version="1.13.1" />
Expand Down
2 changes: 1 addition & 1 deletion examples/Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NBomber" Version="5.7.0" />
<PackageReference Include="NBomber" Version="5.8.0-beta.4" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ public static class ColumnNames
public const string ScenarioTimestamp = "scenario_timestamp";

Check warning on line 6 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.ScenarioTimestamp'
public const string SessionId = "session_id";

Check warning on line 7 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.SessionId'
public const string CurrentOperation = "current_operation";

Check warning on line 8 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.CurrentOperation'
public const string Metadata = "metadata";

Check warning on line 9 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.Metadata'

public const string NodeInfo = "node_info";

Check warning on line 11 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.NodeInfo'
public const string TestSuite = "test_suite";

Check warning on line 12 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.TestSuite'
public const string TestName = "test_name";

Check warning on line 13 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.TestName'

public const string Scenario = "scenario";

Check warning on line 15 in src/NBomber.Sinks.Timescale/Contracts/ColumnNames.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ColumnNames.Scenario'
public const string Step = "step";

public const string SortIndex = "sort_index";


public const string AllReqCount = "all_req_count";
public const string AllDataAll = "all_data_all";

Expand Down
2 changes: 2 additions & 0 deletions src/NBomber.Sinks.Timescale/Contracts/PointDbRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class PointDbRecord

[Column(ColumnNames.Scenario)] public string Scenario { get; set; }
[Column(ColumnNames.Step)] public string Step { get; set; }
[Column(ColumnNames.SortIndex)] public int SortIndex { get; set; }

[Column(ColumnNames.AllReqCount)] public int AllReqCount { get; set; }
[Column(ColumnNames.AllDataAll)] public long AllDataAll { get; set; }
Expand Down Expand Up @@ -71,5 +72,6 @@ public class NodeInfoDbRecord
[Column(ColumnNames.CurrentOperation)] public OperationType CurrentOperation { get; set; }
[Column(ColumnNames.TestSuite)] public string TestSuite { get; set; }
[Column(ColumnNames.TestName)] public string TestName { get; set; }
[Column(ColumnNames.Metadata)] public string Metadata{ get; set; }
[Column(ColumnNames.NodeInfo)] public string NodeInfo { get; set; }
}
2 changes: 1 addition & 1 deletion src/NBomber.Sinks.Timescale/NBomber.Sinks.Timescale.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NBomber.Contracts" Version="5.5.0" />
<PackageReference Include="NBomber.Contracts" Version="5.6.0-beta.10" />
<PackageReference Include="Npgsql" Version="8.0.4" />
<PackageReference Include="RepoDb.PostgreSql" Version="1.13.1" />
<PackageReference Include="RepoDb.PostgreSql.BulkOperations" Version="1.13.1" />
Expand Down
4 changes: 3 additions & 1 deletion src/NBomber.Sinks.Timescale/SqlQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ CREATE TABLE IF NOT EXISTS ""{StepStatsTable}""
""{ColumnNames.CurrentOperation}"" TEXT,
""{ColumnNames.Scenario}"" TEXT,
""{ColumnNames.Step}"" TEXT,
""{ColumnNames.Step}"" TEXT,
""{ColumnNames.SortIndex}"" INT,
""{ColumnNames.AllReqCount}"" INT,
""{ColumnNames.AllDataAll}"" BIGINT,
Expand Down Expand Up @@ -79,6 +80,7 @@ CREATE TABLE IF NOT EXISTS ""{SessionsTable}""
""{ColumnNames.CurrentOperation}"" TEXT,
""{ColumnNames.TestSuite}"" TEXT,
""{ColumnNames.TestName}"" TEXT,
""{ColumnNames.Metadata}"" JSONB,
""{ColumnNames.NodeInfo}"" JSONB
);
";
Expand Down
8 changes: 6 additions & 2 deletions src/NBomber.Sinks.Timescale/TimescaleDbSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task Init(IBaseContext context, IConfiguration infraConfig)
await migration.Run();
}

public async Task Start()
public async Task Start(SessionStartInfo sessionInfo)
{
if (_mainConnection != null)
{
Expand All @@ -82,6 +82,7 @@ public async Task Start()
CurrentOperation = OperationType.Bombing,
TestSuite = testInfo.TestSuite,
TestName = testInfo.TestName,
Metadata = Json.serialize(sessionInfo),
NodeInfo = Json.serialize(nodeInfo)
};

Expand All @@ -91,13 +92,15 @@ public async Task Start()
""{ColumnNames.CurrentOperation}"",
""{ColumnNames.TestSuite}"",
""{ColumnNames.TestName}"",
""{ColumnNames.Metadata}"",
""{ColumnNames.NodeInfo}"")
VALUES
('{record.Time}',
'{record.SessionId}',
'{record.CurrentOperation}',
'{record.TestSuite}',
'{record.TestName}',
'{record.Metadata}'::jsonb,
'{record.NodeInfo}'::jsonb)";
try
{
Expand Down Expand Up @@ -164,7 +167,7 @@ private async Task SaveScenarioStats(ScenarioStats[] stats, bool isFinal = false

private ScenarioStats AddGlobalInfoStep(ScenarioStats scnStats)
{
var globalStepInfo = new StepStats("global information", scnStats.Ok, scnStats.Fail);
var globalStepInfo = new StepStats("global information", scnStats.Ok, scnStats.Fail, 0);
scnStats.StepStats = scnStats.StepStats.Append(globalStepInfo).ToArray();

return scnStats;
Expand Down Expand Up @@ -197,6 +200,7 @@ private PointDbRecord[] MapToPoint(ScenarioStats scnStats, DateTime currentTime)
CurrentOperation = nodeInfo.CurrentOperation,
Scenario = scnStats.ScenarioName,
Step = step.StepName,
SortIndex = step.SortIndex,

AllReqCount = step.Ok.Request.Count + step.Fail.Request.Count,
AllDataAll = step.Ok.DataTransfer.AllBytes + step.Fail.DataTransfer.AllBytes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -16,7 +16,7 @@
</PackageReference>
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NBomber" Version="5.7.0" />
<PackageReference Include="NBomber" Version="5.8.0-beta.4" />
<PackageReference Include="RepoDb.PostgreSql" Version="1.13.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down

0 comments on commit ab58779

Please sign in to comment.