Skip to content

Commit

Permalink
support run bench tpcc on playground
Browse files Browse the repository at this point in the history
  • Loading branch information
shonge committed Jul 21, 2021
1 parent 2506020 commit 3224bab
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
38 changes: 37 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -520,4 +556,4 @@
"shelljs": "^0.8.4",
"tmp": "^0.2.1"
}
}
}
15 changes: 13 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions src/playground/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 3224bab

Please sign in to comment.