Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Add more test domains. (#12898)

Dave Bakkerf10f708c0412
diff --git a/crates/test-programs/src/bin/p2_ip_name_lookup.rs b/crates/test-programs/src/bin/p2_ip_name_lookup.rs
index 9e8e6eb531..3930d8e608 100644
--- a/crates/test-programs/src/bin/p2_ip_name_lookup.rs
+++ b/crates/test-programs/src/bin/p2_ip_name_lookup.rs
@@ -5,7 +5,13 @@ fn main() {
// Valid domains
resolve("localhost").unwrap();
- resolve_at_least_one_of(&["example.com", "api.github.com"]);
+ resolve_at_least_one_of(&[
+ "example.com",
+ "api.github.com",
+ "docs.wasmtime.dev",
+ "bytecodealliance.org",
+ "www.rust-lang.org",
+ ]);
// NB: this is an actual real resolution, so it might time out, might cause
// issues, etc. This result is ignored to prevent flaky failures in CI.
diff --git a/crates/test-programs/src/bin/p3_sockets_ip_name_lookup.rs b/crates/test-programs/src/bin/p3_sockets_ip_name_lookup.rs
index b8b72a2a43..6437c09b01 100644
--- a/crates/test-programs/src/bin/p3_sockets_ip_name_lookup.rs
+++ b/crates/test-programs/src/bin/p3_sockets_ip_name_lookup.rs
@@ -1,4 +1,3 @@
-use futures::join;
use test_programs::p3::wasi::sockets::ip_name_lookup::{ErrorCode, resolve_addresses};
use test_programs::p3::wasi::sockets::types::IpAddress;
@@ -14,16 +13,33 @@ async fn resolve_one(name: &str) -> Result<IpAddress, ErrorCode> {
.to_owned())
}
+/// Attempts to resolve at least one of `domains`. Allows failure so long as one
+/// succeeds. Intended to help make this test less flaky while still also
+/// testing live services.
+async fn resolve_at_least_one_of(domains: &[&str]) {
+ for domain in domains {
+ match resolve_one(domain).await {
+ Ok(_) => return,
+ Err(e) => eprintln!("failed to resolve `{domain}`: {e}"),
+ }
+ }
+
+ panic!("should have been able to resolve at least one domain");
+}
+
impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
async fn run() -> Result<(), ()> {
// Valid domains
- let (res0, res1) = join!(
- resolve_addresses("localhost".into()),
- resolve_addresses("example.com".into())
- );
- if res0.is_err() && res1.is_err() {
- panic!("should have been able to resolve at least one domain");
- }
+ resolve_one("localhost").await.unwrap();
+
+ resolve_at_least_one_of(&[
+ "example.com",
+ "api.github.com",
+ "docs.wasmtime.dev",
+ "bytecodealliance.org",
+ "www.rust-lang.org",
+ ])
+ .await;
// NB: this is an actual real resolution, so it might time out, might cause
// issues, etc. This result is ignored to prevent flaky failures in CI.