Skip to content

Commit 8853ef7

Browse files
committed
setLimits() with enable param test has written, but skipped. issue 510 -bmp
1 parent 32a6d66 commit 8853ef7

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

tests/main.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -870,46 +870,53 @@ describe('BrowserMob Proxy Client general test', () => {
870870
console.log(value);
871871
done(new Error(value));});
872872
});
873-
it('should setup latency to each HTTP request', (done) => {
873+
/*
874+
skip - look here : https://github.com/lightbody/browsermob-proxy/issues/510
875+
*/
876+
it.skip('should setup latency to each HTTP request', (done) => {
877+
878+
const upstreamKbps = 100;
879+
const deltaInPercent = 1;
880+
const enable = 'false';
874881

875-
const latency = 1000;
876-
const deltaInPercent = 10;
877-
const limitsSetterObject = { latency : latency};
878882

883+
let limitsSetterObject = { upstreamKbps : upstreamKbps};
879884
let browserMobProxyClient = undefined;
880885

881886
(new bmpClient(bmpHost, bmpPort)).create()
882887
.then((client) => {
883888
browserMobProxyClient = client;
884889
return browserMobProxyClient.setLimits(limitsSetterObject);
885890
})
891+
.then(() => {
892+
limitsSetterObject = {enable : enable};
893+
return browserMobProxyClient.setLimits(limitsSetterObject);
894+
})
886895
.then(() => {
887896
return browserMobProxyClient.newHar();
888897
})
889898
.then(() => {
890-
return request(`${moronHTTPUrl}`,
899+
return request(`${moronHTTPUrl}/1MbitContent`,
891900
{method : 'GET', proxy : `http://${bmpHost}:${browserMobProxyClient.port}`});
892901
})
893902
.then(() => {
894903
return browserMobProxyClient.getHar();
895904
})
896905
.then((har) => {
906+
console.log(har.log.entries[0].timings);
907+
const duration = har.log.entries[0].timings.receive;
908+
const currentUpstreamSpeed = (moronHTTP.oneMbitBuffer.length / 1024) / (duration / 1000);
909+
const currentDeltaInPercent = (currentUpstreamSpeed > upstreamKbps) ?
910+
(100 - (currentUpstreamSpeed - upstreamKbps) / currentUpstreamSpeed * 100)
911+
: (100 - (upstreamKbps - currentUpstreamSpeed) / upstreamKbps * 100);
897912

898-
const duration = har.log.entries[0].timings.send;
899-
const currentSpeed = (moronHTTP.oneMbitBuffer.length / 1024) / (duration / 1000);
900-
901-
let currentDeltaInPercent = currentSpeed/latency * 100 - 100;
902-
903-
if(currentDeltaInPercent > deltaInPercent){
904-
currentDeltaInPercent = latency/currentSpeed * 100 - 100;
905-
if(currentDeltaInPercent <= deltaInPercent) {
906-
done();
907-
} else {
908-
done(new Error('Delta between current latency speed and expected is too big'));
909-
}
910-
} else {
913+
console.log(`duration : ${duration/1000}, curentDeltaInPercent : ${currentDeltaInPercent}%`);
914+
if(currentDeltaInPercent <= deltaInPercent) {
911915
done();
916+
} else {
917+
done(new Error('Delta between current upstream speed and expected is too big'));
912918
}
919+
913920
})
914921
.catch((value) => {
915922
console.log(value);

0 commit comments

Comments
 (0)