@powersync/service-module-mysql 0.1.8 → 0.2.0
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.
- package/CHANGELOG.md +30 -0
- package/dist/module/MySQLModule.d.ts +3 -2
- package/dist/module/MySQLModule.js +8 -2
- package/dist/module/MySQLModule.js.map +1 -1
- package/dist/replication/BinLogReplicator.d.ts +1 -0
- package/dist/replication/BinLogReplicator.js +4 -0
- package/dist/replication/BinLogReplicator.js.map +1 -1
- package/dist/replication/BinLogStream.js +17 -6
- package/dist/replication/BinLogStream.js.map +1 -1
- package/dist/replication/MySQLConnectionManagerFactory.d.ts +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.js +11 -7
- package/dist/types/types.js.map +1 -1
- package/dist/utils/mysql-utils.js +1 -0
- package/dist/utils/mysql-utils.js.map +1 -1
- package/package.json +8 -7
- package/src/module/MySQLModule.ts +18 -4
- package/src/replication/BinLogReplicator.ts +5 -0
- package/src/replication/BinLogStream.ts +19 -8
- package/src/replication/MySQLConnectionManagerFactory.ts +1 -1
- package/src/types/types.ts +20 -7
- package/src/utils/mysql-utils.ts +1 -0
- package/test/src/BinLogStream.test.ts +9 -8
- package/test/src/BinlogStreamUtils.ts +2 -0
- package/test/src/env.ts +4 -1
- package/test/src/setup.ts +5 -1
- package/test/src/util.ts +5 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,7 +3,8 @@ import { putOp, removeOp } from '@powersync/service-core-tests';
|
|
|
3
3
|
import { v4 as uuid } from 'uuid';
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
5
|
import { BinlogStreamTestContext } from './BinlogStreamUtils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { env } from './env.js';
|
|
7
|
+
import { INITIALIZED_MONGO_STORAGE_FACTORY, INITIALIZED_POSTGRES_STORAGE_FACTORY } from './util.js';
|
|
7
8
|
|
|
8
9
|
const BASIC_SYNC_RULES = `
|
|
9
10
|
bucket_definitions:
|
|
@@ -12,13 +13,13 @@ bucket_definitions:
|
|
|
12
13
|
- SELECT id, description FROM "test_data"
|
|
13
14
|
`;
|
|
14
15
|
|
|
15
|
-
describe(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
16
|
+
describe.skipIf(!env.TEST_MONGO_STORAGE)(' Binlog stream - mongodb', { timeout: 20_000 }, function () {
|
|
17
|
+
defineBinlogStreamTests(INITIALIZED_MONGO_STORAGE_FACTORY);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe.skipIf(!env.TEST_POSTGRES_STORAGE)(' Binlog stream - postgres', { timeout: 20_000 }, function () {
|
|
21
|
+
defineBinlogStreamTests(INITIALIZED_POSTGRES_STORAGE_FACTORY);
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
function defineBinlogStreamTests(factory: storage.TestStorageFactory) {
|
|
24
25
|
test('Replicate basic values', async () => {
|
|
@@ -49,6 +49,7 @@ export class BinlogStreamTestContext {
|
|
|
49
49
|
this.abortController.abort();
|
|
50
50
|
await this.streamPromise;
|
|
51
51
|
await this.connectionManager.end();
|
|
52
|
+
await this.factory[Symbol.asyncDispose]();
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
[Symbol.asyncDispose]() {
|
|
@@ -104,6 +105,7 @@ export class BinlogStreamTestContext {
|
|
|
104
105
|
|
|
105
106
|
async replicateSnapshot() {
|
|
106
107
|
await this.binlogStream.initReplication();
|
|
108
|
+
await this.storage!.autoActivate();
|
|
107
109
|
this.replicationDone = true;
|
|
108
110
|
}
|
|
109
111
|
|
package/test/src/env.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { utils } from '@powersync/lib-services-framework';
|
|
|
3
3
|
export const env = utils.collectEnvironmentVariables({
|
|
4
4
|
MYSQL_TEST_URI: utils.type.string.default('mysql://root:mypassword@localhost:3306/mydatabase'),
|
|
5
5
|
MONGO_TEST_URL: utils.type.string.default('mongodb://localhost:27017/powersync_test'),
|
|
6
|
+
PG_STORAGE_TEST_URL: utils.type.string.default('postgres://postgres:postgres@localhost:5431/powersync_storage_test'),
|
|
6
7
|
CI: utils.type.boolean.default('false'),
|
|
7
|
-
SLOW_TESTS: utils.type.boolean.default('false')
|
|
8
|
+
SLOW_TESTS: utils.type.boolean.default('false'),
|
|
9
|
+
TEST_MONGO_STORAGE: utils.type.boolean.default('true'),
|
|
10
|
+
TEST_POSTGRES_STORAGE: utils.type.boolean.default('true')
|
|
8
11
|
});
|
package/test/src/setup.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { container } from '@powersync/lib-services-framework';
|
|
2
2
|
import { test_utils } from '@powersync/service-core-tests';
|
|
3
|
-
import { beforeAll } from 'vitest';
|
|
3
|
+
import { beforeAll, beforeEach } from 'vitest';
|
|
4
4
|
|
|
5
5
|
beforeAll(async () => {
|
|
6
6
|
// Executes for every test file
|
|
7
7
|
container.registerDefaults();
|
|
8
8
|
await test_utils.initMetrics();
|
|
9
9
|
});
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await test_utils.resetMetrics();
|
|
13
|
+
});
|
package/test/src/util.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as types from '@module/types/types.js';
|
|
2
2
|
import { getMySQLVersion, isVersionAtLeast } from '@module/utils/mysql-utils.js';
|
|
3
3
|
import * as mongo_storage from '@powersync/service-module-mongodb-storage';
|
|
4
|
+
import * as postgres_storage from '@powersync/service-module-postgres-storage';
|
|
4
5
|
import mysqlPromise from 'mysql2/promise';
|
|
5
6
|
import { env } from './env.js';
|
|
6
7
|
|
|
@@ -16,6 +17,10 @@ export const INITIALIZED_MONGO_STORAGE_FACTORY = mongo_storage.MongoTestStorageF
|
|
|
16
17
|
isCI: env.CI
|
|
17
18
|
});
|
|
18
19
|
|
|
20
|
+
export const INITIALIZED_POSTGRES_STORAGE_FACTORY = postgres_storage.PostgresTestStorageFactoryGenerator({
|
|
21
|
+
url: env.PG_STORAGE_TEST_URL
|
|
22
|
+
});
|
|
23
|
+
|
|
19
24
|
export async function clearTestDb(connection: mysqlPromise.Connection) {
|
|
20
25
|
const version = await getMySQLVersion(connection);
|
|
21
26
|
if (isVersionAtLeast(version, '8.4.0')) {
|