From 59919d48a9cb0e7a89ccbd0201574e20a19ff3ad Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Tue, 7 Feb 2023 17:10:00 -0800 Subject: [PATCH 1/7] integration-tests/node: Progress on workbench stability tests --- .../mysql-client-tests/node/database.js | 3 +- .../mysql-client-tests/node/helpers.js | 16 ++ .../mysql-client-tests/node/index.js | 26 +--- .../mysql-client-tests/node/package-lock.json | 13 +- .../mysql-client-tests/node/package.json | 3 +- .../mysql-client-tests/node/workbench.js | 26 ++++ .../node/workbenchTests/branches.js | 92 +++++++++++ .../node/workbenchTests/databases.js | 49 ++++++ .../node/workbenchTests/index.js | 48 ++++++ .../node/workbenchTests/logs.js | 53 +++++++ .../node/workbenchTests/matchers.js | 67 ++++++++ .../node/workbenchTests/merge.js | 43 ++++++ .../node/workbenchTests/table.js | 143 ++++++++++++++++++ 13 files changed, 561 insertions(+), 21 deletions(-) create mode 100644 integration-tests/mysql-client-tests/node/workbench.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/branches.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/databases.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/index.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/logs.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/matchers.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/merge.js create mode 100644 integration-tests/mysql-client-tests/node/workbenchTests/table.js diff --git a/integration-tests/mysql-client-tests/node/database.js b/integration-tests/mysql-client-tests/node/database.js index ce93b6f2c2..bc23f907bd 100644 --- a/integration-tests/mysql-client-tests/node/database.js +++ b/integration-tests/mysql-client-tests/node/database.js @@ -1,4 +1,4 @@ -import mysql from "mysql"; +import mysql from "mysql2"; export class Database { constructor(config) { @@ -14,6 +14,7 @@ export class Database { }); }); } + close() { this.connection.end((err) => { if (err) { diff --git a/integration-tests/mysql-client-tests/node/helpers.js b/integration-tests/mysql-client-tests/node/helpers.js index 8fcf0151b4..61d008a32f 100644 --- a/integration-tests/mysql-client-tests/node/helpers.js +++ b/integration-tests/mysql-client-tests/node/helpers.js @@ -1,3 +1,5 @@ +import { mysql as escapeQueryWithParameters } from "yesql"; + const args = process.argv.slice(2); const user = args[0]; const port = args[1]; @@ -16,3 +18,17 @@ export function getConfig() { database: dbName, }; } + +export function assertQueryResult(q, resultStr, expected, rows, matcher) { + if (matcher) { + return matcher(rows, expected); + } + if (q.toLowerCase().includes("dolt_commit")) { + return rows.length === 1 && rows[0].hash.length === 32; + } + return resultStr === JSON.stringify(expected); +} + +export function getQueryWithEscapedParameters(q, parameters) { + return escapeQueryWithParameters(q)(parameters || {}); +} diff --git a/integration-tests/mysql-client-tests/node/index.js b/integration-tests/mysql-client-tests/node/index.js index 413b352e7b..a19e96bbf3 100644 --- a/integration-tests/mysql-client-tests/node/index.js +++ b/integration-tests/mysql-client-tests/node/index.js @@ -1,5 +1,5 @@ import { Database } from "./database.js"; -import { getConfig } from "./helpers.js"; +import { assertQueryResult, getConfig } from "./helpers.js"; const tests = [ { @@ -8,11 +8,9 @@ const tests = [ fieldCount: 0, affectedRows: 0, insertId: 0, + info: "", serverStatus: 2, - warningCount: 0, - message: "", - protocol41: true, - changedRows: 0, + warningStatus: 0, }, }, { @@ -43,11 +41,9 @@ const tests = [ fieldCount: 0, affectedRows: 1, insertId: 0, + info: "", serverStatus: 2, - warningCount: 0, - message: "", - protocol41: true, - changedRows: 0, + warningStatus: 0, }, }, { q: "select * from test", res: [{ pk: 0, value: 0 }] }, @@ -61,11 +57,9 @@ const tests = [ fieldCount: 0, affectedRows: 1, insertId: 0, + info: "", serverStatus: 2, - warningCount: 0, - message: "", - protocol41: true, - changedRows: 0, + warningStatus: 0, }, }, { q: "call dolt_commit('-a', '-m', 'my commit2')", res: [] }, @@ -88,11 +82,7 @@ async function main() { .then((rows) => { const resultStr = JSON.stringify(rows); const result = JSON.parse(resultStr); - if ( - resultStr !== JSON.stringify(expected) && - test.q.includes("dolt_commit") && - !(rows.length === 1 && rows[0].hash.length > 0) - ) { + if (!assertQueryResult(test.q, resultStr, expected, rows)) { console.log("Query:", test.q); console.log("Results:", result); console.log("Expected:", expected); diff --git a/integration-tests/mysql-client-tests/node/package-lock.json b/integration-tests/mysql-client-tests/node/package-lock.json index daaa50c802..774cba332b 100644 --- a/integration-tests/mysql-client-tests/node/package-lock.json +++ b/integration-tests/mysql-client-tests/node/package-lock.json @@ -12,7 +12,8 @@ "knex": "^2.4.0", "mysql": "^2.18.1", "mysql2": "^2.3.3", - "wtfnode": "^0.9.1" + "wtfnode": "^0.9.1", + "yesql": "^5.0.0" } }, "node_modules/bignumber.js": { @@ -448,6 +449,11 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yesql": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yesql/-/yesql-5.0.0.tgz", + "integrity": "sha512-ua4Ok0hv6Q+KPn2oJrGNRfsubYnKPLJAt6kvawG6Aqb6yg4Cm1T2JIBveFNx0aDhCIansNVq/9MFzuvmNdnJnw==" } }, "dependencies": { @@ -776,6 +782,11 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "yesql": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yesql/-/yesql-5.0.0.tgz", + "integrity": "sha512-ua4Ok0hv6Q+KPn2oJrGNRfsubYnKPLJAt6kvawG6Aqb6yg4Cm1T2JIBveFNx0aDhCIansNVq/9MFzuvmNdnJnw==" } } } diff --git a/integration-tests/mysql-client-tests/node/package.json b/integration-tests/mysql-client-tests/node/package.json index f1edcc04d1..1e0a21947a 100644 --- a/integration-tests/mysql-client-tests/node/package.json +++ b/integration-tests/mysql-client-tests/node/package.json @@ -13,6 +13,7 @@ "knex": "^2.4.0", "mysql": "^2.18.1", "mysql2": "^2.3.3", - "wtfnode": "^0.9.1" + "wtfnode": "^0.9.1", + "yesql": "^5.0.0" } } diff --git a/integration-tests/mysql-client-tests/node/workbench.js b/integration-tests/mysql-client-tests/node/workbench.js new file mode 100644 index 0000000000..177fc89546 --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbench.js @@ -0,0 +1,26 @@ +import { Database } from "./database.js"; +import { getConfig } from "./helpers.js"; +import runWorkbenchTests from "./workbenchTests/index.js"; + +// Table + +// Workspaces + +// Diffs + +// Docs + +// Views + +// Tags + +async function workbench() { + const database = new Database(getConfig()); + + await runWorkbenchTests(database); + + database.close(); + process.exit(0); +} + +workbench(); diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js new file mode 100644 index 0000000000..a867343f6c --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js @@ -0,0 +1,92 @@ +import { branchesMatcher } from "./matchers.js"; +import { getArgs } from "../helpers.js"; + +const args = getArgs(); + +export const branchTests = [ + { + q: `CALL DOLT_BRANCH(:newBranchName, :fromRefName)`, + p: { newBranchName: "mybranch", fromRefName: "main" }, + res: [{ status: 0 }], + }, + { + q: `USE ::dbName`, + p: { dbName: `${args.dbName}/mybranch` }, + res: { + fieldCount: 0, + affectedRows: 0, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: "create table test (pk int, `value` int, primary key(pk))", + res: { + fieldCount: 0, + affectedRows: 0, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `CALL DOLT_COMMIT("-A", "-m", :commitMsg, "--author", :authorName)`, + p: { + commitMsg: "Create table test", + authorName: "Dolt ", + }, + res: [{ hash: "" }], + }, + { + q: `SELECT * FROM dolt_branches WHERE name NOT LIKE "workspaces/%" LIMIT 200`, + res: [ + { + name: "main", + latest_committer: "Taylor Bantle", + latest_committer_email: "taylor@liquidata.co", + // TODO: uncomment + // latest_committer: "mysql-test-runner", + // latest_committer_email: "mysql-test-runner@liquidata.co", + }, + { + name: "mybranch", + latest_committer: "Dolt", + latest_committer_email: "dolt@dolthub.com", + }, + ], + matcher: branchesMatcher, + }, + { + q: `CALL DOLT_CHECKOUT("-b", :branchName)`, + p: { branchName: "branch-to-delete" }, + res: [{ status: 0 }], + }, + { + q: `SELECT COUNT(*) FROM dolt_branches WHERE name NOT LIKE "workspaces/%" LIMIT 200`, + res: [{ ["COUNT(*)"]: 3 }], + }, + { + q: `USE ::dbName`, + p: { dbName: `${args.dbName}/main` }, + res: { + fieldCount: 0, + affectedRows: 0, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `CALL DOLT_BRANCH("-D", :branchName)`, + p: { branchName: "branch-to-delete" }, + res: [{ status: 0 }], + }, + { + q: `SELECT COUNT(*) FROM dolt_branches WHERE name NOT LIKE "workspaces/%" LIMIT 200`, + res: [{ ["COUNT(*)"]: 2 }], + }, +]; diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/databases.js b/integration-tests/mysql-client-tests/node/workbenchTests/databases.js new file mode 100644 index 0000000000..6fd29a2934 --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/databases.js @@ -0,0 +1,49 @@ +import { getArgs } from "../helpers.js"; + +const args = getArgs(); + +export const databaseTests = [ + { + q: `USE ::dbName`, + p: { dbName: `${args.dbName}/main` }, + res: { + fieldCount: 0, + affectedRows: 0, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `SHOW DATABASES`, + res: [ + { Database: "information_schema" }, + { Database: "mysql" }, + { Database: "mysql_client" }, + { Database: "mysql_client/main" }, + ], + }, + { + q: `CREATE DATABASE ::dbName`, + p: { dbName: "new_db" }, + res: { + fieldCount: 0, + affectedRows: 1, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `SHOW DATABASES`, + res: [ + { Database: "information_schema" }, + { Database: "mysql" }, + { Database: "mysql_client" }, + { Database: "mysql_client/main" }, + { Database: "new_db" }, + ], + }, +]; diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/index.js b/integration-tests/mysql-client-tests/node/workbenchTests/index.js new file mode 100644 index 0000000000..b2d45e634c --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/index.js @@ -0,0 +1,48 @@ +import { branchTests } from "./branches.js"; +import { databaseTests } from "./databases.js"; +import { logTests } from "./logs.js"; +import { mergeTests } from "./merge.js"; +import { tableTests } from "./table.js"; +import { + assertQueryResult, + getQueryWithEscapedParameters, +} from "../helpers.js"; + +export default async function runWorkbenchTests(database) { + await runTests(database, databaseTests); + await runTests(database, branchTests); + await runTests(database, logTests); + await runTests(database, mergeTests); + await runTests(database, tableTests); +} + +async function runTests(database, tests) { + await Promise.all( + tests.map((test) => { + const expected = test.res; + const { sql, values } = getQueryWithEscapedParameters(test.q, test.p); + return database + .query(sql, values) + .then((rows) => { + const resultStr = JSON.stringify(rows); + const result = JSON.parse(resultStr); + if ( + !assertQueryResult(test.q, resultStr, expected, rows, test.matcher) + ) { + console.log("Query:", test.q); + console.log("Results:", result); + console.log("Expected:", expected); + throw new Error("Query failed"); + } else { + console.log("Query succeeded:", test.q); + // console.log("RES", resultStr); + // console.log("EXP", expected); + } + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); + }) + ); +} diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/logs.js b/integration-tests/mysql-client-tests/node/workbenchTests/logs.js new file mode 100644 index 0000000000..902e2724f8 --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/logs.js @@ -0,0 +1,53 @@ +import { logsMatcher } from "./matchers.js"; + +export const logTests = [ + { + q: `SELECT * FROM DOLT_LOG(:refName, '--parents') LIMIT :limit OFFSET :offset`, + p: { refName: "main", limit: 10, offset: 0 }, + res: [ + { + message: "Initialize data repository", + parentsLength: 0, + committer: "Taylor Bantle", + email: "taylor@liquidata.co", + // TODO: uncomment + // committer: "mysql-test-runner", + // email: "mysql-test-runner@liquidata.co", + }, + ], + matcher: logsMatcher, + }, + { + q: `SELECT * FROM dolt_log AS OF :refName`, + p: { refName: "mybranch" }, + res: [ + { + message: "Create table test", + committer: "Dolt", + email: "dolt@dolthub.com", + }, + { + message: "Initialize data repository", + committer: "Taylor Bantle", + email: "taylor@liquidata.co", + // TODO: uncomment + // committer: "mysql-test-runner", + // email: "mysql-test-runner@liquidata.co", + }, + ], + matcher: logsMatcher, + }, + { + q: `SELECT * FROM DOLT_LOG(:refRange, '--parents')`, + p: { refRange: "main..mybranch" }, + res: [ + { + message: "Create table test", + parentsLength: 1, + committer: "Dolt", + email: "dolt@dolthub.com", + }, + ], + matcher: logsMatcher, + }, +]; diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/matchers.js b/integration-tests/mysql-client-tests/node/workbenchTests/matchers.js new file mode 100644 index 0000000000..5441ecc35c --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/matchers.js @@ -0,0 +1,67 @@ +export function branchesMatcher(rows, exp) { + if (rows.length !== exp.length) { + return false; + } + for (let i = 0; i < rows.length; i++) { + if (rows[i].name !== exp[i].name) { + return false; + } + if (rows[i].hash.length !== 32) { + return false; + } + if (rows[i].latest_commit_date.length === 0) { + return false; + } + if (rows[i].latest_committer !== exp[i].latest_committer) { + return false; + } + if (rows[i].latest_committer_email !== exp[i].latest_committer_email) { + return false; + } + } + return true; +} + +export function logsMatcher(rows, exp) { + if (rows.length !== exp.length) { + return false; + } + for (let i = 0; i < rows.length; i++) { + if (rows[i].message !== exp[i].message) { + return false; + } + if (rows[i].commit_hash.length !== 32) { + return false; + } + if (rows[i].date.length === 0) { + return false; + } + if (rows[i].committer !== exp[i].committer) { + return false; + } + if (rows[i].email !== exp[i].email) { + return false; + } + if (exp[i].parentsLength !== undefined) { + if ( + rows[i].parents.split(", ").filter((v) => !!v.length).length !== + exp[i].parentsLength + ) { + return false; + } + } + } + return true; +} + +export function mergeBaseMatcher(rows, exp) { + if (rows.length !== 1 || exp.length !== 1) { + return false; + } + Object.keys(exp).forEach((key) => { + if (rows[key].length !== 32) { + return false; + } + }); + return true; +} diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js new file mode 100644 index 0000000000..4b6f654e51 --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js @@ -0,0 +1,43 @@ +import { logsMatcher, mergeBaseMatcher } from "./matchers.js"; + +export const mergeTests = [ + { + q: `SELECT DOLT_MERGE_BASE(:fromBranchName, :toBranchName)`, + p: { fromBranchName: "mybranch", toBranchName: "main" }, + res: [{ "DOLT_MERGE_BASE('mybranch', 'main')": "" }], + matcher: mergeBaseMatcher, + }, + { + q: `CALL DOLT_MERGE(:branchName, "--no-ff", "-m", :commitMsg)`, + p: { branchName: "mybranch", commitMsg: "Merge mybranch into main" }, + res: [{ fast_forward: 1, conflicts: 0 }], + }, + { + q: `SELECT * FROM DOLT_LOG(:refName, '--parents') LIMIT :limit OFFSET :offset`, + p: { refName: "main", limit: 10, offset: 0 }, + res: [ + { + message: "Merge mybranch into main", + parentsLength: 2, + committer: "mysql-test-runner", + email: "mysql-test-runner@liquidata.co", + }, + { + message: "Create table test", + parentsLength: 1, + committer: "Dolt", + email: "dolt@dolthub.com", + }, + { + message: "Initialize data repository", + parentsLength: 0, + committer: "Taylor Bantle", + email: "taylor@liquidata.co", + // TODO: uncomment + // committer: "mysql-test-runner", + // email: "mysql-test-runner@liquidata.co", + }, + ], + matcher: logsMatcher, + }, +]; diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/table.js b/integration-tests/mysql-client-tests/node/workbenchTests/table.js new file mode 100644 index 0000000000..54c2f92279 --- /dev/null +++ b/integration-tests/mysql-client-tests/node/workbenchTests/table.js @@ -0,0 +1,143 @@ +import { getArgs } from "../helpers.js"; + +const args = getArgs(); + +export const tableTests = [ + { + q: "INSERT INTO test VALUES (0, 0), (1, 1), (2,2)", + res: { + fieldCount: 0, + affectedRows: 3, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `CREATE UNIQUE INDEX test_idx ON test (pk, value)`, + res: { + fieldCount: 0, + affectedRows: 0, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `SHOW CREATE TABLE ::tableName AS OF :refName`, + p: { tableName: "test", refName: "main" }, + res: [ + // Should not show new index in working set + { + Table: "test", + "Create Table": + "CREATE TABLE `test` (\n" + + " `pk` int NOT NULL,\n" + + " `value` int,\n" + + " PRIMARY KEY (`pk`)\n" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin", + }, + ], + }, + { + q: `CALL DOLT_COMMIT("-A", "-m", :commitMsg)`, + p: { commitMsg: "Add some rows and a column index" }, + res: [{ hash: "" }], + }, + { + q: `DESCRIBE ::tableName AS OF :refName`, + p: { tableName: "test", refName: "main" }, + res: [ + { + Field: "pk", + Type: "int", + Null: "NO", + Key: "PRI", + Default: "NULL", + Extra: "", + }, + { + Field: "value", + Type: "int", + Null: "YES", + Key: "", + Default: "NULL", + Extra: "", + }, + ], + }, + { + q: `SELECT + table_name, index_name, comment, non_unique, GROUP_CONCAT(column_name ORDER BY seq_in_index) AS COLUMNS + FROM information_schema.statistics + WHERE table_schema=:tableSchema AND table_name=:tableName AND index_name!="PRIMARY" + GROUP BY index_name;`, + p: { tableSchema: `${args.dbName}/main`, tableName: "test" }, + res: [ + { + TABLE_NAME: "test", + INDEX_NAME: "test_idx", + COMMENT: "", + NON_UNIQUE: 0, + COLUMNS: "pk,value", + }, + ], + }, + { + q: "CREATE TABLE test_info (id int, info varchar(255), test_pk int, primary key(id), foreign key (test_pk) references test(pk))", + res: { + fieldCount: 0, + affectedRows: 0, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: "INSERT INTO test_info VALUES (1, 'info about test pk 0', 0)", + res: { + fieldCount: 0, + affectedRows: 1, + insertId: 0, + info: "", + serverStatus: 2, + warningStatus: 0, + }, + }, + { + q: `CALL DOLT_COMMIT("-A", "-m", :commitMsg)`, + p: { commitMsg: "Add test_info with foreign key" }, + res: [{ hash: "" }], + }, + { + q: `SHOW FULL TABLES AS OF :refName WHERE table_type = 'BASE TABLE'`, + p: { refName: "main" }, + res: [ + { "Tables_in_mysql_client/main": "test", Table_type: "BASE TABLE" }, + { "Tables_in_mysql_client/main": "test_info", Table_type: "BASE TABLE" }, + ], + }, + { + q: `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name=:tableName AND table_schema=:tableSchema AND referenced_table_schema IS NOT NULL`, + p: { tableName: "test_info", tableSchema: `${args.dbName}/main` }, + res: [ + { + CONSTRAINT_CATALOG: "def", + CONSTRAINT_SCHEMA: "mysql_client/main", + CONSTRAINT_NAME: "s7utamh8", + TABLE_CATALOG: "def", + TABLE_SCHEMA: "mysql_client/main", + TABLE_NAME: "test_info", + COLUMN_NAME: "test_pk", + ORDINAL_POSITION: 1, + POSITION_IN_UNIQUE_CONSTRAINT: 1, + REFERENCED_TABLE_SCHEMA: "mysql_client/main", + REFERENCED_TABLE_NAME: "test", + REFERENCED_COLUMN_NAME: "pk", + }, + ], + }, +]; From 33afd3275f0bdd49f6fbe9db2febd176f3fb7a48 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Wed, 8 Feb 2023 09:41:53 -0800 Subject: [PATCH 2/7] Add to bats --- .../mysql-client-tests/mysql-client-tests.bats | 4 ++++ .../node/workbenchTests/branches.js | 8 ++++---- .../node/workbenchTests/logs.js | 16 ++++++++-------- .../node/workbenchTests/merge.js | 8 ++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/integration-tests/mysql-client-tests/mysql-client-tests.bats b/integration-tests/mysql-client-tests/mysql-client-tests.bats index 5c76c8dd07..8688331a20 100644 --- a/integration-tests/mysql-client-tests/mysql-client-tests.bats +++ b/integration-tests/mysql-client-tests/mysql-client-tests.bats @@ -68,6 +68,10 @@ teardown() { node $BATS_TEST_DIRNAME/node/knex.js $USER $PORT $REPO_NAME } +@test "node mysql client, hosted workbench stability" { + node $BATS_TEST_DIRNAME/node/workbench.js $USER $PORT $REPO_NAME +} + @test "c mysql connector" { (cd $BATS_TEST_DIRNAME/c; make clean; make) $BATS_TEST_DIRNAME/c/mysql-connector-c-test $USER $PORT $REPO_NAME diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js index a867343f6c..da8edff9df 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js @@ -45,11 +45,11 @@ export const branchTests = [ res: [ { name: "main", - latest_committer: "Taylor Bantle", - latest_committer_email: "taylor@liquidata.co", + // latest_committer: "Taylor Bantle", + // latest_committer_email: "taylor@liquidata.co", // TODO: uncomment - // latest_committer: "mysql-test-runner", - // latest_committer_email: "mysql-test-runner@liquidata.co", + latest_committer: "mysql-test-runner", + latest_committer_email: "mysql-test-runner@liquidata.co", }, { name: "mybranch", diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/logs.js b/integration-tests/mysql-client-tests/node/workbenchTests/logs.js index 902e2724f8..9f44f0ae3b 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/logs.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/logs.js @@ -8,11 +8,11 @@ export const logTests = [ { message: "Initialize data repository", parentsLength: 0, - committer: "Taylor Bantle", - email: "taylor@liquidata.co", + // committer: "Taylor Bantle", + // email: "taylor@liquidata.co", // TODO: uncomment - // committer: "mysql-test-runner", - // email: "mysql-test-runner@liquidata.co", + committer: "mysql-test-runner", + email: "mysql-test-runner@liquidata.co", }, ], matcher: logsMatcher, @@ -28,11 +28,11 @@ export const logTests = [ }, { message: "Initialize data repository", - committer: "Taylor Bantle", - email: "taylor@liquidata.co", + // committer: "Taylor Bantle", + // email: "taylor@liquidata.co", // TODO: uncomment - // committer: "mysql-test-runner", - // email: "mysql-test-runner@liquidata.co", + committer: "mysql-test-runner", + email: "mysql-test-runner@liquidata.co", }, ], matcher: logsMatcher, diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js index 4b6f654e51..75a3167580 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js @@ -31,11 +31,11 @@ export const mergeTests = [ { message: "Initialize data repository", parentsLength: 0, - committer: "Taylor Bantle", - email: "taylor@liquidata.co", + // committer: "Taylor Bantle", + // email: "taylor@liquidata.co", // TODO: uncomment - // committer: "mysql-test-runner", - // email: "mysql-test-runner@liquidata.co", + committer: "mysql-test-runner", + email: "mysql-test-runner@liquidata.co", }, ], matcher: logsMatcher, From 54cf7bde1a96351ac8d550fd9e29a23ccfe243fc Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Wed, 8 Feb 2023 10:03:17 -0800 Subject: [PATCH 3/7] Fix tests, add CODEOWNERS --- CODEOWNERS | 23 +++++++++++++++++++ .../node/workbenchTests/databases.js | 12 +++++----- .../node/workbenchTests/table.js | 16 ++++++------- 3 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000..5361be842c --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,23 @@ +# Lines starting with '#' are comments. + +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in the repo. + +# * @defunkt + +# Order is important. The last matching pattern has the most precedence. + +# So if a pull request only touches javascript files, only these owners + +# will be requested to review. + +# *.js @octocat @github/js + +# You can also use email addresses if you prefer. + +# docs/* docs@example.com + +# Begin dolt repository owners + +integration-tests/mysql-client-tests/node/* @tbantle22 diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/databases.js b/integration-tests/mysql-client-tests/node/workbenchTests/databases.js index 6fd29a2934..0a50aa1844 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/databases.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/databases.js @@ -1,11 +1,11 @@ import { getArgs } from "../helpers.js"; -const args = getArgs(); +const { dbName } = getArgs(); export const databaseTests = [ { q: `USE ::dbName`, - p: { dbName: `${args.dbName}/main` }, + p: { dbName: `${dbName}/main` }, res: { fieldCount: 0, affectedRows: 0, @@ -20,8 +20,8 @@ export const databaseTests = [ res: [ { Database: "information_schema" }, { Database: "mysql" }, - { Database: "mysql_client" }, - { Database: "mysql_client/main" }, + { Database: `${dbName}` }, + { Database: `${dbName}/main` }, ], }, { @@ -41,8 +41,8 @@ export const databaseTests = [ res: [ { Database: "information_schema" }, { Database: "mysql" }, - { Database: "mysql_client" }, - { Database: "mysql_client/main" }, + { Database: `${dbName}` }, + { Database: `${dbName}/main` }, { Database: "new_db" }, ], }, diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/table.js b/integration-tests/mysql-client-tests/node/workbenchTests/table.js index 54c2f92279..d677dd15fe 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/table.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/table.js @@ -1,6 +1,6 @@ import { getArgs } from "../helpers.js"; -const args = getArgs(); +const { dbName } = getArgs(); export const tableTests = [ { @@ -74,7 +74,7 @@ export const tableTests = [ FROM information_schema.statistics WHERE table_schema=:tableSchema AND table_name=:tableName AND index_name!="PRIMARY" GROUP BY index_name;`, - p: { tableSchema: `${args.dbName}/main`, tableName: "test" }, + p: { tableSchema: `${dbName}/main`, tableName: "test" }, res: [ { TABLE_NAME: "test", @@ -116,25 +116,25 @@ export const tableTests = [ q: `SHOW FULL TABLES AS OF :refName WHERE table_type = 'BASE TABLE'`, p: { refName: "main" }, res: [ - { "Tables_in_mysql_client/main": "test", Table_type: "BASE TABLE" }, - { "Tables_in_mysql_client/main": "test_info", Table_type: "BASE TABLE" }, + { [`Tables_in_${dbName}/main`]: "test", Table_type: "BASE TABLE" }, + { [`Tables_in_${dbName}/main`]: "test_info", Table_type: "BASE TABLE" }, ], }, { q: `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name=:tableName AND table_schema=:tableSchema AND referenced_table_schema IS NOT NULL`, - p: { tableName: "test_info", tableSchema: `${args.dbName}/main` }, + p: { tableName: "test_info", tableSchema: `${dbName}/main` }, res: [ { CONSTRAINT_CATALOG: "def", - CONSTRAINT_SCHEMA: "mysql_client/main", + CONSTRAINT_SCHEMA: `${dbName}/main`, CONSTRAINT_NAME: "s7utamh8", TABLE_CATALOG: "def", - TABLE_SCHEMA: "mysql_client/main", + TABLE_SCHEMA: `${dbName}/main`, TABLE_NAME: "test_info", COLUMN_NAME: "test_pk", ORDINAL_POSITION: 1, POSITION_IN_UNIQUE_CONSTRAINT: 1, - REFERENCED_TABLE_SCHEMA: "mysql_client/main", + REFERENCED_TABLE_SCHEMA: `${dbName}/main`, REFERENCED_TABLE_NAME: "test", REFERENCED_COLUMN_NAME: "pk", }, From 08e82201249ebbc4e328e98010a65b298dd8e4ec Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Wed, 8 Feb 2023 13:39:45 -0800 Subject: [PATCH 4/7] Fix tests --- .../mysql-client-tests/node/workbench.js | 12 ------------ .../node/workbenchTests/databases.js | 8 ++++---- .../mysql-client-tests/node/workbenchTests/index.js | 8 ++++++-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/integration-tests/mysql-client-tests/node/workbench.js b/integration-tests/mysql-client-tests/node/workbench.js index 177fc89546..ceb897696d 100644 --- a/integration-tests/mysql-client-tests/node/workbench.js +++ b/integration-tests/mysql-client-tests/node/workbench.js @@ -2,18 +2,6 @@ import { Database } from "./database.js"; import { getConfig } from "./helpers.js"; import runWorkbenchTests from "./workbenchTests/index.js"; -// Table - -// Workspaces - -// Diffs - -// Docs - -// Views - -// Tags - async function workbench() { const database = new Database(getConfig()); diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/databases.js b/integration-tests/mysql-client-tests/node/workbenchTests/databases.js index 0a50aa1844..4801b908d0 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/databases.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/databases.js @@ -18,10 +18,10 @@ export const databaseTests = [ { q: `SHOW DATABASES`, res: [ - { Database: "information_schema" }, - { Database: "mysql" }, { Database: `${dbName}` }, { Database: `${dbName}/main` }, + { Database: "information_schema" }, + { Database: "mysql" }, ], }, { @@ -39,10 +39,10 @@ export const databaseTests = [ { q: `SHOW DATABASES`, res: [ - { Database: "information_schema" }, - { Database: "mysql" }, { Database: `${dbName}` }, { Database: `${dbName}/main` }, + { Database: "information_schema" }, + { Database: "mysql" }, { Database: "new_db" }, ], }, diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/index.js b/integration-tests/mysql-client-tests/node/workbenchTests/index.js index b2d45e634c..77f38bc087 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/index.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/index.js @@ -14,6 +14,12 @@ export default async function runWorkbenchTests(database) { await runTests(database, logTests); await runTests(database, mergeTests); await runTests(database, tableTests); + // TODO: + // Workspaces + // Diffs + // Docs + // Views + // Tags } async function runTests(database, tests) { @@ -35,8 +41,6 @@ async function runTests(database, tests) { throw new Error("Query failed"); } else { console.log("Query succeeded:", test.q); - // console.log("RES", resultStr); - // console.log("EXP", expected); } }) .catch((err) => { From dea7adac21c51f770c826fa000f5cac18cb50f81 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Wed, 8 Feb 2023 17:01:17 -0800 Subject: [PATCH 5/7] Check status before merge --- .../mysql-client-tests/node/workbenchTests/merge.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js index 75a3167580..e04bbc3956 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js @@ -7,6 +7,10 @@ export const mergeTests = [ res: [{ "DOLT_MERGE_BASE('mybranch', 'main')": "" }], matcher: mergeBaseMatcher, }, + { + q: `SELECT * FROM dolt_status`, + res: [], + }, { q: `CALL DOLT_MERGE(:branchName, "--no-ff", "-m", :commitMsg)`, p: { branchName: "mybranch", commitMsg: "Merge mybranch into main" }, From b5803a397bbe59708da2336e602d52ffd9e4eee1 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Thu, 9 Feb 2023 09:48:32 -0800 Subject: [PATCH 6/7] Fix --- .../mysql-client-tests/node/workbenchTests/branches.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js index da8edff9df..b366c1ea70 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js @@ -9,6 +9,10 @@ export const branchTests = [ p: { newBranchName: "mybranch", fromRefName: "main" }, res: [{ status: 0 }], }, + { + q: `CALL DOLT_CLEAN('mysqldump_table', 'warehouse')`, + res: [{ status: 0 }], + }, { q: `USE ::dbName`, p: { dbName: `${args.dbName}/mybranch` }, From a7b6797be79945328d9e83de1cdb06a8970b15e4 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Mon, 6 Mar 2023 15:26:45 -0800 Subject: [PATCH 7/7] Clean up --- .../mysql-client-tests/node/workbenchTests/branches.js | 3 --- .../mysql-client-tests/node/workbenchTests/logs.js | 6 ------ .../mysql-client-tests/node/workbenchTests/merge.js | 3 --- 3 files changed, 12 deletions(-) diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js index b366c1ea70..0e1483db1d 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/branches.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/branches.js @@ -49,9 +49,6 @@ export const branchTests = [ res: [ { name: "main", - // latest_committer: "Taylor Bantle", - // latest_committer_email: "taylor@liquidata.co", - // TODO: uncomment latest_committer: "mysql-test-runner", latest_committer_email: "mysql-test-runner@liquidata.co", }, diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/logs.js b/integration-tests/mysql-client-tests/node/workbenchTests/logs.js index 9f44f0ae3b..660e7bd875 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/logs.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/logs.js @@ -8,9 +8,6 @@ export const logTests = [ { message: "Initialize data repository", parentsLength: 0, - // committer: "Taylor Bantle", - // email: "taylor@liquidata.co", - // TODO: uncomment committer: "mysql-test-runner", email: "mysql-test-runner@liquidata.co", }, @@ -28,9 +25,6 @@ export const logTests = [ }, { message: "Initialize data repository", - // committer: "Taylor Bantle", - // email: "taylor@liquidata.co", - // TODO: uncomment committer: "mysql-test-runner", email: "mysql-test-runner@liquidata.co", }, diff --git a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js index e04bbc3956..75b13657de 100644 --- a/integration-tests/mysql-client-tests/node/workbenchTests/merge.js +++ b/integration-tests/mysql-client-tests/node/workbenchTests/merge.js @@ -35,9 +35,6 @@ export const mergeTests = [ { message: "Initialize data repository", parentsLength: 0, - // committer: "Taylor Bantle", - // email: "taylor@liquidata.co", - // TODO: uncomment committer: "mysql-test-runner", email: "mysql-test-runner@liquidata.co", },