Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12811 single agents change endpoint #2777

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1ef023a
PMM-12811 fix a typo
ademidoff Jan 17, 2024
970b9c6
PMM-12811 fix tests
ademidoff Jan 17, 2024
5973853
PMM-12811 modify agents.proto
ademidoff Jan 18, 2024
177260f
PMM-12811 modify agents_server and tests
ademidoff Jan 18, 2024
53495eb
PMM-12811 fix API tests
ademidoff Jan 18, 2024
6174e65
PMM-12811 fix linter warning
ademidoff Jan 18, 2024
33a6f68
PMM-12811 increase container wait time
ademidoff Jan 18, 2024
9659627
PMM-12811 print docker logs on failure
ademidoff Jan 19, 2024
636319d
Merge branch 'v3-api-breaking-changes' into PMM-12811-single-agents-c…
ademidoff Jan 19, 2024
443e191
PMM-12811 increase the container wait time again
ademidoff Jan 19, 2024
8e1d823
PMM-12811 try exit-code param for container launch
ademidoff Jan 19, 2024
62d898b
PMM-12811 check the container exit code
ademidoff Jan 19, 2024
e920eb6
PMM-12811 launch pmm w/o waiting
ademidoff Jan 19, 2024
502f05f
PMM-12811 launch the container manually
ademidoff Jan 19, 2024
2961917
PMM-12811 simplify, remove redundant methods
ademidoff Jan 19, 2024
cf6f8ee
PMM-12811 rename exporter to agent in proto
ademidoff Jan 19, 2024
602045c
PMM-12811 document the change
ademidoff Jan 19, 2024
2f48f8f
PMM-12811 fix API tests
ademidoff Jan 19, 2024
869a075
PMM-12811 fix platform_test.go
ademidoff Jan 19, 2024
a899be9
PMM-12811 prefer a single enable boolean vs paired
ademidoff Jan 30, 2024
db2fc88
PMM-12811 make custom_labels map optional
ademidoff Feb 1, 2024
2ea0e2a
Merge branch 'v3-api-breaking-changes' into PMM-12811-single-agents-c…
ademidoff Feb 1, 2024
75ed7e3
PMM-12811 fix Advisor params
ademidoff Feb 1, 2024
8ecef17
PMM-12811 get rid of remove_custom_labels field
ademidoff Feb 1, 2024
35100a4
PMM-12811 remove a duplicate test
ademidoff Feb 3, 2024
993f1d3
PMM-12811 follow up on review
ademidoff Feb 5, 2024
aa21531
PMM-12811 pass context to changeAgent
ademidoff Feb 5, 2024
f4293f0
PMM-12811 move tableCount to MysqldExporter
ademidoff Feb 5, 2024
4236a74
PMM-12811 pass context around, fix tests
ademidoff Feb 5, 2024
68002bc
PMM-12811 add an annotation about one param
ademidoff Feb 6, 2024
3c7a8cf
Merge branch 'v3-api-breaking-changes' into PMM-12811-single-agents-c…
ademidoff Feb 6, 2024
d3ad3cc
PMM-12811 fix Azure test
ademidoff Feb 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 71 additions & 56 deletions api-tests/inventory/agents_azure_database_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,23 @@ func TestAzureDatabaseExporter(t *testing.T) { //nolint:tparallel
}, getAgentRes)

// Test change API.
changeAzureDatabaseExporterOK, err := client.Default.AgentsService.ChangeAzureDatabaseExporter(&agents.ChangeAzureDatabaseExporterParams{
Body: agents.ChangeAzureDatabaseExporterBody{
AgentID: agentID,
Common: &agents.ChangeAzureDatabaseExporterParamsBodyCommon{
Disable: true,
RemoveCustomLabels: true,
changeAzureDatabaseExporterOK, err := client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
AzureDatabaseExporter: &agents.ChangeAgentParamsBodyAzureDatabaseExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyAzureDatabaseExporterCommon{
Disable: true,
RemoveCustomLabels: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeAzureDatabaseExporterOK{
Payload: &agents.ChangeAzureDatabaseExporterOKBody{
AzureDatabaseExporter: &agents.ChangeAzureDatabaseExporterOKBodyAzureDatabaseExporter{
assert.Equal(t, &agents.ChangeAgentOK{
Payload: &agents.ChangeAgentOKBody{
AzureDatabaseExporter: &agents.ChangeAgentOKBodyAzureDatabaseExporter{
NodeID: nodeID,
AgentID: agentID,
PMMAgentID: pmmAgentID,
Expand All @@ -108,22 +111,25 @@ func TestAzureDatabaseExporter(t *testing.T) { //nolint:tparallel
},
}, changeAzureDatabaseExporterOK)

changeAzureDatabaseExporterOK, err = client.Default.AgentsService.ChangeAzureDatabaseExporter(&agents.ChangeAzureDatabaseExporterParams{
Body: agents.ChangeAzureDatabaseExporterBody{
AgentID: agentID,
Common: &agents.ChangeAzureDatabaseExporterParamsBodyCommon{
Enable: true,
CustomLabels: map[string]string{
"new_label": "azure_database_exporter",
changeAzureDatabaseExporterOK, err = client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
AzureDatabaseExporter: &agents.ChangeAgentParamsBodyAzureDatabaseExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyAzureDatabaseExporterCommon{
Enable: true,
CustomLabels: map[string]string{
"new_label": "azure_database_exporter",
},
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeAzureDatabaseExporterOK{
Payload: &agents.ChangeAzureDatabaseExporterOKBody{
AzureDatabaseExporter: &agents.ChangeAzureDatabaseExporterOKBodyAzureDatabaseExporter{
assert.Equal(t, &agents.ChangeAgentOK{
Payload: &agents.ChangeAgentOKBody{
AzureDatabaseExporter: &agents.ChangeAgentOKBodyAzureDatabaseExporter{
NodeID: nodeID,
AgentID: agentID,
PMMAgentID: pmmAgentID,
Expand Down Expand Up @@ -265,19 +271,22 @@ func TestAzureDatabaseExporter(t *testing.T) { //nolint:tparallel
}, getAgentRes)

// Test change API.
changeAzureDatabaseExporterOK, err := client.Default.AgentsService.ChangeAzureDatabaseExporter(&agents.ChangeAzureDatabaseExporterParams{
Body: agents.ChangeAzureDatabaseExporterBody{
AgentID: agentID,
Common: &agents.ChangeAzureDatabaseExporterParamsBodyCommon{
EnablePushMetrics: true,
changeAzureDatabaseExporterOK, err := client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
AzureDatabaseExporter: &agents.ChangeAgentParamsBodyAzureDatabaseExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyAzureDatabaseExporterCommon{
EnablePushMetrics: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeAzureDatabaseExporterOK{
Payload: &agents.ChangeAzureDatabaseExporterOKBody{
AzureDatabaseExporter: &agents.ChangeAzureDatabaseExporterOKBodyAzureDatabaseExporter{
assert.Equal(t, &agents.ChangeAgentOK{
Payload: &agents.ChangeAgentOKBody{
AzureDatabaseExporter: &agents.ChangeAgentOKBodyAzureDatabaseExporter{
NodeID: nodeID,
AgentID: agentID,
PMMAgentID: pmmAgentID,
Expand All @@ -291,19 +300,22 @@ func TestAzureDatabaseExporter(t *testing.T) { //nolint:tparallel
},
}, changeAzureDatabaseExporterOK)

changeAzureDatabaseExporterOK, err = client.Default.AgentsService.ChangeAzureDatabaseExporter(&agents.ChangeAzureDatabaseExporterParams{
Body: agents.ChangeAzureDatabaseExporterBody{
AgentID: agentID,
Common: &agents.ChangeAzureDatabaseExporterParamsBodyCommon{
DisablePushMetrics: true,
changeAzureDatabaseExporterOK, err = client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
AzureDatabaseExporter: &agents.ChangeAgentParamsBodyAzureDatabaseExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyAzureDatabaseExporterCommon{
DisablePushMetrics: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeAzureDatabaseExporterOK{
Payload: &agents.ChangeAzureDatabaseExporterOKBody{
AzureDatabaseExporter: &agents.ChangeAzureDatabaseExporterOKBodyAzureDatabaseExporter{
assert.Equal(t, &agents.ChangeAgentOK{
Payload: &agents.ChangeAgentOKBody{
AzureDatabaseExporter: &agents.ChangeAgentOKBodyAzureDatabaseExporter{
NodeID: nodeID,
AgentID: agentID,
PMMAgentID: pmmAgentID,
Expand All @@ -316,16 +328,19 @@ func TestAzureDatabaseExporter(t *testing.T) { //nolint:tparallel
},
},
}, changeAzureDatabaseExporterOK)
_, err = client.Default.AgentsService.ChangeAzureDatabaseExporter(&agents.ChangeAzureDatabaseExporterParams{
Body: agents.ChangeAzureDatabaseExporterBody{
AgentID: agentID,
Common: &agents.ChangeAzureDatabaseExporterParamsBodyCommon{
EnablePushMetrics: true,
DisablePushMetrics: true,
_, err = client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
AzureDatabaseExporter: &agents.ChangeAgentParamsBodyAzureDatabaseExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyAzureDatabaseExporterCommon{
EnablePushMetrics: true,
DisablePushMetrics: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})

pmmapitests.AssertAPIErrorf(t, err, 400, codes.InvalidArgument, "expected one of param: enable_push_metrics or disable_push_metrics")
})
Expand Down
119 changes: 67 additions & 52 deletions api-tests/inventory/agents_external_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,22 @@ func TestExternalExporter(t *testing.T) {
}, getAgentRes.Payload)

// Test change API.
changeExternalExporterOK, err := client.Default.AgentsService.ChangeExternalExporter(&agents.ChangeExternalExporterParams{
Body: agents.ChangeExternalExporterBody{
AgentID: agentID,
Common: &agents.ChangeExternalExporterParamsBodyCommon{
Disable: true,
RemoveCustomLabels: true,
changeExternalExporterOK, err := client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyExternalExporterCommon{
Disable: true,
RemoveCustomLabels: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeExternalExporterOKBody{
ExternalExporter: &agents.ChangeExternalExporterOKBodyExternalExporter{
assert.Equal(t, &agents.ChangeAgentOKBody{
ExternalExporter: &agents.ChangeAgentOKBodyExternalExporter{
AgentID: agentID,
ServiceID: serviceID,
RunsOnNodeID: genericNodeID,
Expand All @@ -164,21 +167,24 @@ func TestExternalExporter(t *testing.T) {
},
}, changeExternalExporterOK.Payload)

changeExternalExporterOK, err = client.Default.AgentsService.ChangeExternalExporter(&agents.ChangeExternalExporterParams{
Body: agents.ChangeExternalExporterBody{
AgentID: agentID,
Common: &agents.ChangeExternalExporterParamsBodyCommon{
Enable: true,
CustomLabels: map[string]string{
"new_label": "external_exporter",
changeExternalExporterOK, err = client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyExternalExporterCommon{
Enable: true,
CustomLabels: map[string]string{
"new_label": "external_exporter",
},
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeExternalExporterOKBody{
ExternalExporter: &agents.ChangeExternalExporterOKBodyExternalExporter{
assert.Equal(t, &agents.ChangeAgentOKBody{
ExternalExporter: &agents.ChangeAgentOKBodyExternalExporter{
AgentID: agentID,
ServiceID: serviceID,
RunsOnNodeID: genericNodeID,
Expand Down Expand Up @@ -392,18 +398,21 @@ func TestExternalExporter(t *testing.T) {
}, getAgentRes.Payload)

// Test change API.
changeExternalExporterOK, err := client.Default.AgentsService.ChangeExternalExporter(&agents.ChangeExternalExporterParams{
Body: agents.ChangeExternalExporterBody{
AgentID: agentID,
Common: &agents.ChangeExternalExporterParamsBodyCommon{
DisablePushMetrics: true,
changeExternalExporterOK, err := client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyExternalExporterCommon{
DisablePushMetrics: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeExternalExporterOKBody{
ExternalExporter: &agents.ChangeExternalExporterOKBodyExternalExporter{
assert.Equal(t, &agents.ChangeAgentOKBody{
ExternalExporter: &agents.ChangeAgentOKBodyExternalExporter{
AgentID: agentID,
ServiceID: serviceID,
RunsOnNodeID: genericNodeID,
Expand All @@ -417,18 +426,21 @@ func TestExternalExporter(t *testing.T) {
},
}, changeExternalExporterOK.Payload)

changeExternalExporterOK, err = client.Default.AgentsService.ChangeExternalExporter(&agents.ChangeExternalExporterParams{
Body: agents.ChangeExternalExporterBody{
AgentID: agentID,
Common: &agents.ChangeExternalExporterParamsBodyCommon{
EnablePushMetrics: true,
changeExternalExporterOK, err = client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyExternalExporterCommon{
EnablePushMetrics: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
assert.NoError(t, err)
assert.Equal(t, &agents.ChangeExternalExporterOKBody{
ExternalExporter: &agents.ChangeExternalExporterOKBodyExternalExporter{
assert.Equal(t, &agents.ChangeAgentOKBody{
ExternalExporter: &agents.ChangeAgentOKBodyExternalExporter{
AgentID: agentID,
ServiceID: serviceID,
RunsOnNodeID: genericNodeID,
Expand All @@ -442,16 +454,19 @@ func TestExternalExporter(t *testing.T) {
},
}, changeExternalExporterOK.Payload)

_, err = client.Default.AgentsService.ChangeExternalExporter(&agents.ChangeExternalExporterParams{
Body: agents.ChangeExternalExporterBody{
AgentID: agentID,
Common: &agents.ChangeExternalExporterParamsBodyCommon{
EnablePushMetrics: true,
DisablePushMetrics: true,
_, err = client.Default.AgentsService.ChangeAgent(
&agents.ChangeAgentParams{
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
AgentID: agentID,
Common: &agents.ChangeAgentParamsBodyExternalExporterCommon{
EnablePushMetrics: true,
DisablePushMetrics: true,
},
},
},
},
Context: pmmapitests.Context,
})
Context: pmmapitests.Context,
})
pmmapitests.AssertAPIErrorf(t, err, 400, codes.InvalidArgument, "expected one of param: enable_push_metrics or disable_push_metrics")
})
}
Loading
Loading