- 
                Notifications
    You must be signed in to change notification settings 
- Fork 86
Added cleanup code for gcp resources #1453
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
Added cleanup code for gcp resources #1453
Conversation
aaa59a1    to
    131f343      
    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.
Why there are test failures with error in Get count of no of records transferred to target BigQuery Table:
om.google.cloud.bigquery.BigQueryException: Not found: Table cdf-athena:testing_bqmt.E2E_TARGET_cd33fe5f_1249_46b1_8fc3_b8da7dbce6f1 was not found in location US
	at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.translate(HttpBigQueryRpc.java:115)
	at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.queryRpc(HttpBigQueryRpc.java:652)
	at com.google.cloud.bigquery.BigQueryImpl$35.call(BigQueryImpl.java:1282)
	at com.google.cloud.bigquery.BigQueryImpl$35.call(BigQueryImpl.java:1279)
	at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
	at com.google.cloud.bigquery.BigQueryRetryHelper.run(BigQueryRetryHelper.java:64)
	at com.google.cloud.bigquery.BigQueryRetryHelper.runWithRetries(BigQueryRetryHelper.java:38)
	at com.google.cloud.bigquery.BigQueryImpl.queryRpc(BigQueryImpl.java:1278)
	at com.google.cloud.bigquery.BigQueryImpl.query(BigQueryImpl.java:1266)
	at io.cdap.e2e.utils.BigQueryClient.getSoleQueryResult(BigQueryClient.java:86)
	at io.cdap.e2e.utils.BigQueryClient.countBqQuery(BigQueryClient.java:46)
	at io.cdap.plugin.bigquery.stepsdesign.BigQueryBase.getCountOfNoOfRecordsTransferredToTargetBigQueryTable(BigQueryBase.java:90)
	at ✽.Get count of no of records transferred to target BigQuery Table(file:src/e2e-test/features/bigquery/sink/GCSToBigQuery.feature:39)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
POST https://www.googleapis.com/bigquery/v2/projects/cdf-athena/queries
{
  "code" : 404,
  "errors" : [ {
    "domain" : "global",
    "message" : "Not found: Table cdf-athena:testing_bqmt.E2E_TARGET_cd33fe5f_1249_46b1_8fc3_b8da7dbce6f1 was not found in location US",
    "reason" : "notFound"
  } ],
  "message" : "Not found: Table cdf-athena:testing_bqmt.E2E_TARGET_cd33fe5f_1249_46b1_8fc3_b8da7dbce6f1 was not found in location US",
  "status" : "NOT_FOUND"
| 
 Fixed by cdapio/cdap#15724. | 
| } | ||
| } | ||
|  | ||
| @After(order = 1, value = "@BQ_SECOND_RECORD_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.
Should this be BQ_RECORD_SOURCE_TEST? I don't see this tag being used anywhere.
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 are using this is in bqtobq Additional.feature file. so BQ_SECOND_RECORD_SOURCE_TEST is used here
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.
I see, can we please rename both these tags to something meaningful?
It is hard to understand what these both tags are referring to BQ_RECORD_SOURCE_TEST & BQ_SECOND_RECORD_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.
changed done.
131f343    to
    2e53c6a      
    Compare
  
    2e53c6a    to
    39cabe7      
    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.
| @After(order = 1, value = "@BQ_SECONDARY_RECORD_SOURCE_TEST") | ||
| public static void deleteTempSource2BQTable() throws IOException, InterruptedException { | ||
| BigQueryClient.dropBqQuery(bqSourceTable2); | ||
| PluginPropertyUtils.removePluginProp("bqSourceTable2"); | 
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.
before removing the plugin property, we need to fetch it for logging right?
Otherwise bqSourceTable2 would be empty?
Shouldn't it be something like:
bqSourceTable2 = PluginPropertyUtils.pluginProp("bqSourceTable2");
PluginPropertyUtils.removePluginProp("bqSourceTable2");
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.
Actually the logger is at right position. The way you have written is also right but we already assigned globally assigned bqSourceTable2 in before hook. so no need to add in after hook. And either after removing PluginPropertyUtils.removePluginProp("bqSourceTable2") we still have globally assigned bqSourceTable2 so we can use logger after remove 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.
The source of truth here would be the pluginProperties file so I think we should always fetch the values from there instead of relying on the before hook.
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 the step
| 
 | 
| 
 Even though plugin automatically creating the tables while writing, we do need to clean them up, and we should also correctly log which tables are getting deleted. | 
39cabe7    to
    72dda1b      
    Compare
  
    | 
 added the logger step and removed the step for clean up | 
72dda1b    to
    06c2750      
    Compare
  
    06c2750    to
    4523759      
    Compare
  
    

This PR contains after hooks for test cases in which the after hook to clean up resources is not available.