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

Add snapshot testing to CLI & set up AWS mock #13672

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

blaginin
Copy link
Contributor

@blaginin blaginin commented Dec 5, 2024

Which issue does this PR close?

Related to #13456 (comment)

Rationale for this change

We currently don't test whether our external integrations actually work: as a result #13576 has happened.

What changes are included in this PR?

Integration tests for S3.

Are there any user-facing changes?

No.

@blaginin blaginin changed the title Add snap to CLI & set up AWS mock Add snapshot testing to CLI & set up AWS mock Dec 6, 2024
@@ -0,0 +1,16 @@
# you should have localstack up, e.g by
#$ LOCALSTACK_VERSION=sha256:a0b79cb2430f1818de2c66ce89d41bba40f5a1823410f5a7eaf3494b692eed97
#$ podman run -d -p 4566:4566 localstack/localstack@$LOCALSTACK_VERSION
Copy link
Member

Choose a reason for hiding this comment

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

arguably docker is kind of more standard way.

also, would it be possible not to require manual copy-pasting of the commmands?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exit_code: 0
----- stdout -----
+----------+
| Int64(1) |
Copy link
Member

Choose a reason for hiding this comment

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

How are these files generated / updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


glob!("sql/*.sql", |path| {
let input = fs::read_to_string(path).unwrap();
assert_cmd_snapshot!("test_storage_integration", cli().pass_stdin(input))
Copy link
Member

Choose a reason for hiding this comment

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

would be nice to pull "test_storage_integration" out of the test name automatically, to avoid copy-paste mistakes.

fwiw such functionality exists in the goldie crate (that's also for output testing), and is as simple as

#[macro_export]
macro_rules! current_function_plain_name {
    () => {{
        fn f() {}
        fn type_name_of_val<T>(_: T) -> &'static str {
            ::std::any::type_name::<T>()
        }
        let mut name = type_name_of_val(f).strip_suffix("::f").unwrap_or("");
        while let Some(rest) = name.strip_suffix("::{{closure}}") {
            name = rest;
        }
        name.split("::").last().unwrap_or(name)
    }};
}

(admittedly hacky, but quite helpful)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, fixed in 53c9c51

@github-actions github-actions bot added documentation Improvements or additions to documentation sql SQL Planner development-process Related to development process of DataFusion core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Dec 10, 2024
@blaginin
Copy link
Contributor Author

This PR is ready ish for the reivew - but i want to merge #13576 first, so this one has a smaller diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Related to common crate core Core DataFusion crate development-process Related to development process of DataFusion documentation Improvements or additions to documentation sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants