Skip to content

Commit ccb4794

Browse files
KirillKurdyukovmessieurMe
authored andcommitted
dev: slo topic job (ydb-platform#271)
* Reader client for YDB topics * Fixed: send PartitionIds in InitRequest. * Do a committed offset on StopPartitionSessionRequest event anyway. * Added log info on StopPartitionSessionRequest event. * PartitioningSettings were changed to change the PartitionCountLimit to MaxActivePartitions. * Updated Ydb.Protos 1.0.6 -> 1.1.1.
1 parent 2bf2307 commit ccb4794

File tree

26 files changed

+556
-117
lines changed

26 files changed

+556
-117
lines changed

.github/workflows/slo-topic.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: SLO YDB Topics
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: "45 * * * *"
10+
jobs:
11+
ydb-slo-topic-action:
12+
name: SLO Topic test
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Install .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: 8.0.x
22+
- name: Set up Docker Compose
23+
uses: hoverkraft-tech/[email protected]
24+
with:
25+
compose-file: "./slo/playground/configs/compose.yaml"
26+
- name: Prepare SLO Database
27+
run: |
28+
cd slo/src/TopicService
29+
dotnet run create grpc://localhost:2135 /Root/testdb
30+
- name: Run SLO Tests
31+
run: |
32+
cd slo/src/TopicService
33+
dotnet run run grpc://localhost:2135 /Root/testdb \
34+
--write-rps 50 \
35+
--time 600

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
* Reader client for YDB topics
2+
* Fixed: send PartitionIds in InitRequest.
3+
* Do a committed offset on StopPartitionSessionRequest event anyway.
4+
* Added log info on StopPartitionSessionRequest event.
5+
* PartitioningSettings were changed to change the PartitionCountLimit to MaxActivePartitions.
16
* Dev: updated System.IdentityModel.Tokens.Jwt from version 0.7.0 to version 8.5.0.
27
* PartitionSession.Stop uses committedOffset to complete commit tasks.
38
* Changed batch type: IReadOnlyCollection<Message<TValue>> -> IReadOnlyList<Message<TValue>>.
49
* Invoking TryReadRequestBytes before deserializing message.
5-
* Updated Ydb.Protos 1.0.6 -> 1.1.0: Updated version of the Grpc.Net.Client library to 2.67.0.
10+
* Updated Ydb.Protos 1.0.6 -> 1.1.1: Updated version of the Grpc.Net.Client library to 2.67.0 and proto messages.
611
* Fixed: YdbDataReader.GetDataTypeName for optional values.
712
* Added support for "Columns" collectionName in YdbConnection.GetSchema(Async).
813

slo/playground/configs/chaos.sh

100644100755
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,31 @@ get_random_container() {
2020

2121
sleep 60
2222

23-
get_random_container
24-
25-
sh -c "docker stop ${nodeForChaos} -t 30"
26-
sh -c "docker start ${nodeForChaos}"
27-
28-
sleep 60
29-
30-
get_random_container
31-
32-
sh -c "docker restart ${nodeForChaos} -t 0"
33-
34-
sleep 60
23+
echo "Start CHAOS YDB cluster!"
24+
25+
for i in $(seq 1 5)
26+
do
27+
echo "docker stop/start iteration $i"
28+
29+
get_random_container
30+
31+
sh -c "docker stop ${nodeForChaos} -t 10"
32+
sh -c "docker start ${nodeForChaos}"
33+
34+
sleep 40
35+
done
36+
37+
for i in $(seq 1 5)
38+
do
39+
echo "docker restart iteration $i"
40+
41+
get_random_container
42+
43+
sh -c "docker restart ${nodeForChaos} -t 0"
44+
45+
sleep 40
46+
done
3547

3648
get_random_container
3749

3850
sh -c "docker kill -s SIGKILL ${nodeForChaos}"
39-
40-
sleep 60

slo/playground/configs/compose.yaml

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
# Code generated by Github Action; DO NOT EDIT.
2-
31
x-runtime: &runtime
42
hostname: localhost
53
platform: linux/amd64
64
privileged: true
75
network_mode: host
86

97
x-ydb-node: &ydb-node
10-
image: cr.yandex/crptqonuodf51kdj7a7d/ydb:24.2.7
8+
image: cr.yandex/crptqonuodf51kdj7a7d/ydb:24.3.11.13
119
restart: always
1210
<<: *runtime
1311
volumes:
@@ -270,42 +268,16 @@ services:
270268
tenant-init:
271269
condition: service_completed_successfully
272270

273-
prometheus:
274-
image: prom/prometheus
275-
restart: unless-stopped
271+
chaos:
272+
image: docker:latest
273+
restart: on-failure
274+
container_name: ydb-chaos
276275
<<: *runtime
277-
ports:
278-
- "9090:9090"
276+
entrypoint: ["/bin/sh", "-c", "chmod +x /opt/ydb/chaos.sh && ls -la /opt/ydb && /opt/ydb/chaos.sh"]
279277
volumes:
280-
- ./prometheus.yml:/etc/prometheus/prometheus.yml
281-
deploy: &monitoring-deploy
282-
resources:
283-
limits:
284-
cpus: "0.1"
285-
memory: 1000M
286-
reservations:
287-
cpus: "0.001"
288-
memory: 50M
289-
290-
prometheus-pushgateway:
291-
image: prom/pushgateway
292-
restart: unless-stopped
293-
<<: *runtime
294-
ports:
295-
- "9091:9091"
296-
deploy:
297-
<<: *monitoring-deploy
298-
299-
# chaos:
300-
# image: docker:latest
301-
# restart: on-failure
302-
# container_name: ydb-chaos
303-
# <<: *runtime
304-
# entrypoint: ["/bin/sh", "-c", "ls -la /opt/ydb && /opt/ydb/chaos.sh"]
305-
# volumes:
306-
# - ./chaos.sh:/opt/ydb/chaos.sh
307-
# - ./ydb.yaml:/opt/ydb/cfg/config.yaml
308-
# - /var/run/docker.sock:/var/run/docker.sock
309-
# depends_on:
310-
# static-0:
311-
# condition: service_healthy
278+
- ./chaos.sh:/opt/ydb/chaos.sh
279+
- ./ydb.yaml:/opt/ydb/cfg/config.yaml
280+
- /var/run/docker.sock:/var/run/docker.sock
281+
depends_on:
282+
static-0:
283+
condition: service_healthy

slo/playground/configs/prometheus.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

slo/playground/configs/ydb.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
pqconfig:
2+
require_credentials_in_new_protocol: false
3+
14
actor_system_config:
25
cpu_count: 1
36
node_type: STORAGE
@@ -40,7 +43,7 @@ domains_config:
4043
vdisk_kind: Default
4144
state_storage:
4245
- ring:
43-
node: [1]
46+
node: [ 1 ]
4447
nto_select: 1
4548
ssid: 1
4649
host_configs:

slo/src/AdoNet/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
using AdoNet;
44
using Internal;
55

6-
await Cli.Run(new SloContext(), args);
6+
await Cli.Run(new SloTableContext(), args);

slo/src/AdoNet/SloContext.cs renamed to slo/src/AdoNet/SloTableContext.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace AdoNet;
1010

11-
public class SloContext : SloContext<YdbDataSource>
11+
public class SloTableContext : SloTableContext<YdbDataSource>
1212
{
1313
private readonly AsyncPolicy _policy = Policy.Handle<YdbException>(exception => exception.IsTransient)
1414
.WaitAndRetryAsync(10, attempt => TimeSpan.FromMilliseconds(attempt * 10),
@@ -103,6 +103,9 @@ protected override Task<YdbDataSource> CreateClient(Config config)
103103
var port = splitEndpoint[1].Split(":")[1];
104104

105105
return Task.FromResult(new YdbDataSource(new YdbConnectionStringBuilder
106-
{ UseTls = useTls, Host = host, Port = int.Parse(port), Database = config.Db, LoggerFactory = Factory }));
106+
{
107+
UseTls = useTls, Host = host, Port = int.Parse(port), Database = config.Db,
108+
LoggerFactory = ISloContext.Factory
109+
}));
107110
}
108111
}

slo/src/Internal/Cli.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static class Cli
1414

1515
private static readonly Option<string> PromPgwOption = new(
1616
"--prom-pgw",
17-
"prometheus push gateway") { IsRequired = true };
17+
"prometheus push gateway");
1818

1919
private static readonly Option<string> ResourceYdbPath = new(
2020
new[] { "-t", "--resource-ydb-path" },
@@ -23,7 +23,7 @@ public static class Cli
2323

2424
private static readonly Option<int> WriteTimeoutOption = new(
2525
"--write-timeout",
26-
() => 1000,
26+
() => 100,
2727
"write timeout seconds");
2828

2929
private static readonly Option<int> ReportPeriodOption = new(
@@ -101,7 +101,7 @@ public static class Cli
101101
CreateCommand, RunCommand
102102
};
103103

104-
public static async Task<int> Run<T>(SloContext<T> sloContext, string[] args) where T : IDisposable
104+
public static async Task<int> Run(ISloContext sloContext, string[] args)
105105
{
106106
CreateCommand.SetHandler(async createConfig => { await sloContext.Create(createConfig); },
107107
new CreateConfigBinder(EndpointArgument, DbArgument, ResourceYdbPath, MinPartitionsCountOption,

slo/src/Internal/SloContext.cs renamed to slo/src/Internal/SloTableContext.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@
77

88
namespace Internal;
99

10-
public abstract class SloContext<T> where T : IDisposable
10+
public interface ISloContext
1111
{
1212
// ReSharper disable once StaticMemberInGenericType
13-
protected static readonly ILoggerFactory Factory =
13+
public static readonly ILoggerFactory Factory =
1414
LoggerFactory.Create(builder =>
1515
{
1616
builder.AddConsole().SetMinimumLevel(LogLevel.Information);
1717
builder.AddFilter("Ydb.Sdk.Ado", LogLevel.Debug);
1818
builder.AddFilter("Ydb.Sdk.Services.Query", LogLevel.Debug);
19-
builder.AddFilter("Ydb.Sdk.Services.Topic", LogLevel.Debug);
2019
});
2120

22-
protected static readonly ILogger Logger = Factory.CreateLogger<SloContext<T>>();
21+
22+
public Task Create(CreateConfig config);
23+
24+
public Task Run(RunConfig runConfig);
25+
}
26+
27+
public abstract class SloTableContext<T> : ISloContext where T : IDisposable
28+
{
29+
protected static readonly ILogger Logger = ISloContext.Factory.CreateLogger<SloTableContext<T>>();
2330

2431
private volatile int _maxId;
2532

0 commit comments

Comments
 (0)