refactoring timeouts
This commit is contained in:
parent
b3d6ded23f
commit
9a2c014fbb
|
@ -190,7 +190,7 @@ this is just too unreliable at this point :(
|
|||
FileLog.MAIN.logLine("AUTOTEST setEngineType " + type);
|
||||
// sendCommand(CMD_PINS);
|
||||
currentEngineType = type;
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, 2 * Timeouts.CMD_TIMEOUT);
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT);
|
||||
// TODO: document the reason for this sleep?!
|
||||
sleep(1);
|
||||
sendCommand(getEnableCommand("self_stimulation"));
|
||||
|
@ -495,9 +495,9 @@ this is just too unreliable at this point :(
|
|||
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT);
|
||||
}
|
||||
|
||||
private static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) {
|
||||
private static void sendCommand(String command, int retryTimeoutMs, int timeoutMs) {
|
||||
assertNull("Fatal not expected", criticalError);
|
||||
IoUtil.sendCommand(command, retryTimeoutMs, totalTimeoutSeconds);
|
||||
IoUtil.sendCommand(command, retryTimeoutMs, timeoutMs);
|
||||
}
|
||||
|
||||
private static void assertEquals(double expected, double actual) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
import static com.rusefi.IoUtil.*;
|
||||
import static com.rusefi.RealHwTest.startRealHardwareTest;
|
||||
|
@ -25,12 +26,12 @@ public class EnduranceTest {
|
|||
IoUtil.realHardwareConnect(port);
|
||||
for (int i = 0; i < count; i++) {
|
||||
AutoTest.currentEngineType = 3;
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, AutoTest.COMPLEX_COMMAND_RETRY, 60);
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, AutoTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT);
|
||||
sleep(2);
|
||||
sendCommand(getEnableCommand("self_stimulation"));
|
||||
// IoUtil.changeRpm(1200);
|
||||
AutoTest.currentEngineType = 28;
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, AutoTest.COMPLEX_COMMAND_RETRY, 60);
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, AutoTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT);
|
||||
sleep(2);
|
||||
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class IoUtil {
|
|||
/**
|
||||
* blocking method which would for confirmation from rusEfi
|
||||
*/
|
||||
static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) {
|
||||
static void sendCommand(String command, int retryTimeoutMs, int timeoutMs) {
|
||||
final CountDownLatch responseLatch = new CountDownLatch(1);
|
||||
long time = System.currentTimeMillis();
|
||||
FileLog.MAIN.logLine("Sending command [" + command + "]");
|
||||
|
@ -53,15 +53,15 @@ public class IoUtil {
|
|||
FileLog.MAIN.logLine("Got confirmation in " + (System.currentTimeMillis() - begin) + "ms");
|
||||
}
|
||||
});
|
||||
wait(responseLatch, totalTimeoutSeconds);
|
||||
wait(responseLatch, timeoutMs);
|
||||
if (responseLatch.getCount() > 0)
|
||||
FileLog.MAIN.logLine("No confirmation in " + retryTimeoutMs);
|
||||
FileLog.MAIN.logLine("Command [" + command + "] executed in " + (System.currentTimeMillis() - time));
|
||||
}
|
||||
|
||||
static void wait(CountDownLatch responseLatch, int seconds) {
|
||||
static void wait(CountDownLatch responseLatch, int milliseconds) {
|
||||
try {
|
||||
responseLatch.await(seconds, TimeUnit.SECONDS);
|
||||
responseLatch.await(milliseconds, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
|
@ -153,13 +153,13 @@ public class TestingUtils {
|
|||
result.set(value);
|
||||
}
|
||||
});
|
||||
int timeout = 60;
|
||||
int timeoutMs = 60 * Timeouts.SECOND;
|
||||
long waitStartTime = System.currentTimeMillis();
|
||||
IoUtil.wait(engineChartLatch, timeout);
|
||||
IoUtil.wait(engineChartLatch, timeoutMs);
|
||||
FileLog.MAIN.logLine("got next chart in " + (System.currentTimeMillis() - waitStartTime) + "ms for engine_type " + AutoTest.currentEngineType);
|
||||
LinkManager.engineState.replaceStringValueAction(EngineReport.ENGINE_CHART, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
if (result.get() == null)
|
||||
throw new IllegalStateException("Chart timeout: " + timeout);
|
||||
throw new IllegalStateException("Chart timeout: " + timeoutMs);
|
||||
return result.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ public interface Timeouts {
|
|||
int SECOND = 1000;
|
||||
int COMMAND_TIMEOUT_SEC = 10; // seconds
|
||||
int BINARY_IO_TIMEOUT = 5 * SECOND;
|
||||
int CMD_TIMEOUT = 20;
|
||||
int READ_IMAGE_TIMEOUT = 60 * SECOND;
|
||||
|
||||
int CONNECTION_RESTART_DELAY = 20 * SECOND;
|
||||
int CONNECTION_STATUS_TIMEOUT = 3 * SECOND;
|
||||
|
||||
int CMD_TIMEOUT = 20 * SECOND;
|
||||
int SET_ENGINE_TIMEOUT = 60 * SECOND;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue