mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #6298 from sinsharat/master
store: added missing test case scenerio for scan of de-queued entries
This commit is contained in:
commit
f4c30425c0
@ -14,7 +14,11 @@
|
|||||||
|
|
||||||
package store
|
package store
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
etcdErr "github.com/coreos/etcd/error"
|
||||||
|
)
|
||||||
|
|
||||||
// TestEventQueue tests a queue with capacity = 100
|
// TestEventQueue tests a queue with capacity = 100
|
||||||
// Add 200 events into that queue, and test if the
|
// Add 200 events into that queue, and test if the
|
||||||
@ -86,6 +90,26 @@ func TestScanHistory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEventIndexHistoryCleared(t *testing.T) {
|
||||||
|
eh := newEventHistory(5)
|
||||||
|
|
||||||
|
// Add
|
||||||
|
eh.addEvent(newEvent(Create, "/foo", 1, 1))
|
||||||
|
eh.addEvent(newEvent(Create, "/foo/bar", 2, 2))
|
||||||
|
eh.addEvent(newEvent(Create, "/foo/foo", 3, 3))
|
||||||
|
eh.addEvent(newEvent(Create, "/foo/bar/bar", 4, 4))
|
||||||
|
eh.addEvent(newEvent(Create, "/foo/foo/foo", 5, 5))
|
||||||
|
|
||||||
|
// Add a new event which will replace/de-queue the first entry
|
||||||
|
eh.addEvent(newEvent(Create, "/foo/bar/bar/bar", 6, 6))
|
||||||
|
|
||||||
|
// test for the event which has been replaced.
|
||||||
|
_, err := eh.scan("/foo", false, 1)
|
||||||
|
if err == nil || err.ErrorCode != etcdErr.EcodeEventIndexCleared {
|
||||||
|
t.Fatalf("scan error cleared index should return err with %d got (%v)", etcdErr.EcodeEventIndexCleared, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestFullEventQueue tests a queue with capacity = 10
|
// TestFullEventQueue tests a queue with capacity = 10
|
||||||
// Add 1000 events into that queue, and test if scanning
|
// Add 1000 events into that queue, and test if scanning
|
||||||
// works still for previous events.
|
// works still for previous events.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user