Merge branch 'veilidchat-work' into 'main'
veilid-tools unit test fixes See merge request veilid/veilid!97
This commit is contained in:
commit
fe8e963af7
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -5896,7 +5896,6 @@ dependencies = [
|
|||||||
"oslog",
|
"oslog",
|
||||||
"paranoid-android",
|
"paranoid-android",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"parking_lot 0.12.1",
|
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"range-set-blaze",
|
"range-set-blaze",
|
||||||
"rust-fsm",
|
"rust-fsm",
|
||||||
|
@ -115,10 +115,12 @@ build-linux-arm64:
|
|||||||
# Unit tests
|
# Unit tests
|
||||||
unit-tests-linux-amd64:
|
unit-tests-linux-amd64:
|
||||||
FROM +code-linux
|
FROM +code-linux
|
||||||
|
ENV RUST_BACKTRACE=1
|
||||||
RUN cargo test --target x86_64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo test --target x86_64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
||||||
|
|
||||||
# unit-tests-linux-arm64:
|
# unit-tests-linux-arm64:
|
||||||
# FROM +code-linux
|
# FROM +code-linux
|
||||||
|
# ENV RUST_BACKTRACE=1
|
||||||
# RUN cargo test --target aarch64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
# RUN cargo test --target aarch64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
||||||
|
|
||||||
# Package
|
# Package
|
||||||
|
@ -338,8 +338,9 @@ Future<T> processFuturePlain<T>(Future<dynamic> future) {
|
|||||||
switch (list[0] as int) {
|
switch (list[0] as int) {
|
||||||
case messageOk:
|
case messageOk:
|
||||||
{
|
{
|
||||||
if (list[1] == null) {
|
if (list[1] == null && null is! T) {
|
||||||
throw VeilidAPIExceptionInternal("Null MESSAGE_OK value");
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
"Null MESSAGE_OK value on non-nullable type");
|
||||||
}
|
}
|
||||||
return list[1] as T;
|
return list[1] as T;
|
||||||
}
|
}
|
||||||
@ -377,10 +378,15 @@ Future<T> processFutureJson<T>(
|
|||||||
}
|
}
|
||||||
case messageOkJson:
|
case messageOkJson:
|
||||||
{
|
{
|
||||||
if (list[1] == null) {
|
if (list[1] is! String) {
|
||||||
throw VeilidAPIExceptionInternal("Null MESSAGE_OK_JSON value");
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
"Non-string MESSAGE_OK_JSON value");
|
||||||
}
|
}
|
||||||
var ret = jsonDecode(list[1] as String);
|
var ret = jsonDecode(list[1] as String);
|
||||||
|
if (ret == null) {
|
||||||
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
"Null JSON object on non nullable type");
|
||||||
|
}
|
||||||
return jsonConstructor(ret);
|
return jsonConstructor(ret);
|
||||||
}
|
}
|
||||||
case messageErrJson:
|
case messageErrJson:
|
||||||
@ -416,7 +422,14 @@ Future<T?> processFutureOptJson<T>(
|
|||||||
if (list[1] == null) {
|
if (list[1] == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (list[1] is! String) {
|
||||||
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
"Non-string MESSAGE_OK_JSON optional value");
|
||||||
|
}
|
||||||
var ret = jsonDecode(list[1] as String);
|
var ret = jsonDecode(list[1] as String);
|
||||||
|
if (ret == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return jsonConstructor(ret);
|
return jsonConstructor(ret);
|
||||||
}
|
}
|
||||||
case messageErrJson:
|
case messageErrJson:
|
||||||
|
@ -12,7 +12,7 @@ const MAX_LEN: usize = LengthType::MAX as usize;
|
|||||||
|
|
||||||
// XXX: keep statistics on all drops and why we dropped them
|
// XXX: keep statistics on all drops and why we dropped them
|
||||||
// XXX: move to config eventually?
|
// XXX: move to config eventually?
|
||||||
const FRAGMENT_LEN: usize = 1280 - HEADER_LEN;
|
pub const FRAGMENT_LEN: usize = 1280 - HEADER_LEN;
|
||||||
const MAX_CONCURRENT_HOSTS: usize = 256;
|
const MAX_CONCURRENT_HOSTS: usize = 256;
|
||||||
const MAX_ASSEMBLIES_PER_HOST: usize = 256;
|
const MAX_ASSEMBLIES_PER_HOST: usize = 256;
|
||||||
const MAX_BUFFER_PER_HOST: usize = 256 * 1024;
|
const MAX_BUFFER_PER_HOST: usize = 256 * 1024;
|
||||||
|
@ -86,7 +86,7 @@ pub async fn test_one_frag_out_in() {
|
|||||||
// Sending
|
// Sending
|
||||||
println!("sending");
|
println!("sending");
|
||||||
for _ in 0..10000 {
|
for _ in 0..10000 {
|
||||||
let random_len = (get_random_u32() % 1000) as usize + 1280;
|
let random_len = (get_random_u32() % 1000) as usize + FRAGMENT_LEN;
|
||||||
let mut message = vec![1u8; random_len];
|
let mut message = vec![1u8; random_len];
|
||||||
random_bytes(&mut message);
|
random_bytes(&mut message);
|
||||||
let remote_addr = random_sockaddr();
|
let remote_addr = random_sockaddr();
|
||||||
@ -289,7 +289,7 @@ pub async fn test_many_frags_with_drops() {
|
|||||||
println!("sending");
|
println!("sending");
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
let random_len = (get_random_u32() % 65536) as usize;
|
let random_len = (get_random_u32() % 65536) as usize;
|
||||||
if random_len > 1280 {
|
if random_len > FRAGMENT_LEN {
|
||||||
total_fragged += 1;
|
total_fragged += 1;
|
||||||
}
|
}
|
||||||
total_sent_size += random_len;
|
total_sent_size += random_len;
|
||||||
|
Loading…
Reference in New Issue
Block a user