Skip to content

Commit

Permalink
test with kind k8s v1.30 (signalfx#1341)
Browse files Browse the repository at this point in the history
* test with kind k8s v1.30

* fix another fn

* update tests for kind 1.30

* skip journald on 1-30

* fix version
  • Loading branch information
jinja2 authored Jul 11, 2024
1 parent 1251af9 commit f205edb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/functional_test_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# The kubernetes_version matrix entries are currently following native Kubernetes version support and +1, see: https://endoflife.date/kubernetes
# To check latest versions, see: https://hub.docker.com/r/kindest/node/tags
k8s-version:
# TODO: Add 1.30 support once Kind publishes an official 1.30 image
- v1.30.0 # Support: 28 Apr 2025 - 28 Jun 2025
- v1.29.0 # Support: 28 Dec 2024 - 28 Feb 2025
- v1.28.0 # Support: 28 Aug 2024 - 28 Oct 2024
- v1.27.3 # Support: 28 Apr 2024 - 28 Jun 2024
Expand Down Expand Up @@ -60,6 +60,8 @@ jobs:
run: |
make cert-manager
- name: run functional tests
env:
K8S_VERSION: ${{ matrix.k8s-version }}
run: |
cd functional_tests
go test -v
Expand Down
28 changes: 18 additions & 10 deletions functional_tests/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const (
kindValuesDir = "expected_kind_values"
)

var archRe = regexp.MustCompile("-amd64$|-arm64$|-ppc64le$")

// Test_Functions tests the chart with a real k8s cluster.
// Run the following commands prior to running the test locally:
//
Expand Down Expand Up @@ -601,6 +603,10 @@ func testDotNetTraces(t *testing.T) {
require.NoError(t, err)
}

func containerImageShorten(value string) string {
return archRe.ReplaceAllString(value[(strings.LastIndex(value, "/")+1):], "")
}

func shortenNames(value string) string {
if strings.HasPrefix(value, "kube-proxy") {
return "kube-proxy"
Expand Down Expand Up @@ -649,9 +655,6 @@ func testK8sClusterReceiverMetrics(t *testing.T) {
require.NoError(t, err)

replaceWithStar := func(string) string { return "*" }
containerImageShorten := func(value string) string {
return value[(strings.LastIndex(value, "/") + 1):]
}

var selected *pmetric.Metrics
for h := len(metricsConsumer.AllMetrics()) - 1; h >= 0; h-- {
Expand Down Expand Up @@ -693,6 +696,7 @@ func testK8sClusterReceiverMetrics(t *testing.T) {
pmetrictest.IgnoreMetricAttributeValue("k8s.replicaset.uid", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("k8s.replicaset.name", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("k8s.namespace.uid", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("container.image.name", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("container.image.tag", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("k8s.node.uid", metricNames...),
pmetrictest.IgnoreMetricValues(metricNames...),
Expand Down Expand Up @@ -722,6 +726,7 @@ func testK8sClusterReceiverMetrics(t *testing.T) {
}

func testAgentLogs(t *testing.T) {

logsConsumer := setupOnce(t).logsConsumer
waitForLogs(t, 5, logsConsumer)

Expand Down Expand Up @@ -773,10 +778,14 @@ func testAgentLogs(t *testing.T) {
}
}
}
t.Run("test journald sourcetypes are set", func(t *testing.T) {
assert.Contains(t, journalDsourceTypes, "kube:journald:containerd.service")
assert.Contains(t, journalDsourceTypes, "kube:journald:kubelet.service")
})
if strings.HasPrefix(os.Getenv("K8S_VERSION"), "v1.30") {
t.Log("Skipping test for journald sourcetypes for cluster version 1.30")
} else {
t.Run("test journald sourcetypes are set", func(t *testing.T) {
assert.Contains(t, journalDsourceTypes, "kube:journald:containerd.service")
assert.Contains(t, journalDsourceTypes, "kube:journald:kubelet.service")
})
}
t.Run("test node.js log records", func(t *testing.T) {
assert.NotNil(t, helloWorldLogRecord)
sourceType, ok := helloWorldResource.Attributes().Get("com.splunk.sourcetype")
Expand Down Expand Up @@ -933,9 +942,7 @@ func testAgentMetrics(t *testing.T) {
require.NoError(t, err)

replaceWithStar := func(string) string { return "*" }
containerImageShorten := func(value string) string {
return value[(strings.LastIndex(value, "/") + 1):]
}

selectedInternalMetrics := selectMetricSet(expectedInternalMetrics, "otelcol_process_runtime_total_alloc_bytes", agentMetricsConsumer, false)
if selectedInternalMetrics == nil {
t.Skip("No metric batch identified with the right metric count, exiting")
Expand All @@ -954,6 +961,7 @@ func testAgentMetrics(t *testing.T) {
pmetrictest.IgnoreMetricAttributeValue("k8s.replicaset.uid", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("k8s.replicaset.name", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("k8s.namespace.uid", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("container.image.name", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("container.image.tag", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("k8s.node.uid", metricNames...),
pmetrictest.IgnoreMetricAttributeValue("net.host.name", metricNames...),
Expand Down

0 comments on commit f205edb

Please sign in to comment.