mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
Updated mongodb src
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/howeyc/gopass"
|
||||
"github.com/montanaflynn/stats"
|
||||
"github.com/pborman/getopt"
|
||||
"github.com/percona/toolkit-go/mongolib/proto"
|
||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
@@ -9,9 +9,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/percona/toolkit-go/mongolib/proto"
|
||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||
|
||||
"gopkg.in/mgo.v2/dbtest" // mock
|
||||
"gopkg.in/mgo.v2/dbtest"
|
||||
)
|
||||
|
||||
var Server dbtest.DBServer
|
||||
|
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
"github.com/howeyc/gopass"
|
||||
"github.com/pborman/getopt"
|
||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||
"github.com/percona/percona-toolkit/src/go/pt-mongodb-summary/templates"
|
||||
"github.com/percona/pmgo"
|
||||
"github.com/percona/toolkit-go/mongolib/proto"
|
||||
"github.com/percona/toolkit-go/pt-mongodb-summary/templates"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
"gopkg.in/mgo.v2"
|
||||
|
@@ -10,9 +10,9 @@ import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||
"github.com/percona/pmgo/pmgomock"
|
||||
"github.com/percona/toolkit-go/mongolib/proto"
|
||||
"github.com/percona/toolkit-go/pt-mongodb-summary/test"
|
||||
"github.com/percona/toolkit-go-old/pt-mongodb-summary/test"
|
||||
)
|
||||
|
||||
func TestGetOpCounterStats(t *testing.T) {
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/percona/toolkit-go/mongolib/proto"
|
||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
|
@@ -1,69 +0,0 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func RootDir() (string, error) {
|
||||
out, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
|
||||
if err != nil {
|
||||
rootdir, err := searchDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return rootdir, nil
|
||||
}
|
||||
return strings.Replace(string(out), "\n", "", -1), nil
|
||||
}
|
||||
|
||||
func searchDir() (string, error) {
|
||||
|
||||
rootdir := ""
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
if FileExists(dir + "/.git") {
|
||||
rootdir = filepath.Clean(dir + "test")
|
||||
break
|
||||
}
|
||||
dir = dir + "/.."
|
||||
}
|
||||
if rootdir == "" {
|
||||
return "", fmt.Errorf("cannot detect root dir")
|
||||
}
|
||||
return rootdir, nil
|
||||
}
|
||||
|
||||
func FileExists(file string) bool {
|
||||
_, err := os.Lstat(file)
|
||||
if err == nil {
|
||||
return true
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func LoadJson(filename string, destination interface{}) error {
|
||||
dat, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(dat, &destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user