Skip to content

Commit 45768c3

Browse files
authored
Backport : Enable vector test to run only in AzureDB (#2762)
* Enable vector test in AzureDB * jdk8 failure : for testing * Added VectorTag interface * Added custom annotation to run tests on AzureDB * Added vectorTest tag along with AzureDB tag
1 parent b46d2d6 commit 45768c3

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyCSVTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.microsoft.sqlserver.jdbc.TestUtils;
4545
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
4646
import com.microsoft.sqlserver.testframework.AbstractTest;
47+
import com.microsoft.sqlserver.testframework.AzureDB;
4748
import com.microsoft.sqlserver.testframework.Constants;
4849
import com.microsoft.sqlserver.testframework.DBConnection;
4950
import com.microsoft.sqlserver.testframework.DBResultSet;
@@ -620,6 +621,7 @@ public void testBulkCopyWithComputedColumnNotAsLastColumn() {
620621
* BulkCopyCSVTestInputWithVector.csv file
621622
*/
622623
@Test
624+
@AzureDB
623625
@Tag(Constants.vectorTest)
624626
public void testBulkCopyVectorFromCSV() throws SQLException {
625627
String dstTable = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTable"));
@@ -697,6 +699,7 @@ public void testBulkCopyVectorFromCSV() throws SQLException {
697699
* BulkCopyCSVTestInputWithMultipleVectorColumn.csv file
698700
*/
699701
@Test
702+
@AzureDB
700703
@Tag(Constants.vectorTest)
701704
public void testBulkCopyVectorFromCSVWithMultipleColumns() throws SQLException {
702705
String dstTable = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTable"));
@@ -764,6 +767,7 @@ public void testBulkCopyVectorFromCSVWithMultipleColumns() throws SQLException {
764767
* BulkCopyCSVTestWithMultipleVectorColumnWithPipeDelimiter.csv file
765768
*/
766769
@Test
770+
@AzureDB
767771
@Tag(Constants.vectorTest)
768772
public void testBulkCopyVectorFromCSVWithMultipleColumnsWithPipeDelimiter() throws SQLException {
769773
String dstTable = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTable"));
@@ -831,6 +835,7 @@ public void testBulkCopyVectorFromCSVWithMultipleColumnsWithPipeDelimiter() thro
831835
* metadata.
832836
*/
833837
@Test
838+
@AzureDB
834839
@Tag(Constants.vectorTest)
835840
public void testBulkCopyVectorFromCSVWithIncorrectDimension() throws SQLException {
836841
String dstTable = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTable"));

src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyISQLServerBulkRecordTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.microsoft.sqlserver.jdbc.TestUtils;
4343
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
4444
import com.microsoft.sqlserver.testframework.AbstractTest;
45+
import com.microsoft.sqlserver.testframework.AzureDB;
4546
import com.microsoft.sqlserver.testframework.Constants;
4647
import com.microsoft.sqlserver.testframework.DBConnection;
4748
import com.microsoft.sqlserver.testframework.DBStatement;
@@ -161,6 +162,7 @@ public void testBulkCopyDateTimePrecision() throws SQLException {
161162
* Test bulk copy with a single Vector row.
162163
*/
163164
@Test
165+
@AzureDB
164166
@Tag(Constants.vectorTest)
165167
public void testBulkCopyVector() throws SQLException {
166168
String dstTable = TestUtils
@@ -586,6 +588,7 @@ public void testBulkCopyWithCountVerification() throws SQLException {
586588
* to destination table with VECTOR column.
587589
*/
588590
@Test
591+
@AzureDB
589592
@Tag(Constants.vectorTest)
590593
public void testBulkCopyTableToTableJsonToVector() throws Exception {
591594
String srcTable = TestUtils.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier("testSrcJsonTable"));
@@ -661,6 +664,7 @@ private static Object[] parseJsonArrayToFloatArray(String json) {
661664
* Test bulk copy with null Vector data.
662665
*/
663666
@Test
667+
@AzureDB
664668
@Tag(Constants.vectorTest)
665669
public void testBulkCopyVectorNull() throws SQLException {
666670
String dstTable = TestUtils
@@ -708,6 +712,7 @@ public void testBulkCopyVectorNull() throws SQLException {
708712
* incompatible with vector".
709713
*/
710714
@Test
715+
@AzureDB
711716
@Tag(Constants.vectorTest)
712717
public void testBulkCopyVectorUsingBulkCopySourceAsVarBinary() {
713718
String varbinaryTable = TestUtils
@@ -769,6 +774,7 @@ public void testBulkCopyVectorUsingBulkCopySourceAsVarBinary() {
769774
* incompatible with varbinary(max)".
770775
*/
771776
@Test
777+
@AzureDB
772778
@Tag(Constants.vectorTest)
773779
public void testBulkCopyVectorUsingBulkCopyDestinationAsVarBinary() {
774780
String vectorTable = TestUtils.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier("testVectorTable"));
@@ -836,6 +842,7 @@ public void testBulkCopyVectorUsingBulkCopyDestinationAsVarBinary() {
836842
* The operation should succeed, and the data should be validated.
837843
*/
838844
@Test
845+
@AzureDB
839846
@Tag(Constants.vectorTest)
840847
public void testBulkCopyVectorUsingBulkCopySourceAsVarchar() {
841848
String varcharTable = TestUtils.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier("testVarcharTable"));
@@ -903,6 +910,7 @@ public void testBulkCopyVectorUsingBulkCopySourceAsVarchar() {
903910
* The operation should succeed, and the data should be validated.
904911
*/
905912
@Test
913+
@AzureDB
906914
@Tag(Constants.vectorTest)
907915
public void testBulkCopyVectorUsingBulkCopyDestinationAsVarchar() {
908916
String vectorTable = TestUtils.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier("testVectorTable"));
@@ -973,6 +981,7 @@ public void testBulkCopyVectorUsingBulkCopyDestinationAsVarchar() {
973981
* The operation should fail with an error: "The vector dimensions 3 and 4 do not match."
974982
*/
975983
@Test
984+
@AzureDB
976985
@Tag(Constants.vectorTest)
977986
public void testBulkCopyVectorWithMismatchedDimensions() {
978987
String srcTable = TestUtils.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier("testSrcTable"));
@@ -1031,6 +1040,7 @@ public void testBulkCopyVectorWithMismatchedDimensions() {
10311040
* Test bulk copy with a large number of records to check performance.
10321041
*/
10331042
@Test
1043+
@AzureDB
10341044
@Tag(Constants.vectorTest)
10351045
public void testBulkCopyPerformance() throws SQLException {
10361046
String tableName = AbstractSQLGenerator.escapeIdentifier("srcTable");

src/test/java/com/microsoft/sqlserver/jdbc/databasemetadata/DatabaseMetaDataTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import com.microsoft.sqlserver.jdbc.TestUtils;
5757
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
5858
import com.microsoft.sqlserver.testframework.AbstractTest;
59+
import com.microsoft.sqlserver.testframework.AzureDB;
5960
import com.microsoft.sqlserver.testframework.Constants;
6061

6162

@@ -1091,6 +1092,7 @@ public void testGetSchemasWithAndWithoutCatalog() throws SQLException {
10911092
* @throws SQLException
10921093
*/
10931094
@Test
1095+
@AzureDB
10941096
@Tag(Constants.vectorTest)
10951097
public void testVectorMetaData() throws SQLException {
10961098
String vectorTableName = RandomUtil.getIdentifier("vectorTable");

src/test/java/com/microsoft/sqlserver/jdbc/datatypes/VectorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.microsoft.sqlserver.jdbc.TestUtils;
3131
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
3232
import com.microsoft.sqlserver.testframework.AbstractTest;
33+
import com.microsoft.sqlserver.testframework.AzureDB;
3334
import com.microsoft.sqlserver.testframework.Constants;
3435

3536
import microsoft.sql.Vector;
@@ -45,6 +46,7 @@
4546

4647
@RunWith(JUnitPlatform.class)
4748
@DisplayName("Test Vector Data Type")
49+
@AzureDB
4850
@Tag(Constants.vectorTest)
4951
public class VectorTest extends AbstractTest {
5052

src/test/java/com/microsoft/sqlserver/jdbc/preparedStatement/BatchExecutionWithBulkCopyTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import com.microsoft.sqlserver.jdbc.TestUtils;
5555
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
5656
import com.microsoft.sqlserver.testframework.AbstractTest;
57+
import com.microsoft.sqlserver.testframework.AzureDB;
5758
import com.microsoft.sqlserver.testframework.Constants;
5859
import com.microsoft.sqlserver.testframework.PrepUtil;
5960

@@ -1266,6 +1267,7 @@ public void testBulkInsertWithNullDataForAllTemporalTypesAndMoney() throws Excep
12661267
* Test inserting vector data using prepared statement with bulk copy enabled.
12671268
*/
12681269
@Test
1270+
@AzureDB
12691271
@Tag(Constants.vectorTest)
12701272
public void testInsertVectorWithBulkCopy() throws Exception {
12711273
String tableName = RandomUtil.getIdentifier("BulkCopyVectorTest");
@@ -1304,6 +1306,7 @@ public void testInsertVectorWithBulkCopy() throws Exception {
13041306
* Test inserting null vector data using prepared statement with bulk copy enabled.
13051307
*/
13061308
@Test
1309+
@AzureDB
13071310
@Tag(Constants.vectorTest)
13081311
public void testInsertNullVectorWithBulkCopy() throws Exception {
13091312
String tableName = RandomUtil.getIdentifier("BulkCopyVectorTest");
@@ -1343,6 +1346,7 @@ public void testInsertNullVectorWithBulkCopy() throws Exception {
13431346
* Test inserting vector data using prepared statement with bulk copy enabled for performance.
13441347
*/
13451348
@Test
1349+
@AzureDB
13461350
@Tag(Constants.vectorTest)
13471351
public void testInsertWithBulkCopyPerformance() throws SQLException {
13481352
String tableName = AbstractSQLGenerator.escapeIdentifier("BulkCopyVectorPerformanceTest");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
3+
* available under the terms of the MIT License. See the LICENSE file in the project root for more information.
4+
*/
5+
6+
package com.microsoft.sqlserver.testframework;
7+
8+
import java.lang.annotation.ElementType;
9+
import java.lang.annotation.Retention;
10+
import java.lang.annotation.RetentionPolicy;
11+
import java.lang.annotation.Target;
12+
13+
import org.junit.jupiter.api.Tag;
14+
15+
/*
16+
* Custom annotation to run tests only on Azure DBs
17+
*/
18+
@Target({ElementType.METHOD, ElementType.TYPE})
19+
@Retention(RetentionPolicy.RUNTIME)
20+
@Tag(Constants.xSQLv11)
21+
@Tag(Constants.xSQLv12)
22+
@Tag(Constants.xSQLv14)
23+
@Tag(Constants.xSQLv15)
24+
@Tag(Constants.xSQLv16)
25+
@Tag(Constants.xAzureSQLDW)
26+
@Tag(Constants.xAzureSQLMI)
27+
public @interface AzureDB {}

0 commit comments

Comments
 (0)