Skip to content

Commit

Permalink
add e2e tests for php, swift, oci, longevity
Browse files Browse the repository at this point in the history
Signed-off-by: Rajat Jindal <[email protected]>
  • Loading branch information
rajatjindal committed Mar 3, 2023
1 parent e7b9941 commit 7c45978
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cargo_target_dep::build_target_dep;

const RUST_HTTP_INTEGRATION_TEST: &str = "tests/http/simple-spin-rust";
const RUST_HTTP_INTEGRATION_ENV_TEST: &str = "tests/http/headers-env-routes-test";
const RUST_HTTP_INTEGRATION_KEY_VALUE_TEST: &str = "tests/http/key-value";
const RUST_HTTP_INTEGRATION_KEY_VALUE_TEST: &str = "tests/testcases/key-value";
const RUST_HTTP_VAULT_CONFIG_TEST: &str = "tests/http/vault-config-test";
const RUST_OUTBOUND_REDIS_INTEGRATION_TEST: &str = "tests/outbound-redis/http-rust-outbound-redis";

Expand Down Expand Up @@ -136,7 +136,7 @@ fn run<S: Into<String> + AsRef<std::ffi::OsStr>>(
println!("{:#?}", std::str::from_utf8(&output.stderr).unwrap());
println!("{:#?}", std::str::from_utf8(&output.stdout).unwrap());
// just fail
assert_eq!(0, code);
assert_eq!(0, code, "{:?}", cmd);
}

output
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e-testing/src/asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ where
op, left, right,
),
}
}
}
2 changes: 1 addition & 1 deletion crates/e2e-testing/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod asserts;
pub mod controller;
pub mod http_asserts;
pub mod metadata_extractor;
pub mod spin;
pub mod spin_controller;
pub mod testcase;
pub mod utils;
pub mod http_asserts;
2 changes: 1 addition & 1 deletion crates/e2e-testing/src/spin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ pub fn version() -> Result<String> {
Ok(output) => Ok(format!("{:#?}", std::str::from_utf8(&output.stdout)?)),
Err(err) => Err(err),
}
}
}
4 changes: 2 additions & 2 deletions e2e-tests.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ RUN tinygo version; \
node --version; \
swift --version;

RUN wget https:/fermyon/spin/releases/download/${SPIN_VERSION}/spin-${SPIN_VERSION}-linux-aarch64.tar.gz && \
tar -xvf spin-${SPIN_VERSION}-linux-aarch64.tar.gz && \
RUN wget https:/fermyon/spin/releases/download/${SPIN_VERSION}/spin-${SPIN_VERSION}-linux-amd64.tar.gz && \
tar -xvf spin-${SPIN_VERSION}-linux-amd64.tar.gz && \
ls -ltr && \
mv spin /usr/local/bin/spin;

Expand Down
29 changes: 26 additions & 3 deletions tests/testcases/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#[cfg(feature = "e2e-tests")]
pub mod all {
use anyhow::Result;
use e2e_testing::asserts::assert_http_response;
use e2e_testing::controller::Controller;
use e2e_testing::http_asserts::assert_http_response;
use e2e_testing::metadata_extractor::AppMetadata;
use e2e_testing::spin;
use e2e_testing::testcase::TestCaseBuilder;
use e2e_testing::utils;
use hyper::Method;
Expand Down Expand Up @@ -60,6 +61,8 @@ pub mod all {
) -> Result<()> {
assert_http_response(
metadata.base.as_str(),
Method::GET,
"",
200,
&[],
Some("Hello from the Python SDK"),
Expand Down Expand Up @@ -97,6 +100,8 @@ pub mod all {
) -> Result<()> {
assert_http_response(
metadata.base.as_str(),
Method::GET,
"",
200,
&[],
Some("Hello Fermyon Spin\n"),
Expand Down Expand Up @@ -128,6 +133,8 @@ pub mod all {
) -> Result<()> {
assert_http_response(
metadata.base.as_str(),
Method::GET,
"",
200,
&[],
Some("Hello from WAGI/1!\n"),
Expand Down Expand Up @@ -866,7 +873,15 @@ pub mod all {
_: Option<BufReader<ChildStdout>>,
_: Option<BufReader<ChildStderr>>,
) -> Result<()> {
assert_http_response(metadata.base.as_str(), 200, &[], Some("Hello Fermyon!\n")).await
assert_http_response(
metadata.base.as_str(),
Method::GET,
"",
200,
&[],
Some("Hello Fermyon!\n"),
)
.await
}

let registry = "registry:5000";
Expand Down Expand Up @@ -901,7 +916,7 @@ pub mod all {
let current_spin_version = match spin::version() {
Ok(version) => version,
Err(err) => {
println!("{}", err);
println!("error getting spin version {}", err);
"".to_string()
}
};
Expand All @@ -916,6 +931,8 @@ pub mod all {
) -> Result<()> {
assert_http_response(
get_url(metadata.base.as_str(), "/golang").as_str(),
Method::GET,
"",
200,
&[],
Some("Hello Fermyon!\n"),
Expand All @@ -924,6 +941,8 @@ pub mod all {

assert_http_response(
get_url(metadata.base.as_str(), "/rust").as_str(),
Method::GET,
"",
200,
&[],
Some("Hello, Fermyon"),
Expand All @@ -932,6 +951,8 @@ pub mod all {

assert_http_response(
get_url(metadata.base.as_str(), "/javascript").as_str(),
Method::GET,
"",
200,
&[],
Some("Hello from JS-SDK"),
Expand All @@ -940,6 +961,8 @@ pub mod all {

assert_http_response(
get_url(metadata.base.as_str(), "/typescript").as_str(),
Method::GET,
"",
200,
&[],
Some("Hello from TS-SDK"),
Expand Down

0 comments on commit 7c45978

Please sign in to comment.