-
Notifications
You must be signed in to change notification settings - Fork 392
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
[#6131] feat (gvfs-fuse): Add integration test framework of gvfs-fuse #6160
Changes from all commits
9810afd
4350b43
81bbf63
6b68650
922ed0a
3435810
4ad62ed
7900190
4e34bd2
1f014f6
0960c08
8f9bea8
536ff25
52649d7
00bb21f
6c29810
7a32f7f
eb23de6
5ed1a21
14cfdc9
078a2e9
e278ccf
629d449
ed3d1b4
df7b0da
1907c9e
1b8a949
016aec2
df64efd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,13 +334,22 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> { | |
file.flush().await | ||
} | ||
|
||
async fn close_file(&self, _file_id: u64, fh: u64) -> Result<()> { | ||
async fn close_file(&self, file_id: u64, fh: u64) -> Result<()> { | ||
let file_entry = self.get_file_entry(file_id).await; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why adding this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if the file has been deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is no file entry, is it expected not closing the open file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, closing deleted file may cause bugs. |
||
|
||
let opened_file = self | ||
.opened_file_manager | ||
.remove(fh) | ||
.ok_or(Errno::from(libc::EBADF))?; | ||
let mut file = opened_file.lock().await; | ||
file.close().await | ||
|
||
// todo: need to handle racing condition and corner case when the file has been deleted. | ||
if file_entry.is_ok() { | ||
let mut file = opened_file.lock().await; | ||
file.close().await | ||
} else { | ||
// If the file has been deleted, it does not cause a leak even if it has not been closed. | ||
Ok(()) | ||
} | ||
} | ||
|
||
async fn read(&self, file_id: u64, fh: u64, offset: u64, size: u32) -> Result<Bytes> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,22 +261,29 @@ fn opendal_filemode_to_filetype(mode: EntryMode) -> FileType { | |
mod test { | ||
use crate::config::AppConfig; | ||
use crate::s3_filesystem::extract_s3_config; | ||
use crate::s3_filesystem::tests::s3_test_config; | ||
use crate::test_enable_with; | ||
use crate::RUN_TEST_WITH_S3; | ||
use opendal::layers::LoggingLayer; | ||
use opendal::{services, Builder, Operator}; | ||
|
||
#[tokio::test] | ||
async fn test_s3_stat() { | ||
let config = AppConfig::from_file(Some("tests/conf/gvfs_fuse_s3.toml")).unwrap(); | ||
let opendal_config = extract_s3_config(&config); | ||
|
||
fn create_opendal(config: &AppConfig) -> Operator { | ||
let opendal_config = extract_s3_config(config); | ||
let builder = services::S3::from_map(opendal_config); | ||
|
||
// Init an operator | ||
let op = Operator::new(builder) | ||
Operator::new(builder) | ||
.expect("opendal create failed") | ||
.layer(LoggingLayer::default()) | ||
.finish(); | ||
.finish() | ||
} | ||
|
||
#[tokio::test] | ||
async fn s3_ut_test_s3_stat() { | ||
FANNG1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test_enable_with!(RUN_TEST_WITH_S3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems hacks, could you refer other rust projects for more general way to control the tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can’t find a good way to mark the test tags and run them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try using this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is generally used to control whether a module participates in compilation, and I haven't seen any projects using it to control tests. People familiar with Rust might find this confusing, right? It also cannot filter out tests that do not have feature = "ENABLE_S3_TEST" enabled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There have a lib can mark tags for the testers. but it can not work with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
let config = s3_test_config(); | ||
let op = create_opendal(&config); | ||
let path = "/"; | ||
let list = op.list(path).await; | ||
if let Ok(l) = list { | ||
|
@@ -294,4 +301,30 @@ mod test { | |
println!("stat error: {:?}", meta.err()); | ||
} | ||
} | ||
|
||
#[tokio::test] | ||
async fn s3_ut_test_s3_delete() { | ||
test_enable_with!(RUN_TEST_WITH_S3); | ||
let config = s3_test_config(); | ||
|
||
let op = create_opendal(&config); | ||
let path = "/s1/fileset1/gvfs_test/test_dir/test_file"; | ||
|
||
let meta = op.stat(path).await; | ||
if let Ok(m) = meta { | ||
println!("stat result: {:?}", m); | ||
} else { | ||
println!("stat error: {:?}", meta.err()); | ||
} | ||
|
||
let result = op.remove(vec![path.to_string()]).await; | ||
match result { | ||
Ok(_) => { | ||
println!("Delete successful (or no-op)."); | ||
} | ||
Err(e) => { | ||
println!("Delete failed: {:?}", e); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe move this two line to the
Build and test Gvfs-fuse
may be more properThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one above builds
gvfs-fuse
, and the below builds the Gravitino server needed for testing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK