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

[GCSIO] Fix internal unit test failure #32518

Merged
merged 6 commits into from
Sep 23, 2024
Merged

Conversation

shunping
Copy link
Contributor

@shunping shunping commented Sep 20, 2024

Skip or mock the check of is_soft_delete_enabled, because it requires a networck connection to access GCS.

@shunping
Copy link
Contributor Author

r: @ahmedabu98 @Abacn

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@@ -1023,7 +1023,8 @@ def _handle_temp_and_staging_locations(self, validator):
def validate(self, validator):
errors = []
if validator.is_service_runner():
errors.extend(self._handle_temp_and_staging_locations(validator))
if not self.view_as(TestOptions).dry_run:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a comment stating "this needs Internet connection and/or credentials"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.36%. Comparing base (75a4637) to head (a508281).
Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #32518      +/-   ##
============================================
- Coverage     57.37%   57.36%   -0.01%     
  Complexity     1474     1474              
============================================
  Files           966      966              
  Lines        153593   153595       +2     
  Branches       1076     1076              
============================================
- Hits          88118    88114       -4     
- Misses        63271    63277       +6     
  Partials       2204     2204              
Flag Coverage Δ
python 81.56% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shunping shunping changed the title Fix internal unit test failure [GCSIO] Fix internal unit test failure Sep 20, 2024
@shunping
Copy link
Contributor Author

shunping commented Sep 20, 2024

@Abacn could you take another look?

@@ -718,6 +719,7 @@ def test_validation_good_stg_good_temp(self):
'--staging_location=gs://beam/stg',
'--temp_location=gs://beam/tmp'
])
options.view_as(TestOptions).dry_run = True
Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to prefer mock as dryRun is too broad and may affect other behaviors that reduce test coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, mock does not work when tests are run in our GitHub actions. Because we don't have google-cloud-storage installed for these unit tests on pipeline. As a result, mocking on 'apache_beam.io.gcp.gcsio' will give an error, and I don't want to have a condition inside the test to say "if we can load the package, we will do the mock; otherwise we skip it".

I am open to any suggestions though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An example of test failure if mocking is used https://github.com/apache/beam/actions/runs/10963819700/job/30446103406

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I have some idea which may need more changes. Will try and report back.

Copy link
Contributor Author

@shunping shunping Sep 21, 2024

Choose a reason for hiding this comment

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

Ok. I made some changes to mock conditionally. PTAL

@shunping shunping marked this pull request as draft September 21, 2024 00:18
@shunping shunping marked this pull request as ready for review September 21, 2024 11:06
@Abacn Abacn merged commit 42efefd into apache:master Sep 23, 2024
93 checks passed
reeba212 pushed a commit to reeba212/beam that referenced this pull request Dec 4, 2024
* Fix internal unit test failure.

* Minor refactor and add comment.

* Fix test failure in github action.

* Mock is_soft_delete_enabled only if gcsio can be loaded.

* Disable unused import lint. It is using in mock.

* Format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants