@@ -680,3 +680,135 @@ func (s *GoofysTest) TestListParallelExpireNoCloud(t *C) {
680
680
<- ch
681
681
<- ch
682
682
}
683
+
684
+ // Case # 3 - start listing, trigger slurp for other directories, verify that eviction didn't affect correctness of listings
685
+ func (s * GoofysTest ) TestListSlurpExpireNoCloud (t * C ) {
686
+ var err error
687
+
688
+ flags := cfg .DefaultFlags ()
689
+
690
+ // Set low eviction limits
691
+ flags .StatCacheTTL = 1 * time .Second
692
+ flags .EntryLimit = 100
693
+
694
+ // Use mocked backend
695
+ backend := & TestBackend {
696
+ err : syscall .ENOSYS ,
697
+ ListBlobsFunc : func (param * ListBlobsInput ) (* ListBlobsOutput , error ) {
698
+ p , d , a := NilStr (param .Prefix ), NilStr (param .Delimiter ), NilStr (param .StartAfter )
699
+ time .Sleep (1 * time .Second )
700
+ fmt .Printf ("ListBlobs: Prefix=%v, Delimiter=%v, StartAfter=%v\n " , p , d , a )
701
+ if p == "" && d == "" && (a == "testdir" || a == "testdir/g" || a == "testdir/h" || a == "testdir/i" ) {
702
+ return & ListBlobsOutput {
703
+ IsTruncated : true ,
704
+ Items : []BlobItemOutput {
705
+ {Key : PString (a + "/" )},
706
+ },
707
+ }, nil
708
+ } else if p == "" && d == "" && (a == "testdir/" || a == "testdir/g/" || a == "testdir/h/" || a == "testdir/i/" ) {
709
+ var o []BlobItemOutput
710
+ if a <= "testdir/" {
711
+ for i := 0 ; i < 100 ; i ++ {
712
+ o = append (o , BlobItemOutput {Key : PString ("testdir/f" + fmt .Sprintf ("%04d" , i ))})
713
+ }
714
+ o = append (o , BlobItemOutput {Key : PString ("testdir/g/" )})
715
+ }
716
+ if a <= "testdir/g/" {
717
+ for i := 0 ; i < 100 ; i ++ {
718
+ o = append (o , BlobItemOutput {Key : PString ("testdir/g/gf" + fmt .Sprintf ("%04d" , i ))})
719
+ }
720
+ o = append (o , BlobItemOutput {Key : PString ("testdir/h/" )})
721
+ }
722
+ if a <= "testdir/h/" {
723
+ for i := 0 ; i < 100 ; i ++ {
724
+ o = append (o , BlobItemOutput {Key : PString ("testdir/h/hf" + fmt .Sprintf ("%04d" , i ))})
725
+ }
726
+ o = append (o , BlobItemOutput {Key : PString ("testdir/i/" )})
727
+ }
728
+ for i := 0 ; i < 100 ; i ++ {
729
+ o = append (o , BlobItemOutput {Key : PString ("testdir/i/if" + fmt .Sprintf ("%04d" , i ))})
730
+ }
731
+ return & ListBlobsOutput {
732
+ IsTruncated : a < "testdir/i/" ,
733
+ Items : o ,
734
+ }, nil
735
+ } else if p == "testdir/" && d == "/" && a == "" {
736
+ var o []BlobItemOutput
737
+ for i := 0 ; i < 100 ; i ++ {
738
+ o = append (o , BlobItemOutput {Key : PString ("testdir/f" + fmt .Sprintf ("%04d" , i ))})
739
+ }
740
+ return & ListBlobsOutput {
741
+ IsTruncated : true ,
742
+ Items : o ,
743
+ Prefixes : []BlobPrefixOutput {
744
+ {Prefix : PString ("testdir/g/" )},
745
+ {Prefix : PString ("testdir/h/" )},
746
+ {Prefix : PString ("testdir/i/" )},
747
+ },
748
+ }, nil
749
+ } else if p == "testdir/" && d == "/" && a == "testdir/i/" {
750
+ var o []BlobItemOutput
751
+ for i := 0 ; i < 100 ; i ++ {
752
+ o = append (o , BlobItemOutput {Key : PString ("testdir/j" + fmt .Sprintf ("%04d" , i ))})
753
+ }
754
+ return & ListBlobsOutput {
755
+ IsTruncated : false ,
756
+ Items : o ,
757
+ }, nil
758
+ }
759
+ return nil , syscall .ENOSYS
760
+ },
761
+ }
762
+ s .cloud = backend
763
+ s .fs , err = newGoofys (context .Background (), "test" , flags , func (string , * cfg.FlagStorage ) (StorageBackend , error ) {
764
+ return backend , nil
765
+ })
766
+ t .Assert (err , IsNil )
767
+
768
+ var names []string
769
+ for i := 0 ; i < 100 ; i ++ {
770
+ names = append (names , "f" + fmt .Sprintf ("%04d" , i ))
771
+ }
772
+ names = append (names , "g" , "h" , "i" )
773
+ for i := 0 ; i < 100 ; i ++ {
774
+ names = append (names , "j" + fmt .Sprintf ("%04d" , i ))
775
+ }
776
+ in , err := s .fs .LookupPath ("testdir" )
777
+ t .Assert (err , IsNil )
778
+ dh := in .OpenDir ()
779
+ t .Assert (namesOf (s .readDirFully (t , dh )), DeepEquals , names )
780
+ dh .CloseDir ()
781
+
782
+ // Sleep a bit to trigger eviction
783
+ time .Sleep (1 * time .Second )
784
+
785
+ names = nil
786
+ for i := 0 ; i < 100 ; i ++ {
787
+ names = append (names , "gf" + fmt .Sprintf ("%04d" , i ))
788
+ }
789
+ in , err = s .fs .LookupPath ("testdir/g" )
790
+ t .Assert (err , IsNil )
791
+ dh = in .OpenDir ()
792
+ t .Assert (namesOf (s .readDirFully (t , dh )), DeepEquals , names )
793
+ dh .CloseDir ()
794
+
795
+ names = nil
796
+ for i := 0 ; i < 100 ; i ++ {
797
+ names = append (names , "hf" + fmt .Sprintf ("%04d" , i ))
798
+ }
799
+ in , err = s .fs .LookupPath ("testdir/h" )
800
+ t .Assert (err , IsNil )
801
+ dh = in .OpenDir ()
802
+ t .Assert (namesOf (s .readDirFully (t , dh )), DeepEquals , names )
803
+ dh .CloseDir ()
804
+
805
+ names = nil
806
+ for i := 0 ; i < 100 ; i ++ {
807
+ names = append (names , "if" + fmt .Sprintf ("%04d" , i ))
808
+ }
809
+ in , err = s .fs .LookupPath ("testdir/i" )
810
+ t .Assert (err , IsNil )
811
+ dh = in .OpenDir ()
812
+ t .Assert (namesOf (s .readDirFully (t , dh )), DeepEquals , names )
813
+ dh .CloseDir ()
814
+ }
0 commit comments