Skip to content

Commit

Permalink
test: update slo tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Polyakov <[email protected]>
  • Loading branch information
polRk committed Dec 9, 2024
1 parent 85f7f71 commit be2fcff
Show file tree
Hide file tree
Showing 14 changed files with 5,618 additions and 191 deletions.
113 changes: 73 additions & 40 deletions .github/workflows/slo.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,91 @@
name: SLO

on:
push:
branches:
- main
pull_request:
branches:
- main
- master
- release-*
workflow_dispatch:
inputs:
github_pull_request_number:
required: true
slo_workload_duration_seconds:
default: '600'
required: false
slo_workload_read_max_rps:
default: '1000'
required: false
slo_workload_write_max_rps:
default: '100'
required: false

jobs:
test-slo:
concurrency:
group: slo-${{ github.ref }}
ydb-slo-action:
if: (!contains(github.event.pull_request.labels.*.name, 'no slo'))

name: Run YDB SLO Tests
runs-on: ubuntu-latest
name: SLO test
permissions:
checks: write
pull-requests: write
contents: read
issues: write

concurrency:
group: slo-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run SLO
uses: ydb-platform/slo-tests@main
continue-on-error: true
- name: Install NodeJS
uses: actions/setup-node@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KUBECONFIG_B64: ${{ secrets.SLO_KUBE_CONFIG }}
AWS_CREDENTIALS_B64: ${{ secrets.SLO_AWS_CREDENTIALS }}
AWS_CONFIG_B64: ${{ secrets.SLO_AWS_CONFIG }}
DOCKER_USERNAME: ${{ secrets.SLO_DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.SLO_DOCKER_PASSWORD }}
DOCKER_REPO: ${{ secrets.SLO_DOCKER_REPO }}
DOCKER_FOLDER: ${{ secrets.SLO_DOCKER_FOLDER }}
s3_endpoint: ${{ secrets.SLO_S3_ENDPOINT }}
s3_images_folder: ${{ vars.SLO_S3_IMAGES_FOLDER }}
grafana_domain: ${{ vars.SLO_GRAFANA_DOMAIN }}
grafana_dashboard: ${{ vars.SLO_GRAFANA_DASHBOARD }}
ydb_version: 'newest'
timeBetweenPhases: 30
shutdownTime: 30

language_id0: 'nodejs'
workload_path0: 'slo-workload'
language0: 'Native ydb-nodejs-sdk general'
workload_build_context0: ..
workload_build_options0: -f Dockerfile --build-arg SRC_PATH=slo-workload --build-arg JOB_NAME=workload-slo

- uses: actions/upload-artifact@v4
if: always()
node-version: 'lts/Hydrogen'
cache: 'npm'

- name: Install dependencies
run: |
npm ci
npm ci --prefix slo-workload
npm run build
- name: Initialize YDB SLO
uses: ydb-platform/ydb-slo-action/init@main
with:
github_pull_request_number: ${{ github.event.inputs.github_pull_request_number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
workload_name: nodejs
ydb_database_node_count: 5

- name: Prepare SLO Database
run: |
npm start --prefix slo-workload -- create grpc://localhost:2135 /Root/testdb
- name: Run SLO Tests
env:
REF: '${{ github.head_ref || github.ref }}'
run: |
npm start --prefix slo-workload -- run grpc://localhost:2135 /Root/testdb \
--prom-pgw http://localhost:9091 \
--report-period 250 \
--time ${{inputs.slo_workload_duration_seconds || 600}} \
--read-rps ${{inputs.slo_workload_read_max_rps || 1000}} \
--write-rps ${{inputs.slo_workload_write_max_rps || 100}} \
--read-timeout 1000 \
--write-timeout 1000
- if: always()
name: Cleanup SLO Database
run: |
npm start --prefix slo-workload -- cleanup grpc://localhost:2135 /Root/testdb
- if: always()
name: Store ydb chaos testing logs
run: |
docker logs ydb-chaos > chaos-ydb.log
- if: always()
uses: actions/upload-artifact@v4
with:
name: slo-logs
path: logs/
name: nodejs-chaos-ydb.log
path: ./chaos-ydb.log
retention-days: 1
10 changes: 6 additions & 4 deletions examples/query-service/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
process.env.YDB_SDK_PRETTY_LOGS = '1';

import {Driver, getCredentialsFromEnv, Logger, TypedValues, RowType} from 'ydb-sdk';
import {Row} from './data-helpers';
import {main} from '../utils';
import { Driver, getCredentialsFromEnv, Logger, TypedValues, RowType } from 'ydb-sdk';
import { Row } from './data-helpers';
import { main } from '../utils';

const TABLE = 'query_service_table';

Expand Down Expand Up @@ -59,7 +59,9 @@ async function select(driver: Driver) {
});
let rowsCount = 0;
for await (const resultSet of res.resultSets) {
resultSet.rows
console.info(`ResultSet index: ${resultSet.index}`)

for await (const row of resultSet.rows) {
rowsCount++;
console.info(`row: ${JSON.stringify(row)}`);
Expand Down Expand Up @@ -124,7 +126,7 @@ async function bulkUpsert(driver: Driver) {
async function run(logger: Logger, endpoint: string, database: string) {
const authService = getCredentialsFromEnv();
logger.info('Driver initializing...');
const driver = new Driver({endpoint, database, authService});
const driver = new Driver({ endpoint, database, authService });
const timeout = 10000;
if (!await driver.ready(timeout)) {
logger.fatal(`Driver has not become ready in ${timeout}ms!`);
Expand Down
8 changes: 4 additions & 4 deletions examples/topic-service/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Driver as YDB, getCredentialsFromEnv, Context, SimpleLogger} from 'ydb-sdk';
import {Ydb} from "ydb-sdk-proto";
import { Driver as YDB, getCredentialsFromEnv, Context, SimpleLogger } from 'ydb-sdk';
import { Ydb } from "ydb-sdk-proto";
import Codec = Ydb.Topic.Codec;

require('dotenv').config();

async function run() {
// const logger = getDefaultLogger();
const logger = new SimpleLogger({envKey: 'YDB_TEST_LOG_LEVEL'});
const logger = new SimpleLogger({ envKey: 'YDB_TEST_LOG_LEVEL' });
const authService = getCredentialsFromEnv(logger);
const db = new YDB({
connectionString: process.env.YDB_CONNECTION_STRING || 'grpc://localhost:2136?database=/local',
Expand Down Expand Up @@ -72,7 +72,7 @@ async function run() {
}
],
}],
}));
}));
}
await writer.close(); // // graceful close() - will finish after receiving confirmation that all messages have been processed by the server
// await Promise.all(promises); // another option
Expand Down
8 changes: 8 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ module.exports = {
semi: true,
singleQuote: true,
bracketSpacing: false,
overrides: [
{
files: ['*.yml', '*.yaml'],
options: {
tabWidth: 2,
},
},
],
};
1 change: 0 additions & 1 deletion slo-workload/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ node_modules
dist
.vscode
runStats.json
package-lock.json
Loading

0 comments on commit be2fcff

Please sign in to comment.