-
Notifications
You must be signed in to change notification settings - Fork 973
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parameterizing spanner Host in spanner tests (#2020)
* Parameterizing spanner Host parameter in spanner tests * move testName cleanup logic to templateTestBase * spotless * Creating spannerTemplateITBase class for parameters for all SpannerITs * Adding comments * Adding a debug log * Spotless fix
- Loading branch information
1 parent
1c29788
commit a77d886
Showing
10 changed files
with
90 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...le-cloud-platform/src/main/java/org/apache/beam/it/gcp/spanner/SpannerTemplateITBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.apache.beam.it.gcp.spanner; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import org.apache.beam.it.gcp.TemplateTestBase; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
/** | ||
* Base class for all Spanner template integration tests. This class parameterizes the spannerHost | ||
* for all subclasses. If the "spannerHost" system property is not set, the value of spannerHost | ||
* will be set to STAGING_SPANNER_HOST and DEFAULT_SPANNER_HOST (as defined in {@link | ||
* SpannerResourceManager}). All tests in the base class will be run twice: once with spannerHost | ||
* set to STAGING_SPANNER_HOST and once with spannerHost set to DEFAULT_SPANNER_HOST. Otherwise, If | ||
* the "spannerHost" system property is set, its value will be used to set spannerHost. All | ||
* subclasses must use SpannerResourceManager.useCustomHost() and pass the spannerHost parameter to | ||
* it. | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public abstract class SpannerTemplateITBase extends TemplateTestBase { | ||
|
||
@Parameterized.Parameter(0) | ||
public String spannerHost; | ||
|
||
@Parameterized.Parameter(1) | ||
public String spannerHostName; | ||
|
||
// Because of parameterization, the test names will have subscripts. For example: | ||
// testSpannerToGCSAvroBase[Staging] | ||
@Parameters(name = "{1}") | ||
public static Collection parameters() { | ||
if (System.getProperty("spannerHost") != null) { | ||
return Arrays.asList(new Object[][] {{System.getProperty("spannerHost"), "Custom"}}); | ||
} | ||
return Arrays.asList( | ||
new Object[][] { | ||
{SpannerResourceManager.STAGING_SPANNER_HOST, "Staging"}, | ||
{SpannerResourceManager.DEFAULT_SPANNER_HOST, "Default"} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.