MCPcopy
hub / github.com/cubefs/cubefs / TestWriteProtectionMechanism

Function TestWriteProtectionMechanism

sdk/data/stream/async_flush_sequencer_test.go:61–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestWriteProtectionMechanism(t *testing.T) {
62 // Create a mock streamer
63 s := &Streamer{
64 inode: 12345,
65 }
66
67 // Create a mock handler
68 handler := &ExtentHandler{
69 id: 1,
70 }
71
72 // Test write protection
73 s.startWriteProtection(handler)
74
75 // Verify handler is protected
76 if !s.isHandlerProtected(handler) {
77 t.Errorf("Handler should be protected after startWriteProtection")
78 }
79
80 // Test with different handler
81 otherHandler := &ExtentHandler{
82 id: 2,
83 }
84 if s.isHandlerProtected(otherHandler) {
85 t.Errorf("Other handler should not be protected")
86 }
87
88 // End write protection
89 s.endWriteProtection()
90
91 // Verify handler is no longer protected
92 if s.isHandlerProtected(handler) {
93 t.Errorf("Handler should not be protected after endWriteProtection")
94 }
95
96 log.LogDebugf("Write protection test passed")
97}

Callers

nothing calls this directly

Calls 5

startWriteProtectionMethod · 0.95
isHandlerProtectedMethod · 0.95
endWriteProtectionMethod · 0.95
LogDebugfFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected