Skip to content

Commit

Permalink
Fix a bunch of issues with tests
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Hollensbe <[email protected]>
  • Loading branch information
erikh committed Mar 30, 2022
1 parent 8d51d33 commit 82dcc02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
47 changes: 25 additions & 22 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod sixplane {
let mut ips = service.lookup_aaaa(record.clone()).await;
ips.sort();

assert_eq!(ips.sort(), listen_ips.clone().to_ipv6_vec().sort());
assert_eq!(ips, listen_ips.clone().to_ipv6_vec());
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ mod rfc4193 {
let mut ips = service.lookup_aaaa(record.clone()).await;
ips.sort();

assert_eq!(ips.sort(), listen_ips.clone().to_ipv6_vec().sort());
assert_eq!(ips, listen_ips.clone().to_ipv6_vec());
}

let ptr_records: Vec<String> = service
Expand Down Expand Up @@ -204,10 +204,10 @@ mod rfc4193 {
for _ in 0..10000 {
// randomly switch order
if rand::random::<bool>() {
assert_eq!(
service.lookup_aaaa(record.clone()).await.sort(),
listen_ips.clone().to_ipv6_vec().sort()
);
let mut ips = service.lookup_aaaa(record.clone()).await;
ips.sort();

assert_eq!(ips, listen_ips.clone().to_ipv6_vec(),);

assert_eq!(
service
Expand All @@ -229,10 +229,9 @@ mod rfc4193 {
&record.to_string()
);

assert_eq!(
service.lookup_aaaa(record.clone()).await.sort(),
listen_ips.clone().to_ipv6_vec().sort()
);
let mut ips = service.lookup_aaaa(record.clone()).await;
ips.sort();
assert_eq!(ips, listen_ips.clone().to_ipv6_vec(),);
}
}
}
Expand Down Expand Up @@ -454,7 +453,7 @@ mod ipv4 {
let mut ips = service.lookup_a(record.clone()).await;
ips.sort();

assert_eq!(ips.sort(), listen_ips.clone().to_ipv4_vec().sort());
assert_eq!(ips, listen_ips.clone().to_ipv4_vec());
}

let ptr_records: Vec<String> = service
Expand Down Expand Up @@ -485,10 +484,9 @@ mod ipv4 {
for _ in 0..10000 {
// randomly switch order
if rand::random::<bool>() {
assert_eq!(
service.lookup_a(record.clone()).await.sort(),
listen_ips.clone().to_ipv4_vec().sort()
);
let mut ips = service.lookup_a(record.clone()).await;
ips.sort();
assert_eq!(ips, listen_ips.clone().to_ipv4_vec(),);

assert_eq!(
service
Expand All @@ -510,10 +508,9 @@ mod ipv4 {
&record.to_string()
);

assert_eq!(
service.lookup_a(record.clone()).await.sort(),
listen_ips.clone().to_ipv4_vec().sort()
);
let mut ips = service.lookup_a(record.clone()).await;
ips.sort();
assert_eq!(ips, listen_ips.clone().to_ipv4_vec(),);
}
}
}
Expand Down Expand Up @@ -705,11 +702,13 @@ async fn test_get_listen_ip() -> Result<(), anyhow::Error> {
TestNetwork::new_multi_ip("basic-ipv4", &mut TestContext::default().await, ips.clone())
.await
.unwrap();
ips.sort();

let mut listen_ips =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap()).await?;
listen_ips.sort();

assert_eq!(listen_ips.sort(), ips.sort());
assert_eq!(listen_ips, ips);
eprintln!("My listen IPs are {}", listen_ips.join(", "));

let tn = TestNetwork::new("rfc4193-only", &mut TestContext::default().await)
Expand All @@ -718,10 +717,12 @@ async fn test_get_listen_ip() -> Result<(), anyhow::Error> {

let mut listen_ips =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap()).await?;
listen_ips.sort();

let mut ips = vec![tn.member().clone().rfc4193()?.ip().to_string()];
ips.sort();

assert_eq!(listen_ips.sort(), ips.sort());
assert_eq!(listen_ips, ips);
eprintln!("My listen IPs are {}", listen_ips.join(", "));

drop(tn);
Expand All @@ -732,10 +733,12 @@ async fn test_get_listen_ip() -> Result<(), anyhow::Error> {

let mut listen_ips =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap()).await?;
listen_ips.sort();

let mut ips = vec![tn.member().clone().sixplane()?.ip().to_string()];
ips.sort();

assert_eq!(listen_ips.sort(), ips.sort());
assert_eq!(listen_ips, ips);
eprintln!("My listen IPs are {}", listen_ips.join(", "));

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ fn create_resolvers(sockets: Vec<SocketAddr>) -> Resolvers {
});

let mut opts = ResolverOpts::default();
opts.timeout = Duration::new(10, 0);
opts.attempts = 10;
opts.cache_size = 0;
opts.rotate = true;
opts.use_hosts_file = false;
Expand Down

0 comments on commit 82dcc02

Please sign in to comment.