This repository was archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
PMM-4669 Added TLS field in PostgreSQL tests #42
Open
percona-csalguero
wants to merge
7
commits into
master
Choose a base branch
from
PMM-4534
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd552fd
PMM-4534 Added TLS field in PostgreSQL tests
percona-csalguero 9bea191
PMM-4534 Set pmm branch to pmm-2.0
percona-csalguero d355da8
Merge branch 'master' into PMM-4534
percona-csalguero 428a5a0
PMM-4534 Added MongoDB explain action
percona-csalguero 635ee05
PMM-4534 Update API.
AlekSi fa8bf0a
Merge branch 'master' into PMM-4534
AlekSi bf92d36
Vendor goimports.
AlekSi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,23 +1,161 @@ | ||
| package management | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/AlekSi/pointer" | ||
| "github.com/percona/percona-toolkit/src/go/mongolib/proto" | ||
| inventoryClient "github.com/percona/pmm/api/inventorypb/json/client" | ||
| "github.com/percona/pmm/api/inventorypb/json/client/agents" | ||
| "github.com/percona/pmm/api/inventorypb/json/client/services" | ||
| "github.com/percona/pmm/api/managementpb/json/client" | ||
| "github.com/percona/pmm/api/managementpb/json/client/actions" | ||
| mongodb "github.com/percona/pmm/api/managementpb/json/client/mongo_db" | ||
| "github.com/percona/pmm/api/managementpb/json/client/node" | ||
| "github.com/percona/pmm/api/managementpb/json/client/service" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "go.mongodb.org/mongo-driver/bson" | ||
| "google.golang.org/grpc/codes" | ||
|
|
||
| pmmapitests "github.com/Percona-Lab/pmm-api-tests" | ||
| ) | ||
|
|
||
| func TestMongoDBExplain(t *testing.T) { | ||
| t.Run("MongoDB explain", func(t *testing.T) { | ||
| nodeName := pmmapitests.TestString(t, "node-name-for-all-fields") | ||
| nodeID, pmmAgentID := registerGenericNode(t, node.RegisterBody{ | ||
| NodeName: nodeName, | ||
| NodeType: pointer.ToString(node.RegisterBodyNodeTypeGENERICNODE), | ||
| }) | ||
| defer pmmapitests.RemoveNodes(t, nodeID) | ||
| defer removePMMAgentWithSubAgents(t, pmmAgentID) | ||
|
|
||
| serviceName := pmmapitests.TestString(t, "service-name-for-all-fields") | ||
|
|
||
| params := &mongodb.AddMongoDBParams{ | ||
| Context: pmmapitests.Context, | ||
| Body: mongodb.AddMongoDBBody{ | ||
| NodeID: nodeID, | ||
| PMMAgentID: pmmAgentID, | ||
| ServiceName: serviceName, | ||
| Address: "10.10.10.10", | ||
| Port: 27017, | ||
| Username: "username", | ||
| Password: "password", | ||
| QANMongodbProfiler: true, | ||
|
|
||
| SkipConnectionCheck: true, | ||
| }, | ||
| } | ||
| addMongoDBOK, err := client.Default.MongoDB.AddMongoDB(params) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, addMongoDBOK) | ||
| require.NotNil(t, addMongoDBOK.Payload.Service) | ||
| serviceID := addMongoDBOK.Payload.Service.ServiceID | ||
| fmt.Printf("ServiceID: %s\n", serviceID) | ||
| defer pmmapitests.RemoveServices(t, serviceID) | ||
|
|
||
| // Check that service is created and its fields. | ||
| serviceOK, err := inventoryClient.Default.Services.GetService(&services.GetServiceParams{ | ||
| Body: services.GetServiceBody{ | ||
| ServiceID: serviceID, | ||
| }, | ||
| Context: pmmapitests.Context, | ||
| }) | ||
| assert.NoError(t, err) | ||
| assert.NotNil(t, serviceOK) | ||
| assert.Equal(t, services.GetServiceOKBody{ | ||
| Mongodb: &services.GetServiceOKBodyMongodb{ | ||
| ServiceID: serviceID, | ||
| NodeID: nodeID, | ||
| ServiceName: serviceName, | ||
| Address: "10.10.10.10", | ||
| Port: 27017, | ||
| }, | ||
| }, *serviceOK.Payload) | ||
|
|
||
| // -------------------------------------------------------------------------------------- | ||
| eq := proto.ExampleQuery{ | ||
| Ns: "test.coll", | ||
| Op: "query", | ||
| Query: proto.BsonD{ | ||
| { | ||
| Key: "k", | ||
| Value: proto.BsonD{ | ||
| { | ||
| Key: "$lte", | ||
| Value: int32(1), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| Command: nil, | ||
| OriginatingCommand: nil, | ||
| UpdateObj: nil, | ||
| } | ||
| buf, _ := bson.MarshalExtJSON(eq, true, true) | ||
| explainActionOK, err := client.Default.Actions.StartMongoDBExplainAction(&actions.StartMongoDBExplainActionParams{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. client.Default.Actions.StartMongoDBExplainAction undefined (type *actions.Client has no field or method StartMongoDBExplainAction) (from |
||
| Context: pmmapitests.Context, | ||
| Body: actions.StartMongoDBExplainActionBody{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StartMongoDBExplainActionBody not declared by package actions (from |
||
| //PMMAgentID: "/agent_id/f235005b-9cca-4b73-bbbd-1251067c3138", | ||
| ServiceID: serviceID, | ||
| Database: "test", | ||
| Query: string(buf), | ||
| }, | ||
| }) | ||
| require.NoError(t, err) | ||
| require.NotEmpty(t, explainActionOK.Payload.ActionID) | ||
|
|
||
| time.Sleep(2 * time.Second) | ||
|
|
||
| actionOK, err := client.Default.Actions.GetAction(&actions.GetActionParams{ | ||
| Context: pmmapitests.Context, | ||
| Body: actions.GetActionBody{ | ||
| ActionID: explainActionOK.Payload.ActionID, | ||
| }, | ||
| }) | ||
| require.NoError(t, err) | ||
| require.Empty(t, actionOK.Payload.Error) | ||
| // -------------------------------------------------------------------------------------- | ||
| // Check that exporters are added. | ||
| listAgents, err := inventoryClient.Default.Agents.ListAgents(&agents.ListAgentsParams{ | ||
| Context: pmmapitests.Context, | ||
| Body: agents.ListAgentsBody{ | ||
| ServiceID: serviceID, | ||
| }, | ||
| }) | ||
| assert.NoError(t, err) | ||
| require.NotNil(t, listAgents) | ||
| defer removeAllAgentsInList(t, listAgents) | ||
|
|
||
| require.Len(t, listAgents.Payload.MongodbExporter, 1) | ||
| require.Len(t, listAgents.Payload.QANMongodbProfilerAgent, 1) | ||
| assert.Equal(t, agents.ListAgentsOKBody{ | ||
| MongodbExporter: []*agents.MongodbExporterItems0{ | ||
| { | ||
| AgentID: listAgents.Payload.MongodbExporter[0].AgentID, | ||
| ServiceID: serviceID, | ||
| PMMAgentID: pmmAgentID, | ||
| Username: "username", | ||
| Password: "password", | ||
| }, | ||
| }, | ||
| QANMongodbProfilerAgent: []*agents.QANMongodbProfilerAgentItems0{ | ||
| { | ||
| AgentID: listAgents.Payload.QANMongodbProfilerAgent[0].AgentID, | ||
| ServiceID: serviceID, | ||
| PMMAgentID: pmmAgentID, | ||
| Username: "username", | ||
| Password: "password", | ||
| }, | ||
| }, | ||
| }, *listAgents.Payload) | ||
| }) | ||
| } | ||
|
|
||
| func TestAddMongoDB(t *testing.T) { | ||
| t.Run("Basic", func(t *testing.T) { | ||
| nodeName := pmmapitests.TestString(t, "node-for-basic-name") | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unknown field
Keyin struct literal (fromtypecheck)