Skip to content

Commit cabc9a9

Browse files
authored
[chore] Add GKE helm tests and resource attribute test (#2149)
Signed-off-by: Dani Louca <dlouca@splunk.com>
1 parent 993b4ce commit cabc9a9

File tree

6 files changed

+312
-1
lines changed

6 files changed

+312
-1
lines changed

.github/workflows/functional_test_v2.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,83 @@ jobs:
477477
UPGRADE_FROM_CHART_DIR: base/splunk-otel-collector
478478
run: |
479479
TEARDOWN_BEFORE_SETUP=true SUITE=functional make functionaltest
480+
481+
gke-test:
482+
name: Test helm install in GKE - credentials needed
483+
if: |
484+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
485+
(github.ref == 'refs/heads/main')
486+
env:
487+
KUBE_TEST_ENV: gke
488+
runs-on: ubuntu-latest
489+
continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'Ignore Tests') }}
490+
steps:
491+
- uses: actions/checkout@v5
492+
- uses: actions/setup-go@v6
493+
with:
494+
go-version: ${{ env.GO_VERSION }}
495+
cache-dependency-path: '**/go.sum'
496+
- uses: 'google-github-actions/auth@v3.0.0'
497+
with:
498+
project_id: ${{ secrets.GKE_PROJECT }}
499+
credentials_json: ${{ secrets.GKE_SA_KEY }}
500+
- uses: google-github-actions/setup-gcloud@v3.0.1
501+
with:
502+
project_id: ${{ secrets.GKE_PROJECT }}
503+
- uses: google-github-actions/get-gke-credentials@v3.0.0
504+
with:
505+
cluster_name: ${{ secrets.GKE_CLUSTER }}
506+
location: ${{ secrets.GKE_REGION }}
507+
project_id: ${{ secrets.GKE_PROJECT }}
508+
- name: Update dependencies
509+
run: |
510+
make dep-update
511+
- name: run functional tests
512+
env:
513+
HOST_ENDPOINT: 0.0.0.0
514+
run: |
515+
TEARDOWN_BEFORE_SETUP=true SUITE=functional make functionaltest
516+
517+
gke-upgrade-test:
518+
name: Test helm upgrade in GKE - credentials needed
519+
if: |
520+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
521+
(github.ref == 'refs/heads/main')
522+
env:
523+
KUBE_TEST_ENV: gke
524+
SKIP_TESTS: "true"
525+
runs-on: ubuntu-latest
526+
continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'Ignore Tests') }}
527+
steps:
528+
- uses: actions/checkout@v5
529+
- name: Download the latest published release to use as a base for the upgrade
530+
run: |
531+
helm repo add splunk-otel-collector-chart https://signalfx.github.io/splunk-otel-collector-chart
532+
helm repo update
533+
helm pull splunk-otel-collector-chart/splunk-otel-collector --untar --untardir base
534+
- uses: actions/setup-go@v6
535+
with:
536+
go-version: ${{ env.GO_VERSION }}
537+
cache-dependency-path: '**/go.sum'
538+
- uses: 'google-github-actions/auth@v3.0.0'
539+
with:
540+
project_id: ${{ secrets.GKE_PROJECT }}
541+
credentials_json: ${{ secrets.GKE_SA_KEY }}
542+
- uses: google-github-actions/setup-gcloud@v3.0.1
543+
with:
544+
project_id: ${{ secrets.GKE_PROJECT }}
545+
- uses: google-github-actions/get-gke-credentials@v3.0.0
546+
with:
547+
cluster_name: ${{ secrets.GKE_CLUSTER }}
548+
location: ${{ secrets.GKE_REGION }}
549+
project_id: ${{ secrets.GKE_PROJECT }}
550+
- name: Update dependencies
551+
run: |
552+
make dep-update
553+
- name: run functional tests
554+
env:
555+
HOST_ENDPOINT: 0.0.0.0
556+
UPGRADE_FROM_VALUES: gke_upgrade_from_previous_release_values.yaml
557+
UPGRADE_FROM_CHART_DIR: base/splunk-otel-collector
558+
run: |
559+
TEARDOWN_BEFORE_SETUP=true SUITE=functional make functionaltest

functional_tests/functional/functional_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
eksTestKubeEnv = "eks"
5151
eksAutoModeTestKubeEnv = "eks/auto-mode"
5252
eksFargateTestKubeEnv = "eks/fargate"
53+
gkeTestKubeEnv = "gke"
5354
autopilotTestKubeEnv = "gke/autopilot"
5455
aksTestKubeEnv = "aks"
5556
gceTestKubeEnv = "gce"
@@ -60,6 +61,7 @@ const (
6061
eksValuesDir = "expected_eks_values"
6162
eksAutoModeValuesDir = "expected_eks_auto_mode_values"
6263
aksValuesDir = "expected_aks_values"
64+
gkeValuesDir = "expected_gke_values"
6365
agentLabelSelector = "component=otel-collector-agent"
6466
clusterReceiverLabelSelector = "component=otel-k8s-cluster-receiver"
6567
linuxPodMetricsPath = "/tmp/metrics.json"
@@ -203,6 +205,8 @@ func deployChartsAndApps(t *testing.T, testKubeConfig string) {
203205
addChartInfo("eks_auto_mode_test_values.yaml.tmpl", internal.GetDefaultChartOptions())
204206
case eksFargateTestKubeEnv:
205207
addChartInfo("eks_fargate_test_values.yaml.tmpl", internal.GetDefaultChartOptions())
208+
case gkeTestKubeEnv:
209+
addChartInfo("gke_test_values.yaml.tmpl", internal.GetDefaultChartOptions())
206210
default:
207211
addChartInfo("test_values.yaml.tmpl", internal.GetDefaultChartOptions())
208212
}
@@ -549,7 +553,7 @@ func runHostedClusterTests(t *testing.T, kubeTestEnv string) {
549553
client, err := kubernetes.NewForConfig(kubeConfig)
550554
require.NoError(t, err)
551555
switch kubeTestEnv {
552-
case eksTestKubeEnv, eksAutoModeTestKubeEnv, aksTestKubeEnv:
556+
case eksTestKubeEnv, eksAutoModeTestKubeEnv, aksTestKubeEnv, gkeTestKubeEnv:
553557
expectedValuesDir = selectExpectedValuesDir(kubeTestEnv)
554558
t.Run("agent resource attributes validation", func(t *testing.T) {
555559
validateResourceAttributes(t, client, kubeConfig, "agent")
@@ -568,6 +572,8 @@ func selectExpectedValuesDir(kubeTestEnv string) string {
568572
return eksAutoModeValuesDir
569573
case aksTestKubeEnv:
570574
return aksValuesDir
575+
case gkeTestKubeEnv:
576+
return gkeValuesDir
571577
default:
572578
return eksValuesDir
573579
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
resourceMetrics:
2+
- resource:
3+
attributes:
4+
- key: cloud.account.id
5+
value:
6+
stringValue: abcd
7+
- key: cloud.platform
8+
value:
9+
stringValue: abcd
10+
- key: cloud.provider
11+
value:
12+
stringValue: abcd
13+
- key: cloud.region
14+
value:
15+
stringValue: abcd
16+
- key: host.id
17+
value:
18+
stringValue: abcd
19+
- key: host.name
20+
value:
21+
stringValue: abcd
22+
- key: k8s.cluster.name
23+
value:
24+
stringValue: test
25+
- key: k8s.namespace.name
26+
value:
27+
stringValue: abcd
28+
- key: k8s.node.name
29+
value:
30+
stringValue: abcd
31+
- key: k8s.pod.name
32+
value:
33+
stringValue: abcd
34+
- key: k8s.pod.uid
35+
value:
36+
stringValue: abcd
37+
- key: os.type
38+
value:
39+
stringValue: abcd
40+
- key: otelcol.service.mode
41+
value:
42+
stringValue: abcd
43+
- key: server.port
44+
value:
45+
stringValue: abcd
46+
- key: service.instance.id
47+
value:
48+
stringValue: abcd
49+
- key: service.name
50+
value:
51+
stringValue: abcd
52+
- key: service.version
53+
value:
54+
stringValue: abcd
55+
- key: splunk_otlp_histograms
56+
value:
57+
stringValue: abcd
58+
- key: url.scheme
59+
value:
60+
stringValue: abcd
61+
- key: cluster_name
62+
value:
63+
stringValue: abcd
64+
- key: customfield1
65+
value:
66+
stringValue: abcd
67+
- key: customfield2
68+
value:
69+
stringValue: abcd
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
resourceMetrics:
2+
- resource:
3+
attributes:
4+
- key: cloud.account.id
5+
value:
6+
stringValue: abcd
7+
- key: cloud.platform
8+
value:
9+
stringValue: abcd
10+
- key: cloud.provider
11+
value:
12+
stringValue: abcd
13+
- key: cloud.region
14+
value:
15+
stringValue: abcd
16+
- key: host.id
17+
value:
18+
stringValue: abcd
19+
- key: host.name
20+
value:
21+
stringValue: abcd
22+
- key: k8s.cluster.name
23+
value:
24+
stringValue: test
25+
- key: k8s.namespace.name
26+
value:
27+
stringValue: abcd
28+
- key: k8s.node.name
29+
value:
30+
stringValue: abcd
31+
- key: k8s.pod.name
32+
value:
33+
stringValue: abcd
34+
- key: k8s.pod.uid
35+
value:
36+
stringValue: abcd
37+
- key: os.type
38+
value:
39+
stringValue: abcd
40+
- key: otelcol.service.mode
41+
value:
42+
stringValue: abcd
43+
- key: server.port
44+
value:
45+
stringValue: abcd
46+
- key: service.instance.id
47+
value:
48+
stringValue: abcd
49+
- key: service.name
50+
value:
51+
stringValue: abcd
52+
- key: service.version
53+
value:
54+
stringValue: abcd
55+
- key: metric_source
56+
value:
57+
stringValue: abcd
58+
- key: url.scheme
59+
value:
60+
stringValue: abcd
61+
- key: cluster_name
62+
value:
63+
stringValue: abcd
64+
- key: customfield1
65+
value:
66+
stringValue: abcd
67+
- key: customfield2
68+
value:
69+
stringValue: abcd
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
splunkObservability:
3+
realm: CHANGEME
4+
accessToken: CHANGEME
5+
ingestUrl: {{ .AgentEndpoint }}
6+
apiUrl: {{ .ApiURLEndpoint }}
7+
8+
splunkPlatform:
9+
token: foobar
10+
endpoint: {{ .LogHecEndpoint }}
11+
12+
agent:
13+
config:
14+
exporters:
15+
otlp:
16+
endpoint: {{ .OtlpEndpoint }}
17+
tls:
18+
insecure: true
19+
file:
20+
path: /tmp/metrics.json
21+
service:
22+
pipelines:
23+
traces:
24+
exporters:
25+
- otlp
26+
metrics/agent:
27+
exporters:
28+
- file
29+
clusterReceiver:
30+
eventsEnabled: true
31+
config:
32+
exporters:
33+
signalfx:
34+
ingest_url: {{ .K8sClusterEndpoint }}
35+
tls:
36+
insecure: true
37+
file:
38+
path: /tmp/metrics.json
39+
service:
40+
pipelines:
41+
metrics/collector:
42+
exporters:
43+
- file
44+
45+
k8sObjects:
46+
- name: pods
47+
- name: namespaces
48+
- name: nodes
49+
- name: events
50+
mode: watch
51+
52+
extraAttributes:
53+
fromAnnotations:
54+
- key: splunk.com/customField
55+
tag_name: customField
56+
fromLabels:
57+
- key: app
58+
from: pod
59+
- key: app
60+
from: namespace
61+
62+
custom:
63+
- name: "cluster_name"
64+
value: "ci-gke-k8s-cluster"
65+
- name: "customfield1"
66+
value: "customvalue1"
67+
- name: "customfield2"
68+
value: "customvalue2"
69+
70+
clusterName: test
71+
environment: test
72+
cloudProvider: gcp
73+
distribution: gke
74+
operatorcrds:
75+
install: true
76+
operator:
77+
enabled: true
78+
admissionWebhooks:
79+
certManager:
80+
enabled: false
81+
autoGenerateCert:
82+
enabled: true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cloudProvider: gcp
2+
distribution: gke
3+
splunkObservability:
4+
realm: us0
5+
accessToken: xxxxx

0 commit comments

Comments
 (0)