Better fix for TrafficShapingHandlerTest
Motivation: The test procedure is unstable when testing quick time (factor less or equal to 1). Changing to default 10ms in this case will force time to be correct and time to be checked only when factor is >= 2. Modifications: When factor is <= 1, minimalWaitBetween is 10ms Result: Hoping this version is finally stable.
This commit is contained in:
parent
0ca84b3527
commit
bcbc23913e
@ -58,7 +58,7 @@ public class TrafficShapingHandlerTest extends AbstractSocketTest {
|
|||||||
static final int bandwidthFactor = 12;
|
static final int bandwidthFactor = 12;
|
||||||
static final int minfactor = 3;
|
static final int minfactor = 3;
|
||||||
static final int maxfactor = bandwidthFactor + (bandwidthFactor / 2);
|
static final int maxfactor = bandwidthFactor + (bandwidthFactor / 2);
|
||||||
static final long stepms = 1000 / bandwidthFactor;
|
static final long stepms = (1000 / bandwidthFactor - 10) / 10 * 10;
|
||||||
static final long minimalms = Math.max(stepms / 2, 20) / 10 * 10;
|
static final long minimalms = Math.max(stepms / 2, 20) / 10 * 10;
|
||||||
static final long check = 10;
|
static final long check = 10;
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
@ -97,7 +97,11 @@ public class TrafficShapingHandlerTest extends AbstractSocketTest {
|
|||||||
long[] minimalWaitBetween = new long[multipleMessage.length + 1];
|
long[] minimalWaitBetween = new long[multipleMessage.length + 1];
|
||||||
minimalWaitBetween[0] = 0;
|
minimalWaitBetween[0] = 0;
|
||||||
for (int i = 0; i < multipleMessage.length; i++) {
|
for (int i = 0; i < multipleMessage.length; i++) {
|
||||||
minimalWaitBetween[i + 1] = (multipleMessage[i] - 1) * stepms + minimalms;
|
if (multipleMessage[i] > 1) {
|
||||||
|
minimalWaitBetween[i + 1] = (multipleMessage[i] - 1) * stepms + minimalms;
|
||||||
|
} else {
|
||||||
|
minimalWaitBetween[i + 1] = 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return minimalWaitBetween;
|
return minimalWaitBetween;
|
||||||
}
|
}
|
||||||
@ -105,7 +109,11 @@ public class TrafficShapingHandlerTest extends AbstractSocketTest {
|
|||||||
private static long[] computeWaitWrite(int[] multipleMessage) {
|
private static long[] computeWaitWrite(int[] multipleMessage) {
|
||||||
long[] minimalWaitBetween = new long[multipleMessage.length + 1];
|
long[] minimalWaitBetween = new long[multipleMessage.length + 1];
|
||||||
for (int i = 0; i < multipleMessage.length; i++) {
|
for (int i = 0; i < multipleMessage.length; i++) {
|
||||||
minimalWaitBetween[i] = (multipleMessage[i] - 1) * stepms + minimalms;
|
if (multipleMessage[i] > 1) {
|
||||||
|
minimalWaitBetween[i] = (multipleMessage[i] - 1) * stepms + minimalms;
|
||||||
|
} else {
|
||||||
|
minimalWaitBetween[i] = 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return minimalWaitBetween;
|
return minimalWaitBetween;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user