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

[HA Agent] e2e test tag ha_agent_enabled:true #33269

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions pkg/aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,9 @@ func (agg *BufferedAggregator) tags(withVersion bool) []string {
tags = append(tags, "package_version:"+version.AgentPackageVersion)
}
}
if agg.haAgent.Enabled() {
tags = append(tags, "ha_agent_enabled:true")
}
// nil to empty string
// This is expected by other components/tests
if tags == nil {
Expand Down
18 changes: 14 additions & 4 deletions pkg/aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func TestDefaultSeries(t *testing.T) {
require.Equal(t, 1, len(m))
require.Equal(t, "datadog.agent.up", m[0].CheckName)
require.Equal(t, servicecheck.ServiceCheckOK, m[0].Status)
require.Equal(t, []string{}, m[0].Tags)
require.Equal(t, []string{"ha_agent_enabled:true"}, m[0].Tags)
require.Equal(t, agg.hostname, m[0].Host)

return true
Expand All @@ -306,22 +306,22 @@ func TestDefaultSeries(t *testing.T) {
expectedSeries := metrics.Series{&metrics.Serie{
Name: fmt.Sprintf("datadog.%s.running", flavor.GetFlavor()),
Points: []metrics.Point{{Value: 1, Ts: float64(start.Unix())}},
Tags: tagset.CompositeTagsFromSlice([]string{"version:" + version.AgentVersion}),
Tags: tagset.CompositeTagsFromSlice([]string{"version:" + version.AgentVersion, "ha_agent_enabled:true"}),
Host: agg.hostname,
MType: metrics.APIGaugeType,
SourceTypeName: "System",
}, &metrics.Serie{
Name: fmt.Sprintf("datadog.%s.ha_agent.running", agg.agentName),
Points: []metrics.Point{{Value: float64(1), Ts: float64(start.Unix())}},
Tags: tagset.CompositeTagsFromSlice([]string{"agent_state:standby"}),
Tags: tagset.CompositeTagsFromSlice([]string{"ha_agent_enabled:true", "agent_state:standby"}),
Host: agg.hostname,
MType: metrics.APIGaugeType,
SourceTypeName: "System",
}, &metrics.Serie{
Name: fmt.Sprintf("n_o_i_n_d_e_x.datadog.%s.payload.dropped", flavor.GetFlavor()),
Points: []metrics.Point{{Value: 0, Ts: float64(start.Unix())}},
Host: agg.hostname,
Tags: tagset.CompositeTagsFromSlice([]string{}),
Tags: tagset.CompositeTagsFromSlice([]string{"ha_agent_enabled:true"}),
MType: metrics.APIGaugeType,
SourceTypeName: "System",
NoIndex: true,
Expand Down Expand Up @@ -645,6 +645,16 @@ func TestTags(t *testing.T) {
withVersion: true,
want: []string{"container_name:agent", "version:" + version.AgentVersion, "kube_cluster_name:foo"},
},
{
name: "tags disabled, without version, ha agent enabled",
hostname: "hostname",
tlmContainerTagsEnabled: false,
agentTags: func(types.TagCardinality) ([]string, error) { return nil, errors.New("disabled") },
globalTags: func(types.TagCardinality) ([]string, error) { return nil, errors.New("disabled") },
withVersion: false,
haAgentEnabled: true,
want: []string{"ha_agent_enabled:true"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/new-e2e/tests/ha-agent/haagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *haAgentTestSuite) TestHaAgentRunningMetrics() {
s.T().Logf(" datadog.agent.ha_agent.running metric tags: %+v", metric.Tags)
}

tags := []string{"agent_state:unknown"}
tags := []string{"agent_state:unknown", "ha_agent_enabled:true"}
metrics, err = fakeClient.FilterMetrics("datadog.agent.ha_agent.running", fakeintakeclient.WithTags[*aggregator.MetricSeries](tags))
require.NoError(c, err)
assert.NotEmpty(c, metrics)
Expand Down
Loading