@cubejs-backend/testing-shared 0.35.79 → 0.35.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,11 @@
1
+ import { StartedNetwork } from 'testcontainers';
1
2
  export interface ContainerVolumeDefinition {
2
3
  source: string;
3
4
  target: string;
4
5
  bindMode?: 'rw' | 'ro';
5
6
  }
6
7
  export interface DBRunnerContainerOptions {
8
+ network?: StartedNetwork;
7
9
  volumes?: ContainerVolumeDefinition[];
8
10
  version?: string;
9
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"db-runner.abstract.d.ts","sourceRoot":"","sources":["../../../src/db-container-runners/db-runner.abstract.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,8BAAsB,gBAAgB;CAErC"}
1
+ {"version":3,"file":"db-runner.abstract.d.ts","sourceRoot":"","sources":["../../../src/db-container-runners/db-runner.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,8BAAsB,gBAAgB;CAErC"}
@@ -1 +1 @@
1
- {"version":3,"file":"db-runner.abstract.js","sourceRoot":"","sources":["../../../src/db-container-runners/db-runner.abstract.ts"],"names":[],"mappings":";;;AAWA,sCAAsC;AACtC,MAAsB,gBAAgB;CAErC;AAFD,4CAEC"}
1
+ {"version":3,"file":"db-runner.abstract.js","sourceRoot":"","sources":["../../../src/db-container-runners/db-runner.abstract.ts"],"names":[],"mappings":";;;AAcA,sCAAsC;AACtC,MAAsB,gBAAgB;CAErC;AAFD,4CAEC"}
@@ -9,4 +9,6 @@ export * from './prestodb';
9
9
  export * from './mssql';
10
10
  export * from './trino';
11
11
  export * from './oracle';
12
+ export * from './kafka';
13
+ export * from './ksql';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db-container-runners/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db-container-runners/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -25,4 +25,6 @@ __exportStar(require("./prestodb"), exports);
25
25
  __exportStar(require("./mssql"), exports);
26
26
  __exportStar(require("./trino"), exports);
27
27
  __exportStar(require("./oracle"), exports);
28
+ __exportStar(require("./kafka"), exports);
29
+ __exportStar(require("./ksql"), exports);
28
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db-container-runners/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,4CAA0B;AAC1B,gDAA8B;AAC9B,0CAAwB;AACxB,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db-container-runners/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,4CAA0B;AAC1B,gDAA8B;AAC9B,0CAAwB;AACxB,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB"}
@@ -0,0 +1,5 @@
1
+ import { DbRunnerAbstract, DBRunnerContainerOptions } from './db-runner.abstract';
2
+ export declare class KafkaDBRunner extends DbRunnerAbstract {
3
+ static startContainer(options: DBRunnerContainerOptions): Promise<import("@testcontainers/kafka").StartedKafkaContainer>;
4
+ }
5
+ //# sourceMappingURL=kafka.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kafka.d.ts","sourceRoot":"","sources":["../../../src/db-container-runners/kafka.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAElF,qBAAa,aAAc,SAAQ,gBAAgB;WACnC,cAAc,CAAC,OAAO,EAAE,wBAAwB;CA0B/D"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KafkaDBRunner = void 0;
4
+ const kafka_1 = require("@testcontainers/kafka");
5
+ const db_runner_abstract_1 = require("./db-runner.abstract");
6
+ class KafkaDBRunner extends db_runner_abstract_1.DbRunnerAbstract {
7
+ static startContainer(options) {
8
+ const version = process.env.TEST_KAFKA_VERSION || options.version || '7.6.0';
9
+ const container = new kafka_1.KafkaContainer(`confluentinc/cp-kafka:${version}`)
10
+ .withKraft()
11
+ .withEnvironment({
12
+ KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: '1',
13
+ KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: '1',
14
+ KAFKA_NUM_PARTITIONS: '1',
15
+ KAFKA_DEFAULT_REPLICATION_FACTOR: '1',
16
+ })
17
+ .withExposedPorts(9093)
18
+ .withStartupTimeout(10 * 1000);
19
+ if (options.network) {
20
+ container.withNetwork(options.network);
21
+ container.withNetworkAliases('kafka');
22
+ }
23
+ if (options.volumes) {
24
+ const binds = options.volumes.map(v => ({ source: v.source, target: v.target, mode: v.bindMode }));
25
+ container.withBindMounts(binds);
26
+ }
27
+ return container.start();
28
+ }
29
+ }
30
+ exports.KafkaDBRunner = KafkaDBRunner;
31
+ //# sourceMappingURL=kafka.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kafka.js","sourceRoot":"","sources":["../../../src/db-container-runners/kafka.ts"],"names":[],"mappings":";;;AAAA,iDAAuD;AACvD,6DAAkF;AAElF,MAAa,aAAc,SAAQ,qCAAgB;IAC1C,MAAM,CAAC,cAAc,CAAC,OAAiC;QAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC;QAE7E,MAAM,SAAS,GAAG,IAAI,sBAAc,CAAC,yBAAyB,OAAO,EAAE,CAAC;aACrE,SAAS,EAAE;aACX,eAAe,CAAC;YACf,8CAA8C,EAAE,GAAG;YACnD,mCAAmC,EAAE,GAAG;YACxC,oBAAoB,EAAE,GAAG;YACzB,gCAAgC,EAAE,GAAG;SACtC,CAAC;aACD,gBAAgB,CAAC,IAAI,CAAC;aACtB,kBAAkB,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QAEjC,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACvC,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACnG,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SACjC;QAED,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AA3BD,sCA2BC"}
@@ -0,0 +1,7 @@
1
+ import { StartedTestContainer } from 'testcontainers';
2
+ import { DbRunnerAbstract, DBRunnerContainerOptions } from './db-runner.abstract';
3
+ export declare class KsqlDBRunner extends DbRunnerAbstract {
4
+ static startContainer(options: DBRunnerContainerOptions): Promise<StartedTestContainer>;
5
+ static loadData(db: StartedTestContainer): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=ksql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ksql.d.ts","sourceRoot":"","sources":["../../../src/db-container-runners/ksql.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAElF,qBAAa,YAAa,SAAQ,gBAAgB;WAClC,cAAc,CAAC,OAAO,EAAE,wBAAwB;WA0B1C,QAAQ,CAAC,EAAE,EAAE,oBAAoB;CAiDtD"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.KsqlDBRunner = void 0;
7
+ const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const testcontainers_1 = require("testcontainers");
9
+ const shared_1 = require("@cubejs-backend/shared");
10
+ const db_runner_abstract_1 = require("./db-runner.abstract");
11
+ class KsqlDBRunner extends db_runner_abstract_1.DbRunnerAbstract {
12
+ static startContainer(options) {
13
+ const version = process.env.TEST_KSQL_VERSION || options.version || '7.6.0';
14
+ const bootstrapServers = 'kafka:9092';
15
+ const container = new testcontainers_1.GenericContainer(`confluentinc/cp-ksqldb-server:${version}`)
16
+ .withEnvironment({
17
+ KSQL_BOOTSTRAP_SERVERS: bootstrapServers,
18
+ KSQL_KSQL_STREAMS_BOOTSTRAP_SERVERS: bootstrapServers,
19
+ KSQL_KSQL_SERVICE_ID: 'service-id',
20
+ })
21
+ .withExposedPorts(8088)
22
+ .withStartupTimeout(30 * 1000);
23
+ if (options.network) {
24
+ container.withNetwork(options.network);
25
+ container.withNetworkAliases('ksql');
26
+ }
27
+ if (options.volumes) {
28
+ const binds = options.volumes.map(v => ({ source: v.source, target: v.target, mode: v.bindMode }));
29
+ container.withBindMounts(binds);
30
+ }
31
+ return container.start();
32
+ }
33
+ static async loadData(db) {
34
+ const ksqlUrl = `http://${db.getHost()}:${db.getMappedPort(8088)}`;
35
+ let attempts = 0;
36
+ while (attempts < 10) {
37
+ const res = await (0, node_fetch_1.default)(`${ksqlUrl}/ksql`, {
38
+ method: 'POST',
39
+ headers: { Accept: 'application/json' },
40
+ body: JSON.stringify({
41
+ ksql: 'LIST STREAMS;',
42
+ streamsProperties: {}
43
+ })
44
+ });
45
+ const body = await res.json();
46
+ if (body.message !== 'KSQL is not yet ready to serve requests.') {
47
+ console.log('KSQL ready');
48
+ break;
49
+ }
50
+ console.log('KSQL not ready yet');
51
+ attempts++;
52
+ await (0, shared_1.pausePromise)(300);
53
+ }
54
+ const resCreateStream = await (0, node_fetch_1.default)(`${ksqlUrl}/ksql`, {
55
+ method: 'POST',
56
+ headers: { Accept: 'application/json' },
57
+ body: JSON.stringify({
58
+ ksql: "CREATE OR REPLACE STREAM REQUESTS (ID STRING, TIMESTAMP TIMESTAMP, TENANT_ID INTEGER, REQUEST_ID STRING) WITH (KAFKA_TOPIC = 'REQUESTS', KEY_FORMAT = 'JSON', PARTITIONS = 1, REPLICAS = 1, VALUE_FORMAT = 'JSON');",
59
+ streamsProperties: {}
60
+ })
61
+ });
62
+ console.log('KSQL CREATE STREAM', await resCreateStream.json());
63
+ const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000).toJSON();
64
+ const today = new Date(Date.now() - 1000).toJSON();
65
+ const resInsertYesterday = await (0, node_fetch_1.default)(`${ksqlUrl}/ksql`, {
66
+ method: 'POST',
67
+ headers: { Accept: 'application/json' },
68
+ body: JSON.stringify({
69
+ ksql: `INSERT INTO REQUESTS VALUES ('1', '${yesterday}', 1, 'req-stream-1');INSERT INTO REQUESTS VALUES ('1', '${today}', 1, 'req-stream-2');`,
70
+ streamsProperties: {}
71
+ })
72
+ });
73
+ console.log('KSQL INSERT', await resInsertYesterday.json());
74
+ }
75
+ }
76
+ exports.KsqlDBRunner = KsqlDBRunner;
77
+ //# sourceMappingURL=ksql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ksql.js","sourceRoot":"","sources":["../../../src/db-container-runners/ksql.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,mDAAwE;AACxE,mDAAsD;AACtD,6DAAkF;AAElF,MAAa,YAAa,SAAQ,qCAAgB;IACzC,MAAM,CAAC,cAAc,CAAC,OAAiC;QAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IA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EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,IAAI,EAAE,sCAAsC,SAAS,4DAA4D,KAAK,wBAAwB;gBAC9I,iBAAiB,EAAE,EAAE;aACtB,CAAC;SACH,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF;AA5ED,oCA4EC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-backend/testing-shared",
3
- "version": "0.35.79",
3
+ "version": "0.35.81",
4
4
  "description": "Cube.js Testing Helpers",
5
5
  "author": "Cube Dev, Inc.",
6
6
  "license": "Apache-2.0",
@@ -21,12 +21,13 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@cubejs-backend/dotenv": "^9.0.2",
24
- "@cubejs-backend/query-orchestrator": "^0.35.78",
25
- "@cubejs-backend/schema-compiler": "^0.35.79",
24
+ "@cubejs-backend/query-orchestrator": "^0.35.81",
25
+ "@cubejs-backend/schema-compiler": "^0.35.81",
26
26
  "@cubejs-backend/shared": "^0.35.67",
27
+ "@testcontainers/kafka": "~10.13.0",
27
28
  "dedent": "^0.7.0",
28
29
  "node-fetch": "^2.6.7",
29
- "testcontainers": "^10.10.4"
30
+ "testcontainers": "^10.13.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@cubejs-backend/linter": "^0.35.0",
@@ -53,5 +54,5 @@
53
54
  "eslintConfig": {
54
55
  "extends": "../cubejs-linter"
55
56
  },
56
- "gitHead": "33b138321d8bc65b303a7692dfb07dc8bcb105f0"
57
+ "gitHead": "995f526853573d15ee57566c14c129005ca34f0f"
57
58
  }