Skip to content

Commit 8168a31

Browse files
fix linter
1 parent ad25e3a commit 8168a31

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

src/Ydb.Sdk/test/Ydb.Sdk.Ado.Stress.Loader/Cli.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class Cli
99
"connectionString",
1010
"YDB connection string ADO NET format"
1111
);
12-
12+
1313
private static readonly Option<int> PeakRps = new("--peak-rps", () => 1000,
1414
"Peak RPS load (top of the step)");
1515

@@ -19,16 +19,16 @@ public static class Cli
1919
private static readonly Option<int> MinRps = new("--min-rps", () => 1,
2020
"Minimum RPS load (bottom of the step, 1-2 RPS)");
2121

22-
private static readonly Option<int> PeakDurationSeconds = new("--peak-duration", () => 60,
22+
private static readonly Option<int> PeakDurationSeconds = new("--peak-duration", () => 600,
2323
"Duration of peak load in seconds");
2424

25-
private static readonly Option<int> MediumDurationSeconds = new("--medium-duration", () => 30,
25+
private static readonly Option<int> MediumDurationSeconds = new("--medium-duration", () => 1800,
2626
"Duration of medium load in seconds");
2727

28-
private static readonly Option<int> MinDurationSeconds = new("--min-duration", () => 30,
28+
private static readonly Option<int> MinDurationSeconds = new("--min-duration", () => 1800,
2929
"Duration of minimum load in seconds");
3030

31-
private static readonly Option<int> TotalTestTimeSeconds = new("--total-time", () => 600,
31+
private static readonly Option<int> TotalTestTimeSeconds = new("--total-time", () => 14400,
3232
"Total test duration in seconds");
3333

3434
private static readonly Option<string?> SaFilePath = new("--sa-file-path",

src/Ydb.Sdk/test/Ydb.Sdk.Ado.Stress.Loader/StressTestTank.cs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public StressTestTank(StressTestConfig config)
1818
_logger = loggerFactory.CreateLogger<StressTestTank>();
1919
_settings = new YdbConnectionStringBuilder(config.ConnectionString)
2020
{
21-
LoggerFactory = loggerFactory,
2221
CredentialsProvider =
2322
config.SaFilePath != null ? new ServiceAccountProvider(config.SaFilePath, loggerFactory) : null
2423
};
@@ -67,22 +66,19 @@ Starting YDB ADO.NET Stress Test Tank
6766
private async Task RunLoadPatternAsync(LoadPattern loadPattern, CancellationToken cancellationToken)
6867
{
6968
var currentRpsSource = new CancellationTokenSource();
70-
var workerTasks = new List<Task>();
71-
72-
// Start background task to update RPS based on load pattern
7369
var rpsControllerTask = Task.Run(async () =>
7470
{
71+
// ReSharper disable once PossiblyMistakenUseOfCancellationToken
7572
await foreach (var targetRps in loadPattern.GetLoadStepsAsync(cancellationToken))
7673
{
7774
await currentRpsSource.CancelAsync();
78-
await Task.WhenAll(workerTasks);
79-
workerTasks.Clear();
8075

8176
currentRpsSource = new CancellationTokenSource();
8277
var combinedToken = CancellationTokenSource
8378
.CreateLinkedTokenSource(cancellationToken, currentRpsSource.Token).Token;
84-
await StartWorkersForRpsAsync(targetRps, workerTasks, combinedToken);
79+
_ = StartWorkersForRpsAsync(targetRps, combinedToken);
8580
}
81+
// ReSharper disable once PossiblyMistakenUseOfCancellationToken
8682
}, cancellationToken);
8783

8884
try
@@ -92,12 +88,10 @@ private async Task RunLoadPatternAsync(LoadPattern loadPattern, CancellationToke
9288
finally
9389
{
9490
await currentRpsSource.CancelAsync();
95-
await Task.WhenAll(workerTasks);
9691
}
9792
}
9893

99-
private async Task StartWorkersForRpsAsync(int targetRps, List<Task> workerTasks,
100-
CancellationToken cancellationToken)
94+
private async Task StartWorkersForRpsAsync(int targetRps, CancellationToken cancellationToken)
10195
{
10296
if (targetRps <= 0) return;
10397

@@ -120,22 +114,25 @@ private async Task StartWorkersForRpsAsync(int targetRps, List<Task> workerTasks
120114
continue;
121115
}
122116

123-
workerTasks.Add(
124-
Task.Run(async () =>
117+
_ = Task.Run(async () =>
118+
{
119+
try
125120
{
126-
try
127-
{
128-
await using var ydbConnection = new YdbConnection(_settings);
129-
await ydbConnection.OpenAsync(cancellationToken);
130-
await new YdbCommand(ydbConnection) { CommandText = _config.TestQuery }
131-
.ExecuteNonQueryAsync(cancellationToken);
132-
}
133-
catch (Exception e)
121+
await using var ydbConnection = new YdbConnection(_settings);
122+
await ydbConnection.OpenAsync(cancellationToken);
123+
await new YdbCommand(ydbConnection) { CommandText = _config.TestQuery }
124+
.ExecuteNonQueryAsync(cancellationToken);
125+
}
126+
catch (YdbException e)
127+
{
128+
if (e.Code == StatusCode.ClientTransportTimeout)
134129
{
135-
_logger.LogError(e, "Fail operation");
130+
return;
136131
}
137-
}, cancellationToken)
138-
);
132+
133+
_logger.LogError(e, "Fail operation");
134+
}
135+
}, cancellationToken);
139136
}
140137
}
141138

0 commit comments

Comments
 (0)