speed up tests: reduce SNMP timeout from 1s to 200ms
This commit is contained in:
parent
57ace0297b
commit
7b793b315a
1 changed files with 10 additions and 10 deletions
|
|
@ -50,13 +50,13 @@ struct SnmpIsolatedWalkHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
const SNMP_TIMEOUT_SECS: i64 = 10;
|
const SNMP_TIMEOUT_US: i64 = 10_000_000; // 10 seconds
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
const SNMP_RETRIES: i32 = 2;
|
const SNMP_RETRIES: i32 = 2;
|
||||||
|
|
||||||
// Use short timeouts in tests to avoid 90+ second waits on unreachable hosts
|
// Use short timeouts in tests - just enough to prove the operation fails
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
const SNMP_TIMEOUT_SECS: i64 = 1;
|
const SNMP_TIMEOUT_US: i64 = 200_000; // 200ms
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
const SNMP_RETRIES: i32 = 0;
|
const SNMP_RETRIES: i32 = 0;
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ impl SnmpClient {
|
||||||
port,
|
port,
|
||||||
&community,
|
&community,
|
||||||
version_num,
|
version_num,
|
||||||
SNMP_TIMEOUT_SECS * 1_000_000,
|
SNMP_TIMEOUT_US,
|
||||||
SNMP_RETRIES,
|
SNMP_RETRIES,
|
||||||
v3_config.as_ref(),
|
v3_config.as_ref(),
|
||||||
&oid,
|
&oid,
|
||||||
|
|
@ -262,7 +262,7 @@ impl SnmpClient {
|
||||||
port,
|
port,
|
||||||
&community,
|
&community,
|
||||||
version_num,
|
version_num,
|
||||||
SNMP_TIMEOUT_SECS * 1_000_000,
|
SNMP_TIMEOUT_US,
|
||||||
SNMP_RETRIES,
|
SNMP_RETRIES,
|
||||||
v3_config.as_ref(),
|
v3_config.as_ref(),
|
||||||
&oid,
|
&oid,
|
||||||
|
|
@ -395,7 +395,7 @@ impl SnmpSession {
|
||||||
port,
|
port,
|
||||||
comm_cstr.as_ptr(),
|
comm_cstr.as_ptr(),
|
||||||
version_num,
|
version_num,
|
||||||
SNMP_TIMEOUT_SECS * 1_000_000,
|
SNMP_TIMEOUT_US,
|
||||||
SNMP_RETRIES,
|
SNMP_RETRIES,
|
||||||
v3_c_config
|
v3_c_config
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -1091,7 +1091,7 @@ mod tests {
|
||||||
// sequential async operations.
|
// sequential async operations.
|
||||||
let client = SnmpClient::new();
|
let client = SnmpClient::new();
|
||||||
|
|
||||||
for _ in 0..3 {
|
for _ in 0..2 {
|
||||||
let result = client
|
let result = client
|
||||||
.get("192.0.2.1", "public", "2c", 161, "1.3.6.1.2.1.1.1.0", None)
|
.get("192.0.2.1", "public", "2c", 161, "1.3.6.1.2.1.1.1.0", None)
|
||||||
.await;
|
.await;
|
||||||
|
|
@ -1226,7 +1226,7 @@ mod tests {
|
||||||
161,
|
161,
|
||||||
"public",
|
"public",
|
||||||
2,
|
2,
|
||||||
SNMP_TIMEOUT_SECS * 1_000_000,
|
SNMP_TIMEOUT_US,
|
||||||
SNMP_RETRIES,
|
SNMP_RETRIES,
|
||||||
None,
|
None,
|
||||||
"1.3.6.1.2.1.1.1.0",
|
"1.3.6.1.2.1.1.1.0",
|
||||||
|
|
@ -1241,7 +1241,7 @@ mod tests {
|
||||||
161,
|
161,
|
||||||
"public",
|
"public",
|
||||||
2,
|
2,
|
||||||
SNMP_TIMEOUT_SECS * 1_000_000,
|
SNMP_TIMEOUT_US,
|
||||||
SNMP_RETRIES,
|
SNMP_RETRIES,
|
||||||
None,
|
None,
|
||||||
"not-a-valid-oid",
|
"not-a-valid-oid",
|
||||||
|
|
@ -1260,7 +1260,7 @@ mod tests {
|
||||||
161,
|
161,
|
||||||
"public",
|
"public",
|
||||||
2,
|
2,
|
||||||
SNMP_TIMEOUT_SECS * 1_000_000,
|
SNMP_TIMEOUT_US,
|
||||||
SNMP_RETRIES,
|
SNMP_RETRIES,
|
||||||
None,
|
None,
|
||||||
"1.3.6.1.2.1.1",
|
"1.3.6.1.2.1.1",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue