|
|
@ -6,7 +6,7 @@ import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/raft"
|
|
|
|
"github.com/hashicorp/raft"
|
|
|
|
"github.com/hashicorp/raft-boltdb"
|
|
|
|
"github.com/rqlite/raft-boltdb"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func Test_LogNewEmpty(t *testing.T) {
|
|
|
|
func Test_LogNewEmpty(t *testing.T) {
|
|
|
@ -40,7 +40,6 @@ func Test_LogNewEmpty(t *testing.T) {
|
|
|
|
if lci != 0 {
|
|
|
|
if lci != 0 {
|
|
|
|
t.Fatalf("got wrong value for last command index of not empty log: %d", lci)
|
|
|
|
t.Fatalf("got wrong value for last command index of not empty log: %d", lci)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_LogNewExistNotEmpty(t *testing.T) {
|
|
|
|
func Test_LogNewExistNotEmpty(t *testing.T) {
|
|
|
@ -225,6 +224,29 @@ func Test_LogLastCommandIndexNotExist(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Test_LogStats(t *testing.T) {
|
|
|
|
|
|
|
|
path := mustTempFile()
|
|
|
|
|
|
|
|
defer os.Remove(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write some entries directory to the BoltDB Raft store.
|
|
|
|
|
|
|
|
bs, err := raftboltdb.NewBoltStore(path)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("failed to create bolt store: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 4; i > 0; i-- {
|
|
|
|
|
|
|
|
if err := bs.StoreLog(&raft.Log{
|
|
|
|
|
|
|
|
Index: uint64(i),
|
|
|
|
|
|
|
|
}); err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("failed to write entry to raft log: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = bs.Stats()
|
|
|
|
|
|
|
|
if err := bs.Close(); err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("failed to close bolt db: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// mustTempFile returns a path to a temporary file in directory dir. It is up to the
|
|
|
|
// mustTempFile returns a path to a temporary file in directory dir. It is up to the
|
|
|
|
// caller to remove the file once it is no longer needed.
|
|
|
|
// caller to remove the file once it is no longer needed.
|
|
|
|
func mustTempFile() string {
|
|
|
|
func mustTempFile() string {
|
|
|
|