-
Notifications
You must be signed in to change notification settings - Fork 2
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
e2e BQ test scenarios new feature #17
base: develop
Are you sure you want to change the base?
Conversation
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.
Reviewed
public static void createSourceBQExistingTable() throws IOException, InterruptedException { | ||
bqSourceTable = "E2E_SOURCE_" + UUID.randomUUID().toString().replaceAll("-" , "_"); | ||
io.cdap.e2e.utils.BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqSourceTable + "` " + | ||
"(CustomerID INT64, LastName STRING, " + "FirstName STRING," + |
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.
Table should include string, int, float, bool datatypes .(in both the tests) Go through the ITN class once and the buganizer ticket .https://buganizer.corp.google.com/issues/282611750 , https://github.com/cdapio/cdap-integration-tests/blob/develop/integration-test-remote/src/test/java/io/cdap/cdap/app/etl/gcp/GoogleBigQueryTest.java
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.
done ...added the datatypes in the hook
@@ -920,4 +920,46 @@ public static void createSourceBQUpdateTable() throws IOException, InterruptedEx | |||
PluginPropertyUtils.addPluginProp(" bqTargetTable", bqTargetTable); | |||
BeforeActions.scenario.write("BQ Target Table " + bqTargetTable + " updated successfully"); | |||
} | |||
|
|||
@Before(order = 1, value = "@BQ_EXISTING_SOURCE_TEST") |
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.
Add the after hook as well.
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.
resolved
PluginPropertyUtils.addPluginProp("bqSourceTable", bqSourceTable); | ||
BeforeActions.scenario.write("BQ Source Table " + bqSourceTable + " created successfully"); | ||
} | ||
@Before(order = 1, value = "@BQ_EXISTING_SINK_TEST") |
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.
Add the after hook as well.
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.
resolved
@@ -186,6 +186,7 @@ bqInvalidRefName=invalidRef&^*&&* | |||
bqDatatypeChange1=[{"key":"Id","value":"long"},{"key":"Value","value":"long"}] | |||
bqDataTypeTestFileSchema1=[{"key":"Id","value":"long"},{"key":"Value","value":"long"},\ | |||
{"key":"UID","value":"string"}] | |||
bqexpectedfile=testdata/BigQuery/BQExistingTableFile |
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.
nit:camelcase
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.
resolved
8905a21
to
aca8121
Compare
@@ -262,3 +262,81 @@ Feature: BigQuery source - Verification of BigQuery to BigQuery successful data | |||
Then Open and capture logs | |||
Then Verify the pipeline status is "Succeeded" | |||
Then Validate the values of records transferred to BQ sink is equal to the values from source BigQuery table | |||
|
|||
@BQ_EXISTING_SOURCE_TEST @BQ_EXISTING_SINK_TEST | |||
Scenario: Validate successful record transfer from BigQuery source(existing table) to BigQuery sink(existing table) |
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.
All the scenarios heading needs to be updated as per ITN class for ease of scenario understanding. can be same as mentioned in ITN 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.
scenarios are updated as per ITN 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.
Reviewed , please address the comments.
And Replace input plugin property: "dataset" with value: "dataset" | ||
Then Override Service account details if set in environment variables | ||
And Enter input plugin property: "table" with value: "bqSourceTable" | ||
Then Validate "BigQuery" plugin properties |
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.
Why are we not using 'get schema' before validating ? In case of tables this is an ideal step.
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.
Resolved.Added schema step.
When Select plugin: "BigQuery" from the plugins list as: "Sink" | ||
Then Connect plugins: "BigQuery" and "BigQuery2" to establish connection | ||
Then Navigate to the properties page of plugin: "BigQuery" | ||
And Enter input plugin property: "referenceName" with value: "Reference" |
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.
We should use "useConnection:"true" here as per the ITN description .
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.
Resolved. Scenarios are updated and use connection is used in all the scenarios
When Expand Plugin group in the LHS plugins list: "Sink" | ||
When Select plugin: "BigQuery" from the plugins list as: "Sink" | ||
Then Connect plugins: "BigQuery" and "BigQuery2" to establish connection | ||
Then Navigate to the properties page of plugin: "BigQuery" |
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.
We should use "useConnection:"true" here as per the ITN description .
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.
Resolved. Scenarios are updated and use connection is used in all the scenarios
When Expand Plugin group in the LHS plugins list: "Sink" | ||
When Select plugin: "BigQuery" from the plugins list as: "Sink" | ||
Then Connect plugins: "BigQuery" and "BigQuery2" to establish connection | ||
Then Navigate to the properties page of plugin: "BigQuery" |
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.
We should use "useConnection:"true" here as per the ITN description .
Then Verify the pipeline status is "Succeeded" | ||
Then Validate the values of records transferred to BQ sink is equal to the values from source BigQuery table | ||
|
||
@BQ_INSERT_SOURCE_TEST @BQ_SINK_TEST |
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.
Please use correct hook , as per the ITN the sink table is an existing table with data .
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 is the upsert button, so it will insert the data in the new table created
@@ -262,3 +262,81 @@ Feature: BigQuery source - Verification of BigQuery to BigQuery successful data | |||
Then Open and capture logs | |||
Then Verify the pipeline status is "Succeeded" | |||
Then Validate the values of records transferred to BQ sink is equal to the values from source BigQuery table | |||
|
|||
@BQ_EXISTING_SOURCE_TEST @BQ_EXISTING_SINK_TEST | |||
Scenario: Validate successful record transfer from BigQuery source(existing table) to BigQuery sink(existing table) |
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.
for this scenario use connection is true for both source and sink in ITN , please use .
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.
resolved
When Expand Plugin group in the LHS plugins list: "Sink" | ||
When Select plugin: "BigQuery" from the plugins list as: "Sink" | ||
Then Connect plugins: "BigQuery" and "BigQuery2" to establish connection | ||
Then Navigate to the properties page of plugin: "BigQuery" |
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.
useConnection should be true as per ITN.
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.
resolved
Then Wait till pipeline is in running state | ||
Then Open and capture logs | ||
Then Verify the pipeline status is "Succeeded" | ||
Then Validate the data transferred from BQ to BQ with actual And expected file for: "bqexpectedfile" |
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 will fail as it does not match the key in plugin properties bqExpectedFile , Have you executed in local ?
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.
resolved
/** | ||
* BigQuery Plugin Existing Table validation. | ||
*/ | ||
public class BQValidationExistingTables { |
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.
@bharatgulati Please review the below logic for validation .
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.
Change the class name to something relevant like BQTableValidation or something like that.
} | ||
} | ||
} catch (IOException e) { | ||
System.err.println("Error reading the file: " + e.getMessage()); |
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.
add logger.error instead of sysout
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.
resoved
public class BQValidationExistingTables { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(BQValidationExistingTables.class); | ||
static Gson gson = new Gson(); |
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.
Add access modifier of Gson
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.
added modifier
return isMatched; | ||
} | ||
|
||
public static void getFileData(String fileName, Map<String, JsonObject> fileMap) { |
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.
Add a java doc for this function
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.
resolved
|
||
private static final Logger LOG = LoggerFactory.getLogger(BQValidationExistingTables.class); | ||
static Gson gson = new Gson(); | ||
public static boolean validateActualDataToExpectedData(String table, String fileName) throws IOException, |
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.
Add a java doc for this function
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.
added javadoc
getBigQueryTableData(table, bigQueryMap); | ||
getFileData(importbqexpectedfile.toString(), fileMap); | ||
|
||
boolean isMatched = matchJsonMaps(bigQueryMap, fileMap); |
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.
remove matchJsonMaps function and match bigqueryMap and fileMap with equals function.
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.
done
if (!map1.keySet().equals(map2.keySet())) { | ||
return false; | ||
} | ||
for (String key : map1.keySet()) { |
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.
Remove this function
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.
removed
@@ -160,4 +161,13 @@ public void enterTheBigQuerySourcePropertyForViewMaterializationDataset(String v | |||
public void enterBigQuerySourcePropertyTableNameAsView() { | |||
CdfBigQueryPropertiesActions.enterBigQueryTable(TestSetupHooks.bqSourceView); | |||
} | |||
|
|||
@Then("Validate the data transferred from BQ to BQ with actual And expected file for: {string}") | |||
public void validateTheDataFromBQToBQWithActualAndExpectedFileFor(String expectedFile) throws IOException, |
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.
Rename it to BigQuery from BQ
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.
renamed
InterruptedException, URISyntaxException { | ||
Map<String, JsonObject> bigQueryMap = new HashMap<>(); | ||
Map<String, JsonObject> fileMap = new HashMap<>(); | ||
Path importbqexpectedfile = Paths.get(BQValidationExistingTables.class.getResource("/" + fileName).toURI()); |
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.
Rename importbqexpectedfile to bqExpectedFilePath or just path
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.
renamed
1c1b2b5
to
dc8764b
Compare
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.
Approved
4cbaecd
to
6b78689
Compare
e2e BQ new tests scenarios
6b78689
to
c5fb04d
Compare
fc2efdf
to
5f4f137
Compare
No description provided.