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

Move rest of e2e tests over to new testing framework #2224

Merged
merged 15 commits into from
Jan 16, 2024
Merged

Move rest of e2e tests over to new testing framework #2224

merged 15 commits into from
Jan 16, 2024

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Jan 11, 2024

This PR moves all e2e tests over to the new testing framework. See #2223 for more details on what this involves.

The e2e tests are not really factored as a testing framework but rather a loose collection of functions that use the lower-level testing framework to build up there tests. There is definitely room for improvement here to make adding e2e tests even easier, but for now, it's a relief to see that writing these tests with the low-level framework is actually fairly straight-forwarded.

As an example, here's the most complicated e2e test we currently have which tests whether running an app from a registry works:

   #[test]
    fn registry_works() -> anyhow::Result<()> {
        // configure that we're using the registry service. this service is backed by a Docker image
        let services = testing_framework::ServicesConfig::new(vec!["registry".into()])?;
        // when determining the args to pass to `spin up` first push the image to the registry
        let spin_up_args = |env: &mut testing_framework::TestEnvironment<()>| {
            let registry_url = format!(
                "localhost:{}/spin-e2e-tests/registry-works/v1",
                env.get_port(5000)?
                    .context("no registry port was exposed by test services")?
            );
            let mut registry_push = std::process::Command::new(spin_binary());
            registry_push.args(&["registry", "push", &registry_url, "--insecure"]);
            env.run_in(&mut registry_push)?;
            Ok(vec![
                "--from-registry".into(),
                registry_url,
                "--insecure".into(),
            ])
        };
        
        // Create a smoke test
        let mut env = bootstrap_smoke_test(
            &services,
            None,
            &[],
            "http-rust",
            |_| Ok(Vec::new()),
            |_| Ok(()),
            spin_up_args,
            testing_framework::SpinMode::Http,
        )?;

         // Assert against the Spin runtime
        assert_spin_request(
            env.runtime_mut(),
            testing_framework::Request::new(reqwest::Method::GET, "/"),
            200,
            &[],
            "Hello, Fermyon",
        )?;
        Ok(())
    }

Base automatically changed from e2e-testing-framework to main January 12, 2024 12:48
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev force-pushed the more-e2e branch 2 times, most recently from 79b501a to 52a1d56 Compare January 12, 2024 14:42
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev force-pushed the more-e2e branch 3 times, most recently from b6dd3ce to 70cb41a Compare January 12, 2024 15:03
@rylev rylev marked this pull request as ready for review January 12, 2024 15:06
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev force-pushed the more-e2e branch 6 times, most recently from 96e9fb9 to 9c6117f Compare January 15, 2024 13:25
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev merged commit bbbb59b into main Jan 16, 2024
11 checks passed
@rylev rylev deleted the more-e2e branch January 16, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants