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

Add tests for SnowflakeFileTransferAgent (part 1) #1288

Merged
merged 2 commits into from
Mar 13, 2023

Conversation

sfc-gh-ext-simba-lb
Copy link
Contributor

Overview

SNOW-XXXXX

External contributors - please answer these questions before submitting a pull request. Thanks!

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

Pre-review checklist

  • This change has passed precommit
  • I have reviewed code coverage report for my PR in (Sonarqube)

@sfc-gh-ext-simba-lb sfc-gh-ext-simba-lb requested a review from a team as a code owner March 9, 2023 23:57
@@ -315,6 +320,11 @@ private static InputStreamWithMetadata compressStreamWithGZIP(

countingStream.flush();

// Normal flow will never hit here. This is only for testing purposes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you write a utility method as same stuff is there multiple time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a method to check if the exception injection was enabled. The other parts are checking specific exceptions that the method could throw. Extracting this to a utility method may result in having to change the signatures of the methods to handle additional exceptions they wouldn't throw in normal flow.

remove file callable injection

put command

fix tests
@@ -315,6 +324,12 @@ private static InputStreamWithMetadata compressStreamWithGZIP(

countingStream.flush();

// Normal flow will never hit here. This is only for testing purposes
if (isInjectedFileTransferExceptionEnabled()
&& injectedFileTransferException instanceof NoSuchAlgorithmException) {
Copy link
Collaborator

@sfc-gh-igarish sfc-gh-igarish Mar 10, 2023

Choose a reason for hiding this comment

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

why can't we make new method like void checkForInjectedTransferException() throws NoSuchAlgorithmException
{
if (isInjectedFileTransferExceptionEnabled()
&& injectedFileTransferException instanceof NoSuchAlgorithmException) {
throw (NoSuchAlgorithmException) SnowflakeFileTransferAgent.injectedFileTransferException;
}
}

then calll this method everywhere.

@sonarqubemergegate
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sfc-gh-ext-simba-lb sfc-gh-ext-simba-lb force-pushed the fileTransferAgentTests branch 2 times, most recently from fcae45f to c095f40 Compare March 13, 2023 17:08
Copy link
Collaborator

@sfc-gh-igarish sfc-gh-igarish left a comment

Choose a reason for hiding this comment

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

LGTM

try to remove some duplication and add more tests

remove duplication

fix test
@sfc-gh-ext-simba-lb sfc-gh-ext-simba-lb merged commit 7cd122d into master Mar 13, 2023
@sfc-gh-ext-simba-lb sfc-gh-ext-simba-lb deleted the fileTransferAgentTests branch March 13, 2023 19:06
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants