Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@datagrok/api-tests

Package Overview
Dependencies
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datagrok/api-tests - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

connections/clickhouse-api-tests.json

2

.eslintrc.json
{
"env": {
"browser": true,
"es2021": true
"es2022": true
},

@@ -6,0 +6,0 @@ "extends": [

{
"#type": "DataConnection",
"name": "MSSQLApiTests",
"friendlyName": "Tests",
"friendlyName": "MSSQLApiTests",
"parameters": {

@@ -6,0 +6,0 @@ "server": "db.datagrok.ai",

{
"#type": "DataConnection",
"name": "OracleApiTests",
"friendlyName": "Tests",
"friendlyName": "OracleApiTests",
"parameters": {

@@ -6,0 +6,0 @@ "server": "db.datagrok.ai",

{
"#type": "DataConnection",
"name": "PostgreSQLApiTests",
"friendlyName": "Tests",
"friendlyName": "PostgreSQLApiTests",
"parameters": {

@@ -6,0 +6,0 @@ "server": "db.datagrok.ai",

{
"#type": "DataConnection",
"name": "SnowflakeApiTests",
"friendlyName": "Tests",
"friendlyName": "SnowflakeApiTests",
"parameters": {
"region": "west-europe",
"accountLocator": "ni99608",
"cloud": "azure",
"region": "us-east4",
"accountLocator": "mf34438",
"cloud": "gcp",
"db": "test",

@@ -14,4 +14,4 @@ "warehouse": "COMPUTE_WH"

"parameters" : {
"login": "pasha32662",
"password": "pBx7dyjp_"
"login": "datagrok",
"password": "Datagrok1"
}

@@ -21,2 +21,2 @@ },

"description": "Test data"
}
}
{
"name": "@datagrok/api-tests",
"friendlyName": "API Tests",
"version": "1.6.0",
"version": "1.7.0",
"author": {

@@ -18,3 +18,3 @@ "name": "Alexander Paramonov",

"cash-dom": "^8.1.1",
"datagrok-api": "^1.13.0",
"datagrok-api": "^1.14.0",
"dayjs": "latest",

@@ -32,7 +32,7 @@ "rxjs": "^6.6.7",

"root-require": "latest",
"source-map-loader": "^4.0.1",
"ts-loader": "^9.2.6",
"typescript": "^4.4.4",
"typescript": "^5.0.4",
"webpack": "^5.59.1",
"webpack-cli": "^4.9.1",
"source-map-loader": "^4.0.1"
"webpack-cli": "^4.9.1"
},

@@ -39,0 +39,0 @@ "scripts": {

@@ -28,2 +28,45 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

});
test('perfGen', async () => {
const query = await grok.dapi.queries.include('params,connection').filter(`friendlyName="Perf"`).first();
const call = query.prepare();
await call.call();
const t = call.getOutputParamValue() as DG.DataFrame;
console.log(t);
console.log(query);
});
test('ScalarQueryTest', async () => {
const query = await grok.dapi.queries.filter(`friendlyName = "Postgre Scalar Output"`).include('params').first();
const call = query.prepare();
await call.call();
const t = call.getOutputParamValue() as number;
console.log(t);
if (t != 830)
// eslint-disable-next-line no-throw-literal
throw 'Rows number in' + query.name + 'table is not as expected';
});
test('External Provider Chembl Perf', async () => {
const query = await grok.dapi.queries.filter(`friendlyName = "ChemblPerfGenerated"`).include('params').first();
const lim = 5000000;
const call = query.prepare({'num': lim});
await call.call();
const t = call.getOutputParamValue() as DG.DataFrame;
if (t.rowCount != lim)
// eslint-disable-next-line no-throw-literal
throw 'Rows number in' + query.name + 'table is not as expected';
});
test('External Provider First part', async () => {
const query = await grok.dapi.queries.filter(`friendlyName = "Compounds"`).include('params').first();
const call = query.prepare();
call.call();
setTimeout(() => {
const t = call.getOutputParamValue() as DG.DataFrame;
if (t == null)
// eslint-disable-next-line no-throw-literal
throw 'First rows await time exceeded';
}, 2000);
});
});

@@ -5,2 +5,3 @@ import {category, expect, expectObject, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {_package} from '../package-test';

@@ -12,8 +13,7 @@ category('Dapi: packages', () => {

});
test('find', async () => {
const apiTestsPack =
DG.toJs((await grok.dapi.packages.list()).filter((pack) => pack.name === 'ApiTests')[0]) as DG.Package;
expectObject((await grok.dapi.packages.find(apiTestsPack.id)), apiTestsPack);
const apiTestsPackage = await grok.dapi.packages.find(_package.id);
expect(apiTestsPackage.updatedOn.toString(), _package.updatedOn.toString());
});
});

@@ -51,3 +51,3 @@ import * as DG from 'datagrok-api/dg';

Honda, Accord, 6, 1.8, 20000
BMW, 328i, 4, 1.7, 60000
BMW, 328i, 4, 1.7, 60000
BMW, 535i, 6, 1.5, 35000

@@ -304,3 +304,3 @@ Tesla, Roadster, , 1.6, 100000

c.set(1, dayjs('2022-01-01'));
expect(c.get(1).valueOf(), 1640988000000);
expect(c.get(1).valueOf(), 1640995200000);
c.set(1, null);

@@ -307,0 +307,0 @@ expect(c.get(1), null);

@@ -34,3 +34,28 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

test('ParseQnum', () => check({
'ParseQnum("10")': 10.000000000000004,
'ParseQnum("<10")': 10.000000000000002,
'ParseQnum(">10")': 10.000000000000005,
'ParseQnum(" < 10")': 10.000000000000002,
'ParseQnum("> 10")': 10.000000000000005,
}));
test('Qnum', () => check({
'ToString(Qnum(1.5, "="))': '1.5000000000000004',
'ToString(Qnum(1.5, "<"))': '1.5000000000000002',
'ToString(Qnum(1.5, ">"))': '1.5000000000000007',
'ToString(Qnum(-1, "="))': '-1.0000000000000004',
'ToString(Qnum(-1, "<"))': '-1.0000000000000002',
'ToString(Qnum(-1, ">"))': '-1.0000000000000007',
}));
test('QnumToString', () => check({
'QnumToString(Qnum(1.5, "="))': '1.50',
'QnumToString(Qnum(1.5, "<"))': '<1.50',
'QnumToString(Qnum(1.5, ">"))': '>1.50',
'QnumToString(Qnum(1.115, "="))': '1.11',
'QnumToString(Qnum(1.115, "<"))': '<1.11',
'QnumToString(Qnum(1.115, ">"))': '>1.11',
}));
test('ToString', () => check({

@@ -37,0 +62,0 @@ 'ToString(1)': '1',

import * as grok from 'datagrok-api/grok';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import {category, expect, test} from '@datagrok-libraries/utils/src/test';

@@ -9,11 +11,11 @@ import {check} from './utils';

test('Date', () => check({
'Date(2020, 1, 1)': dayjs('2020-01-01'),
'Date(2000, 10, 1)': dayjs('2000-10-01'),
'Date(2040, 1, 30)': dayjs('2040-01-30'),
'Date(2020, 1, 1)': dayjs.utc('2020-01-01'),
'Date(2000, 10, 1)': dayjs.utc('2000-10-01'),
'Date(2040, 1, 30)': dayjs.utc('2040-01-30'),
}));
test('DateAdd', () => check({
'DateAdd(Date(2020, 1, 1), 86400000)': dayjs('2020-01-01').add(1, 'd'),
'DateAdd(Date(2020, 1, 1), 10800000)': dayjs('2020-01-01').add(3, 'h'),
'DateAdd(Date(2020, 1, 1), 3605000)': dayjs('2020-01-01').add(1, 'h').add(5, 's'),
'DateAdd(Date(2020, 1, 1), 86400000)': dayjs.utc('2020-01-01').add(1, 'd'),
'DateAdd(Date(2020, 1, 1), 10800000)': dayjs.utc('2020-01-01').add(3, 'h'),
'DateAdd(Date(2020, 1, 1), 3605000)': dayjs.utc('2020-01-01').add(1, 'h').add(5, 's'),
}));

@@ -31,3 +33,2 @@

const tolerance = 10;
console.log('Date', now.valueOf());
expect(Math.abs(dayjs().valueOf() - now.valueOf()) <= tolerance, true);

@@ -37,4 +38,4 @@ });

test('DateTime', () => check({
'DateTime(2020, 1, 1, 23, 59, 45, 999)': dayjs(new Date(2020, 0, 1, 23, 59, 45, 999)),
'DateTime(2050, 10, 10, 0, 15, 5, 0)': dayjs(new Date(2050, 9, 10, 0, 15, 5, 0)),
'DateTime(2020, 1, 1, 23, 59, 45, 999)': dayjs.utc('2020-1-1 23:59:45.999'),
'DateTime(2050, 10, 10, 0, 15, 5, 0)': dayjs.utc('2050-10-10 0:15:5'),
}));

@@ -115,3 +116,3 @@

test('Today', () => check({
'Today()': dayjs().hour(0).minute(0).second(0).millisecond(0),
'Today()': dayjs.utc().hour(0).minute(0).second(0).millisecond(0),
}));

@@ -118,0 +119,0 @@

@@ -185,2 +185,9 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

test('Qualifier', () => check({
'Qualifier(Qnum(1.5, "="))': '=',
'Qualifier(Qnum(1.5, "<"))': '<',
'Qualifier(Qnum(1.5, ">"))': '>',
'Qualifier(1)': '=',
}));
test('RandBetween', () => checkRandomInt({

@@ -187,0 +194,0 @@ 'RandBetween(5, 7)': [5, 7],

@@ -46,3 +46,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

await grok.dapi.projects.open('Test upload project');
expect(grok.shell.v.name, 'demog 1000')
expect(grok.shell.v.name, 'Datagrok');

@@ -49,0 +49,0 @@ grok.shell.closeAll();

@@ -8,2 +8,3 @@ import * as DG from 'datagrok-api/dg';

import './dataframe/datetime-columns-join';
import './dataframe/dataframe-join';
import './functions/functions';

@@ -13,2 +14,3 @@ import './shell/shell';

import './views/docking';
import './views/docking-nested';
import './views/events';

@@ -58,2 +60,3 @@ import './views/layouts';

// import './connections/queries-test';
// import './connections/perf-tests';
import './connections/get-all-top100';

@@ -82,2 +85,4 @@ import './scripts/scripts-params';

import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test';
import {Column, DataFrame, DataQuery, FuncCall} from 'datagrok-api/dg';
import {filter} from 'rxjs/operators';

@@ -131,1 +136,84 @@ export const _package = new DG.Package();

}
//name: testConnections
//output: dataframe result
//top-menu: Tools | Dev | Test Connections
export async function testConnections(): Promise<DG.DataFrame> {
const connections: string[] = ['PostgreSQLApiTests', 'SnowflakeApiTests', 'MSSQLApiTests', 'OracleApiTests'];
const tables: string[] = ['Long', 'Normal', 'Wide', 'Tiny'];
const fetchSizes: string[] = ['big', 'dynamic', 'low'];
// const queriesFriendlyNames: string[] = ['PostgresNormal', 'PostgresLong', 'PostgresWide'];
const l = connections.length * tables.length * fetchSizes.length;
const df = DataFrame.fromColumns([Column.string('type', l), Column.string('fetch', l),
Column.string('db', l), Column.int('TTFR', l), Column.int('TTC', l)]);
let startTime: number;
let ttfr: number;
let callCheck: (value: FuncCall) => boolean;
let ttfrSet = false;
// @ts-ignore
grok.functions.onParamsUpdated.pipe(filter((c) => callCheck(c) && !ttfrSet)).subscribe(() => {
ttfr = Date.now() - startTime;
df.columns.byName('TTFR').set(row, ttfr);
ttfrSet = true;
});
let row = 0;
for (const con of connections) {
for (const table of tables) {
for (const fetchSize of fetchSizes) {
if (table == 'Long' && fetchSize == 'low')
continue;
const connection = await grok.dapi.connections.filter(`name = "${con}"`).first();
ttfrSet = false;
df.columns.byName('type').set(row, table);
df.columns.byName('fetch').set(row, fetchSize);
df.columns.byName('db').set(row, con);
callCheck = (c: FuncCall) => c.aux.get('fetchSize') == fetchSize &&
// @ts-ignore
(c.func as DataQuery).connection.name == con;
const preTable = con.startsWith('Snowflake') ? 'TEST.' : '';
let sql;
if (table == 'Tiny') {
if (con.startsWith('Oracle'))
sql = `select * from Test_Long WHERE ROWNUM = 1`;
else if (con.startsWith('MS'))
sql = `select TOP 1 * from Test_Long`;
else
sql = 'select 1';
} else
sql = `select * from ${preTable}Test_${table}`;
const query = `--fetchSize: ${fetchSize}\n${sql}\n--end`;
startTime = Date.now();
console.log('executing' + query);
const q = connection.query('adhoc', sql);
const call = q.prepare();
// @ts-ignore
call.setAuxValue('fetchSize', fetchSize);
await call.call();
// await grok.data.db.query(connection.id, query);
console.log('executed');
df.columns.byName('TTC').set(row, Date.now() - startTime);
row++;
};
};
};
df;
grok.shell.addTableView(df);
return df;
}

@@ -9,3 +9,3 @@ {

"module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["es2020", "dom", "ES2021.String"], /* Specify library files to be included in the compilation. */
"lib": ["ES2022", "dom"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */

@@ -12,0 +12,0 @@ // "checkJs": true, /* Report errors in .js files. */

@@ -33,2 +33,4 @@ const path = require('path');

'rxjs': 'rxjs',
'dayjs': 'dayjs',
'dayjs/plugin/utc': 'utc',
'rxjs/operators': 'rxjs.operators',

@@ -35,0 +37,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc