mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
test, status: cover unresolved cut settlement observations
This commit is contained in:
1 parent
3699af659f
commit
7534c0fc99
2 files changed
+15
-2
No files matched your search
@@ -3,6 +3,7 @@ package storage
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -39,6 +40,12 @@ func (r *currentCutHeldRemote) CASHead(ctx context.Context, expected chunkHeadVe
|
||||
}
|
||||
return r.fakeChunkRemote.CASHead(ctx, expected, next)
|
||||
}
|
||||
func (r *currentCutHeldRemote) GetHead(ctx context.Context) (chunkHead, error) {
|
||||
if err := r.wait(ctx, "settle"); err != nil {
|
||||
return chunkHead{}, err
|
||||
}
|
||||
return r.fakeChunkRemote.GetHead(ctx)
|
||||
}
|
||||
func currentCutJSON(t *testing.T, layer chunkLayer) map[string]any {
|
||||
t.Helper()
|
||||
raw, err := json.Marshal(layer.Stats())
|
||||
@@ -52,7 +59,7 @@ func currentCutJSON(t *testing.T, layer chunkLayer) map[string]any {
|
||||
return status
|
||||
}
|
||||
func TestCurrentCutStatusNamesTheHeldPhaseAndClearsOnExit(t *testing.T) {
|
||||
for _, phase := range []string{"upload", "commit"} {
|
||||
for _, phase := range []string{"upload", "commit", "settle"} {
|
||||
t.Run(phase, func(t *testing.T) {
|
||||
s, remote, layer, writes := precopyLayer(t, 1024, 0)
|
||||
if _, ok := currentCutJSON(t, layer)["CurrentCut"]; ok {
|
||||
@@ -60,6 +67,11 @@ func TestCurrentCutStatusNamesTheHeldPhaseAndClearsOnExit(t *testing.T) {
|
||||
}
|
||||
held := ¤tCutHeldRemote{fakeChunkRemote: remote, phase: phase, entered: make(chan struct{}), release: make(chan struct{})}
|
||||
layer.remote = held
|
||||
if phase == "settle" {
|
||||
remote.mu.Lock()
|
||||
remote.casModes = []fakeCASMode{casUnknownNotApplied}
|
||||
remote.mu.Unlock()
|
||||
}
|
||||
writes.write(t, s, 1, 0x37)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
@@ -88,7 +100,7 @@ func TestCurrentCutStatusNamesTheHeldPhaseAndClearsOnExit(t *testing.T) {
|
||||
release.Do(func() { close(held.release) })
|
||||
select {
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
if (phase == "settle" && !errors.Is(err, errChunkCASOutcomeUnknown)) || (phase != "settle" && err != nil) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
|
||||
@@ -741,6 +741,7 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
st.MapPersistNs += time.Since(start).Nanoseconds()
|
||||
}
|
||||
readCapturedHead := func() (chunkHead, error) {
|
||||
l.cutPhase("settle")
|
||||
start := time.Now()
|
||||
head, err := readChunkHead(ctx, l.remote)
|
||||
st.HeadReadbackNs += time.Since(start).Nanoseconds()
|
||||
|
||||
Reference in new issue
Block a user