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

E2E Error Output Tests #1502

Merged
merged 5 commits into from
May 23, 2023
Merged

E2E Error Output Tests #1502

merged 5 commits into from
May 23, 2023

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented May 17, 2023

This adds the start of a testing of the error output from spin. The end vision is an easy way for developers to add tests for some sort of broken Spin experience and test the actual stdout/stderr output against some expected output.

We're not quite there, but this PR makes significant changes to the e2e testing framework to allow for test Spin apps to fail with (necessarily) failing the test. I've added one test as well to give an idea of how these tests might work in the future. However, I expect the experience of adding new tests to improve with time as we bake in more convention on how to write such tests.

Note: I did quite a bit of clean up along the way which might make this somewhat difficult to review. I apologize for this, but I hope the intention is still clear. Please let me know if you need more explanation of the changes, and I can write up a more thorough summary.

@rylev rylev requested a review from rajatjindal May 17, 2023 11:56
}

//this ensure we have mutex lock until here
drop(x);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could tell this drop call is not necessary (the mutex lock will be dropped right after this at the end of the function.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itowlson suggested to use explicit drops for better readability.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I understand that when the drop happens early, and you want to show that the lock has been given up before doing more work, but the drop will happen right after this... This strikes me as fairly unidiomatic.

Err(err) => Err(err),
}
let output = utils::run(&["spin", "--version"], None, None)?;
utils::assert_success(&output);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may eventually remove these assertions in favor of the top-level testing code asserting success. For now though we'll leave this here as every test assumes that these calls succeed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -35,7 +35,7 @@ services:
registry:
image: ${REGISTRY_IMAGE:-registry:2}
ports:
- "5000:5000"
- "5001:5000"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change because macOS uses port 5000 for ControlCenter now...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkill -f ControlCenter has become my go-to these days.. I think you can stop it altogether, but the change LGTM.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to change this port in tests/testcases/mod.rs as we use it there

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or may be not. because tests run in docker context as well

@rylev rylev force-pushed the e2e-errors-messages branch 5 times, most recently from a2db514 to d6d2c37 Compare May 19, 2023 09:08
if let Some(envs) = envs {
for (k, v) in envs {
cmd.env(k, v);
}
}

let output = cmd.output()?;
let code = output.status.code().expect("should have status code");
println!("Running command: {cmd:?}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to move this to debug instead of printing always?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally did this so that it was clear if the tests panicked due to the command failing what the command was (since the command itself is no longer printed in the panic message). I'm not against moving to debug but this might make it less obvious what went wrong when something did. Perhaps we leave it for now, and see how annoying it is before changing it?

@rajatjindal
Copy link
Collaborator

these changes looks good to me. once again, thank you for putting in time to make improvements here.

Copy link
Collaborator

@rajatjindal rajatjindal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets 🚢 it.

@rylev
Copy link
Collaborator Author

rylev commented May 23, 2023

Annoyingly the broken test consistently works locally. Looks like for some reason there's some extra whitespace produced by spin when running on the CI server.

rylev added 5 commits May 23, 2023 14:43
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 merged commit f3a251e into main May 23, 2023
@rylev rylev deleted the e2e-errors-messages branch May 23, 2023 14:37
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.

3 participants