From 3224babd1c6bfb971b167411f8a9f907c0bc895f Mon Sep 17 00:00:00 2001 From: shonge Date: Thu, 22 Jul 2021 03:54:23 +0800 Subject: [PATCH] support run bench tpcc on playground --- package.json | 38 +++++++++++++++++++++++++++++++++++++- src/extension.ts | 15 +++++++++++++-- src/playground/command.ts | 20 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fd2e61e..9c6d2f6 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,22 @@ "command": "ticode.playground.restart", "title": "Restart" }, + { + "command": "ticode.playground.tpccPrepare", + "title": "TPCC-Prepare" + }, + { + "command": "ticode.playground.tpccRun", + "title": "TPCC-Run" + }, + { + "command": "ticode.playground.tpccCleanUp", + "title": "TPCC-CleanUp" + }, + { + "command": "ticode.playground.tpccCheck", + "title": "TPCC-Check" + }, { "command": "ticode.cluster.refresh", "title": "TiCode: Refresh Cluters", @@ -342,6 +358,26 @@ "when": "view == ticode-tiup-playground && viewItem =~ /^playground-instance-tidb/", "group": "1@1" }, + { + "command": "ticode.playground.tpccPrepare", + "when": "view == ticode-tiup-playground && viewItem =~ /^playground-instance-tidb/", + "group": "2@1" + }, + { + "command": "ticode.playground.tpccRun", + "when": "view == ticode-tiup-playground && viewItem =~ /^playground-instance-tidb/", + "group": "2@2" + }, + { + "command": "ticode.playground.tpccCleanUp", + "when": "view == ticode-tiup-playground && viewItem =~ /^playground-instance-tidb/", + "group": "2@3" + }, + { + "command": "ticode.playground.tpccCheck", + "when": "view == ticode-tiup-playground && viewItem =~ /^playground-instance-tidb/", + "group": "2@4" + }, { "command": "ticode.playground.debugCluster", "when": "view == ticode-tiup-playground && viewItem == playground-cluster", @@ -520,4 +556,4 @@ "shelljs": "^0.8.4", "tmp": "^0.2.1" } -} +} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index d61bfeb..f2959ba 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -114,7 +114,18 @@ export async function activate(context: vscode.ExtensionContext) { registerCommand('ticode.playground.connectMySQL', (treeItem) => { PlaygroundCommand.connectMySQL(tiup) }), - + registerCommand('ticode.playground.tpccPrepare', (treeItem) => { + PlaygroundCommand.tpccPrepare(tiup) + }), + registerCommand('ticode.playground.tpccRun', (treeItem) => { + PlaygroundCommand.tpccRun(tiup) + }), + registerCommand('ticode.playground.tpccCleanUp', (treeItem) => { + PlaygroundCommand.tpccCleanUp(tiup) + }), + registerCommand('ticode.playground.tpccCheck', (treeItem) => { + PlaygroundCommand.tpccCheck(tiup) + }), /** * TiUP Cluster */ @@ -349,7 +360,7 @@ export async function activate(context: vscode.ExtensionContext) { } // this method is called when your extension is deactivated -export function deactivate() {} +export function deactivate() { } function registerCommand( command: string, diff --git a/src/playground/command.ts b/src/playground/command.ts index 0ce41d1..575810e 100644 --- a/src/playground/command.ts +++ b/src/playground/command.ts @@ -253,6 +253,26 @@ export class PlaygroundCommand { tiup.invokeAnyInNewTerminal(cmd, 'connect tidb') } + static async tpccPrepare(tiup: TiUP) { + const cmd = `tiup bench tpcc prepare --host 127.0.0.1 --port 4000 --user root` + tiup.invokeAnyInNewTerminal(cmd, 'TPCC Prepare') + } + + static async tpccRun(tiup: TiUP) { + const cmd = `tiup bench tpcc run --host 127.0.0.1 --port 4000 --user root` + tiup.invokeAnyInNewTerminal(cmd, 'TPCC Run') + } + + static async tpccCleanUp(tiup: TiUP) { + const cmd = `tiup bench tpcc cleanup --host 127.0.0.1 --port 4000 --user root` + tiup.invokeAnyInNewTerminal(cmd, 'TPCC CleanUp') + } + + static async tpccCheck(tiup: TiUP) { + const cmd = `tiup bench tpcc check --host 127.0.0.1 --port 4000 --user root` + tiup.invokeAnyInNewTerminal(cmd, 'TPCC Check') + } + static async stopPlayground() { // use "ps ax" instead of "ps aux" make the PID first column let cr = await shell.exec('ps ax | grep tiup-playground | grep -v grep')