gemercheung 3 rokov pred
rodič
commit
95f69b62f8

+ 9 - 6
packages/main/command/test.mjs

@@ -3,6 +3,11 @@ import customParser from "socket.io-msgpack-parser";
 
 const url = process.argv[2];
 const count = process.argv[3];
+const userStartId = process.argv[4];
+const testSceneNum = process.argv[5] || "t-test";
+const roomId = process.argv[6] || "00001";
+
+console.log("argv", userStartId, testSceneNum, roomId);
 
 console.log("socket-info::url:config-->", url);
 console.log("socket-info::url:count-->", count);
@@ -17,15 +22,15 @@ const EMIT_INTERVAL_IN_MS = 1000;
 let clientCount = 0;
 let lastReport = new Date().getTime();
 let packetsSinceLastReport = 0;
-let testSceneNum = "t-test";
-let roomId = "00001";
-let userLimitNum = 2000;
+// let testSceneNum = "t-test";
+// let roomId = "00001";
+let userLimitNum = MAX_CLIENTS;
 let agentId = 0;
 
 const createAgent = () => {
   agentId += 1;
   const nickName = `test_name_${agentId}`;
-  const userId = `6666666${agentId}`;
+  const userId = `${userStartId}${agentId}`;
   const role = agentId === 1 ? "leader" : "customer";
   createClient({ userId, nickName, from: "0", role: role });
   createClient({ userId, nickName, from: "1", role: role });
@@ -91,5 +96,3 @@ const printReport = () => {
 };
 
 setInterval(printReport, 5000);
-
-// console.log("argv", process.argv);

+ 9 - 3
packages/main/src/mainWindow.ts

@@ -38,7 +38,12 @@ async function createWindow() {
     }
     ipcMain.on('start-Benmark-test', (_, data) => {
       console.log('hey', data);
-      const { url, count, stop } = data;
+      const {
+        url,
+        count,
+        userStartId,
+        testSceneNum,
+        roomId, stop } = data;
       if (stop) {
         try {
           if (ptyProcess) {
@@ -61,10 +66,11 @@ async function createWindow() {
 
         const BenmarkFilePath = join(__dirname, '../../main/command/test.mjs');
         const nodePathProduction = join(process.resourcesPath, 'app/node_modules/node/bin/node.exe');
-        const nodePath =  app.isPackaged ? nodePathProduction :'node';
+        const nodePath = app.isPackaged ? nodePathProduction : 'node';
 
         // browserWindow.webContents.send('terminal.resourcesPath', app.isPackaged);
-        ptyProcess = pty.spawn(shell, [`${nodePath} ${BenmarkFilePath}`, `${url}`, `${count}`], {
+        ptyProcess = pty.spawn(shell, [`${nodePath} ${BenmarkFilePath}`, `${url}`, `${count}`, 
+        `${userStartId}`, `${testSceneNum}`, `${roomId}`], {
           name: 'xterm-color',
           cols: 80,
           rows: 30,

+ 2 - 0
packages/main/src/muti-client.mjs

@@ -1,3 +1,5 @@
+
+// demo 
 import { io } from "socket.io-client";
 import customParser from "socket.io-msgpack-parser";
 const URL = process.env.URL || "wss://test-socket.4dkankan.com";

+ 30 - 12
packages/renderer/src/App.vue

@@ -9,6 +9,9 @@ import { FitAddon } from 'xterm-addon-fit';
 const config = ref({
   url: 'wss://test-socket.4dkankan.com',
   count: 200,
+  userStartId: '6666666',
+  testSceneNum: 't-test',
+  roomId: '00001',
   isStart: false,
 });
 let terminal: Terminal | null;
@@ -42,6 +45,9 @@ function start() {
   ipc.send('start-Benmark-test', {
     url: config.value.url,
     count: config.value.count,
+    userStartId: config.value.userStartId,
+    testSceneNum: config.value.testSceneNum,
+    roomId: config.value.roomId,
   });
 }
 function stop() {
@@ -67,22 +73,34 @@ function stop() {
     <figure>
       <span class="label">测试人数:</span> <input v-model="config.count">
     </figure>
+    <figure>
+      <span class="label">用户起始ID:</span>
+      <input v-model="config.userStartId">
+    </figure>
+    <figure>
+      <span class="label">测试场景号:</span>
+      <input v-model="config.testSceneNum">
+    </figure>
+    <figure>
+      <span class="label">测试房间号:</span>
+      <input v-model="config.roomId">
+    </figure>
   </fieldset>
 
   <div class="btns">
-    <button
-      v-show="!config.isStart"
-      class="start"
-      @click="start"
+    <button
+      v-show="!config.isStart"
+      class="start"
+      @click="start"
     >
       开始测试
     </button>
-    <button
-      v-show="config.isStart"
-      class="end"
-      @click="stop"
-    >
-      停止测试
+    <button
+      v-show="config.isStart"
+      class="end"
+      @click="stop"
+    >
+      停止测试
     </button>
   </div>
   <div id="terminal" />
@@ -99,8 +117,8 @@ function stop() {
   max-width: 700px;
 }
 fieldset {
-  margin: 2rem;
-  padding: 1rem;
+  margin: 10px;
+  padding: 10px;
 }
 fieldset .label {
   min-width: 120px;