tools/scripts/check_server/testcase.js
aozhiwei c7005a40f3 1
2022-04-28 11:59:30 +08:00

126 lines
2.7 KiB
JavaScript

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;