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

[fs] Expose an experimental fs module with an open function and a File abstraction (1/3) #3165

Merged
merged 18 commits into from
Nov 13, 2023

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Jul 5, 2023

What?

This Pull Request aims to address #3142 and is the first step towards introducing a fs module to k6 as tracked by #3141.

In this Pull Request we:

  • introduce a k6/experimental/fs module
  • exposing:
    • an open function that ensures the file is loaded in memory once, and returns a File object to the user.
    • a File object abstraction to the JS runtime: which currently supports a single Stat method and exposes a Name property.
    • a FileInfo abstraction that is returned by the File.stat method and exposes the name (basename) of the file and its size as properties to the JS runtime.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make ci-like-lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

closes #3142

ref #3141
ref #2974

@oleiade oleiade added this to the v0.46.0 milestone Jul 5, 2023
@oleiade oleiade self-assigned this Jul 5, 2023
@oleiade oleiade marked this pull request as draft July 5, 2023 09:37
@github-actions github-actions bot requested review from imiric and mstoykov July 5, 2023 09:37
@oleiade oleiade removed the request for review from mstoykov July 5, 2023 09:37
@oleiade
Copy link
Member Author

oleiade commented Jul 5, 2023

🗣️ the "convert to draft" button doesn't seem to work at the moment...

@codecov-commenter
Copy link

codecov-commenter commented Jul 5, 2023

Codecov Report

Attention: 66 lines in your changes are missing coverage. Please review.

Comparison is base (d26bde8) 73.37% compared to head (9826b91) 73.31%.

❗ Current head 9826b91 differs from pull request most recent head d48fb67. Consider uploading reports for the commit d48fb67 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3165      +/-   ##
==========================================
- Coverage   73.37%   73.31%   -0.06%     
==========================================
  Files         261      266       +5     
  Lines       19779    19988     +209     
==========================================
+ Hits        14513    14655     +142     
- Misses       4369     4423      +54     
- Partials      897      910      +13     
Flag Coverage Δ
ubuntu 73.26% <68.42%> (-0.05%) ⬇️
windows 73.17% <68.42%> (-0.06%) ⬇️

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

Files Coverage Δ
js/jsmodules.go 100.00% <100.00%> (ø)
js/modules/k6/experimental/fs/file.go 100.00% <100.00%> (ø)
js/modules/k6/experimental/fs/errors.go 80.00% <80.00%> (ø)
js/modules/k6/experimental/fs/cache.go 55.55% <55.55%> (ø)
js/modules/k6/experimental/fs/errors_gen.go 9.09% <9.09%> (ø)
js/modules/k6/experimental/fs/module.go 71.09% <71.09%> (ø)

... and 1 file with indirect coverage changes

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

Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

Good first step @oleiade! 👏

Just have some minor and nitpicky comments/questions.

js/modules/k6/experimental/fs/module.go Outdated Show resolved Hide resolved
js/modules/k6/experimental/fs/file.go Outdated Show resolved Hide resolved
js/modules/k6/experimental/fs/goja.go Outdated Show resolved Hide resolved
js/modules/k6/experimental/fs/module.go Outdated Show resolved Hide resolved
js/modules/k6/experimental/fs/module.go Outdated Show resolved Hide resolved
js/modules/k6/experimental/fs/module.go Outdated Show resolved Hide resolved
js/modules/k6/experimental/fs/module.go Outdated Show resolved Hide resolved
@oleiade oleiade force-pushed the experimental/fs branch 14 times, most recently from fbec26b to 02c5120 Compare July 11, 2023 14:55
@oleiade oleiade changed the title ⚠️ WIP ⚠️ Expose an experimental fs module with an open function and a File abstraction Expose an experimental fs module with an open function and a File abstraction Jul 11, 2023
@oleiade oleiade force-pushed the experimental/fs branch 2 times, most recently from 113d0e1 to c20e063 Compare July 12, 2023 08:32
@oleiade
Copy link
Member Author

oleiade commented Nov 10, 2023

I have created #3454 to factor fsext.Abs out of this PR. I will remove the relevant commit and rebase on master once #3454 is merged 🤞🏻

@oleiade
Copy link
Member Author

oleiade commented Nov 10, 2023

Heads-up that I intend to clean up the history of the PR once I get approvals, so that we can create a merge commit 👍🏻

js/modules/k6/experimental/fs/module.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@codebien codebien left a comment

Choose a reason for hiding this comment

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

🎉 👏

Copy link
Collaborator

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

👍

@oleiade
Copy link
Member Author

oleiade commented Nov 13, 2023

🎉 I'll go ahead and squash and merge instead of making a merge commit as I realized that some of the changes applied as part of the PR review apply to content that was part of children's PRs, and that would make the whole branch cleanup quite nasty (if not impossible).

@oleiade oleiade merged commit 24ae4d9 into master Nov 13, 2023
22 checks passed
@oleiade oleiade deleted the experimental/fs branch November 13, 2023 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-needed A PR which will need a separate PR for documentation enhancement feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the File API's open method, base File abstraction and File.stat operation.
6 participants