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

KSQL-398: integration test covering quickstart scenarios #431

Conversation

apurvam
Copy link
Contributor

@apurvam apurvam commented Nov 2, 2017

This patch covers all the queries in the quickstart, including the 'plain' select statements.

I have noticed that the join between the pageviews stream and the users table sometimes results in 'null' values for the columns in the users table. @hjafarpour thinks that this is because the rocksdb store isn't ready when the join is executed, resulting in an empty user table and null values for the corresponding fields in the join.

@ghost
Copy link

ghost commented Nov 2, 2017

@confluentinc It looks like @apurvam just signed our Contributor License Agreement. 👍

Always at your service,

clabot

@dguy
Copy link
Contributor

dguy commented Nov 2, 2017

retest this please

@@ -112,6 +112,10 @@ public void sql(String sql) throws Exception {
return ksqlEngine.getLiveQueries();
}

public KsqlEngine getKsqlEngine() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to expose this? i.e., it seems it is only required for the purpose of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I said below, we need a reference to the ksqlEngine to submit non-persistent queries. The integration test is in a separate package, so it can't be package-private. Open to suggestions for how to resolve this. One option is to enable the ksqlContext.sql method to run non-persistent queries. But I am not sure if that makes sense from an API perspective.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need another way where we don't expose the KsqlEngine from an API PoV it is a big increase in the surface area

Copy link
Contributor

Choose a reason for hiding this comment

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

@bluemonk3y @hjafarpour thoughts on this? i.e, it seems that the KsqlContext is pretty limited. Is this ok? Should we make it a bit more useable, so we can easily do what @apurvam is trying to achieve without having to get a handle to the ksqlEngine?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, KsqlContext should not expose the engine.
@apurvam maybe you can use KsqlEngine directly in your test.

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 updated the code to use KSQLEngine directly.

String query = String.format("SELECT * from %s;", userTable);
log.debug("Sending query: {}", query);

List<QueryMetadata> queries = ksqlContext.getKsqlEngine().buildMultipleQueries(false, query, Collections.emptyMap());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use ksqlContext.sql(...) here and then call ksqlContext.getRunningQueries()?
Same in the other tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't use ksqlContext.sql directly because it has an explicit check that the queries submitted through that method are persistent queries. These are not persistent queries, so they need to be submitted directly to the ksqlEngine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a bit of a shame. Means that KsqlContext is extremely limiting! I know not for this PR, just saying

BlockingQueue<KeyValue<String, GenericRow>> rowQueue = queryMetadata.getRowQueue();

Set<String> actualUsers = new HashSet<>();
Set<String> expectedUsers = new HashSet<>(Arrays.asList("USER_0", "USER_1", "USER_2", "USER_3", "USER_4"));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Utils.mkSet(...)

List<String> actualPages = new ArrayList<>();
List<String> actualUsers = new ArrayList<>();

while (results.size() < 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a timeout on this loop? Or maybe use TestUtils#waitForCondition? i.e., is there a chance this will loop forever?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea. I was thinking about that. It's better to just fail out if we don't get anything after a minute or something, rather than having the test hang.

List<String> actualPages = new ArrayList<>();
List<String> expectedPages = Arrays.asList("PAGE_5");

while (actualPages.size() < 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

replicatonFactor) {
log.info("Creating topic '{}'", topic);

public void createTopic(final String topic, final int numPartitions, final short replicatonFactor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method overrides a the same method from the interface. It needs @Override annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. That is a rebase mistake. Will clean it up.

@hjafarpour
Copy link
Contributor

retest this please

@apurvam apurvam force-pushed the KSQL-398-integration-test-covering-quickstart-scenarios branch from 25403c6 to c63600b Compare November 3, 2017 19:48
@apurvam
Copy link
Contributor Author

apurvam commented Nov 7, 2017

I'm still waiting for one more LGTM before merging, as per our agreed conventions.

Copy link
Contributor

@dguy dguy left a comment

Choose a reason for hiding this comment

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

LGTM

@apurvam apurvam merged commit 5af365c into confluentinc:4.0.x Nov 8, 2017
@apurvam apurvam deleted the KSQL-398-integration-test-covering-quickstart-scenarios branch November 8, 2017 19:25
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