@@ -70,6 +70,8 @@ const (
70
70
kindValuesDir = "expected_kind_values"
71
71
)
72
72
73
+ var archRe = regexp .MustCompile ("-amd64$|-arm64$|-ppc64le$" )
74
+
73
75
// Test_Functions tests the chart with a real k8s cluster.
74
76
// Run the following commands prior to running the test locally:
75
77
//
@@ -601,6 +603,10 @@ func testDotNetTraces(t *testing.T) {
601
603
require .NoError (t , err )
602
604
}
603
605
606
+ func containerImageShorten (value string ) string {
607
+ return archRe .ReplaceAllString (value [(strings .LastIndex (value , "/" )+ 1 ):], "" )
608
+ }
609
+
604
610
func shortenNames (value string ) string {
605
611
if strings .HasPrefix (value , "kube-proxy" ) {
606
612
return "kube-proxy"
@@ -649,9 +655,6 @@ func testK8sClusterReceiverMetrics(t *testing.T) {
649
655
require .NoError (t , err )
650
656
651
657
replaceWithStar := func (string ) string { return "*" }
652
- containerImageShorten := func (value string ) string {
653
- return value [(strings .LastIndex (value , "/" ) + 1 ):]
654
- }
655
658
656
659
var selected * pmetric.Metrics
657
660
for h := len (metricsConsumer .AllMetrics ()) - 1 ; h >= 0 ; h -- {
@@ -693,6 +696,7 @@ func testK8sClusterReceiverMetrics(t *testing.T) {
693
696
pmetrictest .IgnoreMetricAttributeValue ("k8s.replicaset.uid" , metricNames ... ),
694
697
pmetrictest .IgnoreMetricAttributeValue ("k8s.replicaset.name" , metricNames ... ),
695
698
pmetrictest .IgnoreMetricAttributeValue ("k8s.namespace.uid" , metricNames ... ),
699
+ pmetrictest .IgnoreMetricAttributeValue ("container.image.name" , metricNames ... ),
696
700
pmetrictest .IgnoreMetricAttributeValue ("container.image.tag" , metricNames ... ),
697
701
pmetrictest .IgnoreMetricAttributeValue ("k8s.node.uid" , metricNames ... ),
698
702
pmetrictest .IgnoreMetricValues (metricNames ... ),
@@ -722,6 +726,7 @@ func testK8sClusterReceiverMetrics(t *testing.T) {
722
726
}
723
727
724
728
func testAgentLogs (t * testing.T ) {
729
+
725
730
logsConsumer := setupOnce (t ).logsConsumer
726
731
waitForLogs (t , 5 , logsConsumer )
727
732
@@ -773,10 +778,14 @@ func testAgentLogs(t *testing.T) {
773
778
}
774
779
}
775
780
}
776
- t .Run ("test journald sourcetypes are set" , func (t * testing.T ) {
777
- assert .Contains (t , journalDsourceTypes , "kube:journald:containerd.service" )
778
- assert .Contains (t , journalDsourceTypes , "kube:journald:kubelet.service" )
779
- })
781
+ if strings .HasPrefix (os .Getenv ("K8S_VERSION" ), "v1.30" ) {
782
+ t .Log ("Skipping test for journald sourcetypes for cluster version 1.30" )
783
+ } else {
784
+ t .Run ("test journald sourcetypes are set" , func (t * testing.T ) {
785
+ assert .Contains (t , journalDsourceTypes , "kube:journald:containerd.service" )
786
+ assert .Contains (t , journalDsourceTypes , "kube:journald:kubelet.service" )
787
+ })
788
+ }
780
789
t .Run ("test node.js log records" , func (t * testing.T ) {
781
790
assert .NotNil (t , helloWorldLogRecord )
782
791
sourceType , ok := helloWorldResource .Attributes ().Get ("com.splunk.sourcetype" )
@@ -933,9 +942,7 @@ func testAgentMetrics(t *testing.T) {
933
942
require .NoError (t , err )
934
943
935
944
replaceWithStar := func (string ) string { return "*" }
936
- containerImageShorten := func (value string ) string {
937
- return value [(strings .LastIndex (value , "/" ) + 1 ):]
938
- }
945
+
939
946
selectedInternalMetrics := selectMetricSet (expectedInternalMetrics , "otelcol_process_runtime_total_alloc_bytes" , agentMetricsConsumer , false )
940
947
if selectedInternalMetrics == nil {
941
948
t .Skip ("No metric batch identified with the right metric count, exiting" )
@@ -954,6 +961,7 @@ func testAgentMetrics(t *testing.T) {
954
961
pmetrictest .IgnoreMetricAttributeValue ("k8s.replicaset.uid" , metricNames ... ),
955
962
pmetrictest .IgnoreMetricAttributeValue ("k8s.replicaset.name" , metricNames ... ),
956
963
pmetrictest .IgnoreMetricAttributeValue ("k8s.namespace.uid" , metricNames ... ),
964
+ pmetrictest .IgnoreMetricAttributeValue ("container.image.name" , metricNames ... ),
957
965
pmetrictest .IgnoreMetricAttributeValue ("container.image.tag" , metricNames ... ),
958
966
pmetrictest .IgnoreMetricAttributeValue ("k8s.node.uid" , metricNames ... ),
959
967
pmetrictest .IgnoreMetricAttributeValue ("net.host.name" , metricNames ... ),
0 commit comments