Skip to content

Commit

Permalink
chore: linted partially, integration tests are failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Zorkaltsev committed Oct 30, 2023
1 parent 7bcb5a8 commit 4ad13e9
Show file tree
Hide file tree
Showing 54 changed files with 275 additions and 193 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/integration/alter-table.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Driver from '../../driver';
import { destroyDriver, initDriver } from '../../test-utils';
import { destroyDriver, initDriver } from '../../utils/tests/test-utils';
import {
AlterTableDescription,
AlterTableSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/bulk-upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
initDriver,
Row,
TABLE,
} from '../../test-utils';
} from '../../utils/tests/test-utils';
import { Session } from '../../table';

const readTable = async (session: Session): Promise<Row[]> => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/bytestring-identity.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Driver from '../../driver';
import { destroyDriver, initDriver, TABLE } from '../../test-utils';
import { destroyDriver, initDriver, TABLE } from '../../utils/tests/test-utils';
import { Column, Session, TableDescription } from '../../table';
import { declareType, TypedData, Types } from '../../types';
import { withRetries } from '../../retries';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/connection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initDriver, destroyDriver } from '../../test-utils';
import { initDriver, destroyDriver } from '../../utils/tests/test-utils';

describe('Connection', () => {
it('Test GRPC connection', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/create-table.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Long from 'long';
import { Ydb } from 'ydb-sdk-proto';
import Driver from '../../driver';
import { destroyDriver, initDriver } from '../../test-utils';
import { destroyDriver, initDriver } from '../../utils/tests/test-utils';
import { Column, DescribeTableSettings, TableDescription } from '../../table';
import { TypedValues, Types } from '../../types';

Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/integration/graceful-session-close.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import http from 'http';
import Driver from '../../driver';
import { destroyDriver, initDriver } from '../../test-utils';
import { sleep } from '../../utils';
import { destroyDriver, initDriver } from '../../utils/tests/test-utils';

import { sleep } from '../../utils/sleep';

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

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/read-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
initDriver,
Row,
TABLE,
} from '../../test-utils';
} from '../../utils/tests/test-utils';
import { ReadTableSettings, Session } from '../../table';
import { TypedValues, TypedData } from '../../types';

Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/integration/retries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import {
} from '../../errors';
import { LogLevel, SimpleLogger } from '../../utils/simple-logger';
import { retryable, RetryParameters } from '../../retries';
import { destroyDriver, initDriver } from '../../test-utils';
import { pessimizable } from '../../utils';
import { destroyDriver, initDriver } from '../../utils/tests/test-utils';

import { pessimizable } from '../../utils/pessimizable';

const logger = new SimpleLogger({ level: LogLevel.error });

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/scan-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
fillTableWithData,
initDriver,
Row,
} from '../../test-utils';
} from '../../utils/tests/test-utils';
import { Session } from '../../table';
import { TypedData } from '../../types';

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/integration/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Long from 'long';
import { google, Ydb } from 'ydb-sdk-proto';
import Driver from '../../driver';
import { initDriver, destroyDriver } from '../../test-utils';
import { initDriver, destroyDriver } from '../../utils/tests/test-utils';
import { TypedData, TypedValues, Types } from '../../types';
import NullValue = google.protobuf.NullValue;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BackoffSettings } from '../../retries';
import * as utils from '../../utils';
import * as utilsSleep from '../../utils/sleep';

const runTest = (backoff: BackoffSettings, retries: number, min: number, max: number) => {
it(`have correct value for ${retries} retries`, () => {
let timeout = -1;
const spy = jest.spyOn(utils, 'sleep').mockImplementation((val) => {
const spy = jest.spyOn(utilsSleep, 'sleep').mockImplementation((val) => {
timeout = val;

return Promise.resolve();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as grpc from '@grpc/grpc-js';
import { IAuthService } from './IAuthService';
import { IAuthService } from './i-auth-service';

export class AnonymousAuthService implements IAuthService {
constructor() {}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import jwt from 'jsonwebtoken';
import * as grpc from '@grpc/grpc-js';
import { yandex } from 'ydb-sdk-proto';
import { ISslCredentials, makeDefaultSslCredentials } from '../ssl-credentials';
import { GrpcService, sleep, withTimeout } from '../utils';
import { makeCredentialsMetadata } from './makeCredentialsMetadata';
import { IAuthService } from './IAuthService';
import { IIamCredentials } from './IIamCredentials';
import { GrpcService, withTimeout } from '../utils/service-base-classes';
import { makeCredentialsMetadata } from './make-credentials-metadata';
import { IAuthService } from './i-auth-service';
import { IIamCredentials } from './i-iam-credentials';
import ICreateIamTokenResponse = yandex.cloud.iam.v1.ICreateIamTokenResponse;
import { retryable } from '../retries';
import IamTokenService = yandex.cloud.iam.v1.IamTokenService;
import { sleep } from '../utils/sleep';

export class IamAuthService implements IAuthService {
private jwtExpirationTimeout = 3600 * 1000;
Expand Down
16 changes: 8 additions & 8 deletions src/credentials/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export * from './IAuthService';
export * from './IIamCredentials';
export * from './i-auth-service';
export * from './i-iam-credentials';

export * from './AnonymousAuthService';
export * from './MetadataAuthService';
export * from './IamAuthService';
export * from './StaticCredentialsAuthService';
export * from './TokenAuthService';
export * from './anonymous-auth-service';
export * from './metadata-auth-service';
export * from './iam-auth-service';
export * from './static-credentials-auth-service';
export * from './token-auth-service';

export * from './makeCredentialsMetadata';
export * from './make-credentials-metadata';
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MetadataTokenService } from '@yandex-cloud/nodejs-sdk/dist/token-service/metadata-token-service';
import * as grpc from '@grpc/grpc-js';
import { makeCredentialsMetadata } from './makeCredentialsMetadata';
import { sleep } from '../utils';
import { IAuthService } from './IAuthService';
import { makeCredentialsMetadata } from './make-credentials-metadata';
import { IAuthService } from './i-auth-service';
import { sleep } from '../utils/sleep';

interface ITokenServiceYC {
getToken: () => Promise<string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Ydb } from 'ydb-sdk-proto';
import { DateTime } from 'luxon';
import * as grpc from '@grpc/grpc-js';
import { getOperationPayload, GrpcService, withTimeout } from '../utils';
import { GrpcService, withTimeout } from '../utils/service-base-classes';
import { ISslCredentials } from '../ssl-credentials';
import { retryable } from '../retries';
import { makeCredentialsMetadata } from './makeCredentialsMetadata';
import { IAuthService } from './IAuthService';
import { makeCredentialsMetadata } from './make-credentials-metadata';
import { IAuthService } from './i-auth-service';
import AuthServiceResult = Ydb.Auth.LoginResult;
import { getOperationPayload } from '../utils/get-operation-payload';

class StaticCredentialsGrpcService extends GrpcService<Ydb.Auth.V1.AuthService> {
constructor(endpoint: string, sslCredentials?: ISslCredentials) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as grpc from '@grpc/grpc-js';
import { IAuthService } from './IAuthService';
import { makeCredentialsMetadata } from './makeCredentialsMetadata';
import { IAuthService } from './i-auth-service';
import { makeCredentialsMetadata } from './make-credentials-metadata';

export class TokenAuthService implements IAuthService {
constructor(private token: string) {}
Expand Down
2 changes: 1 addition & 1 deletion src/decimal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ydb } from 'ydb-sdk-proto';
import Long from 'long';
import { toLong } from './utils';
import IValue = Ydb.IValue;
import { toLong } from './utils/to-long';

const DECIMAL_REGEX = /^-?\d+(\.\d+)?/;

Expand Down
3 changes: 2 additions & 1 deletion src/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import EventEmitter from 'events';
import { DateTime } from 'luxon';
import { Ydb } from 'ydb-sdk-proto';
import { AuthenticatedService, getOperationPayload, withTimeout } from './utils';
import { AuthenticatedService, withTimeout } from './utils/service-base-classes';
import { IAuthService } from './credentials';
import { retryable } from './retries';
// noinspection ES6PreferShortImport
Expand All @@ -11,6 +11,7 @@ import DiscoveryServiceAPI = Ydb.Discovery.V1.DiscoveryService;
import IEndpointInfo = Ydb.Discovery.IEndpointInfo;
import { Events } from './constants';
import { ISslCredentials } from './ssl-credentials';
import { getOperationPayload } from './utils/get-operation-payload';

type SuccessDiscoveryHandler = (result: Endpoint[]) => void;
type FailureDiscoveryHandler = (err: Error) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IAuthService } from './credentials';
import { TimeoutExpired } from './errors';
import { Logger, SimpleLogger } from './utils/simple-logger';
import SchemeClient from './scheme';
import { ClientOptions } from './utils';
import { ClientOptions } from './utils/service-base-classes';
import { parseConnectionString } from './parse-connection-string';
import { makeSslCredentials, ISslCredentials } from './ssl-credentials';
import { ContextWithLogger } from './context-with-logger';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sleep } from '../utils';
// * as utilsSleep insted of simple {sleep} to be able to mock method in unit tests
import * as utilsSleep from '../utils/sleep';

export class BackoffSettings {
/**
Expand All @@ -19,6 +20,6 @@ export class BackoffSettings {
const maxDuration = slotsCount * this.backoffSlotDuration;
const duration = maxDuration * (1 - Math.random() * this.uncertainRatio);

return sleep(duration);
return utilsSleep.sleep(duration);
}
}
4 changes: 2 additions & 2 deletions src/retries/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './BackoffSettings';
export * from './RetryParameters';
export * from './backoff-settings';
export * from './retry-parameters';

export * from './retryable';
export * from './withRetries';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { YdbError } from '../errors';
import { BackoffSettings } from './BackoffSettings';
import { BackoffSettings } from './backoff-settings';

export class RetryParameters {
public retryNotFound: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Logger } from '../utils/simple-logger';
import { TransportError, YdbError } from '../errors';
import * as errors from '../errors';
import { RetryParameters } from './RetryParameters';
import { RetryParameters } from './retry-parameters';
import { getContext } from '../utils/context';
import { Trace } from './consts';

Expand Down
4 changes: 2 additions & 2 deletions src/retries/retryable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger } from '../utils/simple-logger';
import { RetryParameters } from './RetryParameters';
import { RetryStrategy } from './RetryStrategy';
import { RetryParameters } from './retry-parameters';
import { RetryStrategy } from './retry-strategy';
import { getLoggerFromObject } from '../utils/get-logger-from-object';
import { getContext } from '../utils/context';

Expand Down
4 changes: 2 additions & 2 deletions src/retries/withRetries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RetryParameters } from './RetryParameters';
import { RetryStrategy } from './RetryStrategy';
import { RetryParameters } from './retry-parameters';
import { RetryStrategy } from './retry-strategy';
import { ContextWithLogger } from '../context-with-logger';
import { Trace } from './consts';

Expand Down
8 changes: 4 additions & 4 deletions src/scheme.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Ydb } from 'ydb-sdk-proto';
import {
AuthenticatedService,
getOperationPayload,
ensureOperationSucceeded,
pessimizable,
ClientOptions,
} from './utils';
} from './utils/service-base-classes';
import { IAuthService } from './credentials';
// noinspection ES6PreferShortImport
import { Logger } from './utils/simple-logger';
Expand All @@ -22,6 +19,9 @@ import IMakeDirectoryRequest = Ydb.Scheme.IMakeDirectoryRequest;
import IPermissions = Ydb.Scheme.IPermissions;
import { util } from 'protobufjs';
import EventEmitter = util.EventEmitter;
import { pessimizable } from './utils/pessimizable';
import { ensureOperationSucceeded } from './utils/ensure-operation-succeeded';
import { getOperationPayload } from './utils/get-operation-payload';

const preparePermissions = (action?: IPermissions | null) => {
if (action && action.permissionNames) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Ydb } from 'ydb-sdk-proto';
import { Column } from './ydb';
import { TableIndex } from './tableIndex';
import { TableIndex } from './table-index';
import { TtlSettings } from './settings';

export class AlterTableDescription {
Expand Down
19 changes: 8 additions & 11 deletions src/table/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
export * from './alterTableDescription';
export * from './session';
export * from './sessionPool';
export * from './sessionService';
export * from './settings';
export * from './sessionPool';
export * from './sessionService';
export * from './alter-table-description';
export * from './settings';
export * from './tableClient';
export * from './tableDescription';
export * from './tableIndex';
export * from './tableProfile';
export * from './session';
export * from './session-pool';
export * from './session-service';
export * from './table-client';
export * from './table-description';
export * from './table-index';
export * from './table-profile';
export * from './ydb';
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAuthService } from '../../credentials';
import { ISslCredentials } from '../../ssl-credentials';
import { IPoolSettings } from '../../driver';
import { ClientOptions } from '../../utils';
import { ClientOptions } from '../../utils/service-base-classes';
import DiscoveryService from '../../discovery';
import { Logger } from '../../utils/simple-logger';

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/table/sessionPool.ts → src/table/session-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DiscoveryService, { Endpoint } from '../discovery';
import { Session } from './session';
import { IAuthService } from '../credentials';
import { ISslCredentials } from '../ssl-credentials';
import { ClientOptions } from '../utils';
import { ClientOptions } from '../utils/service-base-classes';
import { Logger } from '../utils/simple-logger';
import { Events, SESSION_KEEPALIVE_PERIOD } from '../constants';

Expand All @@ -13,9 +13,9 @@ import {
BadSession,
SessionBusy,
} from '../errors';
import { SessionEvent } from './internal/sessionEvent';
import { ITableClientSettings } from './internal/ITableClientSettings';
import { SessionService } from './sessionService';
import { SessionEvent } from './internal/session-event';
import { ITableClientSettings } from './internal/i-table-client-settings';
import { SessionService } from './session-service';
import { ContextWithLogger } from '../context-with-logger';

export class SessionPool extends EventEmitter {
Expand Down
6 changes: 4 additions & 2 deletions src/table/sessionService.ts → src/table/session-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ydb } from 'ydb-sdk-proto';
import {
AuthenticatedService, ClientOptions, getOperationPayload, pessimizable,
} from '../utils';
AuthenticatedService, ClientOptions,
} from '../utils/service-base-classes';
import { Endpoint } from '../discovery';
import { Logger } from '../utils/simple-logger';
import { IAuthService } from '../credentials';
Expand All @@ -12,6 +12,8 @@ import { Session } from './session';
import TableService = Ydb.Table.V1.TableService;
import CreateSessionRequest = Ydb.Table.CreateSessionRequest;
import CreateSessionResult = Ydb.Table.CreateSessionResult;
import { pessimizable } from '../utils/pessimizable';
import { getOperationPayload } from '../utils/get-operation-payload';

export class SessionService extends AuthenticatedService<TableService> {
public endpoint: Endpoint;
Expand Down
Loading

0 comments on commit 4ad13e9

Please sign in to comment.