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

move more tests to use golden #5779

Merged
merged 6 commits into from
Jan 12, 2025
Merged
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
81 changes: 66 additions & 15 deletions tests/general/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,27 +218,78 @@ service:
// This test also exercises collectd binary usage and managed config writing
func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) {
testutils.SkipIfNotContainerTest(t)
testutils.AssertAllMetricsReceived(t, "activemq.yaml", "activemq_config.yaml", nil,
[]testutils.CollectorBuilder{
func(collector testutils.Collector) testutils.Collector {
cc := collector.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890")
return collector
},
tc := testutils.NewTestcase(t)
defer tc.PrintLogsOnFailure()
defer tc.ShutdownOTLPReceiverSink()

_, shutdown := tc.SplunkOtelCollectorContainer("activemq_config.yaml",
func(c testutils.Collector) testutils.Collector {
cc := c.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890")
return cc
},
)
defer shutdown()
require.EventuallyWithT(t, func(tt *assert.CollectT) {
if len(tc.OTLPReceiverSink.AllMetrics()) == 0 {
assert.Fail(tt, "No metrics collected")
return
}

metricsFound := map[string]struct{}{}
for _, m := range tc.OTLPReceiverSink.AllMetrics() {
for i := 0; i < m.ResourceMetrics().Len(); i++ {
rm := m.ResourceMetrics().At(i)
for j := 0; j < rm.ScopeMetrics().Len(); j++ {
sm := rm.ScopeMetrics().At(j)
for k := 0; k < sm.Metrics().Len(); k++ {
metric := sm.Metrics().At(k)

if metric.Name() == "counter.amq.TotalConnectionsCount" || metric.Name() == "jmx_memory.committed" {
metricsFound[metric.Name()] = struct{}{}
}
}
}
}
}
assert.Equal(tt, 2, len(metricsFound))
}, 30*time.Second, 1*time.Second)
}

func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) {
testutils.SkipIfNotContainerTest(t)
testutils.AssertAllMetricsReceived(t, "solr.yaml", "solr_config.yaml",
nil,
[]testutils.CollectorBuilder{
func(collector testutils.Collector) testutils.Collector {
cc := collector.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890")
return collector
},
tc := testutils.NewTestcase(t)
defer tc.PrintLogsOnFailure()
defer tc.ShutdownOTLPReceiverSink()

_, shutdown := tc.SplunkOtelCollectorContainer("solr_config.yaml",
func(c testutils.Collector) testutils.Collector {
cc := c.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890")
return cc
},
)
defer shutdown()

require.EventuallyWithT(t, func(tt *assert.CollectT) {
if len(tc.OTLPReceiverSink.AllMetrics()) == 0 {
assert.Fail(tt, "No metrics collected")
return
}
metricsFound := map[string]struct{}{}
m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1]
for i := 0; i < m.ResourceMetrics().Len(); i++ {
rm := m.ResourceMetrics().At(i)
for j := 0; j < rm.ScopeMetrics().Len(); j++ {
sm := rm.ScopeMetrics().At(j)
for k := 0; k < sm.Metrics().Len(); k++ {
metric := sm.Metrics().At(k)
if metric.Name() == "counter.solr.http_2xx_responses" {
metricsFound[metric.Name()] = struct{}{}
}
}
}
}
assert.Equal(tt, 1, len(metricsFound))
}, 30*time.Second, 1*time.Second)
}
7 changes: 0 additions & 7 deletions tests/general/testdata/resource_metrics/activemq.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/general/testdata/resource_metrics/solr.yaml

This file was deleted.

Loading