Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.dev.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
YDB_ANONYMOUS_CREDENTIALS=1
YDB_SSL_ROOT_CERTIFICATES_FILE=../slo-tests/playground/data/ydb_certs/ca.pem
YDB_ENDPOINT=grpc://<localhost / fqdn / ip-address>:<2135 / 2136>
YDB_LOG_LEVEL=debug
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

services:
ydb:
image: ghcr.io/ydb-platform/local-ydb:nightly
image: ydbplatform/local-ydb:24.1
ports:
- 2135:2135
- 2136:2136
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

.env

#npm
npm-debug.log*
node_modules
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@types/uuid": "^8.3.4",
"@yandex-cloud/nodejs-sdk": "^2.0.0",
"cross-env": "^7.0.3",
"dotenv": "^16.4.5",
"husky": "^7.0.4",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.1",
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/e2e/connection.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import {initDriver, destroyDriver} from "../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

describe('Connection', () => {
it('Test GRPC connection', async () => {
let driver = await initDriver({endpoint: 'grpc://localhost:2136'});
let driver = await initDriver({endpoint: process.env.YDB_ENDPOINT || 'grpc://localhost:2136'});
await driver.tableClient.withSession(async (session) => {
await session.executeQuery('SELECT 1');
});
await destroyDriver(driver)
});

it('Test GRPCS connection', async () => {
let driver = await initDriver({endpoint: 'grpcs://localhost:2135'});
let driver = await initDriver({endpoint: process.env.YDB_ENDPOINT || 'grpcs://localhost:2135'});
await driver.tableClient.withSession(async (session) => {
await session.executeQuery('SELECT 1');
});
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/e2e/query-service/method-execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import {ctxSymbol} from "../../../query/symbols";
import StatsMode = Ydb.Query.StatsMode;
import ExecMode = Ydb.Query.ExecMode;

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const DATABASE = '/local';
const ENDPOINT = 'grpc://localhost:2136';
const ENDPOINT = process.env.YDB_ENDPOINT || 'grpc://localhost:2136';
const TABLE_NAME = 'test_table_1'

describe('Query.execute()', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/e2e/query-service/query-service-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import fs from "fs";
import {AUTO_TX} from "../../../table";
import {QuerySession, IExecuteResult} from "../../../query";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const DATABASE = '/local';
const ENDPOINT = 'grpcs://localhost:2135';
const ENDPOINT = process.env.YDB_ENDPOINT || 'grpc://localhost:2135';

describe('Query client', () => {

Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/e2e/query-service/rows-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {getDefaultLogger} from "../../../logger/get-default-logger";
import {ctxSymbol} from "../../../query/symbols";
import {Context} from "../../../context";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const DATABASE = '/local';
const ENDPOINT = 'grpcs://localhost:2136';
const ENDPOINT = process.env.YDB_ENDPOINT || 'grpc://localhost:2136';
const TABLE_NAME = 'test_table_3'

interface IRow {
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/e2e/query-service/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {getDefaultLogger} from "../../../logger/get-default-logger";
import {ctxSymbol} from "../../../query/symbols";
import {Context} from "../../../context";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const DATABASE = '/local';
const ENDPOINT = 'grpc://localhost:2136';
const ENDPOINT = process.env.YDB_ENDPOINT || 'grpc://localhost:2136';

describe('Query service transactions', () => {

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/retries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {pessimizable} from "../../utils";
import {destroyDriver, initDriver} from "../../utils/test";
import {LogLevel, SimpleLogger} from "../../logger/simple-logger";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const logger = new SimpleLogger({level: LogLevel.error});
class ErrorThrower {
constructor(public endpoint: Endpoint) {}
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/alter-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
} from "../../../table";
import {initDriver, destroyDriver} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const getTableName = () => `table_alter_${Math.trunc(1000 * Math.random())}`;

describe('Alter table', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/bulk-upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Driver from '../../../driver';
import {TableSession} from "../../../table";
import {Row, initDriver, destroyDriver, createTable, fillTableWithData, TABLE} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

async function readTable(session: TableSession): Promise<Row[]> {
const rows: Row[] = [];

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/bytestring-identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {withRetries} from '../../../retries_obsoleted';
import {Column, TableSession, TableDescription} from "../../../table";
import {initDriver, destroyDriver, TABLE} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

async function createTable(session: TableSession) {
await session.dropTable(TABLE);
await session.createTable(
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/create-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {Ydb} from 'ydb-sdk-proto';
import {Column, DescribeTableSettings, TableDescription} from "../../../table";
import {initDriver, destroyDriver} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const getTableName = () => `table_create_${Math.trunc(100000 * Math.random())}`;

describe('Create table', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {initDriver, destroyDriver} from "../../../utils/test";

const SHUTDOWN_URL = process.env.YDB_SHUTDOWN_URL || 'http://localhost:8765/actors/kqp_proxy?force_shutdown=all';

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

describe('Graceful session close', () => {

// TODO: Fix and enable test nce issue will be resolved https://github.com/ydb-platform/ydb/issues/2981
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/read-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {TypedValues, TypedData} from '../../../types';
import {ReadTableSettings, TableSession} from "../../../table";
import {Row, initDriver, destroyDriver, createTable, fillTableWithData, TABLE} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

async function readTable(session: TableSession, settings: ReadTableSettings): Promise<TypedData[]> {
const rows: TypedData[] = [];

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/scan-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {TypedData} from '../../../types';
import {TableSession} from "../../../table";
import {Row, initDriver, destroyDriver, createTable, fillTableWithData, TABLE} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

async function executeScanQuery(session: TableSession): Promise<TypedData[]> {
const query = `SELECT * FROM ${TABLE};`;

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/e2e/table-service/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {TypedData, TypedValues, Types} from '../../../types';
import NullValue = google.protobuf.NullValue;
import {initDriver, destroyDriver} from "../../../utils/test";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

describe('Types', () => {
let driver: Driver;

Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/e2e/topic-service/internal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {TopicService} from "../../../topic";
import {google, Ydb} from "ydb-sdk-proto";
import {openReadStreamWithEvents, openWriteStreamWithEvents} from "../../../topic/symbols";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

const DATABASE = '/local';
const ENDPOINT = 'grpc://localhost:2136';
const ENDPOINT = process.env.YDB_ENDPOINT || 'grpc://localhost:2136';

describe('Topic: General', () => {
let discoveryService: DiscoveryService;
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/e2e/topic-service/send-messages.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {AnonymousAuthService, Driver as YDB} from '../../../index';
import {google, Ydb} from "ydb-sdk-proto";

if (process.env.TEST_ENVIRONMENT === 'dev') require('dotenv').config();

// create topic

describe('Topic: Send messages', () => {
xdescribe('Topic: Send messages', () => {
let ydb: YDB | undefined;

beforeEach(async () => {
Expand Down
6 changes: 6 additions & 0 deletions src/discovery/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export class Endpoint extends Ydb.Discovery.EndpointInfo {
}

public toString(): string {
// TODO: Find out how to specify a host ip/name for local development
if (process.env.YDB_ENDPOINT) {
const str = process.env.YDB_ENDPOINT;
const n = str.indexOf('://'); // remove grpc(s)?://
return n > 0 ? str.substr(n + 3) : str;
} // for development only
let result = this.address;
if (this.port) {
result += ':' + this.port;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/test/init-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function initDriver(settings?: Partial<IDriverSettings>): Promise<D
}
const sslCredentials = {rootCertificates: fs.readFileSync(certFile)};
const driver = new Driver({
endpoint: `grpc://localhost:2136`,
endpoint: process.env.YDB_ENDPOINT || `grpc://localhost:2136`,
database: DATABASE,
authService: new AnonymousAuthService(),
sslCredentials,
Expand Down