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

Open
wants to merge 30 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

# Conflicts:
#	datafusion-cli/Cargo.lock
Comment on lines +183 to +189
- name: Setup Minio - S3-compatible storage
working-directory: datafusion-cli
run:
echo "MINIO_CONTAINER=$(docker run -d -p 9000:9000 -e MINIO_ROOT_USER=TEST-DataFusionLogin -e MINIO_ROOT_PASSWORD=TEST-DataFusionPassword quay.io/minio/minio server /data)" >> $GITHUB_ENV
- name: Run tests (excluding doctests, but with integration tests)
working-directory: datafusion-cli
run: cargo test --lib --tests --bins --all-features
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alamb you sugessting copying object_store approach for testing.

In object_store, they use Localstack for S3 simulation. It works fine for testing, but the problem is that it doesn't actually validate the credentials.

In another part of object_store, Minio is used, and it does validate credentials. So, I think we should switch to using Minio for testing here.

# Conflicts:
#	datafusion/common/src/config.rs
#	datafusion/core/tests/config_from_env.rs
#	datafusion/sqllogictest/test_files/information_schema.slt
#	docs/source/user-guide/configs.md
@github-actions github-actions bot removed documentation Improvements or additions to documentation sql SQL Planner core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Dec 20, 2024
@blaginin blaginin marked this pull request as ready for review December 20, 2024 18:04
@blaginin blaginin requested a review from findepi December 20, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development-process Related to development process of DataFusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants