@@ -20,6 +20,7 @@ import (
20
20
corev1 "k8s.io/api/core/v1"
21
21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22
22
23
+ "github.com/elastic/elastic-agent-libs/testing/estools"
23
24
"github.com/elastic/elastic-agent/pkg/testing/define"
24
25
)
25
26
@@ -184,6 +185,9 @@ func TestOtelKubeStackHelmEDOTImage(t *testing.T) {
184
185
// - Two Gateway pods to collect, aggregate and forward
185
186
// telemetry.
186
187
k8sStepCheckRunningPods ("app.kubernetes.io/managed-by=opentelemetry-operator" , 4 , "otc-container" ),
188
+ // validate kubeletstats metrics are being
189
+ // pushed
190
+ k8sStepCheckDatastreamsHits (info , "metrics" , "kubeletstatsreceiver.otel" , "default" ),
187
191
},
188
192
},
189
193
{
@@ -277,3 +281,24 @@ func k8sStepCheckRunningPods(podLabelSelector string, expectedPodNumber int, con
277
281
}, 5 * time .Minute , 10 * time .Second , fmt .Sprintf ("at least %d agent containers should be checked" , expectedPodNumber ))
278
282
}
279
283
}
284
+
285
+ // k8sStepCheckDatastreams checks the corresponding Elasticsearch datastreams
286
+ // are created and documents being written
287
+ func k8sStepCheckDatastreamsHits (info * define.Info , dsType , dataset , namespace string ) k8sTestStep {
288
+ datastream := fmt .Sprintf ("%s-%s-%s" , dsType , dataset , namespace )
289
+ return func (t * testing.T , ctx context.Context , kCtx k8sContext , namespace string ) {
290
+ var initDocumentHits estools.Hits
291
+ require .Eventually (t , func () bool {
292
+ docs , err := estools .GetLogsForDatastream (ctx , info .ESClient , dsType , dataset , namespace )
293
+ require .NoError (t , err , "failed to get %s datastream documents" , datastream )
294
+ initDocumentHits = docs .Hits
295
+ return docs .Hits .Total .Value > 0
296
+ }, 5 * time .Minute , 10 * time .Second , fmt .Sprintf ("at least one document should be available for %s datastream" , datastream ))
297
+
298
+ require .Eventually (t , func () bool {
299
+ docs , err := estools .GetLogsForDatastream (ctx , info .ESClient , dsType , dataset , namespace )
300
+ require .NoError (t , err , "failed to get %s datastream documents" , datastream )
301
+ return docs .Hits .Total .Value > initDocumentHits .Total .Value
302
+ }, 5 * time .Minute , 10 * time .Second , fmt .Sprintf ("no new documents for %s datastream" , datastream ))
303
+ }
304
+ }
0 commit comments