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

service: add some unit test cases #1455

Merged
merged 3 commits into from
Nov 3, 2023
Merged

Conversation

hijackthe2
Copy link
Contributor

…e.rs, singleton.rs under service/src

  1. In blob_cache.rs, two simple lines of code have been added to cover previously missed cases.
  2. In block_device.rs, some test cases are added to cover function export(), block_size(), blocks_to_size(), and size_to_blocks().
  3. In fs_cache.rs, some test cases are added to cover function try_from() for struct FsCacheMsgOpen and FsCacheMsgRead.
  4. In singletion.rs, some test cases are added to cover function initialize_blob_cache() and initialize_fscache_service(). In addition, fscache must be correctly enabled as the device file /dev/cachefiles will used by function initialize_fscache_service().

i#tests: add unit test case for service/src/block_device.rs

Relevant Issue (if applicable)

If there are Issues related to this PullRequest, please list it.

Details

Please describe the details of PullRequest.

Types of changes

What types of changes does your PullRequest introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@hijackthe2 hijackthe2 requested a review from a team as a code owner October 27, 2023 03:11
@hijackthe2 hijackthe2 requested review from liubogithub, luodw and adamqqqplay and removed request for a team October 27, 2023 03:11
@hijackthe2 hijackthe2 force-pushed the unit-test branch 3 times, most recently from d84eaef to ad40c69 Compare October 27, 2023 05:50
@hijackthe2 hijackthe2 requested a review from a team as a code owner October 27, 2023 07:18
@hijackthe2 hijackthe2 requested review from jiangliu and gaius-qi and removed request for a team October 27, 2023 07:18
@hijackthe2 hijackthe2 force-pushed the unit-test branch 4 times, most recently from 5aa1d1b to f3c54d1 Compare October 28, 2023 01:28
@codecov
Copy link

codecov bot commented Oct 28, 2023

Codecov Report

Merging #1455 (62adc28) into master (ac55d7f) will increase coverage by 1.28%.
The diff coverage is 98.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1455      +/-   ##
==========================================
+ Coverage   44.37%   45.65%   +1.28%     
==========================================
  Files         123      123              
  Lines       38896    39170     +274     
  Branches    38896    39170     +274     
==========================================
+ Hits        17260    17885     +625     
+ Misses      20695    20298     -397     
- Partials      941      987      +46     
Files Coverage Δ
service/src/blob_cache.rs 82.69% <100.00%> (+4.44%) ⬆️
service/src/fs_cache.rs 29.21% <100.00%> (+20.48%) ⬆️
service/src/singleton.rs 55.26% <100.00%> (+55.26%) ⬆️
service/src/block_device.rs 75.81% <96.99%> (+37.21%) ⬆️

... and 10 files with indirect coverage changes

@adamqqqplay adamqqqplay changed the title tests: add unit test case for blob_cache.rs, block_device.rs, fs_cach… service: add some unit test cases Oct 28, 2023
Copy link
Member

@adamqqqplay adamqqqplay left a comment

Choose a reason for hiding this comment

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

Thanks for your contrbution!

Maybe you could tidy up the commit logs, the current commit logs are a bit redundant.
For example: "smoke ci configurations" could change to "ci" or "action".

@hijackthe2
Copy link
Contributor Author

Thanks for your contrbution!

Maybe you could tidy up the commit logs, the current commit logs are a bit redundant. For example: "smoke ci configurations" could change to "ci" or "action".

Thanks for reply! I have already adjusted the commit information.

@hijackthe2 hijackthe2 force-pushed the unit-test branch 2 times, most recently from 9f4135f to f4e995e Compare October 30, 2023 03:30
service/src/block_device.rs Outdated Show resolved Hide resolved
@hijackthe2 hijackthe2 force-pushed the unit-test branch 3 times, most recently from 516ecd9 to 03e0516 Compare November 1, 2023 03:35
@hijackthe2 hijackthe2 force-pushed the unit-test branch 5 times, most recently from 696606a to 4a84b63 Compare November 2, 2023 02:38
…e.rs, singleton.rs under service/src

1. In blob_cache.rs, two simple lines of code have been added to cover previously missed cases.
2. In block_device.rs, some test cases are added to cover function export(), block_size(), blocks_to_size(), and size_to_blocks().
3. In fs_cache.rs, some test cases are added to cover function try_from() for struct FsCacheMsgOpen and FsCacheMsgRead.
4. In singletion.rs, some test cases are added to cover function initialize_blob_cache() and initialize_fscache_service(). In addition, fscache must be correctly enabled firstly as the device file `/dev/cachefiles` will used by function initialize_fscache_service().

Signed-off-by: hijackthe2 <2948278083@qq.com>
Signed-off-by: hijackthe2 <2948278083@qq.com>
Since using `/dev/cachefiles` requires sudo mode, so some environment variables are defined and we use `sudo -E` to pass these environment variables to sudo operations.

The script file for enabling fscache is misc/fscache/setup.sh

Signed-off-by: hijackthe2 <2948278083@qq.com>
@imeoer imeoer merged commit 689900c into dragonflyoss:master Nov 3, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants