mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 05:29:30 +00:00
Added chunks count
This commit is contained in:
@@ -2,15 +2,19 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
"gopkg.in/mgo.v2/dbtest"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
"github.com/percona/percona-toolkit/src/go/lib/tutil"
|
"github.com/percona/percona-toolkit/src/go/lib/tutil"
|
||||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||||
|
"github.com/percona/pmgo"
|
||||||
"github.com/percona/pmgo/pmgomock"
|
"github.com/percona/pmgo/pmgomock"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -339,6 +343,36 @@ func TestGetChunks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIntegrationGetChunks(t *testing.T) {
|
||||||
|
var server dbtest.DBServer
|
||||||
|
os.Setenv("CHECK_SESSIONS", "0")
|
||||||
|
tempDir, _ := ioutil.TempDir("", "testing")
|
||||||
|
server.SetPath(tempDir)
|
||||||
|
|
||||||
|
session := pmgo.NewSessionManager(server.Session())
|
||||||
|
session.DB("config").C("chunks").Insert(bson.M{"ns": "samples.col1", "count": 2})
|
||||||
|
|
||||||
|
want := []proto.ChunksByCollection{
|
||||||
|
proto.ChunksByCollection{
|
||||||
|
ID: "samples.col1",
|
||||||
|
Count: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
got, err := getChunksCount(session)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error in integration chunks count: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(got, want) {
|
||||||
|
t.Errorf("Invalid integration chunks count.\ngot: %+v\nwant: %+v", got, want)
|
||||||
|
}
|
||||||
|
|
||||||
|
server.Session().DB("config").DropDatabase()
|
||||||
|
server.Session().Close()
|
||||||
|
server.Stop()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func addToCounters(ss proto.ServerStatus, increment int64) proto.ServerStatus {
|
func addToCounters(ss proto.ServerStatus, increment int64) proto.ServerStatus {
|
||||||
ss.Opcounters.Command += increment
|
ss.Opcounters.Command += increment
|
||||||
ss.Opcounters.Delete += increment
|
ss.Opcounters.Delete += increment
|
||||||
|
Reference in New Issue
Block a user