Skip to content

Commit 0bb5ef2

Browse files
committed
lint, update action yml
1 parent 361353e commit 0bb5ef2

File tree

8 files changed

+105
-62
lines changed

8 files changed

+105
-62
lines changed

.github/workflows/slo.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,44 @@ jobs:
4545
name: database-sql-table
4646
path: ./database/sql/table
4747
label: database/sql/table
48+
run_extra_args: ''
49+
create_extra_args: ''
4850
- id: database_sql_query
4951
name: database-sql-query
5052
path: ./database/sql/query
5153
label: database/sql/query
54+
run_extra_args: ''
55+
create_extra_args: ''
5256
- id: native_query
5357
name: native-query
5458
path: ./native/query
5559
label: native/query
60+
run_extra_args: ''
61+
create_extra_args: ''
5662
- id: native_table
5763
name: native-table
5864
path: ./native/table
5965
label: native/table
66+
run_extra_args: ''
67+
create_extra_args: ''
6068
- id: native_table_over_query_service
6169
name: native-table-over-query-service
6270
path: ./native/table/over/query/service
6371
label: native/table/over/query/service
72+
run_extra_args: ''
73+
create_extra_args: ''
6474
- id: native_bulk_upsert
6575
name: native-bulk-upsert
6676
path: ./native/bulk-upsert
6777
label: native/bulk-upsert
78+
run_extra_args: '-batch-size=10'
79+
create_extra_args: ''
80+
- id: native_node_hints
81+
name: native-node-hints
82+
path: ./native/node_hints
83+
label: native/node_hints
84+
run_extra_args: '-prometheus-endpoint http://172.28.0.2:9090 -batch-size=10'
85+
create_extra_args: '-min-partitions-count 10'
6886

6987
concurrency:
7088
group: slo-${{ github.ref }}-${{ matrix.sdk.name }}
@@ -180,35 +198,33 @@ jobs:
180198
fi
181199
182200
- name: Initialize YDB SLO
183-
uses: ydb-platform/ydb-slo-action/init@main
201+
uses: ydb-platform/ydb-slo-action/init@21473ae781c9bc8f16b42dedc79489c1867c6e50
184202
with:
185203
github_issue: ${{ github.event.inputs.github_issue }}
186204
github_token: ${{ secrets.GITHUB_TOKEN }}
187205
workload_name: ${{ matrix.sdk.name }}
188206
workload_current_ref: ${{ github.head_ref || github.ref_name }}
189207
workload_baseline_ref: ${{ steps.baseline.outputs.ref }}
208+
disable_compose_profiles: "${{ matrix.sdk.id == 'native_node_hints' && 'chaos' || '' }}"
190209

191210
- name: Prepare SLO Database
192211
run: |
193212
echo "Preparing SLO database..."
213+
CREATE_EXTRA_ARGS="${{ matrix.sdk.create_extra_args }}"
194214
docker run --rm --network ydb_ydb-net \
195215
--add-host "ydb:172.28.0.11" \
196216
--add-host "ydb:172.28.0.12" \
197217
--add-host "ydb:172.28.0.13" \
198218
--add-host "ydb:172.28.0.99" \
199-
ydb-app-current create grpc://ydb:2136 /Root/testdb
219+
ydb-app-current create grpc://ydb:2136 /Root/testdb $CREATE_EXTRA_ARGS
200220
201221
- name: Run SLO Tests (parallel)
202222
timeout-minutes: 15
203223
run: |
204224
DURATION=${{ inputs.slo_workload_duration_seconds || 600 }}
205225
READ_RPS=${{ inputs.slo_workload_read_max_rps || 1000 }}
206226
WRITE_RPS=${{ inputs.slo_workload_write_max_rps || 1000 }}
207-
208-
EXTRA_ARGS=""
209-
if [ "${{ matrix.sdk.id }}" = "native_bulk_upsert" ]; then
210-
EXTRA_ARGS="--batch-size=10"
211-
fi
227+
RUN_EXTRA_ARGS="${{ matrix.sdk.run_extra_args }}"
212228
213229
ARGS="run grpc://ydb:2136 /Root/testdb \
214230
-otlp-endpoint prometheus:9090 \
@@ -218,7 +234,7 @@ jobs:
218234
-write-rps $WRITE_RPS \
219235
-read-timeout 100 \
220236
-write-timeout 100 \
221-
$EXTRA_ARGS"
237+
$RUN_EXTRA_ARGS"
222238
223239
echo "Starting ydb-app-current..."
224240
docker run -d \

tests/slo/internal/generator/generator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ type Generator interface {
1717
Generate() (Row, error)
1818
}
1919

20-
type GeneratorImpl struct {
20+
type Impl struct {
2121
currentID RowID
2222
mu sync.Mutex
2323
}
2424

25-
func New(id RowID) *GeneratorImpl {
26-
return &GeneratorImpl{
25+
func New(id RowID) *Impl {
26+
return &Impl{
2727
currentID: id,
2828
}
2929
}
3030

31-
func (g *GeneratorImpl) Generate() (Row, error) {
31+
func (g *Impl) Generate() (Row, error) {
3232
g.mu.Lock()
3333
id := g.currentID
3434
g.currentID++

tests/slo/internal/generator/seeded.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func (g *SeededGenerator) Generate() (Row, error) {
4646
} else {
4747
row.ID = g.setRange.Left + g.rng.Uint64()%(g.setRange.Right-g.setRange.Left)
4848
}
49+
4950
return row, nil
5051
}
5152

@@ -54,4 +55,4 @@ func (g *SeededGenerator) SetRange(l uint64, r uint64) {
5455
Left: l,
5556
Right: r,
5657
}
57-
}
58+
}

tests/slo/internal/node_hints/node_hints.go

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66
"log"
77
"math/rand"
88
"slices"
9-
"slo/internal/generator"
109
"sync/atomic"
1110
"time"
1211

1312
"github.com/ydb-platform/ydb-go-sdk/v3"
1413
"github.com/ydb-platform/ydb-go-sdk/v3/table"
1514
"github.com/ydb-platform/ydb-go-sdk/v3/table/options"
1615
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
16+
17+
"slo/internal/generator"
1718
)
1819

1920
func describeTable(ctx context.Context, driver *ydb.Driver, tableName string) (desc options.Description, err error) {
@@ -25,10 +26,12 @@ func describeTable(ctx context.Context, driver *ydb.Driver, tableName string) (d
2526
options.WithShardKeyBounds(),
2627
options.WithShardNodesInfo(),
2728
)
29+
2830
return err
2931
},
3032
table.WithIdempotent(),
3133
)
34+
3235
return desc, err
3336
}
3437

@@ -42,9 +45,9 @@ func extractKey(v types.Value, side int) (uint64, error) {
4245
if types.IsNull(v) {
4346
if side == LEFT {
4447
return 0, nil
45-
} else {
46-
return ^uint64(0), nil
4748
}
49+
50+
return ^uint64(0), nil
4851
}
4952
parts, err := types.TupleItems(v)
5053
if err != nil {
@@ -66,7 +69,6 @@ const (
6669

6770
func MakeNodeSelector(ctx context.Context, driver *ydb.Driver, tableName string) (*NodeSelector, error) {
6871
dsc, err := describeTable(ctx, driver, tableName)
69-
7072
if err != nil {
7173
return nil, err
7274
}
@@ -98,60 +100,70 @@ func MakeNodeSelector(ctx context.Context, driver *ydb.Driver, tableName string)
98100
for _, ps := range dsc.Stats.PartitionStats {
99101
s.NodeIDs = append(s.NodeIDs, ps.LeaderNodeID)
100102
}
103+
101104
return &s, nil
102105
}
103106

104-
func (s *NodeSelector) findNodeID(key uint64) uint32 {
105-
idx, found := slices.BinarySearch(s.UpperBounds, key)
107+
func (ns *NodeSelector) findNodeID(key uint64) uint32 {
108+
idx, found := slices.BinarySearch(ns.UpperBounds, key)
106109
if found {
107110
idx++
108111
}
109-
return s.NodeIDs[idx]
112+
113+
return ns.NodeIDs[idx]
110114
}
111115

112-
func (s *NodeSelector) WithNodeHint(ctx context.Context, key uint64) context.Context {
113-
if s == nil || len(s.NodeIDs) == 0 {
116+
func (ns *NodeSelector) WithNodeHint(ctx context.Context, key uint64) context.Context {
117+
if ns == nil || len(ns.NodeIDs) == 0 {
114118
return ctx
115119
}
116-
return ydb.WithPreferredNodeID(ctx, s.findNodeID(key))
120+
121+
return ydb.WithPreferredNodeID(ctx, ns.findNodeID(key))
117122
}
118123

119-
func (s *NodeSelector) GeneratePartitionKey(partitionId uint64) uint64 {
120-
l := s.UpperBounds[partitionId] - s.LowerBounds[partitionId]
121-
return s.LowerBounds[partitionId] + rand.Uint64()%l
124+
func (ns *NodeSelector) GeneratePartitionKey(partitionID uint64) uint64 {
125+
l := ns.UpperBounds[partitionID] - ns.LowerBounds[partitionID]
126+
127+
return ns.LowerBounds[partitionID] + rand.Uint64()%l
122128
}
123129

124-
func RunUpdates(ctx context.Context, driver *ydb.Driver, tableName string, frequency time.Duration) (*atomic.Pointer[NodeSelector], error) {
130+
func RunUpdates(
131+
ctx context.Context,
132+
driver *ydb.Driver,
133+
tableName string,
134+
frequency time.Duration,
135+
) (*atomic.Pointer[NodeSelector], error) {
125136
var ns atomic.Pointer[NodeSelector]
126137
updateSelector := func() error {
127138
selector, err := MakeNodeSelector(ctx, driver, tableName)
128139
if err != nil {
129140
return err
130141
}
131142
ns.Store(selector)
143+
132144
return nil
133145
}
134146

135147
err := updateSelector()
136148
if err != nil {
137149
return nil, err
138-
} else {
139-
ticker := time.NewTicker(frequency)
140-
go func() {
141-
defer ticker.Stop()
142-
for {
143-
select {
144-
case <-ctx.Done():
145-
return
146-
case <-ticker.C:
147-
err = updateSelector()
148-
if err != nil {
149-
log.Printf("node hints update error: %v\n", err)
150-
}
150+
}
151+
ticker := time.NewTicker(frequency)
152+
go func() {
153+
defer ticker.Stop()
154+
for {
155+
select {
156+
case <-ctx.Done():
157+
return
158+
case <-ticker.C:
159+
err = updateSelector()
160+
if err != nil {
161+
log.Printf("node hints update error: %v\n", err)
151162
}
152163
}
153-
}()
154-
}
164+
}
165+
}()
166+
155167
return &ns, nil
156168
}
157169

@@ -167,5 +179,6 @@ func (ns *NodeSelector) GetRandomNodeID(generator generator.Generator) (int, uin
167179
}
168180
}
169181
log.Panicf("GetRandomNodeID: no nodeID found for shift: %d", shift)
182+
170183
return 0, 0
171184
}

tests/slo/internal/workers/read.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (w *Workers) ReadID() uint64 {
4141
if err != nil {
4242
log.Panicf("generate error: %v", err)
4343
}
44+
4445
return row.ID
4546
}
4647

@@ -57,6 +58,7 @@ func (w *Workers) ReadIDs() []uint64 {
5758
ids = append(ids, row.ID)
5859
}
5960
}
61+
6062
return ids
6163
}
6264

0 commit comments

Comments
 (0)