From 609ff9c28455b7a4d9749802075a983ea491cc52 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 17 Sep 2024 03:47:16 +0330 Subject: [PATCH 01/14] remove always false condition --- .github/workflows/test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f39c8b8fbde..bff23cc1594 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -847,7 +847,6 @@ jobs: run: | make untar-wasmer - name: Test integration CLI - if: false # matrix.build != 'macos-arm' shell: bash run: | export WASMER_PATH=`pwd`/target/${{ matrix.target }}/release/wasmer${{ matrix.exe }} From 7ff3c534371e80f4d8bcbeb0e0f93ef305865446 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Thu, 19 Sep 2024 00:13:56 +0330 Subject: [PATCH 02/14] fix most of the tests --- tests/integration/cli/tests/deploy.rs | 20 +++++++++++++++++++ tests/integration/cli/tests/login.rs | 4 +--- .../cli/tests/packages/axum/Cargo.toml | 19 ++++++++++++------ tests/integration/cli/tests/publish.rs | 6 ++++-- tests/integration/cli/tests/run.rs | 12 ++++------- 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/tests/integration/cli/tests/deploy.rs b/tests/integration/cli/tests/deploy.rs index 4b269ea8dae..83710fe41a0 100644 --- a/tests/integration/cli/tests/deploy.rs +++ b/tests/integration/cli/tests/deploy.rs @@ -201,6 +201,8 @@ fn wasmer_deploy_js() -> anyhow::Result<()> { #[test] fn wasmer_deploy_fails_no_app_name() -> anyhow::Result<()> { + let wapm_dev_token = std::env::var("WAPM_DEV_TOKEN").ok(); + let username = "ciuser"; let php_app_dir = project_root() @@ -230,6 +232,14 @@ fn wasmer_deploy_fails_no_app_name() -> anyhow::Result<()> { .arg(format!("--dir={}", app_dir.display())) .arg("--registry=wasmer.wtf"); + if let Some(token) = wapm_dev_token { + // Special case: GitHub secrets aren't visible to outside collaborators + if token.is_empty() { + return Ok(()); + } + cmd.arg("--token").arg(token); + } + cmd.assert().failure().stderr(predicates::str::contains( "The app.yaml does not specify any app name.", )); @@ -239,6 +249,8 @@ fn wasmer_deploy_fails_no_app_name() -> anyhow::Result<()> { #[test] fn wasmer_deploy_fails_no_owner() -> anyhow::Result<()> { + let wapm_dev_token = std::env::var("WAPM_DEV_TOKEN").ok(); + let app_name = format!("ci-{}", rand::random::()); let php_app_dir = project_root() @@ -268,6 +280,14 @@ fn wasmer_deploy_fails_no_owner() -> anyhow::Result<()> { .arg(format!("--dir={}", app_dir.display())) .arg("--registry=wasmer.wtf"); + if let Some(token) = wapm_dev_token { + // Special case: GitHub secrets aren't visible to outside collaborators + if token.is_empty() { + return Ok(()); + } + cmd.arg("--token").arg(token); + } + cmd.assert() .failure() .stderr(predicates::str::contains("No owner specified")); diff --git a/tests/integration/cli/tests/login.rs b/tests/integration/cli/tests/login.rs index 1dd58b5d51f..d30d28d8f52 100644 --- a/tests/integration/cli/tests/login.rs +++ b/tests/integration/cli/tests/login.rs @@ -55,7 +55,5 @@ fn run_whoami_works() { .assert() .success(); - assert.stdout( - "logged into registry \"https://registry.wasmer.wtf/graphql\" as user \"ciuser\"\n", - ); + assert.stdout("logged into registry wasmer.wtf as user \"ciuser\"\n"); } diff --git a/tests/integration/cli/tests/packages/axum/Cargo.toml b/tests/integration/cli/tests/packages/axum/Cargo.toml index ee730b73da7..43b99b68d82 100644 --- a/tests/integration/cli/tests/packages/axum/Cargo.toml +++ b/tests/integration/cli/tests/packages/axum/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "wasix-axum" version = "0.1.0" @@ -10,11 +12,16 @@ tracing = "0.1.37" tracing-subscriber = { version = "0.3.16", features = ["fmt"] } # NOTE: We need to pin and replace some dependencies to achieve wasix compatibility. -tokio = { version = "=1.24.2", default-features = false, features = ["full"] } -parking_lot = { version = "=0.12.1", features = ["nightly"] } +tokio = { version = "=1.35.1", default-features = false, features = ["full"] } +parking_lot = { version = "=0.12.3", features = ["nightly"] } +parking_lot_core = { version = "=0.9.10", features = ["nightly"] } +libc = { version = "=0.2.152" } [patch.crates-io] -tokio = { git = "https://github.com/wasix-org/tokio.git", branch = "wasix-1.24.2" } -socket2 = { git = "https://github.com/wasix-org/socket2.git", branch = "v0.4.9" } -libc = { git = "https://github.com/wasix-org/libc.git", branch = "master" } -parking_lot = { git = "https://github.com/wasix-org/parking_lot", branch = "master" } +tokio = { git = "https://github.com/wasix-org/tokio.git", branch = "wasix-1.35.1" } +socket2 = { git = "https://github.com/wasix-org/socket2.git", branch = "v0.5.5" } +libc = { git = "https://github.com/wasix-org/libc.git", branch = "v0.2.152" } + +[patch."https://github.com/wasix-org/parking_lot.git"] +parking_lot = { git = "https://github.com/Amanieu/parking_lot", branch = "master" } +parking_lot_core = { git = "https://github.com/Amanieu/parking_lot", branch = "master" } diff --git a/tests/integration/cli/tests/publish.rs b/tests/integration/cli/tests/publish.rs index 44393b0afa7..611f3d0167a 100644 --- a/tests/integration/cli/tests/publish.rs +++ b/tests/integration/cli/tests/publish.rs @@ -99,7 +99,7 @@ fn wasmer_init_publish() { let wapm_dev_token = std::env::var("WAPM_DEV_TOKEN").ok(); let tempdir = tempfile::tempdir().unwrap(); let path = tempdir.path(); - let username = "ciuser"; + let username = "amin"; let random1 = format!("{}", rand::random::()); let random2 = format!("{}", rand::random::()); @@ -206,7 +206,9 @@ fn wasmer_publish_and_run() { let assert = std::process::Command::new(get_wasmer_path()) .arg("run") - .arg(format!("https://wasmer.wtf/{package_name}")) + .arg(format!("{package_name}")) + .arg("--registry") + .arg("https://registry.wasmer.wtf/graphql") .arg("--") .arg("--eval") .arg("console.log('Hello, World!')") diff --git a/tests/integration/cli/tests/run.rs b/tests/integration/cli/tests/run.rs index baa0bd00f9d..36243c3b02c 100644 --- a/tests/integration/cli/tests/run.rs +++ b/tests/integration/cli/tests/run.rs @@ -430,8 +430,7 @@ fn run_test_caching_works_for_packages() { assert .success() - .stderr(contains("wapm_source: Querying the GraphQL API")) - .stderr(contains("builtin_loader: Downloading a webc file")) + .stderr(contains("builtin_loader: webc_package_download_start")) .stderr(contains("module_cache::filesystem: Saved to disk")); let assert = Command::new(get_wasmer_path()) @@ -445,7 +444,6 @@ fn run_test_caching_works_for_packages() { .success(); assert - .stderr(contains("wapm_source: Cache hit!")) .stderr(contains("builtin_loader: Cache hit!")) .stderr(contains("module_cache::filesystem: Cache hit!")); } @@ -466,8 +464,7 @@ fn run_test_caching_works_for_packages_with_versions() { assert .success() - .stderr(contains("wapm_source: Querying the GraphQL API")) - .stderr(contains("builtin_loader: Downloading a webc file")) + .stderr(contains("builtin_loader: webc_package_download_start")) .stderr(contains("module_cache::filesystem: Saved to disk")); let assert = Command::new(get_wasmer_path()) @@ -481,7 +478,6 @@ fn run_test_caching_works_for_packages_with_versions() { assert .success() - .stderr(contains("wapm_source: Cache hit!")) .stderr(contains("builtin_loader: Cache hit!")) .stderr(contains("module_cache::filesystem: Cache hit!")); } @@ -502,7 +498,7 @@ fn run_test_caching_works_for_urls() { assert .success() - .stderr(contains("builtin_loader: Downloading a webc file")) + .stderr(contains("builtin_loader: webc_package_download_start")) .stderr(contains("module_cache::filesystem: Saved to disk")); let assert = Command::new(get_wasmer_path()) @@ -520,7 +516,7 @@ fn run_test_caching_works_for_urls() { .stderr(contains("web_source: Cache hit")) // Cache hit downloading the *.webc file .stderr(contains( - r#"builtin_loader: Cache hit! pkg.name="python" pkg.version=0.1.0"#, + r#"builtin_loader: Cache hit! pkg=sha256:2cf6475ffcfd338775f8eae82af79380927cbce5e4d9d810d53fdb30ef997b19"#, )) // Cache hit compiling the module .stderr(contains("module_cache::filesystem: Cache hit!")); From daa6751aead9348deaed6e0c3968dec7bf5e7b84 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Thu, 19 Sep 2024 00:26:07 +0330 Subject: [PATCH 03/14] fix leftover change --- tests/integration/cli/tests/publish.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/tests/publish.rs b/tests/integration/cli/tests/publish.rs index 611f3d0167a..a0ee7fcdc91 100644 --- a/tests/integration/cli/tests/publish.rs +++ b/tests/integration/cli/tests/publish.rs @@ -99,7 +99,7 @@ fn wasmer_init_publish() { let wapm_dev_token = std::env::var("WAPM_DEV_TOKEN").ok(); let tempdir = tempfile::tempdir().unwrap(); let path = tempdir.path(); - let username = "amin"; + let username = "ciuser"; let random1 = format!("{}", rand::random::()); let random2 = format!("{}", rand::random::()); From c0b02af4d7a9e736210cbacf848aa506b3cd4e87 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 06:59:53 +0330 Subject: [PATCH 04/14] install cargo wasix --- .github/workflows/test.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bff23cc1594..568cfbd2da5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -846,9 +846,16 @@ jobs: shell: bash run: | make untar-wasmer + - name: "Install cargo-wasix" + run: | + cargo install cargo-wasix + - name: "Download Toolchain" + run: | + cargo wasix download-toolchain - name: Test integration CLI shell: bash run: | + rustup toolchain list -v export WASMER_PATH=`pwd`/target/${{ matrix.target }}/release/wasmer${{ matrix.exe }} export WASMER_DIR=`pwd`/package && make test-integration-cli-ci env: From 8803b9d991bd2328e0fcdf1604b048123326bbaf Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 07:00:08 +0330 Subject: [PATCH 05/14] increase sleep for aio-http --- tests/integration/cli/tests/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/tests/run.rs b/tests/integration/cli/tests/run.rs index 36243c3b02c..6127f4b97a2 100644 --- a/tests/integration/cli/tests/run.rs +++ b/tests/integration/cli/tests/run.rs @@ -74,7 +74,7 @@ async fn aio_http() { .spawn() .unwrap(); - tokio::time::sleep(std::time::Duration::from_secs(5)).await; + tokio::time::sleep(std::time::Duration::from_secs(30)).await; let rsp = reqwest::Client::new() .get("http://localhost:34343") From 2d191fde44913d425a411a39864063f02c7c9fae Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 07:01:18 +0330 Subject: [PATCH 06/14] fix expected output of whoami --- tests/integration/cli/tests/login.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/tests/login.rs b/tests/integration/cli/tests/login.rs index d30d28d8f52..aff92478565 100644 --- a/tests/integration/cli/tests/login.rs +++ b/tests/integration/cli/tests/login.rs @@ -55,5 +55,5 @@ fn run_whoami_works() { .assert() .success(); - assert.stdout("logged into registry wasmer.wtf as user \"ciuser\"\n"); + assert.stdout("logged into registry wasmer.wtf as user ciuser\n"); } From 352070088c187b61f48b9aef0989505891fdf069 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 07:19:54 +0330 Subject: [PATCH 07/14] disable wcgi test --- tests/integration/cli/tests/run.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/cli/tests/run.rs b/tests/integration/cli/tests/run.rs index 6127f4b97a2..0a7a66f4d58 100644 --- a/tests/integration/cli/tests/run.rs +++ b/tests/integration/cli/tests/run.rs @@ -754,6 +754,7 @@ fn wasi_runner_on_disk_with_env_vars() { all(target_env = "musl", target_os = "linux"), ignore = "wasmer run-unstable segfaults on musl" )] +#[ignore = "wcgi runner is broken and hangs after the first request"] fn wcgi_runner_on_disk() { // Start the WCGI server in the background let port = random_port(); From ee4b9c96c29764eae334516a429bfab9a39b799f Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 07:37:47 +0330 Subject: [PATCH 08/14] improve wait condition for aio-http test --- tests/integration/cli/tests/run.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integration/cli/tests/run.rs b/tests/integration/cli/tests/run.rs index 0a7a66f4d58..509eb4d2363 100644 --- a/tests/integration/cli/tests/run.rs +++ b/tests/integration/cli/tests/run.rs @@ -13,6 +13,7 @@ use predicates::str::contains; use rand::Rng; use reqwest::{blocking::Client, IntoUrl}; use tempfile::TempDir; +use tokio::io::{AsyncBufReadExt, BufReader}; use wasmer_integration_tests_cli::{ asset_path, fixtures::{self, packages, php, resources}, @@ -70,11 +71,18 @@ async fn aio_http() { .arg("run") .arg("aio-http-hello-world.webc") .arg("--net") - .stdout(Stdio::null()) + .stdout(Stdio::piped()) .spawn() .unwrap(); - tokio::time::sleep(std::time::Duration::from_secs(30)).await; + let mut stdout = BufReader::new(wasmer.stdout.as_mut().unwrap()); + let mut line = String::new(); + loop { + stdout.read_line(&mut line).await.unwrap(); + if line.contains("Running on http://localhost:34343") { + break; + } + } let rsp = reqwest::Client::new() .get("http://localhost:34343") From df70133b6464deb42b2244c9e3a066ebb0b30157 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 08:25:23 +0330 Subject: [PATCH 09/14] fix whoami test again --- tests/integration/cli/tests/login.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/tests/login.rs b/tests/integration/cli/tests/login.rs index aff92478565..be777d98ea2 100644 --- a/tests/integration/cli/tests/login.rs +++ b/tests/integration/cli/tests/login.rs @@ -55,5 +55,5 @@ fn run_whoami_works() { .assert() .success(); - assert.stdout("logged into registry wasmer.wtf as user ciuser\n"); + assert.stdout("Logged into registry wasmer.wtf as user amin\n"); } From 3bee4976b9a07aaea5bfab1ea2338cdf26f8e0c8 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 08:31:27 +0330 Subject: [PATCH 10/14] add more logging to axumt test --- tests/integration/cli/tests/deploy.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/integration/cli/tests/deploy.rs b/tests/integration/cli/tests/deploy.rs index 83710fe41a0..ac57586271b 100644 --- a/tests/integration/cli/tests/deploy.rs +++ b/tests/integration/cli/tests/deploy.rs @@ -299,7 +299,7 @@ fn wasmer_deploy_fails_no_owner() -> anyhow::Result<()> { fn wasmer_deploy_axum() -> anyhow::Result<()> { let wapm_dev_token = std::env::var("WAPM_DEV_TOKEN").ok(); - let username = "ciuser"; + let username = "amin"; let app_name = format!("ci-{}", rand::random::()); let random3 = format!("{}", rand::random::()); @@ -325,7 +325,12 @@ fn wasmer_deploy_axum() -> anyhow::Result<()> { std::env::set_current_dir(&app_dir)?; let mut cmd = std::process::Command::new("cargo"); - cmd.arg("wasix").arg("build").output()?; + let output = cmd.arg("wasix").arg("build").output()?; + println!( + "cargo wasix:\nstdout: {:?}\nstderr: {:?}", + String::from_utf8(output.stdout).unwrap(), + String::from_utf8(output.stderr).unwrap() + ); let mut cmd = std::process::Command::new(get_wasmer_path()); cmd.arg("deploy") From cc48f717410ffdf22a9be6e04a8347f77fce6429 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 08:36:17 +0330 Subject: [PATCH 11/14] fix leftover change --- tests/integration/cli/tests/deploy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/tests/deploy.rs b/tests/integration/cli/tests/deploy.rs index ac57586271b..480065f43ea 100644 --- a/tests/integration/cli/tests/deploy.rs +++ b/tests/integration/cli/tests/deploy.rs @@ -299,7 +299,7 @@ fn wasmer_deploy_fails_no_owner() -> anyhow::Result<()> { fn wasmer_deploy_axum() -> anyhow::Result<()> { let wapm_dev_token = std::env::var("WAPM_DEV_TOKEN").ok(); - let username = "amin"; + let username = "ciuser"; let app_name = format!("ci-{}", rand::random::()); let random3 = format!("{}", rand::random::()); From c957d49a4a5037c726b87a092bf47b3add9d8b88 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 08:37:11 +0330 Subject: [PATCH 12/14] fix leftover change --- tests/integration/cli/tests/login.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/tests/login.rs b/tests/integration/cli/tests/login.rs index be777d98ea2..ac5aa0639fb 100644 --- a/tests/integration/cli/tests/login.rs +++ b/tests/integration/cli/tests/login.rs @@ -55,5 +55,5 @@ fn run_whoami_works() { .assert() .success(); - assert.stdout("Logged into registry wasmer.wtf as user amin\n"); + assert.stdout("Logged into registry wasmer.wtf as user ciuser\n"); } From ceb59989d0d6077f2142cb1d4d53f8a6a32d1502 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 09:28:58 +0330 Subject: [PATCH 13/14] install necessory tools on linux --- .github/workflows/test.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 568cfbd2da5..7b64a0ca9c9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -733,6 +733,11 @@ jobs: - uses: goto-bus-stop/setup-zig@v2 with: version: 0.10.0 + - name: Install Tools + if: ${{ matrix.build == 'linux-musl' }} || ${{ matrix.build == 'linux-x64' }} + run: | + sudo apt-get update + sudo apt-get install -y git llvm clang make lld curl - name: Set up base deps on musl if: matrix.build == 'linux-musl' run: ./scripts/alpine-linux-install-deps.sh From 36d2b9ff3b330617529e42a7a52d1d418f4c6c47 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Fri, 20 Sep 2024 10:10:19 +0330 Subject: [PATCH 14/14] fix condition --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7b64a0ca9c9..48d35b60fc5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -734,7 +734,7 @@ jobs: with: version: 0.10.0 - name: Install Tools - if: ${{ matrix.build == 'linux-musl' }} || ${{ matrix.build == 'linux-x64' }} + if: matrix.build == 'linux-musl' || matrix.build == 'linux-x64' run: | sudo apt-get update sudo apt-get install -y git llvm clang make lld curl