MongoDB EXPLAIN JSON APIs (#454)

* WIP

* PMM-4192 Updated MongoDB fingerprint

SystemProfile has been changed to use the new bson.D from the official
MongoDB driver instead of the old BsonD. Updated the fingerprinter
module and all tests

* PMM-4192 Updated MongoDB explain tests

Updated test to use bson.D instead of BsonD

* PMM-4192 Code clean-up

* PMM-4192 Changes for CR

* PMM-4192 Changes for CR

* PMM-4192 Removed unused deps

Co-authored-by: Carlos <cfsalguero@gmail.com>
This commit is contained in:
Carlos Salguero
2020-07-08 10:25:12 -03:00
committed by GitHub
parent de27179da8
commit c7eed08e33
205 changed files with 481 additions and 13385 deletions

View File

@@ -42,48 +42,48 @@ var (
MongoDBHost = "127.0.0.1"
// Port for standalone instance
MongoDBStandalonePort = os.Getenv(envMongoDBStandalonePort)
MongoDBStandalonePort = getEnvDefault(envMongoDBStandalonePort, "27017")
// MongoDBShard1ReplsetName Replicaset name for shard 1
MongoDBShard1ReplsetName = os.Getenv(envMongoDBShard1ReplsetName)
MongoDBShard1ReplsetName = getEnvDefault(envMongoDBShard1ReplsetName, "rs1")
// MongoDBShard1PrimaryPort is the port for the primary instance of shard 1
MongoDBShard1PrimaryPort = os.Getenv(envMongoDBShard1PrimaryPort)
MongoDBShard1PrimaryPort = getEnvDefault(envMongoDBShard1PrimaryPort, "17001")
// MongoDBShard1Secondary1Port is the port for the secondary instance 1 of shard 1
MongoDBShard1Secondary1Port = os.Getenv(envMongoDBShard1Secondary1Port)
MongoDBShard1Secondary1Port = getEnvDefault(envMongoDBShard1Secondary1Port, "17002")
// MongoDBShard1Secondary2Port is the port for the secondary instance 2 of shard 1
MongoDBShard1Secondary2Port = os.Getenv(envMongoDBShard1Secondary2Port)
MongoDBShard1Secondary2Port = getEnvDefault(envMongoDBShard1Secondary2Port, "17003")
// MongoDBShard2ReplsetName Replicaset name for shard 2
MongoDBShard2ReplsetName = os.Getenv(envMongoDBShard2ReplsetName)
MongoDBShard2ReplsetName = getEnvDefault(envMongoDBShard2ReplsetName, "rs2")
// MongoDBShard2PrimaryPort is the port for the primary instance of shard 2
MongoDBShard2PrimaryPort = os.Getenv(envMongoDBShard2PrimaryPort)
MongoDBShard2PrimaryPort = getEnvDefault(envMongoDBShard2PrimaryPort, "17004")
// MongoDBShard2Secondary1Port is the port for the secondary instance 1 of shard 2
MongoDBShard2Secondary1Port = os.Getenv(envMongoDBShard2Secondary1Port)
MongoDBShard2Secondary1Port = getEnvDefault(envMongoDBShard2Secondary1Port, "17005")
// MongoDBShard2Secondary2Port is the port for the secondary instance 1 of shard 2
MongoDBShard2Secondary2Port = os.Getenv(envMongoDBShard2Secondary2Port)
MongoDBShard2Secondary2Port = getEnvDefault(envMongoDBShard2Secondary2Port, "17006")
// MongoDBShard3ReplsetName Replicaset name for the 3rd cluster
MongoDBShard3ReplsetName = os.Getenv(envMongoDBShard3ReplsetName)
MongoDBShard3ReplsetName = getEnvDefault(envMongoDBShard3ReplsetName, "rs3")
// MongoDBShard3PrimaryPort is the port for the primary instance of 3rd cluster (non-sharded)
MongoDBShard3PrimaryPort = os.Getenv(envMongoDBShard3PrimaryPort)
MongoDBShard3PrimaryPort = getEnvDefault(envMongoDBShard3PrimaryPort, "17021")
// MongoDBShard3Secondary1Port is the port for the secondary instance 1 on the 3rd cluster
MongoDBShard3Secondary1Port = os.Getenv(envMongoDBShard3Secondary1Port)
MongoDBShard3Secondary1Port = getEnvDefault(envMongoDBShard3Secondary1Port, "17022")
// MongoDBShard3Secondary2Port is the port for the secondary instance 2 on the 3rd cluster
MongoDBShard3Secondary2Port = os.Getenv(envMongoDBShard3Secondary2Port)
MongoDBShard3Secondary2Port = getEnvDefault(envMongoDBShard3Secondary2Port, "17023")
// MongoDBConfigsvrReplsetName Replicaset name for the config servers
MongoDBConfigsvrReplsetName = os.Getenv(envMongoDBConfigsvrReplsetName)
MongoDBConfigsvrReplsetName = getEnvDefault(envMongoDBConfigsvrReplsetName, "csReplSet")
// MongoDBConfigsvr1Port Config server primary's port
MongoDBConfigsvr1Port = os.Getenv(envMongoDBConfigsvr1Port)
// MongoDBConfigsvr2Port = os.Getenv(envMongoDBConfigsvr2Port)
// MongoDBConfigsvr3Port = os.Getenv(envMongoDBConfigsvr3Port)
MongoDBConfigsvr1Port = getEnvDefault(envMongoDBConfigsvr1Port, "17007")
// MongoDBConfigsvr2Port = getEnvDefault(envMongoDBConfigsvr2Port)
// MongoDBConfigsvr3Port = getEnvDefault(envMongoDBConfigsvr3Port)
// MongoDBMongosPort mongos port
MongoDBMongosPort = os.Getenv(envMongoDBMongosPort)
MongoDBMongosPort = getEnvDefault(envMongoDBMongosPort, "17000")
// MongoDBUser username for all instances
MongoDBUser = os.Getenv(envMongoDBUser)
MongoDBUser = getEnvDefault(envMongoDBUser, "admin")
// MongoDBPassword password for all instances
MongoDBPassword = os.Getenv(envMongoDBPassword)
MongoDBPassword = getEnvDefault(envMongoDBPassword, "admin123456")
// MongoDBTimeout global connection timeout
MongoDBTimeout = time.Duration(10) * time.Second
@@ -125,6 +125,13 @@ func init() {
MongoDBSSLCACertFile = filepath.Join(MongoDBSSLDir, "rootCA.crt")
}
func getEnvDefault(key, defVal string) string {
if val := os.Getenv(key); val != "" {
return val
}
return defVal
}
// BaseDir returns the project's root dir by asking git
func BaseDir() string {
if basedir != "" {