Skip to content

Enable accountsdb_scan_account_storage_no_bank tests for hot storage#344

Merged
jeffwashington merged 1 commit intoanza-xyz:masterfrom
yhchiang-sol:ts-scan_account_storage-test
Apr 2, 2024
Merged

Enable accountsdb_scan_account_storage_no_bank tests for hot storage#344
jeffwashington merged 1 commit intoanza-xyz:masterfrom
yhchiang-sol:ts-scan_account_storage-test

Conversation

@yhchiang-sol
Copy link
Copy Markdown

@yhchiang-sol yhchiang-sol commented Mar 20, 2024

Problem

test_accountsdb_scan_account_storage_no_bank_one_slot and
test_accountsdb_scan_account_storage_no_bank only run for AppendVec.

Summary of Changes

Enable the above two tests to cover both AppendVec and HotStorage.

Test Plan

Run the newly enabled tests.

Dependency

#334, #446

@yhchiang-sol yhchiang-sol marked this pull request as draft March 20, 2024 19:13
Comment thread accounts-db/src/tiered_storage.rs Outdated
Comment on lines +67 to +75
// promote this to panic soon.
// disabled due to many false positive warnings while running tests.
// blocked by rpc's upgrade to jsonrpc v17
/*
panic!(
"TieredStorage failed to remove backing storage file '{}': {err}",
self.path.display(),
);
);*/
inc_new_counter_info!("append_vec_drop_fail", 1);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This section was copied from the AppendVec. The test will fail without this as some tests sometimes create an empty AccountsFile instance without writing it causing nothing to be dropped.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Which test(s) fail? Can we usually ManuallyDrop, like we do in the append vec tests here?

// wrap AppendVec in ManuallyDrop to ensure we do not remove the backing file when dropped
let av = ManuallyDrop::new(AppendVec::new(path, true, 1024 * 1024));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, when we talked about this offline, can you check if the error is for "file not found" or not? If the error is something else, maybe panic still is the right call.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The counter name should not be "append_vec" though.

Copy link
Copy Markdown
Author

@yhchiang-sol yhchiang-sol Mar 21, 2024

Choose a reason for hiding this comment

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

The enabled tests here will fail because of this. But I think skipping no-such-file-or-directory error should address the problem as we previously discussed.

Manual-drop works as well.

thread 'accounts_db::tests::test_accountsdb_scan_account_storage_no_bank_one_slot' panicked at accounts-db/src/tiered_storage.rs:67:13:
TieredStorage failed to remove backing storage file '/var/folders/2_/848_htk13yb0b_r0wg105t400000gn/T/.tmpFVnzMY/run/0.0': No such file or directory (os error 2)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in #446 that keeps the panic behavior but exclude io::ErrorKind::NotFound.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 20, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.8%. Comparing base (79e316e) to head (9b60781).
⚠️ Report is 6992 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #344   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         843      843           
  Lines      228586   228677   +91     
=======================================
+ Hits       187124   187209   +85     
- Misses      41462    41468    +6     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread accounts-db/src/accounts_db.rs Outdated
Comment on lines +10657 to +10662
#[test]
fn test_accountsdb_scan_account_storage_no_bank() {
accountsdb_scan_account_storage_no_bank_test_case::<WritableAppendVecProvider>();
accountsdb_scan_account_storage_no_bank_test_case::<WritableHotStorageProvider>();
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@brooksprumo: Just want to get quick feedback from you. Here's the way that I am currently developing to enable accounts-db tests for both AppendVec and TieredStorage. Does it look good to you?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You may be able to use test_case to generate these easier. It'll also then create two proper tests, so we can see pass/fail on each accounts file type separately.

Here's an example with generics: https://github.com/frondeus/test-case/blob/master/tests/acceptance_cases/cases_support_generics/src/lib.rs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Neat! This is great! Thanks for the pointer!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed the test to use test_case

Comment thread accounts-db/src/accounts_db.rs Outdated
Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

I can't think of anything better, so seems good for now. The non-test code should be monomorphized and the compiler should optimize any indirection away (I believe/hope!).

Comment thread accounts-db/src/tiered_storage.rs Outdated
Comment on lines +67 to +75
// promote this to panic soon.
// disabled due to many false positive warnings while running tests.
// blocked by rpc's upgrade to jsonrpc v17
/*
panic!(
"TieredStorage failed to remove backing storage file '{}': {err}",
self.path.display(),
);
);*/
inc_new_counter_info!("append_vec_drop_fail", 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, when we talked about this offline, can you check if the error is for "file not found" or not? If the error is something else, maybe panic still is the right call.

Comment thread accounts-db/src/tiered_storage.rs Outdated
footer::{AccountBlockFormat, AccountMetaFormat},
hot::{HotStorageWriter, HOT_FORMAT},
index::IndexBlockFormat,
log::log_enabled,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What's this for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Was for the log. Removed

Comment thread accounts-db/src/tiered_storage.rs Outdated
Comment on lines +67 to +75
// promote this to panic soon.
// disabled due to many false positive warnings while running tests.
// blocked by rpc's upgrade to jsonrpc v17
/*
panic!(
"TieredStorage failed to remove backing storage file '{}': {err}",
self.path.display(),
);
);*/
inc_new_counter_info!("append_vec_drop_fail", 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The counter name should not be "append_vec" though.

Comment thread accounts-db/src/accounts_db.rs Outdated
Comment on lines +10657 to +10662
#[test]
fn test_accountsdb_scan_account_storage_no_bank() {
accountsdb_scan_account_storage_no_bank_test_case::<WritableAppendVecProvider>();
accountsdb_scan_account_storage_no_bank_test_case::<WritableHotStorageProvider>();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You may be able to use test_case to generate these easier. It'll also then create two proper tests, so we can see pass/fail on each accounts file type separately.

Here's an example with generics: https://github.com/frondeus/test-case/blob/master/tests/acceptance_cases/cases_support_generics/src/lib.rs

Comment thread accounts-db/src/accounts_db.rs Outdated

impl AccountStorageEntry {
pub fn new(path: &Path, slot: Slot, id: AppendVecId, file_size: u64) -> Self {
pub fn new<T: WritableAccountsFileProvider>(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please only use T when it's a container and the container can hold any arbitrary type.

How about something like AF instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. Used AP (stands for AccountsFile Provider).

@yhchiang-sol yhchiang-sol force-pushed the ts-scan_account_storage-test branch from 02462f9 to ec97e39 Compare March 26, 2024 18:21
@yhchiang-sol
Copy link
Copy Markdown
Author

Rebased on top of the updated #334. Used test_case. Renamed T -> AP. Bypass file-not-found error on TieredStorage::drop().

@yhchiang-sol yhchiang-sol force-pushed the ts-scan_account_storage-test branch 3 times, most recently from 351322c to bdba36e Compare March 27, 2024 05:56
@yhchiang-sol
Copy link
Copy Markdown
Author

Rebased. Now it depends on #334 and #446.

@jeffwashington jeffwashington force-pushed the ts-scan_account_storage-test branch from bdba36e to 9b60781 Compare April 1, 2024 21:49
@jeffwashington jeffwashington marked this pull request as ready for review April 1, 2024 21:58
@jeffwashington
Copy link
Copy Markdown

@brooksprumo I think the other changes are no longer part of this pr.

@jeffwashington jeffwashington requested a review from HaoranYi April 1, 2024 22:17
Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

:shipit:

To make sure this PR still built, I checked it out and rebased on master. It successfully passed cargo clippy --tests.

@jeffwashington jeffwashington merged commit e815925 into anza-xyz:master Apr 2, 2024
Copy link
Copy Markdown

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants