Skip to content

Commit 278fab9

Browse files
authored
Merge pull request #671 from ydb-platform/slo-workload
SLO workload
2 parents a1025fe + 61945a4 commit 278fab9

File tree

25 files changed

+1754
-14
lines changed

25 files changed

+1754
-14
lines changed

.github/scripts/check-work-copy-equals-to-committed.sh

100644100755
File mode changed.

.github/scripts/format-all-go-code.sh

100644100755
File mode changed.

.github/scripts/format-go-code.sh

100644100755
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ FILEPATH="$1"
77
gofmt -s -w "$FILEPATH"
88

99
# https://github.com/rinchsan/gosimports
10-
gosimports -local github.com/ydb-platform/ydb-go-sdk/v3 -w "$FILEPATH"
10+
if [[ "$FILEPATH" == *"tests/slo/"* ]]
11+
then
12+
gosimports -local slo -w "$FILEPATH"
13+
else
14+
gosimports -local github.com/ydb-platform/ydb-go-sdk/v3 -w "$FILEPATH"
15+
fi
16+
1117

1218
# https://github.com/mvdan/gofumpt
1319
gofumpt -w "$FILEPATH"

.github/scripts/is_autogenerated_file.sh

100644100755
File mode changed.

.github/workflows/lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ jobs:
1818
uses: golangci/golangci-lint-action@v3
1919
with:
2020
version: v1.52.0
21+
golangci-slo:
22+
name: golangci-lint-slo
23+
concurrency:
24+
group: lint-golangci-slo-${{ github.ref }}
25+
cancel-in-progress: true
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- name: generate slo golangci-lint config
31+
run: sed 's/github.com\/ydb-platform\/ydb-go-sdk\/v3/slo/g' .golangci.yml > tests/slo/.golangci.yml
32+
33+
- name: golangci-lint
34+
uses: golangci/golangci-lint-action@v3
35+
with:
36+
version: v1.52.0
37+
working-directory: tests/slo
2138
autoformatter:
2239
name: autoformat check
2340
concurrency:

.github/workflows/slo.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ jobs:
1616
workload_path: tests/slo
1717
workload_build_options: -f Dockerfile --build-arg SRC_PATH=native
1818
workload_build_context: ../..
19-
database_sql:
20-
needs: native
21-
if: github.event.pull_request.head.repo.full_name == 'ydb-platform/ydb-go-sdk'
22-
uses: ydb-platform/slo-tests/.github/workflows/slo.yml@main
23-
secrets: inherit
24-
with:
25-
language_id: go-database-sql
26-
language: go/v3/database/sql
27-
workload_path: tests/slo
28-
workload_build_options: -f Dockerfile --build-arg SRC_PATH=database/sql
29-
workload_build_context: ../..
19+
# database_sql:
20+
# needs: native
21+
# if: github.event.pull_request.head.repo.full_name == 'ydb-platform/ydb-go-sdk'
22+
# uses: ydb-platform/slo-tests/.github/workflows/slo.yml@main
23+
# secrets: inherit
24+
# with:
25+
# language_id: go-database-sql
26+
# language: go/v3/database/sql
27+
# workload_path: tests/slo
28+
# workload_build_options: -f Dockerfile --build-arg SRC_PATH=database/sql
29+
# workload_build_context: ../..

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ linters-settings:
6464
gofmt:
6565
# simplify code: gofmt with `-s` option, true by default
6666
simplify: true
67+
gofumpt:
68+
module-path: github.com/ydb-platform/ydb-go-sdk/v3
6769
goimports:
6870
# put imports beginning with prefix after 3rd-party packages;
6971
# it's a comma-separated list of prefixes

tests/slo/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM golang:1.20 as build
22
ARG SRC_PATH
33
COPY . /src
44
WORKDIR /src/tests/slo/${SRC_PATH}
5-
RUN CGO_ENABLED=0 go build -o /build/slo-go-workload ./...
5+
RUN CGO_ENABLED=0 go build -o /build/slo-go-workload .
66

77
FROM scratch
88
COPY --from=build /build /

tests/slo/README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# SLO workload
2+
3+
SLO is the type of test where app based on ydb-sdk is tested against falling YDB cluster nodes, tablets, network
4+
(that is possible situations for distributed DBs with hundreds of nodes)
5+
6+
### Implementations:
7+
8+
There are two implementations:
9+
10+
- `native` - `./native`
11+
- `database/sql` - `./database/sql`
12+
13+
### Usage:
14+
15+
It has 3 commands:
16+
17+
- `create` - creates table in database
18+
- `cleanup` - drops table in database
19+
- `run` - runs workload (read and write to table with sets RPS)
20+
21+
### Run examples with all arguments:
22+
23+
create:
24+
`slo-go-workload create create grpcs://ydb.cool.example.com:2135 /some/folder -t tableName
25+
-min-partitions-count 6 -max-partitions-count 1000 -partition-size 1 -с 1000
26+
-write-timeout 10000`
27+
28+
cleanup:
29+
`slo-go-workload create cleanup grpcs://ydb.cool.example.com:2135 /some/folder -t tableName`
30+
31+
run:
32+
`slo-go-workload create run grpcs://ydb.cool.example.com:2135 /some/folder -t tableName
33+
-prom-pgw http://prometheus-pushgateway:9091 -report-period 250
34+
-read-rps 1000 -read-timeout 10000
35+
-write-rps 100 -write-timeout 10000
36+
-time 600 -shutdown-time 30`
37+
38+
## Arguments for commands:
39+
40+
### create
41+
`slo-go-workload create <endpoint> <db> [options]`
42+
43+
```
44+
Arguments:
45+
endpoint YDB endpoint to connect to
46+
db YDB database to connect to
47+
48+
Options:
49+
-t -table-name <string> table name to create
50+
51+
-min-partitions-count <int> minimum amount of partitions in table
52+
-max-partitions-count <int> maximum amount of partitions in table
53+
-partition-size <int> partition size in mb
54+
55+
-c -initial-data-count <int> amount of initially created rows
56+
57+
-write-timeout <int> write timeout milliseconds
58+
```
59+
60+
### cleanup
61+
`slo-go-workload cleanup <endpoint> <db> [options]`
62+
63+
```
64+
Arguments:
65+
endpoint YDB endpoint to connect to
66+
db YDB database to connect to
67+
68+
Options:
69+
-t -table-name <string> table name to create
70+
71+
-write-timeout <int> write timeout milliseconds
72+
```
73+
74+
### run
75+
`slo-go-workload run <endpoint> <db> [options]`
76+
77+
```
78+
Arguments:
79+
endpoint YDB endpoint to connect to
80+
db YDB database to connect to
81+
82+
Options:
83+
-t -table-name <string> table name to create
84+
85+
-initial-data-count <int> amount of initially created rows
86+
87+
-prom-pgw <string> prometheus push gateway
88+
-report-period <int> prometheus push period in milliseconds
89+
90+
-read-rps <int> read RPS
91+
-read-timeout <int> read timeout milliseconds
92+
93+
-write-rps <int> write RPS
94+
-write-timeout <int> write timeout milliseconds
95+
96+
-time <int> run time in seconds
97+
-shutdown-time <int> graceful shutdown time in seconds
98+
```
99+
100+
## Authentication
101+
102+
Workload using [ydb-go-sdk-auth-environ](https://github.com/ydb-platform/ydb-go-sdk-auth-environ) for authentication.
103+
104+
## What's inside
105+
When running `run` command, the program creates three jobs: `readJob`, `writeJob`, `metricsJob`.
106+
107+
- `readJob` reads rows from the table one by one with random identifiers generated by writeJob
108+
- `writeJob` generates and inserts rows
109+
- `metricsJob` periodically sends metrics to Prometheus
110+
111+
Table have these fields:
112+
- `id Uint64`
113+
- `hash Uint64 Digest::NumericHash(id)`
114+
- `payload_str UTF8`
115+
- `payload_double Double`
116+
- `payload_timestamp Timestamp`
117+
- `payload_hash Uint64`
118+
119+
Primary key: `("hash", "id")`
120+
121+
## Collected metrics
122+
- `oks` - amount of OK requests
123+
- `not_oks` - amount of not OK requests
124+
- `inflight` - amount of requests in flight
125+
- `latency` - summary of latencies in ms
126+
127+
> You must reset metrics to keep them `0` in prometheus and grafana before beginning and after ending of jobs
128+
129+
In `go` it looks like that:
130+
```go
131+
func (m *Metrics) Reset() error {
132+
m.oks.WithLabelValues(JobRead).Set(0)
133+
m.oks.WithLabelValues(JobWrite).Set(0)
134+
135+
m.notOks.WithLabelValues(JobRead).Set(0)
136+
m.notOks.WithLabelValues(JobWrite).Set(0)
137+
138+
m.inflight.WithLabelValues(JobRead).Set(0)
139+
m.inflight.WithLabelValues(JobWrite).Set(0)
140+
141+
m.latencies.Reset()
142+
143+
return m.Push()
144+
}
145+
```
146+
147+
## Look at metrics in grafana
148+
You can get dashboard used in that test [here](https://github.com/ydb-platform/slo-tests/blob/main/k8s/helms/grafana.yaml#L69) - you will need to import json into grafana.

tests/slo/go.mod

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
module slo
22

33
go 1.20
4+
5+
require (
6+
github.com/prometheus/client_golang v1.14.0
7+
github.com/ydb-platform/ydb-go-sdk-auth-environ v0.1.2
8+
github.com/ydb-platform/ydb-go-sdk-zap v0.15.0
9+
github.com/ydb-platform/ydb-go-sdk/v3 v3.43.0
10+
go.uber.org/zap v1.24.0
11+
golang.org/x/sync v0.1.0
12+
golang.org/x/time v0.3.0
13+
)
14+
15+
require (
16+
github.com/beorn7/perks v1.0.1 // indirect
17+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
18+
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
19+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
20+
github.com/golang/protobuf v1.5.3 // indirect
21+
github.com/google/uuid v1.3.0 // indirect
22+
github.com/jonboulle/clockwork v0.4.0 // indirect
23+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
24+
github.com/prometheus/client_model v0.3.0 // indirect
25+
github.com/prometheus/common v0.37.0 // indirect
26+
github.com/prometheus/procfs v0.8.0 // indirect
27+
github.com/yandex-cloud/go-genproto v0.0.0-20230403093326-123923969dc6 // indirect
28+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20221215182650-986f9d10542f // indirect
29+
github.com/ydb-platform/ydb-go-yc v0.10.2 // indirect
30+
github.com/ydb-platform/ydb-go-yc-metadata v0.5.3 // indirect
31+
go.uber.org/atomic v1.10.0 // indirect
32+
go.uber.org/multierr v1.11.0 // indirect
33+
golang.org/x/net v0.9.0 // indirect
34+
golang.org/x/sys v0.7.0 // indirect
35+
golang.org/x/text v0.9.0 // indirect
36+
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd // indirect
37+
google.golang.org/grpc v1.54.0 // indirect
38+
google.golang.org/protobuf v1.30.0 // indirect
39+
)
40+
41+
replace github.com/ydb-platform/ydb-go-sdk/v3 => ../../.

0 commit comments

Comments
 (0)