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

operator/pkg: unit test utilities #5675

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

Conversation

mohamedawnallah
Copy link
Contributor

Description

In this commit, we unit test utilities on downloader operations and unpacking tar files.

What type of PR is this?

Which issue(s) this PR fixes:
Part of #5491.

Does this PR introduce a user-facing change?:

NONE

@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.60%. Comparing base (c16e52a) to head (49eb96b).
Report is 71 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5675      +/-   ##
==========================================
+ Coverage   35.85%   38.60%   +2.75%     
==========================================
  Files         647      650       +3     
  Lines       45070    55122   +10052     
==========================================
+ Hits        16158    21281    +5123     
- Misses      27664    32480    +4816     
- Partials     1248     1361     +113     
Flag Coverage Δ
unittests 38.60% <100.00%> (+2.75%) ⬆️

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.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

When I run the ut in the windows, it report error:

=== RUN   TestDownloadFile/DownloadFile_FileDownlaoded_
    util_test.go:229: failed to prep before downloading the file, got: failed to create temp file: open C:\Users\C00502~1\AppData\Local\Temp/tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
    util_test.go:236: unexpected error, got: failed to download file. url: https://www.example.com/test-file code: 503
    util_test.go:242: failed to verify the actual of download of file: failed   to read file: open C:\Users\C00502~1\AppData\Local\Temp/tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
--- FAIL: TestDownloadFile (0.00s)
    --- PASS: TestDownloadFile/DownloadFile_UrlIsNotFound_FailedToGetResponse (0.00s)
    --- PASS: TestDownloadFile/DownloadFile_ServiceIsUnavailable_FailedToReachTheService (0.00s)
    --- FAIL: TestDownloadFile/DownloadFile_FileDownlaoded_ (0.00s)

@mohamedawnallah
Copy link
Contributor Author

When I run the ut in the windows, it report error:

=== RUN   TestDownloadFile/DownloadFile_FileDownlaoded_
    util_test.go:229: failed to prep before downloading the file, got: failed to create temp file: open C:\Users\C00502~1\AppData\Local\Temp/tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
    util_test.go:236: unexpected error, got: failed to download file. url: https://www.example.com/test-file code: 503
    util_test.go:242: failed to verify the actual of download of file: failed   to read file: open C:\Users\C00502~1\AppData\Local\Temp/tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
--- FAIL: TestDownloadFile (0.00s)
    --- PASS: TestDownloadFile/DownloadFile_UrlIsNotFound_FailedToGetResponse (0.00s)
    --- PASS: TestDownloadFile/DownloadFile_ServiceIsUnavailable_FailedToReachTheService (0.00s)
    --- FAIL: TestDownloadFile/DownloadFile_FileDownlaoded_ (0.00s)

@XiShanYongYe-Chang Good catch! The current unit testing code assumed it was only targeting the Linux platform, so it used "/" as a separator. I've updated it to use filepath.Join for platform independence. That said, I haven't been able to test it on Windows since I don't have access to one. Could you please test it again and let me know? 🙏

@XiShanYongYe-Chang
Copy link
Member

Okay, let me have a retry.

@mohamedawnallah
Copy link
Contributor Author

mohamedawnallah commented Oct 16, 2024

I've updated the last commit. @XiShanYongYe-Chang, I realized that I forgot to replace one instance where "/" was used. 😁 Please pull the latest commit! 🙏

@XiShanYongYe-Chang
Copy link
Member

It still failed:

=== RUN   TestDownloadFile/DownloadFile_FileDownlaoded_
    util_test.go:230: failed to prep before downloading the file, got: failed to create temp file: open C:\Users\C00502~1\AppData\Local\Temp\tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
    util_test.go:237: unexpected error, got: failed to download file. url: https://www.example.com/test-file code: 503
    util_test.go:243: failed to verify the actual of download of file: failed   to read file: open C:\Users\C00502~1\AppData\Local\Temp\tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
--- FAIL: TestDownloadFile (0.00s)
    --- PASS: TestDownloadFile/DownloadFile_UrlIsNotFound_FailedToGetResponse (0.00s)
    --- PASS: TestDownloadFile/DownloadFile_ServiceIsUnavailable_FailedToReachTheService (0.00s)
    --- FAIL: TestDownloadFile/DownloadFile_FileDownlaoded_ (0.00s)

@XiShanYongYe-Chang
Copy link
Member

/assign

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from xishanyongye-chang. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

In this commit, we unit test utilities on downloader operations and
unpacking tar files.

Signed-off-by: Mohamed Awnallah <[email protected]>
@mohamedawnallah
Copy link
Contributor Author

@XiShanYongYe-Chang, I've updated the commit. I believe the issue is primarily with the naming of the file tempfile-*.txt, but I'm still not 100% sure. Could you please try it again and let me know how it goes? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants