-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package inventorypb | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/percona/pmm/api/inventorypb/types" | ||
) | ||
|
||
// This test ensures that the AgentTypeNames map that holds the human readable agent type | ||
// names is up to date with the types defined in AgentType_name by the proto definition | ||
// by calling the AgentTypeName function using the values from protobuf and it expects the | ||
// result is a non-empty string, meaning that the AgentTypeNames list matches the proto | ||
// definitions | ||
func TestAgentTypes(t *testing.T) { | ||
for _, val := range AgentType_name { | ||
if strings.HasSuffix(val, "INVALID") { | ||
continue | ||
} | ||
assert.NotEmpty(t, types.AgentTypeName(val)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package inventorypb | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/percona/pmm/api/inventorypb/types" | ||
) | ||
|
||
// This test ensures that the NodetypeNames map that holds the human readable agent type | ||
// names is up to date with the types defined in Nodetype_name by the proto definition | ||
// by calling the NodetypeName function using the values from protobuf and it expects the | ||
// result is a non-empty string, meaning that the NodetypeNames list matches the proto | ||
// definitions | ||
func TestNodeTypes(t *testing.T) { | ||
for _, val := range NodeType_name { | ||
if strings.HasSuffix(val, "INVALID") { | ||
continue | ||
} | ||
assert.NotEmpty(t, types.NodeTypeName(val)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package inventorypb | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/percona/pmm/api/inventorypb/types" | ||
) | ||
|
||
// This test ensures that the ServiceTypeNames map that holds the human readable agent type | ||
// names is up to date with the types defined in ServiceType_name by the proto definition | ||
// by calling the ServiceTypeName function using the values from protobuf and it expects the | ||
// result is a non-empty string, meaning that the ServiceTypeNames list matches the proto | ||
// definitions | ||
func TestServiceTypes(t *testing.T) { | ||
for _, val := range ServiceType_name { | ||
if strings.HasSuffix(val, "INVALID") { | ||
continue | ||
} | ||
assert.NotEmpty(t, types.ServiceTypeName(val)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
// this list should be in sync with inventorypb/agents.pb.go | ||
const ( | ||
AgentTypePMMAgent = "PMM_AGENT" | ||
AgentTypeNodeExporter = "NODE_EXPORTER" | ||
AgentTypeMySQLdExporter = "MYSQLD_EXPORTER" | ||
AgentTypeMongoDBExporter = "MONGODB_EXPORTER" | ||
AgentTypePostgresExporter = "POSTGRES_EXPORTER" | ||
AgentTypeProxySQLExporter = "PROXYSQL_EXPORTER" | ||
AgentTypeQANMySQLPerfSchemaAgent = "QAN_MYSQL_PERFSCHEMA_AGENT" | ||
AgentTypeQANMySQLSlowlogAgent = "QAN_MYSQL_SLOWLOG_AGENT" | ||
AgentTypeQANMongoDBProfilerAgent = "QAN_MONGODB_PROFILER_AGENT" | ||
AgentTypeQANPostgreSQLPgStatementsAgent = "QAN_POSTGRESQL_PGSTATEMENTS_AGENT" | ||
AgentTypeRDSExporter = "RDS_EXPORTER" | ||
) | ||
|
||
// agentTypeNames is the human readable list of agent names to be used in reports and | ||
// commands like list or status | ||
var agentTypeNames = map[string]string{ | ||
// no invalid | ||
AgentTypePMMAgent: "pmm_agent", | ||
AgentTypeNodeExporter: "node_exporter", | ||
AgentTypeMySQLdExporter: "mysqld_exporter", | ||
AgentTypeMongoDBExporter: "mongodb_exporter", | ||
AgentTypePostgresExporter: "postgres_exporter", | ||
AgentTypeProxySQLExporter: "proxysql_exporter", | ||
AgentTypeQANMySQLPerfSchemaAgent: "mysql_perfschema_agent", | ||
AgentTypeQANMySQLSlowlogAgent: "mysql_slowlog_agent", | ||
AgentTypeQANMongoDBProfilerAgent: "mongodb_profiler_agent", | ||
AgentTypeQANPostgreSQLPgStatementsAgent: "postgresql_pgstatements_agent", | ||
AgentTypeRDSExporter: "rds_exporter", | ||
} | ||
|
||
// AgentTypeName returns human friendly agent type to be used in reports | ||
func AgentTypeName(t string) string { | ||
res := agentTypeNames[t] | ||
if res == "" { | ||
panic(fmt.Sprintf("no nice string for Agent Type %s", t)) | ||
} | ||
|
||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
// this list should be in sync with inventorypb/nodes.pb.go | ||
const ( | ||
NodeTypeGenericNode = "GENERIC_NODE" | ||
NodeTypeContainerNode = "CONTAINER_NODE" | ||
NodeTypeRemoteNode = "REMOTE_NODE" | ||
NodeTypeRemoteRDSNode = "REMOTE_RDS_NODE" | ||
) | ||
|
||
var nodeTypeNames = map[string]string{ | ||
NodeTypeGenericNode: "generic-node", | ||
NodeTypeContainerNode: "container-node", | ||
NodeTypeRemoteNode: "remote-node", | ||
NodeTypeRemoteRDSNode: "remote-rds-node", | ||
} | ||
|
||
// NodeTypeName returns human friendly agent type to be used in reports | ||
func NodeTypeName(t string) string { | ||
res := nodeTypeNames[t] | ||
if res == "" { | ||
panic(fmt.Sprintf("no nice string for Node Type %s", t)) | ||
} | ||
|
||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
// this list should be in sync with inventorypb/services.pb.go | ||
const ( | ||
ServiceTypeMySQLService = "MYSQL_SERVICE" | ||
ServiceTypeMongoDBService = "MONGODB_SERVICE" | ||
ServiceTypePostgreSQLService = "POSTGRESQL_SERVICE" | ||
ServiceTypeProxySQLService = "PROXYSQL_SERVICE" | ||
) | ||
|
||
var serviceTypeNames = map[string]string{ | ||
ServiceTypeMySQLService: "mysql-service", | ||
ServiceTypeMongoDBService: "mongodb-service", | ||
ServiceTypePostgreSQLService: "postgresql-service", | ||
ServiceTypeProxySQLService: "proxysql-service", | ||
} | ||
|
||
// ServiceTypeName returns human friendly agent type to be used in reports | ||
func ServiceTypeName(t string) string { | ||
res := serviceTypeNames[t] | ||
if res == "" { | ||
panic(fmt.Sprintf("no nice string for Service Type %s", t)) | ||
} | ||
|
||
return res | ||
} |