Skip to content

Commit 1fa9919

Browse files
Added sanity tests for dateTime datatypes (#382)
* Added sanity tests for dateTime datatypes * Added sanity tests for dateTime datatypes * Added sanity tests for dateTime datatypes * Added sanity tests for dateTime datatypes
1 parent 765a7f1 commit 1fa9919

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# Copyright © 2023 Cask Data, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
# use this file except in compliance with the License. You may obtain a copy of
6+
# the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations under
14+
# the License.
15+
#
16+
17+
@Mssql
18+
Feature: Mssql - Verify Mssql source data transfer
19+
@MSSQL_SOURCE_DATATYPES_DATETIME_TEST @MSSQL_SINK_TEST @Mssql_Required
20+
Scenario: To verify data is getting transferred from Mssql to Mssql successfully
21+
Given Open Datafusion Project to configure pipeline
22+
When Expand Plugin group in the LHS plugins list: "Source"
23+
When Select plugin: "SQL Server" from the plugins list as: "Source"
24+
When Expand Plugin group in the LHS plugins list: "Sink"
25+
When Select plugin: "SQL Server" from the plugins list as: "Sink"
26+
Then Connect plugins: "SQL Server" and "SQL Server2" to establish connection
27+
Then Navigate to the properties page of plugin: "SQL Server"
28+
Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName"
29+
Then Replace input plugin property: "host" with value: "host" for Credentials and Authorization related fields
30+
Then Replace input plugin property: "port" with value: "port" for Credentials and Authorization related fields
31+
Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields
32+
Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields
33+
Then Enter input plugin property: "referenceName" with value: "sourceRef"
34+
Then Replace input plugin property: "database" with value: "databaseName"
35+
Then Enter textarea plugin property: "importQuery" with value: "selectQuery"
36+
Then Click on the Get Schema button
37+
Then Verify the Output Schema matches the Expected Schema: "outputDatatypesSchema4"
38+
Then Validate "SQL Server" plugin properties
39+
Then Close the Plugin Properties page
40+
Then Navigate to the properties page of plugin: "SQL Server2"
41+
Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName"
42+
Then Replace input plugin property: "host" with value: "host" for Credentials and Authorization related fields
43+
Then Replace input plugin property: "port" with value: "port" for Credentials and Authorization related fields
44+
Then Replace input plugin property: "database" with value: "databaseName"
45+
Then Replace input plugin property: "tableName" with value: "targetTable"
46+
Then Replace input plugin property: "dbSchemaName" with value: "schema"
47+
Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields
48+
Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields
49+
Then Enter input plugin property: "referenceName" with value: "targetRef"
50+
Then Validate "SQL Server2" plugin properties
51+
Then Close the Plugin Properties page
52+
Then Save the pipeline
53+
Then Preview and run the pipeline
54+
Then Verify the preview of pipeline is "success"
55+
Then Click on preview data for Mssql sink
56+
Then Verify preview output schema matches the outputSchema captured in properties
57+
Then Close the preview data
58+
Then Deploy the pipeline
59+
Then Run the Pipeline in Runtime
60+
Then Wait till pipeline is in running state
61+
Then Open and capture logs
62+
Then Verify the pipeline status is "Succeeded"
63+
Then Validate records transferred to target table are equal to number of records from the source table
64+
65+

mssql-plugin/src/e2e-test/java/io.cdap.plugin/MssqlClient.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,30 @@ public static void createTargetUniqueIdentifierTable(String targetTable, String
155155
}
156156
}
157157

158+
public static void createSourceDateTimeTable(String sourceTable, String schema) throws SQLException,
159+
ClassNotFoundException {
160+
try (Connection connect = getMssqlConnection(); Statement statement = connect.createStatement()) {
161+
String dateTimeColumns = PluginPropertyUtils.pluginProp("dateTimeColumns");
162+
String createSourceTableQuery3 = createTableQuery(sourceTable, schema, dateTimeColumns);
163+
statement.executeUpdate(createSourceTableQuery3);
164+
165+
// Insert dummy data.
166+
String dateTimeValues = PluginPropertyUtils.pluginProp("dateTimeValues");
167+
String dateTimeColumnsList = PluginPropertyUtils.pluginProp("dateTimeColumnsList");
168+
statement.executeUpdate(insertQuery(sourceTable, schema, dateTimeColumnsList,
169+
dateTimeValues));
170+
}
171+
}
172+
173+
public static void createTargetDateTimeTable(String targetTable, String schema) throws SQLException,
174+
ClassNotFoundException {
175+
try (Connection connect = getMssqlConnection(); Statement statement = connect.createStatement()) {
176+
String dateTimeColumns = PluginPropertyUtils.pluginProp("dateTimeColumns");
177+
String createTargetTableQuery3 = createTableQuery(targetTable, schema, dateTimeColumns);
178+
statement.executeUpdate(createTargetTableQuery3);
179+
}
180+
}
181+
158182
public static void deleteTables(String schema, String[] tables)
159183
throws SQLException, ClassNotFoundException {
160184
try (Connection connect = getMssqlConnection(); Statement statement = connect.createStatement()) {

mssql-plugin/src/e2e-test/java/io.cdap.plugin/common.stepsdesign/TestSetupHooks.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ public static void createDatatypesTablesUniqueIdentifier() throws SQLException,
7373
PluginPropertyUtils.pluginProp("schema"));
7474
}
7575

76+
@Before(order = 2, value = "@MSSQL_SOURCE_DATATYPES_DATETIME_TEST")
77+
public static void createDatatypesTablesDateTime() throws SQLException, ClassNotFoundException {
78+
MssqlClient.createSourceDateTimeTable(PluginPropertyUtils.pluginProp("sourceTable"),
79+
PluginPropertyUtils.pluginProp("schema"));
80+
MssqlClient.createTargetDateTimeTable(PluginPropertyUtils.pluginProp("targetTable"),
81+
PluginPropertyUtils.pluginProp("schema"));
82+
}
83+
7684
@After(order = 1, value = "@MSSQL_SINK_TEST")
7785
public static void dropTables() throws SQLException, ClassNotFoundException {
7886
MssqlClient.deleteTables(PluginPropertyUtils.pluginProp("schema"),

mssql-plugin/src/e2e-test/resources/pluginParameters.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ imageColumnsList=(ID,COL1)
3535
imageValues=VALUES ('User1', '0x48692054686572652120486F772061726520796F75206665656C696E6720746F646179203F')
3636
outputDatatypesSchema2=[{"key":"ID","value":"string"},{"key":"COL1","value":"bytes"}]
3737

38-
3938
uniqueIdentifierColumns=(ID VARCHAR(100) PRIMARY KEY, COL1 UNIQUEIDENTIFIER)
4039
uniqueIdentifierColumnsList=(ID, COL1)
4140
uniqueIdentifierValues=VALUES ('User1', '6F9619FF-8B86-D011-B42D-00C04FC964FF')
4241
outputDatatypesSchema3=[{"key":"ID","value":"string"},{"key":"COL1","value":"string"}]
42+
43+
dateTimeColumns=(ID VARCHAR(100) PRIMARY KEY, COL1 DATETIME, COL2 DATETIME2(0))
44+
dateTimeColumnsList=(ID, COL1, COL2)
45+
dateTimeValues=VALUES ('User1', '2023-01-01 01:00:00.000', '2023-01-01 01:00:00.000')
46+
outputDatatypesSchema4=[{"key":"ID","value":"string"},{"key":"COL1","value":"datetime"},\
47+
{"key":"COL2","value":"datetime"}]

0 commit comments

Comments
 (0)