Blame view

loadtest.js 2.07 KB
e45082dc   Nattapon Wongpaet   update mockup
1
2
3
4
5
6
7
8
9
10
11
12
const loadtest = require('loadtest');
 
function statusCallback(error, result, latency) {
    console.log('Current latency %j, result %j, error %j', latency, result, error);
    console.log('----');
    if(result) {
        console.log('Request elapsed milliseconds: ', result.requestElapsed);
        console.log('Request index: ', result.requestIndex);
        console.log('Request loadtest() instance index: ', result.instanceIndex);
    }
}
 
ce84539c   Nattapon Wongpaet   update gen file
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const options = {
    url: 'http://127.0.0.1:5001/api/v3/mpay/billingonbehalf/reserveAndChargeVolume.json',
    maxRequests: 10000,
    requestsPerSecond: 100,
    headers : {
        "Content-Type":"application/json",
        "x-app":"partnerId=30163; ptsAppKeyName=PICO|Browser|1.0.0",
        "x-tid":"SACF-300519siwkxkw7du",
        "X-Public-Id":"sgltest7@corp.ais900dev.org",
        "X-Private-Id":"NI5smn3wWpoPX1ma2jbPiE8hK4QcDqHR1582013702233"
    },
    method: "POST",
    body : {
        "endUserIdentifier":"66932019877",
        "volume":"0",
        "out_trade_no":"nw424bc0bb690c73518a762a2d1a339d7f_COINS12000_20190219095515",
        "subject":"Purchased 12000 coins.",
        "pay_time":"2020-03-24 20:20:20",
        "device_id":"90c73518a762a2d1a339d7f",
        "buyer_pay_fee":"Paid by user",
        "coupon_fee":"20",
        "terminal_type":"IOS",
        "billingText":"test",
        "parameters":{
           "amount":"0",
           "serviceNumber":"35000900022",
           "serviceType":"Download",
           "transactionID":"50609152601999918991",
           "currency":"THB",
           "taxDev":"0",
           "productCode":"Purchased 12000 coins that can be spent on weapons.",
           "productInfo":"COINS12000",
           "merchantContact":"MerchantContactTest",
           "cct":"0",
           "expireDate":"20200523142045",
           "senderName":"Huawei"
        }
     },
    contentType : "application/json",
    statusCallback: statusCallback
};
 
e45082dc   Nattapon Wongpaet   update mockup
55
loadtest.loadTest(options, function(error) {
ce84539c   Nattapon Wongpaet   update gen file
56
57
58
    if (error) {
        return console.error('Got an error: %s', error);
    }
e45082dc   Nattapon Wongpaet   update mockup
59
60
    console.log('Tests run successfully');
});
ce84539c   Nattapon Wongpaet   update gen file

e45082dc   Nattapon Wongpaet   update mockup

ce84539c   Nattapon Wongpaet   update gen file

e45082dc   Nattapon Wongpaet   update mockup