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

Spark 3.5: Remove constructor from parameterized base class #9368

Merged
merged 1 commit into from
Dec 24, 2023

Conversation

nastra
Copy link
Contributor

@nastra nastra commented Dec 23, 2023

After reviewing/merging #9342 I realized that parameterized base classes should not have a constructor but rather have their parameters set via @Parameter. All other setup code should go into a @BeforeEach method to properly initialize the test environment

Parameterized base classes should not have a constructor but rather have
their parameters set via `@Parameter`. All other setup code should go
into a `@BeforeEach` method to properly initialize the test environment
@@ -30,7 +29,7 @@ public abstract class CatalogTestBase extends TestBaseWithCatalog {

// these parameters are broken out to avoid changes that need to modify lots of test suites
@Parameters(name = "catalogName = {0}, implementation = {1}, config = {2}")
public static Object[][] parameters() {
protected static Object[][] parameters() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

JUnit4 required this to be public but for JUnit5 we can make it protected

protected static Object[][] parameters() {
return new Object[][] {
{
SparkCatalogConfig.HADOOP.catalogName(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of the subclasses of this test that didn't specify any particular parameter were running with this configuration (this is also the configuration that was initialized in the default constructors in L70

@@ -50,7 +50,7 @@ public void removeTables() {
sql("DROP TABLE IF EXISTS %s", tableName);
}

@Test
@TestTemplate
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of the subclasses of TestBaseWithCatalog are parameterized tests

@@ -39,11 +38,6 @@

public class TestSparkStagedScan extends CatalogTestBase {

public TestSparkStagedScan(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this and the class below were running with the three different catalog configurations defined in CatalogTestBase and I've verified that this is still the case

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

Great improvement @nastra! Looking good

@nastra nastra merged commit 226a23f into apache:main Dec 24, 2023
31 checks passed
@nastra nastra deleted the spark-parameterized-testing-fix branch December 24, 2023 14:09
lisirrx pushed a commit to lisirrx/iceberg that referenced this pull request Jan 4, 2024
geruh pushed a commit to geruh/iceberg that referenced this pull request Jan 26, 2024
devangjhabakh pushed a commit to cdouglas/iceberg that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants