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

e2e BQ test scenarios new feature #17

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

priyabhatnagar25
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@rahuldash171 rahuldash171 left a 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," +
Copy link
Collaborator

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

Copy link
Collaborator Author

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")
Copy link
Collaborator

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.

Copy link
Collaborator Author

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")
Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:camelcase

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@@ -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)
Copy link
Collaborator

@itsmekumari itsmekumari Sep 21, 2023

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.

Copy link
Collaborator Author

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

Copy link
Collaborator

@rahuldash171 rahuldash171 left a 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
Copy link
Collaborator

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.

Copy link
Collaborator Author

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"
Copy link
Collaborator

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 .

Copy link
Collaborator Author

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"
Copy link
Collaborator

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 .

Copy link
Collaborator Author

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"
Copy link
Collaborator

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
Copy link
Collaborator

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 .

Copy link
Collaborator Author

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)
Copy link
Collaborator

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 .

Copy link
Collaborator Author

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"
Copy link
Collaborator

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.

Copy link
Collaborator Author

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"
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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 .

Copy link
Collaborator

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());
Copy link
Collaborator

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

Copy link
Collaborator Author

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();
Copy link
Collaborator

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

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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

Copy link
Collaborator Author

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,
Copy link
Collaborator

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

Copy link
Collaborator Author

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);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this function

Copy link
Collaborator Author

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,
Copy link
Collaborator

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

Copy link
Collaborator Author

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());
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

@priyabhatnagar25 priyabhatnagar25 force-pushed the e2e_bq_tests branch 2 times, most recently from 1c1b2b5 to dc8764b Compare September 25, 2023 14:20
Copy link
Collaborator

@rahuldash171 rahuldash171 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@priyabhatnagar25 priyabhatnagar25 force-pushed the e2e_bq_tests branch 3 times, most recently from 4cbaecd to 6b78689 Compare September 26, 2023 17:42
e2e BQ new tests scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants