From fbcda3ff32b0b458214e576468b3c74ff755829b Mon Sep 17 00:00:00 2001 From: bharatgulati Date: Fri, 21 Jul 2023 11:23:43 +0530 Subject: [PATCH] Fixing CloudSQL MySQL Build Failures --- .../java/io/cdap/plugin/CloudMySqlClient.java | 5 ++-- .../cloudmysql/stepsdesign/CloudMysql.java | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java index a4e081cf9..ca46e9dae 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java @@ -36,7 +36,7 @@ public class CloudMySqlClient { - private static final String DATATYPES_COLUMNS = PluginPropertyUtils.pluginProp("datatypesColumns"); + private static String dataTypesColumns = PluginPropertyUtils.pluginProp("datatypesColumns"); public static Connection getCloudSqlConnection() throws ClassNotFoundException, SQLException { Class.forName("com.google.cloud.sql.mysql.SocketFactory"); @@ -158,8 +158,7 @@ public static void createSourceDatatypesTable(String sourceTable) throws SQLExce public static void createTargetDatatypesTable(String targetTable) throws SQLException, ClassNotFoundException { try (Connection connect = getCloudSqlConnection(); Statement statement = connect.createStatement()) { - String datatypesColumns = DATATYPES_COLUMNS; - String createTargetTableQuery = "CREATE TABLE " + targetTable + " " + datatypesColumns; + String createTargetTableQuery = "CREATE TABLE " + targetTable + " " + dataTypesColumns; statement.executeUpdate(createTargetTableQuery); } } diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java index 095a848ef..6d68e037f 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java @@ -33,18 +33,22 @@ */ public class CloudMysql implements CdfHelper { - private static final String TARGET_TABLE = PluginPropertyUtils.pluginProp("targetTable"); - private static final String BQ_SOURCE_TABLE = PluginPropertyUtils.pluginProp("bqSourceTable"); + private static String targetTable = PluginPropertyUtils.pluginProp("targetTable"); + + private static String bqSourceTable = PluginPropertyUtils.pluginProp("bqSourceTable"); + + private static String sourceTable = PluginPropertyUtils.pluginProp("sourceTable"); + + private static String bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable"); @Then("Validate the values of records transferred to target table is equal to the values from source table") public void validateTheValuesOfRecordsTransferredToTargetTableIsEqualToTheValuesFromSourceTable() throws SQLException, ClassNotFoundException { - int countRecords = CloudMySqlClient.countRecord(TARGET_TABLE); + int countRecords = CloudMySqlClient.countRecord(targetTable); Assert.assertEquals("Number of records transferred should be equal to records out ", countRecords, recordOut()); BeforeActions.scenario.write(" ******** Number of records transferred ********:" + countRecords); - boolean recordsMatched = CloudMySqlClient.validateRecordValues(PluginPropertyUtils.pluginProp("sourceTable") - , TARGET_TABLE); + boolean recordsMatched = CloudMySqlClient.validateRecordValues(sourceTable, targetTable); Assert.assertTrue("Value of records transferred to the target table should be equal to the value " + "of the records in the source table", recordsMatched); } @@ -52,13 +56,12 @@ public void validateTheValuesOfRecordsTransferredToTargetTableIsEqualToTheValues @Then("Validate the values of records transferred to target Big Query table is equal to the values from source table") public void validateTheValuesOfRecordsTransferredToTargetBigQueryTableIsEqualToTheValuesFromSourceTable() throws InterruptedException, IOException, SQLException, ClassNotFoundException { - int targetBQRecordsCount = BigQueryClient.countBqQuery(PluginPropertyUtils.pluginProp("bqTargetTable")); + int targetBQRecordsCount = BigQueryClient.countBqQuery(bqTargetTable); BeforeActions.scenario.write("No of Records Transferred to BigQuery:" + targetBQRecordsCount); Assert.assertEquals("Out records should match with target BigQuery table records count", CdfPipelineRunAction.getCountDisplayedOnSourcePluginAsRecordsOut(), targetBQRecordsCount); - boolean recordsMatched = BQValidation.validateDBAndBQRecordValues(PluginPropertyUtils.pluginProp - ("sourceTable"), PluginPropertyUtils.pluginProp("bqTargetTable")); + boolean recordsMatched = BQValidation.validateDBAndBQRecordValues(sourceTable, bqTargetTable); Assert.assertTrue("Value of records transferred to the target table should be equal to the value " + "of the records in the source table", recordsMatched); } @@ -67,12 +70,12 @@ public void validateTheValuesOfRecordsTransferredToTargetBigQueryTableIsEqualToT "BigQuery table") public void validateTheValuesOfRecordsTransferredToTargetCloudSQLMySqlTableIsEqualToTheValuesFromSourceBigQueryTable() throws InterruptedException, IOException, SQLException, ClassNotFoundException { - int sourceBQRecordsCount = BigQueryClient.countBqQuery(BQ_SOURCE_TABLE); + int sourceBQRecordsCount = BigQueryClient.countBqQuery(bqSourceTable); BeforeActions.scenario.write("No of Records from source BigQuery table:" + sourceBQRecordsCount); Assert.assertEquals("Out records should match with target PostgreSQL table records count", CdfPipelineRunAction.getCountDisplayedOnSourcePluginAsRecordsOut(), sourceBQRecordsCount); - boolean recordsMatched = BQValidation.validateBQAndDBRecordValues(BQ_SOURCE_TABLE, TARGET_TABLE); + boolean recordsMatched = BQValidation.validateBQAndDBRecordValues(bqSourceTable, targetTable); Assert.assertTrue("Value of records transferred to the target table should be equal to the value " + "of the records in the source table", recordsMatched); }