RG3: the registry purges a deleted chunk's leftovers
Every delete of a chunk in the incoming object store is followed by the runtime's purge of what it left (busstate.Objects.Purge), so the store's kept descriptions equal its live objects; a failed purge is said. Builds: design 47 H2 §813 (8); H-A-227, H-A-366
This commit is contained in:
@@ -8,8 +8,15 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// The incoming store's steps (design 47 H2 §819: one test function for the bounded steps).
|
||||
func TestTheBoundedSteps(t *testing.T) {
|
||||
t.Run("a hung step answers with its name", hungStepAnswersWithItsName)
|
||||
t.Run("a given-up step says when its call ended", givenUpStepSaysWhenItsCallEnded)
|
||||
t.Run("a deleted chunk is purged", deletedChunkIsPurged)
|
||||
}
|
||||
|
||||
// A bus operation that never answers becomes an error naming its step, within the bound.
|
||||
func TestAHungStepAnswersWithItsName(t *testing.T) {
|
||||
func hungStepAnswersWithItsName(t *testing.T) {
|
||||
block := make(chan struct{})
|
||||
defer close(block)
|
||||
_, err := step(10*time.Millisecond, "the write of the idle key", func() (int, error) { <-block; return 0, nil })
|
||||
@@ -22,7 +29,7 @@ func TestAHungStepAnswersWithItsName(t *testing.T) {
|
||||
}
|
||||
|
||||
// A step given up on is said given up by name, and the log says later when the call behind it ended and how (A-443a).
|
||||
func TestAGivenUpStepSaysWhenItsCallEnded(t *testing.T) {
|
||||
func givenUpStepSaysWhenItsCallEnded(t *testing.T) {
|
||||
var mu sync.Mutex
|
||||
var lines []string
|
||||
ended := make(chan struct{})
|
||||
@@ -68,3 +75,31 @@ func TestAFindingIsSaidOffThePath(t *testing.T) {
|
||||
t.Fatal("the call was held by the finding")
|
||||
}
|
||||
}
|
||||
|
||||
// fakeObjects is an object store that counts deletes.
|
||||
type fakeObjects struct{ deleted []string }
|
||||
|
||||
func (f *fakeObjects) Put(string, []byte) error { return nil }
|
||||
func (f *fakeObjects) Get(string) ([]byte, error) { return nil, nil }
|
||||
func (f *fakeObjects) Delete(name string) error { f.deleted = append(f.deleted, name); return nil }
|
||||
func (f *fakeObjects) Used() (uint64, error) { return 0, nil }
|
||||
|
||||
// Every delete of a chunk purges what it left behind, so the store's kept descriptions equal its live objects (design 47
|
||||
// H2 §813 (8)); a purge's failure is said, never swallowed.
|
||||
func deletedChunkIsPurged(t *testing.T) {
|
||||
f := &fakeObjects{}
|
||||
var purged []string
|
||||
b := boundedObjects{f, func(name string) error { purged = append(purged, name); return nil }}
|
||||
for i := range 1000 {
|
||||
if err := b.Delete(fmt.Sprintf("chunk.%d", i)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if len(f.deleted) != 1000 || len(purged) != 1000 || purged[999] != "chunk.999" {
|
||||
t.Fatalf("deleted %d, purged %d", len(f.deleted), len(purged))
|
||||
}
|
||||
b.Purge = func(string) error { return fmt.Errorf("no responders") }
|
||||
if err := b.Delete("chunk.x"); err == nil || !strings.Contains(err.Error(), "no responders") {
|
||||
t.Fatalf("a failed purge answered %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user