1
This commit is contained in:
parent
48e7b73b87
commit
c7005a40f3
@ -1,52 +1,21 @@
|
||||
const axios = require('axios').default;
|
||||
const ws = require('nodejs-websocket');
|
||||
const ClientNet = require('./clientnet');
|
||||
const TestCase = require('./testcase');
|
||||
|
||||
function get(url, params) {
|
||||
return new Promise((resolve) => {
|
||||
const ret = {
|
||||
err: null,
|
||||
response: null,
|
||||
};
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
timeout: 1000 * 10,
|
||||
params: params,
|
||||
responseType: 'text'
|
||||
}).then((response) => {
|
||||
ret.response = response.data;
|
||||
resolve(ret);
|
||||
}).catch((error) => {
|
||||
ret.err = error;
|
||||
resolve(ret);
|
||||
});
|
||||
});
|
||||
}
|
||||
const urls = {
|
||||
'login': 'https://login-z2-test.cebg.games',
|
||||
'relation': 'wss://relation-test.kingsome.cn/friend/websocket',
|
||||
'cloud': 'https://cloud-z2-test.cebg.games',
|
||||
'service': 'https://service-z2-test.cebg.games',
|
||||
'gamelog': 'https://gamelog-z2-test.cebg.games',
|
||||
'mail': 'https://gamemail-z2-test.cebg.games',
|
||||
'game2006api': 'https://game2006api-z2-test.cebg.games',
|
||||
'game2006': 'https://game2006-z2-test.cebg.games',
|
||||
'game2006-n1': 'https://game2006-n1-z2-test.cebg.games',
|
||||
};
|
||||
|
||||
async function start() {
|
||||
let loginData = null;
|
||||
//console.log(err, root);
|
||||
{
|
||||
const {err, response} = await get(
|
||||
'https://login-z2-test.cebg.games/webapp/index.php',
|
||||
{
|
||||
'c': 'Login',
|
||||
'a': 'auth',
|
||||
'gameid': 2006,
|
||||
'channel': 6513,
|
||||
'account': '123456',
|
||||
'openid': '123456'
|
||||
});
|
||||
loginData = response;
|
||||
console.log(loginData);
|
||||
}
|
||||
const clientNet = new ClientNet(
|
||||
'wss://relation-test.kingsome.cn/friend/websocket',
|
||||
'proto/friend/cs_proto.proto',
|
||||
'proto/friend/cs_msgid.proto'
|
||||
);
|
||||
await clientNet.init();
|
||||
const testCase = new TestCase(urls);
|
||||
await testCase.init();
|
||||
/*await clientNet.init();
|
||||
await clientNet.connect();
|
||||
clientNet.on('connect', () => {
|
||||
console.log('onConnect');
|
||||
@ -57,7 +26,7 @@ async function start() {
|
||||
accountId: loginData['account_id'],
|
||||
sessionId: loginData['session_id'],
|
||||
});
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
start();
|
||||
|
@ -41,7 +41,7 @@ class ClientNet {
|
||||
|
||||
async #onReceive(inStream) {
|
||||
inStream.on('readable', async () => {
|
||||
console.log('inStream.readable');
|
||||
//console.log('inStream.readable');
|
||||
const newData = inStream.read();
|
||||
if (newData) {
|
||||
this.recvBuf = Buffer.concat([this.recvBuf, newData]);
|
||||
@ -49,10 +49,10 @@ class ClientNet {
|
||||
}
|
||||
});
|
||||
inStream.on('end', () => {
|
||||
console.log('inStream.end', this.recvBuf.length);
|
||||
//console.log('inStream.end', this.recvBuf.length);
|
||||
});
|
||||
inStream.on('close', () => {
|
||||
console.log('inStream.close');
|
||||
//console.log('inStream.close');
|
||||
});
|
||||
}
|
||||
|
||||
@ -129,6 +129,7 @@ class ClientNet {
|
||||
buf.writeUInt8('S'.charCodeAt(0), 9);
|
||||
buf.writeInt16LE(0, 10);
|
||||
this.conn.sendBinary(Buffer.concat([buf, msgBuf]));
|
||||
console.log(name, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
125
scripts/check_server/testcase.js
Normal file
125
scripts/check_server/testcase.js
Normal file
@ -0,0 +1,125 @@
|
||||
const axios = require('axios').default;
|
||||
const ClientNet = require('./clientnet');
|
||||
|
||||
function httpGet(url, params) {
|
||||
return new Promise((resolve) => {
|
||||
const ret = {
|
||||
err: null,
|
||||
response: null,
|
||||
};
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
timeout: 1000 * 10,
|
||||
params: params,
|
||||
responseType: 'text'
|
||||
}).then((response) => {
|
||||
ret.response = response.data;
|
||||
resolve(ret);
|
||||
}).catch((error) => {
|
||||
ret.err = error;
|
||||
resolve(ret);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class TestCase {
|
||||
|
||||
constructor(urls) {
|
||||
this.urls = urls;
|
||||
this.loginData = '';
|
||||
this.relationWs = new ClientNet(
|
||||
this.urls['relation'],
|
||||
'proto/friend/cs_proto.proto',
|
||||
'proto/friend/cs_msgid.proto'
|
||||
);
|
||||
this.battleWs = new ClientNet(
|
||||
this.urls['game2006'],
|
||||
'proto/battle/cs_proto.proto',
|
||||
'proto/battle/cs_msgid.proto'
|
||||
);
|
||||
}
|
||||
|
||||
async init() {
|
||||
await this.step1();
|
||||
await this.step2();
|
||||
await this.step3();
|
||||
await this.step4();
|
||||
await this.step5();
|
||||
await this.step6();
|
||||
}
|
||||
|
||||
async step1() {
|
||||
const {err, response} = await httpGet(
|
||||
this.urls['login'] + '/webapp/index.php',
|
||||
{
|
||||
'c': 'Login',
|
||||
'a': 'auth',
|
||||
'gameid': 2006,
|
||||
'channel': 6513,
|
||||
'account': '123456',
|
||||
'openid': '123456'
|
||||
});
|
||||
this.loginData = response;
|
||||
console.log('login auth@Login');
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
async step2() {
|
||||
const {err, response} = await httpGet(
|
||||
this.urls['cloud'] + '/webapp/index.php',
|
||||
{
|
||||
'c': 'Ops',
|
||||
'a': 'selfChecking',
|
||||
});
|
||||
console.log('cloud selfChecking@Ops');
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
async step3() {
|
||||
const {err, response} = await httpGet(
|
||||
this.urls['service'] + '/webapp/index.php',
|
||||
{
|
||||
'c': 'Ops',
|
||||
'a': 'selfChecking',
|
||||
});
|
||||
console.log('service selfChecking@Ops');
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
async step4() {
|
||||
const {err, response} = await httpGet(
|
||||
this.urls['gamelog'] + '/webapp/index.php',
|
||||
{
|
||||
'c': 'Ops',
|
||||
'a': 'selfChecking',
|
||||
});
|
||||
console.log('gamelog selfChecking@Ops');
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
async step5() {
|
||||
const {err, response} = await httpGet(
|
||||
this.urls['mail'] + '/webapp/index.php',
|
||||
{
|
||||
'c': 'Ops',
|
||||
'a': 'selfChecking',
|
||||
});
|
||||
console.log('mail selfChecking@Ops');
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
async step6() {
|
||||
const {err, response} = await httpGet(
|
||||
this.urls['game2006api'] + '/webapp/index.php',
|
||||
{
|
||||
'c': 'Ops',
|
||||
'a': 'selfChecking',
|
||||
});
|
||||
console.log('game2006api selfChecking@Ops');
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = TestCase;
|
Loading…
x
Reference in New Issue
Block a user