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

Tests | Move Exclude Groups to Constants and finalize them #1032

Merged
merged 4 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
SQL-2017:
Target_SQL: 'SQL-2k17-03'
Ex_Groups: 'xSQLv13'
Ex_Groups: 'xSQLv14'
SQL-2008R2:
Target_SQL: 'SQL-2k8R2-SP3-1'
Ex_Groups: 'xSQLv12'
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
<properties>
<!-- Allowed values for excluded Groups here - - - - - - - - - - - - -
xSQLv12 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2014
xSQLv13 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2017
xSQLv14 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2019
xSQLv14 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2017
xSQLv15 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2019
xAzureSQLDB - - - - For tests not compatible with Azure SQL Database - -
xAzureSQLDW - - - - For tests not compatible with Azure Data Warehouse -
xAzureSQLMI - - - - For tests not compatible with Azure SQL Managed Instance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Default testing enabled with SQL Server 2019 (SQLv14) -->
<excludeGroups>xSQLv14</excludeGroups>
<excludeGroups>xSQLv15</excludeGroups>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Driver Dependencies -->
<azure.keyvault.version>1.2.0</azure.keyvault.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void testActivityIDPooled() throws Exception {
CountDownLatch latchPoolOuterThread = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
CountDownLatch latchPool = new CountDownLatch(numPooledExecution);

public void run() {
HikariDataSource ds = new HikariDataSource(config);
es.execute(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public class AESetup extends AbstractTest {
public static void setUpConnection() throws TestAbortedException, Exception {
AETestConnectionString = connectionString + ";sendTimeAsDateTime=false";
readFromFile(Constants.JAVA_KEY_STORE_FILENAME, "Alias name");
try (Connection con = PrepUtil.getConnection(AETestConnectionString);
Statement stmt = con.createStatement()) {
try (Connection con = PrepUtil.getConnection(AETestConnectionString); Statement stmt = con.createStatement()) {
dropCEK(stmt);
dropCMK(stmt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
*
*/
@RunWith(JUnitPlatform.class)
@Tag("xSQLv12")
@Tag("xAzureSQLDW")
@Tag("xAzureSQLDB")
@Tag(Constants.xSQLv12)
@Tag(Constants.xAzureSQLDW)
@Tag(Constants.xAzureSQLDB)
public class CallableStatementTest extends AESetup {

private static String multiStatementsProcedure = RandomUtil.getIdentifier("multiStatementsProcedure");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
*
*/
@RunWith(JUnitPlatform.class)
@Tag("xSQLv12")
@Tag("xAzureSQLDW")
@Tag("xAzureSQLDB")
@Tag(Constants.xSQLv12)
@Tag(Constants.xAzureSQLDW)
@Tag(Constants.xAzureSQLDB)
public class JDBCEncryptionDecryptionTest extends AESetup {

private boolean nullable = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
*
*/
@RunWith(JUnitPlatform.class)
@Tag("xSQLv12")
@Tag("xAzureSQLDW")
@Tag("xAzureSQLDB")
@Tag(Constants.xSQLv12)
@Tag(Constants.xAzureSQLDW)
@Tag(Constants.xAzureSQLDB)
public class PrecisionScaleTest extends AESetup {

private static java.util.Date date = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@


@RunWith(JUnitPlatform.class)
@Tag("xSQLv12")
@Tag("xAzureSQLDW")
@Tag("xAzureSQLDB")
@Tag(Constants.xSQLv12)
@Tag(Constants.xAzureSQLDW)
@Tag(Constants.xAzureSQLDB)
public class RegressionAlwaysEncryptedTest extends AESetup {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected Object[][] getContents() {
{"R_createDropAlterTableFailed", "Create/drop/alter table with preparedStatement failed!"},
{"R_grantFailed", "grant table with preparedStatement failed!"},
{"R_connectionIsClosed", "The connection is closed."},
{"R_ConnectionURLNull", "The connection URL is null." },
{"R_ConnectionURLNull", "The connection URL is null."},
{"R_connectionIsNotClosed", "The connection is not closed."},
{"R_invalidExceptionMessage", "Invalid exception message"},
{"R_failedValidate", "failed to validate values in $0} "}, {"R_tableNotDropped", "table not dropped. "},
Expand Down
10 changes: 7 additions & 3 deletions src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class TestUtils {
private static ArrayList<SqlType> types = null;
private static final char[] HEXCHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F'};

final static int ENGINE_EDITION_FOR_SQL_AZURE = 5;
final static int ENGINE_EDITION_FOR_SQL_AZURE_DW = 6;
final static int ENGINE_EDITION_FOR_SQL_AZURE_MI = 8;
Expand All @@ -90,11 +90,14 @@ public class TestUtils {
*/
public static boolean isAzure(Connection con) {
if (null == isAzure) {
try (Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT CAST(SERVERPROPERTY('EngineEdition') as INT)")) {
try (Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT CAST(SERVERPROPERTY('EngineEdition') as INT)")) {
rs.next();

int engineEdition = rs.getInt(1);
isAzure = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE || engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_DW || engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_MI);
isAzure = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE
|| engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_DW
|| engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_MI);
isAzureDW = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_DW);
isAzureMI = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_MI);

Expand All @@ -118,6 +121,7 @@ public static boolean isAzureMI(Connection con) {
isAzure(con);
return isAzureMI;
}

/**
* Read variable from property files if found null try to read from env.
*
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/microsoft/sqlserver/jdbc/TimeoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.runner.RunWith;

import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.Constants;


@RunWith(JUnitPlatform.class)
Expand Down Expand Up @@ -55,15 +56,15 @@ public void after() throws InterruptedException {
}

@Test
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testBasicQueryTimeout() {
assertThrows(SQLTimeoutException.class, () -> {
runQuery(WAIT_FOR_ONE_MINUTE_SQL, TIMEOUT_SECONDS);
});
}

@Test
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testQueryTimeoutValid() {
long start = System.currentTimeMillis();
assertThrows(SQLTimeoutException.class, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.microsoft.sqlserver.jdbc.SQLServerBulkCopy;
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.Constants;
import com.microsoft.sqlserver.testframework.DBConnection;
import com.microsoft.sqlserver.testframework.DBStatement;
import com.microsoft.sqlserver.testframework.DBTable;
Expand All @@ -36,7 +37,7 @@ public class BulkCopyAllTypesTest extends AbstractTest {
* @throws SQLException
*/
@Test
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testTVPResultSet() throws SQLException {
if (isSqlAzureDW()) {
// TODO : Fix this test to run with Azure DW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
@RunWith(JUnitPlatform.class)
@DisplayName("Test bulkCopy with CSV")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public class BulkCopyCSVTest extends AbstractTest {

static String inputFile = "BulkCopyCSVTestInput.csv";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class BulkCopyColumnMappingTest extends BulkCopyTestSetUp {

@Test
@DisplayName("BulkCopy:test no explicit column mapping")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testNoExplicitCM() throws SQLException {
try (DBConnection con = new DBConnection(connectionString); DBStatement stmt = con.createStatement()) {
DBTable destTable = null;
Expand All @@ -62,7 +62,7 @@ public void testNoExplicitCM() throws SQLException {

@Test
@DisplayName("BulkCopy:test explicit column mapping")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testExplicitCM() throws SQLException {
try (DBConnection con = new DBConnection(connectionString); DBStatement stmt = con.createStatement()) {
DBTable destTable = null;
Expand Down Expand Up @@ -149,7 +149,7 @@ public void testUnicodeCM() throws SQLException {

@Test
@DisplayName("BulkCopy:test repetitive column mapping")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testRepetitiveCM() throws SQLException {
try (DBConnection con = new DBConnection(connectionString); DBStatement stmt = con.createStatement()) {
DBTable sourceTable1 = null;
Expand Down Expand Up @@ -373,8 +373,9 @@ private void validateValuesRepetitiveCM(DBConnection con, DBTable sourceTable,
try (DBStatement srcStmt = con.createStatement(); DBStatement dstStmt = con.createStatement();
DBResultSet srcResultSet = srcStmt.executeQuery("SELECT * FROM " + sourceTable.getEscapedTableName()
+ " ORDER BY" + sourceTable.getEscapedColumnName(0));
DBResultSet dstResultSet = dstStmt.executeQuery("SELECT * FROM "
+ destinationTable.getEscapedTableName() + " ORDER BY" + destinationTable.getEscapedColumnName(0))) {
DBResultSet dstResultSet = dstStmt
.executeQuery("SELECT * FROM " + destinationTable.getEscapedTableName() + " ORDER BY"
+ destinationTable.getEscapedColumnName(0))) {
ResultSetMetaData sourceMeta = ((ResultSet) srcResultSet.product()).getMetaData();
int totalColumns = sourceMeta.getColumnCount();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class BulkCopyConnectionTest extends BulkCopyTestSetUp {
* @return
*/
@TestFactory
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public Stream<DynamicTest> generateBulkCopyConstructorTest() {
List<BulkCopyTestWrapper> testData = createTestDatatestBulkCopyConstructor();
// had to avoid using lambdas as we need to test against java7
Expand All @@ -66,7 +66,7 @@ public void execute() {
* @return
*/
@TestFactory
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public Stream<DynamicTest> generateBulkCopyOptionsTest() {
List<BulkCopyTestWrapper> testData = createTestDatatestBulkCopyOption();
return testData.stream().map(new Function<BulkCopyTestWrapper, DynamicTest>() {
Expand Down Expand Up @@ -154,7 +154,7 @@ public void execute() throws SQLException {
*/
@Test
@DisplayName("BulkCopy:test null SQLServerBulkCopyOptions")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testEmptyBulkCopyOptions() {
BulkCopyTestWrapper bulkWrapper = new BulkCopyTestWrapper(connectionString);
bulkWrapper.setUsingConnection((0 == Constants.RANDOM.nextInt(2)) ? true : false, ds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
@RunWith(JUnitPlatform.class)
@DisplayName("Test ISQLServerBulkRecord")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public class BulkCopyISQLServerBulkRecordTest extends AbstractTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.Constants;
import com.microsoft.sqlserver.testframework.PrepUtil;


@RunWith(JUnitPlatform.class)
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public class BulkCopyResultSetCursorTest extends AbstractTest {

static BigDecimal[] expectedBigDecimals = {new BigDecimal("12345.12345"), new BigDecimal("125.123"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.Constants;


@RunWith(JUnitPlatform.class)
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public class BulkCopyRowSetTest extends AbstractTest {

private static String tableName = AbstractSQLGenerator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class BulkCopyTimeoutTest extends BulkCopyTestSetUp {
*/
@Test
@DisplayName("BulkCopy:test zero timeout")
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testZeroTimeOut() throws SQLException {
testBulkCopyWithTimeout(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.Constants;


@RunWith(JUnitPlatform.class)
Expand Down Expand Up @@ -82,7 +83,7 @@ public void testVarchar() throws Exception {
* @throws Exception
*/
@Test
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testSmalldatetime() throws Exception {
variation = "testSmalldatetime";
BulkData bData = new BulkData(variation);
Expand Down Expand Up @@ -111,7 +112,7 @@ public void testSmalldatetime() throws Exception {
* @throws Exception
*/
@Test
@Tag("xAzureSQLDW")
@Tag(Constants.xAzureSQLDW)
public void testSmalldatetimeOutofRange() throws Exception {
variation = "testSmalldatetimeOutofRange";
BulkData bData = new BulkData(variation);
Expand Down
Loading