1
1
#[ cfg( feature = "integration-test" ) ]
2
2
mod test {
3
3
use bytes:: { Buf , BufMut , BytesMut } ;
4
+ use chrono:: { Datelike , Utc } ;
4
5
use hdfs_native:: {
5
6
minidfs:: { DfsFeatures , MiniDfs } ,
6
7
Client , WriteOptions ,
@@ -16,7 +17,7 @@ mod test {
16
17
#[ serial]
17
18
async fn test_object_store ( ) -> object_store:: Result < ( ) > {
18
19
let dfs = MiniDfs :: with_features ( & HashSet :: from ( [ DfsFeatures :: HA ] ) ) ;
19
- let client = Client :: new ( & dfs. url ) . to_object_store_err ( ) ?;
20
+ let client = Arc :: new ( Client :: new ( & dfs. url ) . to_object_store_err ( ) ?) ;
20
21
21
22
// Create a test file with the client directly to sanity check reads and lists
22
23
let mut file = client
@@ -32,9 +33,9 @@ mod test {
32
33
33
34
client. mkdirs ( "/testdir" , 0o755 , true ) . await . unwrap ( ) ;
34
35
35
- let store = HdfsObjectStore :: new ( Arc :: new ( client) ) ;
36
+ let store = HdfsObjectStore :: new ( Arc :: clone ( & client) ) ;
36
37
37
- test_object_store_head ( & store) . await ?;
38
+ test_object_store_head ( & store, & client ) . await ?;
38
39
test_object_store_list ( & store) . await ?;
39
40
test_object_store_rename ( & store) . await ?;
40
41
test_object_store_read ( & store) . await ?;
@@ -45,12 +46,22 @@ mod test {
45
46
Ok ( ( ) )
46
47
}
47
48
48
- async fn test_object_store_head ( store : & HdfsObjectStore ) -> object_store:: Result < ( ) > {
49
+ async fn test_object_store_head (
50
+ store : & HdfsObjectStore ,
51
+ client : & Arc < Client > ,
52
+ ) -> object_store:: Result < ( ) > {
49
53
use object_store:: { path:: Path , ObjectStore } ;
50
54
55
+ let status = client. get_file_info ( "/testfile" ) . await . unwrap ( ) ;
56
+
51
57
let head = store. head ( & Path :: from ( "/testfile" ) ) . await ?;
52
58
assert_eq ! ( head. location, Path :: from( "/testfile" ) ) ;
53
59
assert_eq ! ( head. size, TEST_FILE_INTS * 4 ) ;
60
+ assert_eq ! (
61
+ head. last_modified. timestamp_millis( ) ,
62
+ status. modification_time as i64
63
+ ) ;
64
+ assert_eq ! ( head. last_modified. year( ) , Utc :: now( ) . year( ) ) ;
54
65
55
66
assert ! ( store. head( & Path :: from( "/testfile2" ) ) . await . is_err( ) ) ;
56
67
assert ! ( store. head( & Path :: from( "/testdir" ) ) . await . is_err( ) ) ;
0 commit comments