|
|
@ -13,7 +13,7 @@ func TestOpenFileCache_Basic(t *testing.T) { |
|
|
|
|
|
|
|
|
// Test opening a file
|
|
|
// Test opening a file
|
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "test.txt", |
|
|
|
|
|
|
|
|
Name: "test.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -47,18 +47,18 @@ func TestOpenFileCache_MLFileDetection(t *testing.T) { |
|
|
size uint64 |
|
|
size uint64 |
|
|
expected MLFileType |
|
|
expected MLFileType |
|
|
}{ |
|
|
}{ |
|
|
{"PyTorch model", "/models/checkpoint.pt", "checkpoint.pt", 100*1024*1024, MLFileModel}, |
|
|
|
|
|
{"Dataset image", "/datasets/train/image001.jpg", "image001.jpg", 2*1024*1024, MLFileDataset}, |
|
|
|
|
|
|
|
|
{"PyTorch model", "/models/checkpoint.pt", "checkpoint.pt", 100 * 1024 * 1024, MLFileModel}, |
|
|
|
|
|
{"Dataset image", "/datasets/train/image001.jpg", "image001.jpg", 2 * 1024 * 1024, MLFileDataset}, |
|
|
{"Config file", "/config/training.yaml", "training.yaml", 1024, MLFileConfig}, |
|
|
{"Config file", "/config/training.yaml", "training.yaml", 1024, MLFileConfig}, |
|
|
{"Tensor file", "/tensors/weights.safetensors", "weights.safetensors", 50*1024*1024, MLFileModel}, |
|
|
|
|
|
{"Log file", "/logs/training.log", "training.log", 10*1024, MLFileLog}, |
|
|
|
|
|
{"Regular file", "/documents/readme.txt", "readme.txt", 5*1024, MLFileUnknown}, |
|
|
|
|
|
|
|
|
{"Tensor file", "/tensors/weights.safetensors", "weights.safetensors", 50 * 1024 * 1024, MLFileModel}, |
|
|
|
|
|
{"Log file", "/logs/training.log", "training.log", 10 * 1024, MLFileLog}, |
|
|
|
|
|
{"Regular file", "/documents/readme.txt", "readme.txt", 5 * 1024, MLFileUnknown}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for _, tc := range testCases { |
|
|
for _, tc := range testCases { |
|
|
t.Run(tc.name, func(t *testing.T) { |
|
|
t.Run(tc.name, func(t *testing.T) { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: tc.filename, |
|
|
|
|
|
|
|
|
Name: tc.filename, |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: tc.size, |
|
|
FileSize: tc.size, |
|
|
}, |
|
|
}, |
|
|
@ -90,7 +90,7 @@ func TestOpenFileCache_ChunkMetadata(t *testing.T) { |
|
|
|
|
|
|
|
|
inode := uint64(1) |
|
|
inode := uint64(1) |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "data.bin", |
|
|
|
|
|
|
|
|
Name: "data.bin", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 10240, |
|
|
FileSize: 10240, |
|
|
}, |
|
|
}, |
|
|
@ -135,7 +135,7 @@ func TestOpenFileCache_LRUEviction(t *testing.T) { |
|
|
// Fill cache to capacity
|
|
|
// Fill cache to capacity
|
|
|
for i := 1; i <= 3; i++ { |
|
|
for i := 1; i <= 3; i++ { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "file" + string(rune('0'+i)) + ".txt", |
|
|
|
|
|
|
|
|
Name: "file" + string(rune('0'+i)) + ".txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -147,7 +147,7 @@ func TestOpenFileCache_LRUEviction(t *testing.T) { |
|
|
|
|
|
|
|
|
// Add one more file - should trigger eviction
|
|
|
// Add one more file - should trigger eviction
|
|
|
entry4 := &filer_pb.Entry{ |
|
|
entry4 := &filer_pb.Entry{ |
|
|
Name: "file4.txt", |
|
|
|
|
|
|
|
|
Name: "file4.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -178,7 +178,7 @@ func TestOpenFileCache_TTLCleanup(t *testing.T) { |
|
|
|
|
|
|
|
|
inode := uint64(1) |
|
|
inode := uint64(1) |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "test.txt", |
|
|
|
|
|
|
|
|
Name: "test.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -208,7 +208,7 @@ func TestOpenFileCache_MultipleOpens(t *testing.T) { |
|
|
|
|
|
|
|
|
inode := uint64(1) |
|
|
inode := uint64(1) |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "shared.txt", |
|
|
|
|
|
|
|
|
Name: "shared.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -263,7 +263,7 @@ func TestOpenFileCache_Metrics(t *testing.T) { |
|
|
|
|
|
|
|
|
for _, file := range files { |
|
|
for _, file := range files { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: file.filename, |
|
|
|
|
|
|
|
|
Name: file.filename, |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: file.size, |
|
|
FileSize: file.size, |
|
|
}, |
|
|
}, |
|
|
@ -318,7 +318,7 @@ func TestOpenFileCache_ConcurrentAccess(t *testing.T) { |
|
|
|
|
|
|
|
|
inode := uint64(id) |
|
|
inode := uint64(id) |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "file" + string(rune('0'+id)) + ".txt", |
|
|
|
|
|
|
|
|
Name: "file" + string(rune('0'+id)) + ".txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -375,7 +375,7 @@ func TestMLFileDetector_Extensions(t *testing.T) { |
|
|
for _, tc := range testCases { |
|
|
for _, tc := range testCases { |
|
|
t.Run(tc.filename, func(t *testing.T) { |
|
|
t.Run(tc.filename, func(t *testing.T) { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: tc.filename, |
|
|
|
|
|
|
|
|
Name: tc.filename, |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -417,7 +417,7 @@ func TestMLFileDetector_PathPatterns(t *testing.T) { |
|
|
for _, tc := range testCases { |
|
|
for _, tc := range testCases { |
|
|
t.Run(tc.path, func(t *testing.T) { |
|
|
t.Run(tc.path, func(t *testing.T) { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: tc.filename, |
|
|
|
|
|
|
|
|
Name: tc.filename, |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -445,7 +445,7 @@ func TestMLFileDetector_SizeHeuristics(t *testing.T) { |
|
|
|
|
|
|
|
|
// Large file with model-related name should be detected as model
|
|
|
// Large file with model-related name should be detected as model
|
|
|
largeModelEntry := &filer_pb.Entry{ |
|
|
largeModelEntry := &filer_pb.Entry{ |
|
|
Name: "large_model.bin", |
|
|
|
|
|
|
|
|
Name: "large_model.bin", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 500 * 1024 * 1024, // 500MB
|
|
|
FileSize: 500 * 1024 * 1024, // 500MB
|
|
|
}, |
|
|
}, |
|
|
@ -469,7 +469,7 @@ func TestOpenFileCache_EvictionProtection(t *testing.T) { |
|
|
// Open two files and keep them open
|
|
|
// Open two files and keep them open
|
|
|
for i := 1; i <= 2; i++ { |
|
|
for i := 1; i <= 2; i++ { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "file" + string(rune('0'+i)) + ".txt", |
|
|
|
|
|
|
|
|
Name: "file" + string(rune('0'+i)) + ".txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -481,7 +481,7 @@ func TestOpenFileCache_EvictionProtection(t *testing.T) { |
|
|
|
|
|
|
|
|
// Try to open a third file - should not evict open files
|
|
|
// Try to open a third file - should not evict open files
|
|
|
entry3 := &filer_pb.Entry{ |
|
|
entry3 := &filer_pb.Entry{ |
|
|
Name: "file3.txt", |
|
|
|
|
|
|
|
|
Name: "file3.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -516,7 +516,7 @@ func TestOpenFileCache_GetFileInfo_CacheHitMiss(t *testing.T) { |
|
|
|
|
|
|
|
|
// Add file to cache
|
|
|
// Add file to cache
|
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "test.txt", |
|
|
|
|
|
|
|
|
Name: "test.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -545,7 +545,7 @@ func TestOpenFileCache_Shutdown(t *testing.T) { |
|
|
// Add some files
|
|
|
// Add some files
|
|
|
for i := 1; i <= 3; i++ { |
|
|
for i := 1; i <= 3; i++ { |
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "file" + string(rune('0'+i)) + ".txt", |
|
|
|
|
|
|
|
|
Name: "file" + string(rune('0'+i)) + ".txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -576,7 +576,7 @@ func BenchmarkOpenFileCache_OpenFile(b *testing.B) { |
|
|
defer cache.Shutdown() |
|
|
defer cache.Shutdown() |
|
|
|
|
|
|
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "benchmark.txt", |
|
|
|
|
|
|
|
|
Name: "benchmark.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
@ -597,7 +597,7 @@ func BenchmarkOpenFileCache_GetFileInfo(b *testing.B) { |
|
|
|
|
|
|
|
|
// Pre-populate cache
|
|
|
// Pre-populate cache
|
|
|
entry := &filer_pb.Entry{ |
|
|
entry := &filer_pb.Entry{ |
|
|
Name: "benchmark.txt", |
|
|
|
|
|
|
|
|
Name: "benchmark.txt", |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
Attributes: &filer_pb.FuseAttributes{ |
|
|
FileSize: 1024, |
|
|
FileSize: 1024, |
|
|
}, |
|
|
}, |
|
|
|