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

[Native] Introduce functional native test framework using TestContainers #23094

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

Joe-Abraham
Copy link
Contributor

@Joe-Abraham Joe-Abraham commented Jun 27, 2024

Resolves: #23086

== NO RELEASE NOTE ==

@Joe-Abraham Joe-Abraham requested review from steveburnett and a team as code owners June 27, 2024 06:28
@Joe-Abraham Joe-Abraham changed the title Add ContainerQueryRunner and add Unnest test cases Add ContainerQueryRunner Jun 27, 2024
@Joe-Abraham Joe-Abraham marked this pull request as draft June 27, 2024 08:31
steveburnett
steveburnett previously approved these changes Jun 28, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

@tdcmeehan
Copy link
Contributor

This looks good, but actually most of the expressions in this query runner will be evaluated by the coordinator. Would it be possible to add TPCH data and relevant tests?

@Joe-Abraham Joe-Abraham force-pushed the containertest branch 3 times, most recently from 3a65dd3 to 7174734 Compare July 8, 2024 10:34
@Joe-Abraham Joe-Abraham changed the title Add ContainerQueryRunner Modify TestPrestoContainerBasicQueries to use AbstractTestQueryFramework Jul 8, 2024
@Joe-Abraham Joe-Abraham changed the title Modify TestPrestoContainerBasicQueries to use AbstractTestQueryFramework Improve TestPrestoContainerBasicQueries to use AbstractTestQueryFramework Jul 8, 2024
@Joe-Abraham Joe-Abraham changed the title Improve TestPrestoContainerBasicQueries to use AbstractTestQueryFramework Improve Container based test Jul 8, 2024
@Joe-Abraham Joe-Abraham changed the title Improve Container based test Improve container based test Jul 8, 2024
@Joe-Abraham Joe-Abraham marked this pull request as ready for review July 8, 2024 10:43
@Joe-Abraham
Copy link
Contributor Author

@tdcmeehan We have added a few relevant tests with tables using the TPCH connector. Can you please have a look?

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @Joe-Abraham. Have couple of comments.

@Joe-Abraham Joe-Abraham marked this pull request as draft July 24, 2024 15:46
@Joe-Abraham Joe-Abraham force-pushed the containertest branch 2 times, most recently from b928bc5 to 311da10 Compare July 25, 2024 06:21
@Joe-Abraham Joe-Abraham marked this pull request as ready for review July 25, 2024 06:24
TimeUnit.SECONDS.sleep(5);
}
catch (InterruptedException e) {
throw new RuntimeException(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

or just continue on?

execResult = coordinator.execInContainer(command);
}
catch (IOException e) {
fail("Presto CLI failed with error message: " + e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

It's clearer to the end user to let the exception bubble up and fail the test than convert it into a fail call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Override
   public MaterializedResult execute(Session session, String sql) { ... }

Can we add exceptions to an override method? If so, aren't we required to edit its base class and the other children of the parent class?

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 think this will also introduce many changes in com/facebook/presto/sql/query/QueryAssertions.java wherever the execute gets called.

extends AbstractTestQueryFramework
{
@Test
public void testTpchTinyTables()
Copy link
Contributor

Choose a reason for hiding this comment

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

use a data provider to break this up into tests that an pass and fail independently.

@Joe-Abraham Joe-Abraham force-pushed the containertest branch 4 times, most recently from 15bb23d to a90d325 Compare July 31, 2024 09:47
Copy link
Contributor

@tdcmeehan tdcmeehan left a comment

Choose a reason for hiding this comment

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

Just a couple of nits, otherwise LGTM

return ContainerQueryRunnerUtils.toMaterializedResult(execResult.getStdout());
}
catch (IOException | InterruptedException e) {
fail("Execute failed with error message: " + e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

Rethrow the IOException as UncheckedIOException. For InterruptedException, just rethrow as RuntimeException.

return Boolean.parseBoolean(value);
}
else {
fail("Unsupported type: " + type);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just throw here

Suggested change
fail("Unsupported type: " + type);
throw new UnsupportedOperationException("Unsupported type: " + type);

Copy link
Contributor

@tdcmeehan tdcmeehan left a comment

Choose a reason for hiding this comment

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

Two more minor nits

private final String catalog;
private final String schema;
private final int numberOfWorkers;
Logger logger = Logger.getLogger(ContainerQueryRunner.class.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Logger logger = Logger.getLogger(ContainerQueryRunner.class.getName());
private static Logger logger = Logger.getLogger(ContainerQueryRunner.class.getName());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified it

this.schema = schema;
this.numberOfWorkers = numberOfWorkers;

// TODO: This framework is tested only in Ubuntu x86_64, as there is no support to run the native docker images in ARM based system,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you create an issue for this once it's merged?

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 work is in progress #23275

@tdcmeehan tdcmeehan merged commit c2290c7 into prestodb:master Aug 1, 2024
59 checks passed
Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Lazy review. +1

@Joe-Abraham Joe-Abraham deleted the containertest branch August 1, 2024 16:12
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.

Presto needs a modern functional testing framework that runs tests using real infrastructure
6 participants