From 66a042dcaf138defc123c04d258104cef1685254 Mon Sep 17 00:00:00 2001 From: jonaro00 <54029719+jonaro00@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:51:58 +0100 Subject: [PATCH] chore: remove e2e crate, update development docs --- .circleci/config.yml | 31 -- .dockerignore | 1 - .gitignore | 2 - Cargo.toml | 1 - DEVELOPING.md | 48 +--- Makefile | 5 - e2e/Cargo.toml | 13 - e2e/README.md | 23 -- e2e/tests/integration/actix_web.rs | 23 -- e2e/tests/integration/axum.rs | 20 -- e2e/tests/integration/helpers/mod.rs | 412 --------------------------- e2e/tests/integration/main.rs | 11 - e2e/tests/integration/poem.rs | 83 ------ e2e/tests/integration/rocket.rs | 73 ----- e2e/tests/integration/salvo.rs | 20 -- e2e/tests/integration/thruster.rs | 23 -- e2e/tests/integration/tide.rs | 20 -- e2e/tests/integration/tower.rs | 23 -- e2e/tests/integration/warp.rs | 20 -- 19 files changed, 13 insertions(+), 839 deletions(-) delete mode 100644 e2e/Cargo.toml delete mode 100644 e2e/README.md delete mode 100644 e2e/tests/integration/actix_web.rs delete mode 100644 e2e/tests/integration/axum.rs delete mode 100644 e2e/tests/integration/helpers/mod.rs delete mode 100644 e2e/tests/integration/main.rs delete mode 100644 e2e/tests/integration/poem.rs delete mode 100644 e2e/tests/integration/rocket.rs delete mode 100644 e2e/tests/integration/salvo.rs delete mode 100644 e2e/tests/integration/thruster.rs delete mode 100644 e2e/tests/integration/tide.rs delete mode 100644 e2e/tests/integration/tower.rs delete mode 100644 e2e/tests/integration/warp.rs diff --git a/.circleci/config.yml b/.circleci/config.yml index f19268c2e..ce02c1664 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -275,24 +275,6 @@ jobs: - apply-patches - run: cargo make test-member-integration-docker << parameters.crate >> - save-sccache - e2e-test: # outdated - executor: machine-ubuntu - resource_class: medium - steps: - - install-rust - - checkout - - run: git submodule update --init - - run: make images - - apply-patches - - run: - name: Run the E2E tests - command: | - # clean up a potential existing deployments before running - # the tests just in case the environment is not clean - make down - make up - SHUTTLE_TESTS_NETWORK=shuttle-dev_user-net SHUTTLE_TESTS_RUNTIME_IMAGE=public.ecr.aws/shuttle-dev/deployer:latest cargo test --package shuttle-gateway --all-features --lib -- --nocapture - make test build-and-push: executor: machine-ubuntu parameters: @@ -712,19 +694,6 @@ workflows: filters: branches: only: main - # - e2e-test: - # requires: - # - test-standalone - # - test-standalone-shared-db - # - test-workspace-member - # - test-workspace-member-with-integration-medium - # - test-workspace-member-with-integration-large - # - test-workspace-member-with-integration-xlarge - # - test-workspace-member-with-integration-docker-medium - # - test-workspace-member-with-integration-docker-large - # filters: - # branches: - # only: production unstable: jobs: - approve-deploy-images-unstable: diff --git a/.dockerignore b/.dockerignore index 0f783c818..8a051d14b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,4 +9,3 @@ !**/README.md Makefile /assets -/e2e diff --git a/.gitignore b/.gitignore index 2444e2339..d0cd6bbcc 100644 --- a/.gitignore +++ b/.gitignore @@ -29,8 +29,6 @@ acme*.json **/secrets.tfvar **/.terraform* -e2e/users.toml - # direnv cache directory .direnv/ diff --git a/Cargo.toml b/Cargo.toml index 31e56698d..7a40ea9d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ members = [ "service", ] exclude = [ - "e2e", "examples", "resources", "services", diff --git a/DEVELOPING.md b/DEVELOPING.md index bc71d992d..0d340c1a8 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -20,7 +20,6 @@ graph BT cargo-shuttle:::binary common codegen - e2e proto provisioner:::binary service @@ -41,9 +40,6 @@ graph BT service --> codegen proto ---> common provisioner --> proto - e2e -.->|starts up| gateway - e2e -.->|starts up| auth - e2e -.->|calls| cargo-shuttle user -->|"features = ['codegen']"| service ``` @@ -65,17 +61,14 @@ and renewing SSL certificates through the acme client in the `gateway`. The redirect through `runtime` is to make it available under the prettier name of `shuttle_runtime::main`. - `runtime` contains the `alpha` runtime, which embeds a gRPC server and a `Loader` in a service with the `shuttle_runtime::main` macro. The gRPC server receives commands from `deployer` like `start` and `stop`. - The `Loader` sets up a tracing subscriber and provisions resources for the users service. + The `Loader` sets up a tracing subscriber and provisions resources for the user service. - `service` is where our special `Service` trait is defined. Anything implementing this `Service` can be loaded by the `deployer` and the local runner in `cargo-shuttle`. - The `service` library also defines the `ResourceBuilder` and `Factory` trais which are used in our codegen to provision resources. - The `service` library also contains the utilities we use for compiling users crates with `cargo`. + The `service` library also defines the `ResourceConfigBuilder` trait which is used in our codegen to provision resources. + The `service` library also contains the utilities we use for compiling user crates with `cargo`. - `proto` contains the gRPC server and client definitions to allow `deployer` to communicate with `provisioner`, and to allow the `deployer` and `cargo-shuttle` cli to communicate with the `alpha` runtime. - `resources` contains various implementations of `ResourceBuilder`, which are consumed in the `codegen` to provision resources. -- `services` contains implementations of `Service` for common Rust web frameworks. Anything implementing `Service` can be deployed by shuttle. -- `e2e` just contains tests which starts up the `deployer` in a container and then deploys services to it using `cargo-shuttle`. - -Lastly, the `user service` is not a folder in this repository, but is the user service that will be deployed by `deployer`. +- `services` contains implementations of `Service` for common Rust web frameworks. Anything implementing `Service` can be deployed on Shuttle. ## Running Locally @@ -228,12 +221,10 @@ cargo run -p cargo-shuttle -- --wd --name deploy #### Docker Desktop -If using Docker Desktop on Linux, you might find adding this to your shell config useful to make `bollard` find the Docker socket: +If using Docker Desktop on Unix, you might find adding this to your shell config useful to make `bollard` find the Docker socket: ```sh -if which docker > /dev/null && [ $(docker context show) = "desktop-linux" ]; then - export DOCKER_HOST="unix://$HOME/.docker/desktop/docker.sock" -fi +export DOCKER_HOST="unix://$HOME/.docker/desktop/docker.sock" ``` #### Using Podman instead of Docker @@ -291,38 +282,25 @@ when retrieving a user, and when we'll verify the subscription validity. ## Running Tests -Shuttle has reasonable test coverage - and we are working on improving this -every day. We encourage PRs to come with tests. If you're not sure about -what a test should look like, feel free to [get in touch](https://discord.gg/shuttle). +Install `cargo-make`. To run the unit tests for a specific crate, from the root of the repository run: ```bash # replace with the name of the crate to test, e.g. `shuttle-common` -cargo test -p --all-features --lib -- --nocapture +cargo make test-member ``` -To run the integration tests for a specific crate (if it has any), from the root of the repository run: +Integration tests are split between those that rely on Docker, and those who don't. -```bash -# replace with the name of the crate to test, e.g. `cargo-shuttle` -cargo test -p --all-features --test '*' -- --nocapture -# To streamline and customize the integration tests for CI, bash scripts with these commands and -# any crate-specific commands can be run with: -.//integration.sh -# and/or -.//integration_docker.sh -# Tests that need to start docker containers are separated for CI efficiency, and thus use scripts with `_docker` suffix. -``` - -To run the end-to-end (e2e) tests, from the root of the repository run: +To run the integration tests for a specific crate (if it has any), from the root of the repository run: ```bash -make test +cargo make test-member-integration +# tests that depend on Docker +cargo make test-member-integration-docker ``` -> Note: Running all the end-to-end tests may take a long time, so it is recommended to run individual tests shipped as part of each crate in the workspace first. - ## Windows Considerations Currently, if you try to use 'make images' on Windows, you may find that the shell files cannot be read by Bash/WSL. This is due to the fact that Windows may have pulled the files in CRLF format rather than LF[^1], which causes problems with Bash as to run the commands, Linux needs the file in LF format. diff --git a/Makefile b/Makefile index 06600cb65..c890e806f 100644 --- a/Makefile +++ b/Makefile @@ -178,11 +178,6 @@ otel: deploy: docker-compose.yml $(DOCKER_COMPOSE_ENV) docker stack deploy -c $< $(STACK) -test: - POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) \ - APPS_FQDN=$(APPS_FQDN) \ - cargo test --manifest-path=e2e/Cargo.toml $(CARGO_TEST_FLAGS) -- --nocapture - docker-compose.rendered.yml: docker-compose.yml docker-compose.dev.yml $(DOCKER_COMPOSE_ENV) $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.dev.yml $(DOCKER_COMPOSE_CONFIG_FLAGS) -p $(STACK) config > $@ diff --git a/e2e/Cargo.toml b/e2e/Cargo.toml deleted file mode 100644 index 4895a5ee8..000000000 --- a/e2e/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "e2e" -version = "0.1.0" -edition = "2021" - -[dev-dependencies] -crossterm = "0.26.1" -lazy_static = "1.4.0" -portpicker = "0.1.1" -rand = "0.8.5" -reqwest = { version = "0.11.10", default-features = false, features = ["blocking", "json", "rustls-tls"] } -which = "4.2.5" -tempfile = "3.3.0" diff --git a/e2e/README.md b/e2e/README.md deleted file mode 100644 index 5810dcfc9..000000000 --- a/e2e/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# e2e - -## Overview - -This crate runs all the end-to-end tests for shuttle. These tests must run against a local dev environment, so you first have to set that up by following [these instructions](../DEVELOPING.md). - -Running all the end-to-end tests may take a long time, so it is recommended to run individual tests shipped as part of each crate in the workspace first. - -## Running the tests - -In the root of the repository, run: - -```bash -make test -``` - -To run individual tests, in the root of the e2e directory run: - -```bash -POSTGRES_PASSWORD=postgres APPS_FQDN=unstable.shuttleapp.rs cargo test -- --nocapture -``` - -The server-side logs can be accessed with `docker compose logs`. diff --git a/e2e/tests/integration/actix_web.rs b/e2e/tests/integration/actix_web.rs deleted file mode 100644 index f6a545889..000000000 --- a/e2e/tests/integration/actix_web.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_actix_web() { - let client = helpers::Services::new_docker( - "hello-world (actix-web)", - "actix-web/hello-world", - Color::Green, - ); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-actix-web-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello World!"); -} diff --git a/e2e/tests/integration/axum.rs b/e2e/tests/integration/axum.rs deleted file mode 100644 index 698cd7e35..000000000 --- a/e2e/tests/integration/axum.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_axum() { - let client = - helpers::Services::new_docker("hello-world (axum)", "axum/hello-world", Color::Green); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-axum-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, world!"); -} diff --git a/e2e/tests/integration/helpers/mod.rs b/e2e/tests/integration/helpers/mod.rs deleted file mode 100644 index 915e4b5aa..000000000 --- a/e2e/tests/integration/helpers/mod.rs +++ /dev/null @@ -1,412 +0,0 @@ -use std::io::{self, stderr, stdout, BufRead, Write}; -use std::net::SocketAddr; -use std::path::{Path, PathBuf}; -use std::process::{Child, Command, ExitStatus, Output, Stdio}; -use std::str; -use std::thread::sleep; -use std::time::{Duration, SystemTime}; -use std::{env, path}; - -use crossterm::style::{Color, Stylize}; -use reqwest::blocking::RequestBuilder; - -use lazy_static::lazy_static; -use tempfile::{Builder, TempDir}; - -/// The directory given to `cargo shuttle` run in the context of E2E -/// testing -pub enum TempCargoHome { - /// A directory managed by the caller, no patch applied - User(PathBuf), - /// A directory managed by this crate is created, applies the - /// patch as required - Managed(TempDir), -} - -impl TempCargoHome { - /// Initialize a new `TempCargoHome` with a `shuttle-service` - /// patch unless `SHUTTLE_CARGO_HOME` is set, then use that. With - /// the latter, no patch is applied - pub fn from_env_or_new() -> Self { - match env::var("SHUTTLE_CARGO_HOME") { - Ok(path) => Self::User(path.into()), - Err(_) => { - let dir = Builder::new().prefix("shuttle-tests").tempdir().unwrap(); - - // Apply the `patch.crates-io` for `shuttle-service` - let mut config = std::fs::File::create(dir.path().join("config.toml")).unwrap(); - let p = include_str!("../../../../scripts/patches.toml"); - write!( - config, - "{}", - p.replace("BASE", &format!("{}", WORKSPACE_ROOT.display())) - ) - .unwrap(); - - Self::Managed(dir) - } - } - } - - pub fn path(&self) -> &Path { - match self { - Self::User(path) => path.as_path(), - Self::Managed(dir) => dir.path(), - } - } - - pub fn display(&self) -> path::Display<'_> { - self.path().display() - } -} - -lazy_static! { - static ref WORKSPACE_ROOT: PathBuf = { - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .parent() - .unwrap() - .to_path_buf() - }; - static ref DOCKER: PathBuf = which::which("docker").unwrap(); - static ref MAKE: PathBuf = which::which("make").unwrap(); - static ref CARGO: PathBuf = which::which("cargo").unwrap(); - static ref DB_FQDN: String = env::var("DB_FQDN").unwrap(); - pub static ref APPS_FQDN: String = env::var("APPS_FQDN").unwrap(); - static ref CARGO_HOME: TempCargoHome = TempCargoHome::from_env_or_new(); - static ref LOCAL_UP: () = { - println!( - " ------------------------------------ PREPARING ------------------------------------ -docker: {} -make: {} -cargo: {} -CARGO_HOME: {} ----------------------------------------------------------------------------------- -", - DOCKER.display(), - MAKE.display(), - CARGO.display(), - CARGO_HOME.display() - ); - - Command::new(MAKE.as_os_str()) - .arg("up") - .current_dir(WORKSPACE_ROOT.as_path()) - .output() - .ensure_success("failed to `make up`"); - - Command::new(CARGO.as_os_str()) - .args(["build", "--bin", "cargo-shuttle"]) - .current_dir(WORKSPACE_ROOT.as_path()) - .output() - .ensure_success("failed to `cargo build --bin cargo-shuttle`"); - - let admin_key = if let Ok(key) = env::var("SHUTTLE_API_KEY") { - key - } else { - "dh9z58jttoes3qvt".to_string() - }; - - _ = Command::new(DOCKER.as_os_str()) - .args([ - "compose", - "--file", - "docker-compose.rendered.yml", - "--project-name", - "shuttle-dev", - "exec", - "auth", - "/usr/local/bin/shuttle-auth", - "--state=/var/lib/shuttle-auth", - "init", - "--name", - "test", - "--key", - &admin_key, - ]) - .output(); - }; -} - -trait EnsureSuccess { - fn ensure_success>(self, s: S); -} - -impl EnsureSuccess for io::Result { - fn ensure_success>(self, s: S) { - let exit_status = self.unwrap(); - if !exit_status.success() { - panic!("{}: exit code {}", s.as_ref(), exit_status) - } - } -} - -impl EnsureSuccess for io::Result { - fn ensure_success>(self, s: S) { - self.map(|output| { - let _ = stderr().write_all(&output.stderr); - let _ = stdout().write_all(&output.stdout); - output.status - }) - .ensure_success(s) - } -} - -pub fn log_lines(mut reader: R, target: D) { - let mut buf = [0; 2 << 17]; // 128kb - let mut current_pos = 0; - loop { - let n = reader.read(&mut buf[current_pos..]).unwrap(); - if n == 0 { - break; - } - current_pos += n; - - if buf[current_pos - 1] != b'\n' { - continue; - } - - for line in io::BufReader::new(&buf[..current_pos]).lines() { - println!("{} {}", target, line.unwrap()); - } - - current_pos = 0; - } - - // Log last - if current_pos != 0 { - for line in io::BufReader::new(&buf[..current_pos]).lines() { - println!("{} {}", target, line.unwrap()); - } - } -} - -pub fn spawn_and_log>( - cmd: &mut Command, - target: D, - color: C, -) -> Child { - let mut child = cmd - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .unwrap(); - - let color = color.into(); - let mut stdout = child.stdout.take().unwrap(); - let mut stderr = child.stderr.take().unwrap(); - let stdout_target = format!("{} >>>", target).with(color); - let stderr_target = format!("{} >>>", target).bold().with(color); - std::thread::spawn(move || log_lines(&mut stdout, stdout_target)); - std::thread::spawn(move || log_lines(&mut stderr, stderr_target)); - child -} - -pub struct Services { - api_addr: SocketAddr, - proxy_addr: SocketAddr, - /// Path within the examples dir to a specific example - example_path: String, - target: String, - color: Color, -} - -impl Services { - fn new_free(target: D, example_path: D, color: C) -> Self - where - D: std::fmt::Display, - C: Into, - { - Self { - api_addr: "127.0.0.1:8001".parse().unwrap(), - proxy_addr: "127.0.0.1:8000".parse().unwrap(), - target: target.to_string(), - color: color.into(), - example_path: example_path.to_string(), - } - } - - /// Initializes a a test client - /// - /// # Arguments - /// - /// * `target` - A string that describes the test target - /// * `example_path` - Path to a specific example within the examples dir, this is where - /// `project start` and `deploy` will run - /// * `color` - a preferably unique `crossterm::style::Color` to distinguish test logs - pub fn new_docker(target: D, example_path: D, color: C) -> Self - where - D: std::fmt::Display, - C: Into, - { - let _ = *LOCAL_UP; - let service = Self::new_free(target, example_path, color); - service.wait_ready(Duration::from_secs(15)); - - // Make sure provisioner is ready, else deployers will fail to start up - service.wait_postgres_ready(Duration::from_secs(15)); - service.wait_mongodb_ready(Duration::from_secs(15)); - sleep(Duration::from_secs(5)); - - service - } - - pub fn wait_ready(&self, mut timeout: Duration) { - let mut now = SystemTime::now(); - while !timeout.is_zero() { - match reqwest::blocking::get(format!("http://{}", self.api_addr)) { - Ok(resp) if resp.status().is_success() => return, - _ => sleep(Duration::from_secs(1)), - } - timeout = timeout - .checked_sub(now.elapsed().unwrap()) - .unwrap_or_default(); - now = SystemTime::now(); - } - panic!("timed out while waiting for gateway to / OK"); - } - - pub fn wait_postgres_ready(&self, mut timeout: Duration) { - let mut now = SystemTime::now(); - while !timeout.is_zero() { - let mut run = Command::new(DOCKER.as_os_str()); - run.args([ - "compose", - "--file", - "docker-compose.rendered.yml", - "--project-name", - "shuttle-dev", - "exec", - "postgres", - "pg_isready", - ]); - - if spawn_and_log(&mut run, &self.target, self.color) - .wait() - .unwrap() - .success() - { - return; - } else { - sleep(Duration::from_secs(1)); - } - timeout = timeout - .checked_sub(now.elapsed().unwrap()) - .unwrap_or_default(); - now = SystemTime::now(); - } - panic!("timed out while waiting for postgres to be ready"); - } - - pub fn wait_mongodb_ready(&self, mut timeout: Duration) { - let mut now = SystemTime::now(); - while !timeout.is_zero() { - let mut run = Command::new(DOCKER.as_os_str()); - run.args([ - "compose", - "--file", - "docker-compose.rendered.yml", - "--project-name", - "shuttle-dev", - "exec", - "mongodb", - "mongo", - "--eval", - "print(\"accepting connections\")", - ]); - - if spawn_and_log(&mut run, &self.target, self.color) - .wait() - .unwrap() - .success() - { - return; - } else { - sleep(Duration::from_secs(1)); - } - timeout = timeout - .checked_sub(now.elapsed().unwrap()) - .unwrap_or_default(); - now = SystemTime::now(); - } - panic!("timed out while waiting for mongodb to be ready"); - } - - pub fn wait_deployer_ready(&self, mut timeout: Duration) { - let mut now = SystemTime::now(); - while !timeout.is_zero() { - let mut run = Command::new(WORKSPACE_ROOT.join("target/debug/cargo-shuttle")); - - if env::var("SHUTTLE_API_KEY").is_err() { - run.env("SHUTTLE_API_KEY", "dh9z58jttoes3qvt"); - } - - run.env("CARGO_HOME", CARGO_HOME.path()); - run.args(["project", "status"]) - .current_dir(self.get_full_project_path()); - let stdout = run.output().unwrap().stdout; - let stdout = String::from_utf8(stdout).unwrap(); - - if stdout.contains("ready") { - return; - } else { - sleep(Duration::from_secs(1)); - } - timeout = timeout - .checked_sub(now.elapsed().unwrap()) - .unwrap_or_default(); - now = SystemTime::now(); - } - panic!("timed out while waiting for deployer to be ready"); - } - - pub fn run_client<'s, I>(&self, args: I) -> Child - where - I: IntoIterator, - { - let mut run = Command::new(WORKSPACE_ROOT.join("target/debug/cargo-shuttle")); - - if env::var("SHUTTLE_API_KEY").is_err() { - run.env("SHUTTLE_API_KEY", "dh9z58jttoes3qvt"); - } - - run.env("CARGO_HOME", CARGO_HOME.path()); - - run.args(args).current_dir(self.get_full_project_path()); - spawn_and_log(&mut run, &self.target, self.color) - } - - /// Starts a project and deploys a service for the example in `self.example_path` - pub fn deploy(&self) { - self.run_client(["project", "start"]) - .wait() - .ensure_success("failed to run deploy"); - - self.wait_deployer_ready(Duration::from_secs(120)); - - self.run_client(["deploy", "--allow-dirty"]) - .wait() - .ensure_success("failed to run deploy"); - } - - pub fn get(&self, sub_path: &str) -> RequestBuilder { - reqwest::blocking::Client::new().get(format!("http://{}/{}", self.proxy_addr, sub_path)) - } - - #[allow(dead_code)] - pub fn post(&self, sub_path: &str) -> RequestBuilder { - reqwest::blocking::Client::new().post(format!("http://{}/{}", self.proxy_addr, sub_path)) - } - - /// Gets the full path: the path within examples to a specific example appended to the workspace root - pub fn get_full_project_path(&self) -> PathBuf { - WORKSPACE_ROOT.join("examples").join(&self.example_path) - } -} - -impl Drop for Services { - fn drop(&mut self) { - // Initiate project destruction on test completion - _ = self.run_client(["project", "stop"]).wait(); - } -} diff --git a/e2e/tests/integration/main.rs b/e2e/tests/integration/main.rs deleted file mode 100644 index 8640c4c64..000000000 --- a/e2e/tests/integration/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub mod helpers; - -pub mod actix_web; -pub mod axum; -pub mod poem; -pub mod rocket; -pub mod salvo; -pub mod thruster; -pub mod tide; -pub mod tower; -pub mod warp; diff --git a/e2e/tests/integration/poem.rs b/e2e/tests/integration/poem.rs deleted file mode 100644 index 7f5a566bb..000000000 --- a/e2e/tests/integration/poem.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_poem() { - let client = - helpers::Services::new_docker("hello-world (poem)", "poem/hello-world", Color::Cyan); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-poem-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, world!"); -} - -#[test] -fn postgres_poem() { - let client = helpers::Services::new_docker("postgres (poem)", "poem/postgres", Color::Blue); - client.deploy(); - - let add_response = client - .post("todo") - .body("{\"note\": \"To the stars\"}") - .header("Host", format!("postgres-poem-app.{}", *APPS_FQDN)) - .header("content-type", "application/json") - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(add_response, "{\"id\":1,\"note\":\"To the stars\"}"); - - let fetch_response: String = client - .get("todo/1") - .header("Host", format!("postgres-poem-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(fetch_response, "{\"id\":1,\"note\":\"To the stars\"}"); -} - -#[test] -fn mongodb_poem() { - let client = helpers::Services::new_docker("mongo (poem)", "poem/mongodb", Color::Green); - client.deploy(); - - // post todo and get its generated objectId - let add_response = client - .post("todo") - .body("{\"note\": \"To the stars\"}") - .header("Host", format!("mongodb-poem-app.{}", *APPS_FQDN)) - .header("content-type", "application/json") - .send() - .unwrap() - .text() - .unwrap(); - - // valid objectId is 24 char hex string - assert_eq!( - add_response.len(), - 24, - "response length mismatch: got: {}", - add_response - ); - - let fetch_response: String = client - .get(&format!("todo/{}", add_response)) - .header("Host", format!("mongodb-poem-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(fetch_response, "{\"note\":\"To the stars\"}"); -} diff --git a/e2e/tests/integration/rocket.rs b/e2e/tests/integration/rocket.rs deleted file mode 100644 index bbf4d0017..000000000 --- a/e2e/tests/integration/rocket.rs +++ /dev/null @@ -1,73 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_rocket() { - let client = helpers::Services::new_docker( - "hello-world (rocket)", - "rocket/hello-world", - Color::DarkMagenta, - ); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-rocket-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, world!"); -} - -#[test] -fn postgres_rocket() { - let client = - helpers::Services::new_docker("postgres (rocket)", "rocket/postgres", Color::Magenta); - client.deploy(); - - let add_response = client - .post("todo") - .body("{\"note\": \"To the stars\"}") - .header("Host", format!("postgres-rocket-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(add_response, "{\"id\":1,\"note\":\"To the stars\"}"); - - let fetch_response: String = client - .get("todo/1") - .header("Host", format!("postgres-rocket-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(fetch_response, "{\"id\":1,\"note\":\"To the stars\"}"); -} - -#[test] -fn secrets_rocket() { - let client = helpers::Services::new_docker("secrets (rocket)", "rocket/secrets", Color::Red); - let project_path = client.get_full_project_path(); - std::fs::copy( - project_path.join("Secrets.toml.example"), - project_path.join("Secrets.toml"), - ) - .unwrap(); - - client.deploy(); - let secret_response: String = client - .get("secret") - .header("Host", format!("secrets-rocket-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(secret_response, "the contents of my API key"); -} diff --git a/e2e/tests/integration/salvo.rs b/e2e/tests/integration/salvo.rs deleted file mode 100644 index 01daf0b41..000000000 --- a/e2e/tests/integration/salvo.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_salvo() { - let client = - helpers::Services::new_docker("hello-world (salvo)", "salvo/hello-world", Color::DarkRed); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-salvo-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, world!"); -} diff --git a/e2e/tests/integration/thruster.rs b/e2e/tests/integration/thruster.rs deleted file mode 100644 index ad6a20919..000000000 --- a/e2e/tests/integration/thruster.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_thruster() { - let client = helpers::Services::new_docker( - "hello-world (thruster)", - "thruster/hello-world", - Color::DarkYellow, - ); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-thruster-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, World!"); -} diff --git a/e2e/tests/integration/tide.rs b/e2e/tests/integration/tide.rs deleted file mode 100644 index af4d487fe..000000000 --- a/e2e/tests/integration/tide.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_tide() { - let client = - helpers::Services::new_docker("hello-world (tide)", "tide/hello-world", Color::DarkYellow); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-tide-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, world!"); -} diff --git a/e2e/tests/integration/tower.rs b/e2e/tests/integration/tower.rs deleted file mode 100644 index 5592332aa..000000000 --- a/e2e/tests/integration/tower.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_tower() { - let client = helpers::Services::new_docker( - "hello-world (tower)", - "tower/hello-world", - Color::DarkYellow, - ); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-tower-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, world!"); -} diff --git a/e2e/tests/integration/warp.rs b/e2e/tests/integration/warp.rs deleted file mode 100644 index 802fa2733..000000000 --- a/e2e/tests/integration/warp.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crossterm::style::Color; - -use crate::helpers::{self, APPS_FQDN}; - -#[test] -fn hello_world_warp() { - let client = - helpers::Services::new_docker("hello-world (warp)", "warp/hello-world", Color::Cyan); - client.deploy(); - - let request_text = client - .get("hello") - .header("Host", format!("hello-world-warp-app.{}", *APPS_FQDN)) - .send() - .unwrap() - .text() - .unwrap(); - - assert_eq!(request_text, "Hello, World!"); -}