Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up E2E tests #2032

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
env:
APOLLO_ROVER_DEV_COMPOSITION_VERSION: ${{ matrix.composition-version }}
APOLLO_ROVER_DEV_ROUTER_VERSION: ${{ matrix.router-version }}
APOLLO_ELV2_LICENSE: accept
CARGO_MANIFEST_DIR: ${{ github.workspace }}
APOLLO_KEY: ${{ secrets.APOLLO_KEY_ROVER_E2E_TESTS }}
run: |
Expand Down
51 changes: 34 additions & 17 deletions tests/e2e/install/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
use std::process::Command;
use std::str::from_utf8;

use assert_cmd::prelude::CommandCargoExt;
use assert_fs::TempDir;
use camino::Utf8PathBuf;
use regex::Regex;
use rstest::fixture;
use rstest::rstest;
use rstest::{fixture, rstest};
use serde_json::Value;
use speculoos::{assert_that, boolean::BooleanAssertions};
use speculoos::{assert_that, asserting, boolean::BooleanAssertions};
use tracing_test::traced_test;

#[rstest]
#[case::installs_supergraph_at_pinned_version(Vec::from(["install", "--plugin", "supergraph@=2.8.0"]), "supergraph-v2.8.0")]
#[case::installs_supergraph_at_latest(Vec::from(["install", "--plugin", "supergraph@latest-2"]), "supergraph-")]
#[case::installs_router_at_pinned_version(Vec::from(["install", "--plugin", "router@=1.0.0"]), "router-v1.0.0")]
#[case::installs_router_at_latest(Vec::from(["install", "--plugin", "router@latest"]), "router-")]
#[case::installs_supergraph_at_pinned_version(Vec::from(["install", "--plugin", "supergraph@=2.8.0", "--client-timeout", "120"]), "supergraph-v2.8.0")]
#[case::installs_supergraph_at_latest(Vec::from(["install", "--plugin", "supergraph@latest-2", "--client-timeout", "120"]), "supergraph-")]
#[case::installs_router_at_pinned_version(Vec::from(["install", "--plugin", "router@=1.0.0", "--client-timeout", "120"]), "router-v1.0.0")]
#[case::installs_router_at_latest(Vec::from(["install", "--plugin", "router@latest", "--client-timeout", "120"]), "router-")]
#[ignore]
#[tokio::test(flavor = "multi_thread")]
#[traced_test]
async fn e2e_test_rover_install_plugin(#[case] args: Vec<&str>, #[case] binary_name: &str) {
// GIVEN
// - a install command for the supergraph binary that forces replacement; sometimes this
// - an install command for the supergraph binary that forces replacement; sometimes this
// forces a replacement (whenever there's already a supergraph binary of the right version
// installed) and other times it just intsalls the plugin
// WHEN
Expand All @@ -30,6 +30,14 @@ async fn e2e_test_rover_install_plugin(#[case] args: Vec<&str>, #[case] binary_n
let mut cmd = Command::cargo_bin("rover").expect("Could not find necessary binary");
cmd.env("APOLLO_HOME", temp_dir.clone());
cmd.args(args);
let output = cmd.output().expect("Could not run command");

asserting(&format!(
"Was expecting success but instead got: {}",
from_utf8(output.stderr.as_slice()).unwrap()
))
.that(&output.status.success())
.is_true();

// THEN
// - it successfully installs
Expand All @@ -41,7 +49,7 @@ async fn e2e_test_rover_install_plugin(#[case] args: Vec<&str>, #[case] binary_n
.any(|f| {
f.file_name()
.to_str()
.expect("failed to convert directroy filename to str")
.expect("failed to convert directory filename to str")
.contains(binary_name)
});

Expand All @@ -57,14 +65,15 @@ fn temp_dir() -> Utf8PathBuf {
}

#[rstest]
#[case::force_installs_supergraph(Vec::from(["install", "--force", "--plugin", "supergraph@=2.8.0", "--log", "debug"]), "supergraph-v2.8.0")]
#[case::force_installs_router(Vec::from(["install", "--force", "--plugin", "router@=1.0.0", "--log", "debug"]), "router-v1.0.0")]
#[case::force_installs_supergraph(Vec::from(["install", "--force", "--plugin", "supergraph@=2.8.0", "--log", "debug"]), "supergraph", "supergraph-v2.8.0")]
#[case::force_installs_router(Vec::from(["install", "--force", "--plugin", "router@=1.0.0", "--log", "debug"]), "router", "router-v1.0.0")]
#[ignore]
#[tokio::test(flavor = "multi_thread")]
#[traced_test]
async fn e2e_test_rover_install_plugin_with_force_opt(
#[case] args: Vec<&str>,
#[case] binary_name: &str,
#[case] binary: &str,
#[case] binary_filename: &str,
temp_dir: &Utf8PathBuf,
) {
let bin_path = temp_dir.join(".rover/bin");
Expand All @@ -82,7 +91,11 @@ async fn e2e_test_rover_install_plugin_with_force_opt(
cmd.args(args_without_force_option.clone());
let output = cmd.output().expect("Could not run command");
let stderr = std::str::from_utf8(&output.stderr).expect("failed to convert bytes to a str");
let re = Regex::new("the 'supergraph' plugin was successfully installed").unwrap();
let re = Regex::new(&format!(
"the '{}' plugin was successfully installed",
binary
))
.unwrap();
assert_that(&re.is_match(stderr)).is_true();

let installed = bin_path
Expand All @@ -94,7 +107,7 @@ async fn e2e_test_rover_install_plugin_with_force_opt(
f.file_name()
.to_str()
.expect("failed to convert directroy filename to str")
.contains(binary_name)
.contains(binary_filename)
});
assert_that(&installed).is_true();

Expand All @@ -114,8 +127,8 @@ async fn e2e_test_rover_install_plugin_with_force_opt(
.any(|f| {
f.file_name()
.to_str()
.expect("failed to convert directroy filename to str")
.contains(binary_name)
.expect("failed to convert directory filename to str")
.contains(binary_filename)
});
assert_that!(installed).is_true();

Expand All @@ -125,7 +138,11 @@ async fn e2e_test_rover_install_plugin_with_force_opt(
cmd.args(forced_args);
let output = cmd.output().expect("Could not run command");
let stderr = std::str::from_utf8(&output.stderr).expect("failed to convert bytes to a str");
let re = Regex::new("the 'supergraph' plugin was successfully installed").unwrap();
let re = Regex::new(&format!(
"the '{}' plugin was successfully installed",
binary
))
.unwrap();
assert_that!(re.is_match(stderr)).is_true();
}

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/subgraph/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ async fn e2e_test_rover_subgraph_publish(
schema_path.canonicalize().unwrap().to_str().unwrap(),
"--routing-url",
"https://eu-west-1.performance.graphoscloud.net/perfSubgraph01/graphql",
"--client-timeout",
"120",
&remote_supergraph_publish_test_variant_graphref,
]);
let output = cmd.output().expect("Could not run command");
Expand All @@ -113,7 +115,6 @@ async fn e2e_test_rover_subgraph_publish(
// left with subgraphs lying around. In the future we should move to something like
// test-context (https://docs.rs/test-context/latest/test_context/) so that we get cleanup
// for free. Until then we can manually clean up if it becomes necessary.
// TODO: Replace rstest fixtures with test-context
let mut subgraph_delete_cmd =
Command::cargo_bin("rover").expect("Could not find necessary binary");
subgraph_delete_cmd.args([
Expand Down
Loading