-
Notifications
You must be signed in to change notification settings - Fork 167
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
SNOW-1693588 Upgrade to JUnit5 #1909
base: master
Are you sure you want to change the base?
Conversation
src/test/java/net/snowflake/client/annotations/DontRunOnGithubActions.java
Show resolved
Hide resolved
src/test/java/net/snowflake/client/jdbc/structuredtypes/ResultSetStructuredTypesLatestIT.java
Outdated
Show resolved
Hide resolved
src/test/java/net/snowflake/client/providers/FormatProvider.java
Outdated
Show resolved
Hide resolved
src/test/java/net/snowflake/client/providers/SimpleFormatProvider.java
Outdated
Show resolved
Hide resolved
# Conflicts: # src/test/java/net/snowflake/client/jdbc/ClientMemoryLimitParallelIT.java # src/test/java/net/snowflake/client/jdbc/ConnectionIT.java # src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java # src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataIT.java # src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java # src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultsetIT.java # src/test/java/net/snowflake/client/jdbc/MultiStatementLatestIT.java # src/test/java/net/snowflake/client/jdbc/OpenGroupCLIFuncIT.java # src/test/java/net/snowflake/client/jdbc/PreparedMultiStmtArrowIT.java # src/test/java/net/snowflake/client/jdbc/PreparedMultiStmtIT.java # src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java # src/test/java/net/snowflake/client/jdbc/SnowflakeUtilTest.java # src/test/java/net/snowflake/client/jdbc/StreamLatestIT.java
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
public class CallableStatementITBase extends BaseJDBCTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been created to remove inheritance between CallableStatementIT
and CallableStatementLatestIT
in order to avoid duplicating tests.
@@ -25,6 +27,7 @@ public void setup() { | |||
} | |||
|
|||
@Test | |||
@Disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test has serious isolation problems, and as far as I can tell was never actually ran. To be fixed later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add an issue for such problems and mark the tests with TODO comment with JIRA ID
import org.junit.jupiter.params.provider.ArgumentsSource; | ||
|
||
// @Category(TestCategoryStatement.class) | ||
@Tag(TestTags.STATEMENT) | ||
public class PreparedStatement1IT extends PreparedStatement0IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class combines previous PreparedStatement1IT
and PreparedStatementArrow1IT
|
||
/** | ||
* PreparedStatement integration tests for the latest JDBC driver. This doesn't work for the oldest | ||
* supported driver. Revisit this tests whenever bumping up the oldest supported driver to examine | ||
* if the tests still are not applicable. If it is applicable, move tests to PreparedStatement1IT so | ||
* that both the latest and oldest supported driver run the tests. | ||
*/ | ||
@Category(TestCategoryStatement.class) | ||
// @Category(TestCategoryStatement.class) | ||
@Tag(TestTags.STATEMENT) | ||
public class PreparedStatement1LatestIT extends PreparedStatement0IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class combines previous PreparedStatement1LatestIT
and PreparedStatementArrow1LatestIT
import org.junit.jupiter.params.provider.ArgumentsSource; | ||
|
||
// @Category(TestCategoryStatement.class) | ||
@Tag(TestTags.STATEMENT) | ||
public class PreparedStatement2IT extends PreparedStatement0IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class combines previous PreparedStatement2IT
and PreparedStatementArrow2IT
|
||
/** Test ResultSet */ | ||
@Category(TestCategoryResultSet.class) | ||
// @Category(TestCategoryResultSet.class) | ||
@Tag(TestTags.RESULT_SET) | ||
public class ResultSetIT extends ResultSet0IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now combines old ResultSetIT
and ResultSetArrowIT
|
||
/** SnowflakeResultSetSerializable tests */ | ||
@Category(TestCategoryResultSet.class) | ||
// @Category(TestCategoryResultSet.class) | ||
@Tag(TestTags.RESULT_SET) | ||
public class SnowflakeResultSetSerializableIT extends BaseJDBCTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now handles both json and arrow tests
<dependency> | ||
<groupId>org.apache.maven.surefire</groupId> | ||
<artifactId>surefire-junit-platform</artifactId> | ||
<version>3.5.1</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add version to the properties - here and in other places in poms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
$MVNW_EXE -DjenkinsIT \ | ||
-Djava.io.tmpdir=$WORKSPACE \ | ||
-Djacoco.skip.instrument=false \ | ||
-DtestCategory=net.snowflake.client.category.$c \ | ||
-Dtest="$JDBC_TEST_CATEGORY" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change the property name to JDBC_TEST_SUITES?
here and in other scripts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll do that
@Retention(RetentionPolicy.RUNTIME) | ||
@EnabledIfEnvironmentVariable(named = "SNOWFLAKE_TEST_ACCOUNT", matches = "testaccount") | ||
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = ".*") | ||
public @interface RunOnTestaccount {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename - run on test account not on github actions
@@ -87,7 +86,7 @@ public void testThrowErrorWhenWrongPermissionsForConnectionConfigurationFile() | |||
File tokenFile = new File(Paths.get(tempPath.toString(), "token").toUri()); | |||
prepareConnectionConfigurationTomlFile( | |||
Collections.singletonMap("token_file_path", tokenFile.toString()), false, false); | |||
assumeFalse(RunningNotOnLinuxMac.isNotRunningOnLinuxMac()); | |||
assumeFalse(AssumptionUtils.isNotRunningOnLinuxMac()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we replace the assumptions (here and in other places) with annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can investigate this, for now it is recreating 1:1 original behaviour. I think this can be addressed in a later PR
|
||
@Category(TestCategoryCore.class) | ||
// @Category(TestCategoryCore.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove categories annotations instead of commenting in all places
} | ||
|
||
@Test | ||
public void shouldChooseOcspCacheServerUrls() { | ||
// @Parameterized.Parameters( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove unnecessary comments
import static org.junit.Assume.assumeNoException; | ||
import static org.junit.Assume.assumeTrue; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
// import static org.junit.jupiter.api.Assumptions.assumeNoException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's removed unnecessary code
} | ||
|
||
try (ResultSet resultSet = | ||
databaseMetaData.getCrossReference(null, null, null, null, null, null)) { | ||
assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2)); | ||
MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we import static MatcherAssert.assertThat?
@@ -164,7 +162,7 @@ public void testGetVectorViaGetStringIsEqualToTheGetObject() throws SQLException | |||
assertTrue(resultSet.next()); | |||
assertGetObjectAndGetStringBeTheSame(resultSet, "[-1,5]", 1); | |||
String floatArrayRepresentation = | |||
"json".equals(queryResultFormat) | |||
"JSON".equals(queryResultFormat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use equals ignore case
@@ -1471,14 +1491,63 @@ public void testNoSpaceLeftOnDeviceException() throws SQLException { | |||
} | |||
|
|||
@Test | |||
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class) | |||
@Disabled // ignored until SNOW-1616480 is resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a TODO to comment
# Conflicts: # parent-pom.xml
Overview
SNOW-1693588 upgraded all tests to junit5. There are a lot of changes, but most are of following types:
@Test
annotation, Assumptions, Assertions)@Before
to@BeforeEach
,@BeforeClass
to@BeforeAll
etc.)@BeforeClass
annotations could not be translated to junit5, as the fields they depend on no longer exist. As a result, in those cases relevant functions are now called at the beginning of each test. (Could be remedied later I believe)@Rule
to@TempDir
)@TempDir
on windows)@Category
annotations to junit5@Tag
assertThrows
instead.Pre-review self checklist
master
branchmvn -P check-style validate
)mvn verify
and inspecttarget/japicmp/japicmp.html
)SNOW-XXXX: