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

Support injecting system properties into JUnit tests #19348

Closed
wants to merge 2 commits into from

Conversation

wendigo
Copy link
Contributor

@wendigo wendigo commented Oct 11, 2023

Fixes broken master:

Error:  io.trino.plugin.hive.TestHiveThriftMetastoreWithS3 -- Time elapsed: 0.040 s <<< ERROR!
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.lang.String s3endpoint] in constructor [public io.trino.plugin.hive.TestHiveThriftMetastoreWithS3(java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException].
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

@wendigo wendigo requested a review from findepi October 11, 2023 11:12
@cla-bot cla-bot bot added the cla-signed label Oct 11, 2023
@wendigo wendigo force-pushed the serafin/junit-parameters branch from e5bb317 to 6e0efbe Compare October 11, 2023 11:18
@wendigo wendigo requested review from kokosing and hashhar October 11, 2023 11:18
@wendigo wendigo force-pushed the serafin/junit-parameters branch from 6e0efbe to 3fe29bf Compare October 11, 2023 11:28
@wendigo
Copy link
Contributor Author

wendigo commented Oct 11, 2023

Fixed test classes are running with JUnit

@findepi
Copy link
Member

findepi commented Oct 11, 2023

I allowed myself to merge #19337 to fix the master branch.
Please rebase & revert the revert.

This PR switched ensureTestNamingConvention to run in JUnit to reduce test setups
@wendigo
Copy link
Contributor Author

wendigo commented Oct 11, 2023

@findepi done

@wendigo wendigo force-pushed the serafin/junit-parameters branch from 3fe29bf to 2af5b90 Compare October 11, 2023 12:55

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface SystemProperty
Copy link
Member

Choose a reason for hiding this comment

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

nit:
Define as top level class.
This helps Intellij generate imports

(for nested class Intellij strongly prefers OutClass.InnerClass syntax which is all but pretty)

@@ -56,10 +56,10 @@
import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Copy link
Member

Choose a reason for hiding this comment

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

Separate commit.

Also, just noticed that one of the overrides BaseConnectorTest#ensureTestNamingConvention, does not have @Test annotation (actually it has testng's @Test, but not Junit's @Test).
As a result, the override won't be called.
Please update BaseConnectorTest.ensureTestNamingConvention to have additional junit @Test annotation (but keep testng's for now, since all other test methods are testng's)

Copy link
Member

Choose a reason for hiding this comment

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

When extracting the commit please be so nice to include message from 6858091

For many test classes, this it the last method that is not converted.
For example, running TestInformationSchemaConnector with TestNG will
run only this method. Moving this will make tests like
TestInformationSchemaConnector JUnit-only and improve test overall
time (fewer createQueryRunner invocations).

Obviously, it can be the first JUnit test method for some other classes,
but

  • the train cannot be stopped. We do this sooner or later.
  • AbstractTestQueries are already JUnit; BaseConnectorTest extends
    from AbstractTestQueries and BaseConnectorTest are most likely to
    most expensive setups, because they create dependant services.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In which order I should add this one? Because in either one one of the commits will be broken on it's own

@github-actions github-actions bot added tests:hive iceberg Iceberg connector delta-lake Delta Lake connector hive Hive connector bigquery BigQuery connector labels Oct 11, 2023
@dain
Copy link
Member

dain commented Oct 11, 2023

I'm not sure why we need this. This seems to swap:

this.alternateProjectId = requireNonNull(System.getProperty("testing.alternate-bq-project-id"), "testing.alternate-bq-project-id system property not set");

for

public TestBigQueryWithDifferentProjectIdConnectorSmokeTest(@SystemProperty("testing.alternate-bq-project-id") String alternateProjectId)
{
    this.alternateProjectId = requireNonNull(alternateProjectId, "alternateProjectId is null");
}

Is there some non-obvious improvement? If not, I don't see why we need this.

Copy link
Member

@dain dain left a comment

Choose a reason for hiding this comment

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

I'm not sure why we need this complexity

@wendigo wendigo closed this Oct 12, 2023
@wendigo wendigo deleted the serafin/junit-parameters branch October 12, 2023 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigquery BigQuery connector cla-signed delta-lake Delta Lake connector hive Hive connector iceberg Iceberg connector
Development

Successfully merging this pull request may close these issues.

4 participants