Enhance DiskFS initialization and error handling
- Updated `disk.New` to support asynchronous initialization for large caches, improving responsiveness during startup. - Introduced an eviction function parameter to `disk.New`, ensuring proper handling of over-capacity scenarios. - Enhanced error handling in various components, including memory and disk tests, to ensure robustness and clarity. - Refactored tests to validate new behaviors, including checks for delayed attachment and proper error propagation. - Removed obsolete error handling code and tests related to the now-deleted errors package, streamlining the codebase.
This commit is contained in:
+16
-4
@@ -7,7 +7,10 @@ import (
|
||||
|
||||
func TestGCFS_BasicEvictOnCreate(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := memory.New(400)
|
||||
m, err := memory.New(400)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
g := New(m, LRU)
|
||||
|
||||
// Fill over
|
||||
@@ -27,7 +30,10 @@ func TestGCFS_BasicEvictOnCreate(t *testing.T) {
|
||||
|
||||
func TestAsyncGCFS_Stop(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := memory.New(1 << 20)
|
||||
m, err := memory.New(1 << 20)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ag := NewAsync(m, LRU, true, 0.7, 0.9, 1.0)
|
||||
// do some creates
|
||||
for i := 0; i < 3; i++ {
|
||||
@@ -46,7 +52,10 @@ func TestAsyncGCFS_Stop(t *testing.T) {
|
||||
|
||||
func TestGCFS_ForceAndStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := memory.New(500)
|
||||
m, err := memory.New(500)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
g := New(m, LRU)
|
||||
w, _ := g.Create("f", 400)
|
||||
w.Write(make([]byte, 400))
|
||||
@@ -66,7 +75,10 @@ func TestGCFS_ForceAndStats(t *testing.T) {
|
||||
// TestAsyncGCFS_QueuedAndDoubleStop exercises queueing, running flag, double-stop (issue8 coverage).
|
||||
func TestAsyncGCFS_QueuedAndDoubleStop(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := memory.New(1 << 20)
|
||||
m, err := memory.New(1 << 20)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ag := NewAsync(m, LRU, true, 0.5, 0.8, 1.0)
|
||||
defer ag.Stop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user