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

feat: introduce the sql-based testing tool (YATT) #6051

Merged
merged 4 commits into from
Aug 19, 2020

Conversation

agavra
Copy link
Contributor

@agavra agavra commented Aug 19, 2020

Description

First draft at the fully implemented KsqlTester (see #5965). Review guide:

  • Start by looking at test.sql to see how the testing tool works end-to-end
  • Then look at KsqlTesterTest to see the full test in action. I'm planning on refactoring this further when I make it a standalone tool, but given that I want this to test query upgrades I'm leaving this in a little bit of a rougher state for now
  • Look at SqlTestLoader to see how we load tests
  • Look at AssertExecutor to look at asserting mechanism. I'm planning on improving the assertion mechanism to leverage the SELECT formatting of rows when I make this tool public, but for now it just compares the Generic representation of rows directy
  • The rest is piping/formatting exceptions/etc...

Testing done

  • test.sql tests this end to end

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

}

public enum Type {
TEST("test"),
EXPECTED_ERROR("expected.error"),
EXPECTED_MESSAGE("expected.message"),
ENABLED("enabled"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this because it's not super easy to implement cleanly given the iterative nature of the tests. since the sql file supports multiline comments, it's easy enough to disable a test like this:

/* (disabled)
--@test: foo bar
CREATE STREAM foo...;
INSERT INTO ...;
ASSERT VALUES ...;
*/

}
}

public static void assertStream(final AssertStream assertStatement) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll implement these in a future PR since to do it "right" involves some engine refactoring to leverage what we already have in production code

@agavra agavra marked this pull request as ready for review August 19, 2020 18:18
@agavra agavra requested a review from a team as a code owner August 19, 2020 18:18
-- this test file is a "meta-test" that tests the basic functionality of the KsqlTester
-- eventually, we plan to remove this test in favor of migrating the QTTs over to use this format
-- directly

Copy link
Member

Choose a reason for hiding this comment

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

I see anything related to windowing is missing. Is this because it is not supported in this PR yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Windowed keys aren't yet supported in our grammar so it'll take a bit of extra work to add support for windowing - I'll work on this after I have some basic query upgrade tests written

CREATE STREAM bar AS SELECT * FROM foo;

INSERT INTO foo (rowtime, id, col1) VALUES (1, 1, 1);
ASSERT VALUES bar (rowtime, id, col1) VALUES (1, 1, 1);
Copy link
Member

Choose a reason for hiding this comment

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

Also, Assert stream and Assert table are missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, they are not implemented yet (see AssertExecutor)

Copy link
Member

Choose a reason for hiding this comment

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

I just saw your comment in AssertExecutor so nvm

* @param path the top-level dir to load
*/
public SqlTestLoader(final Predicate<SqlTest> testFilter, final Path path) {
this.shouldRun = Objects.requireNonNull(testFilter, "testFilter");
Copy link
Member

Choose a reason for hiding this comment

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

How would the shouldRun be used? Will there be tests in a test file that one can indicate that they should be skipped? If so, should we add an example to test.sql?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the idea was to use shouldRun to filter tests to run or not run based on some regex exp. I wasn't going to implement it in this PR quite yet but I figured I might as well set it up here

@vpapavas vpapavas self-assigned this Aug 19, 2020
Copy link
Member

@vpapavas vpapavas left a comment

Choose a reason for hiding this comment

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

LGTM! Super excited to see this

@agavra agavra merged commit 33e71c3 into confluentinc:master Aug 19, 2020
@agavra agavra deleted the testing_tool branch August 19, 2020 21:07
sarwarbhuiyan pushed a commit to sarwarbhuiyan/ksql that referenced this pull request Sep 4, 2020
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