Skip to content

Commit

Permalink
code review and fix images
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Oct 5, 2023
1 parent bf72384 commit 813c9ef
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 97 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
matrix:
k8s-version:
- v1.28.0 # Support: 28 Aug 2024 - 28 Oct 2024
- v1.27.4 # Support: 28 Apr 2024 - 28 Jun 2024
- v1.26.7 # Support: 28 Dec 2023 - 28 Feb 2024
- v1.25.12 # Support: 27 Aug 2023 - 27 Oct 2023
- v1.24.16 # Support: 28 May 2023 - 28 Jul 2023
- v1.27.3 # Support: 28 Apr 2024 - 28 Jun 2024
- v1.26.6 # Support: 28 Dec 2023 - 28 Feb 2024
- v1.25.11 # Support: 27 Aug 2023 - 27 Oct 2023
- v1.24.15 # Support: 28 May 2023 - 28 Jul 2023
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
111 changes: 18 additions & 93 deletions e2e_tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/kube"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down Expand Up @@ -57,32 +56,12 @@ func TestTracesReception(t *testing.T) {
chartPath := filepath.Join("..", "helm-charts", "splunk-otel-collector")
chart, err := loader.Load(chartPath)
require.NoError(t, err)
values := map[string]interface{}{
"environment": "dev",
"operator": map[string]interface{}{
"enabled": true,
},
"certmanager": map[string]interface{}{
"enabled": true,
},
"clusterName": "dev",
"splunkObservability": map[string]interface{}{
"realm": "CHANGEME",
"accessToken": "CHANGEME",
},
"agent": map[string]interface{}{
"config": map[string]interface{}{
"exporters": map[string]interface{}{
"otlp": map[string]interface{}{
"endpoint": fmt.Sprintf("%s:4317", hostEndpoint(t)),
"tls": map[string]interface{}{
"insecure": true,
},
},
},
},
},
}
valuesBytes, err := os.ReadFile(filepath.Join("testdata", "operator_values.yaml"))
require.NoError(t, err)
valuesStr := strings.Replace(string(valuesBytes), "$ENDPOINT", fmt.Sprintf("%s:4317", hostEndpoint(t)), 1)
var values map[string]interface{}
err = yaml.Unmarshal([]byte(valuesStr), &values)
require.NoError(t, err)

actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(testKubeConfig, "", "default"), "default", os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
Expand Down Expand Up @@ -121,44 +100,11 @@ func TestTracesReception(t *testing.T) {

deployments := clientset.AppsV1().Deployments("default")

deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "nodejs-test",
Namespace: "default",
Labels: map[string]string{
"app": "nodejs-test",
},
Annotations: map[string]string{
"instrumentation.opentelemetry.io/inject-nodejs": "true",
},
},
Spec: appsv1.DeploymentSpec{

Template: v1.PodTemplateSpec{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "nodejs-test",
Image: "nodejs_test:latest",
ImagePullPolicy: v1.PullNever,
},
},
RestartPolicy: v1.RestartPolicyAlways,
},
ObjectMeta: metav1.ObjectMeta{
Name: "nodejs-test",
Namespace: "default",
Labels: map[string]string{
"app": "nodejs-test",
},
},
},
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app": "nodejs-test",
}},
},
}
var deployment *appsv1.Deployment
b, err := os.ReadFile(filepath.Join("testdata", "nodejs", "deployment.yaml"))
require.NoError(t, err)
err = yaml.Unmarshal(b, &deployment)
require.NoError(t, err)
_, err = deployments.Create(context.Background(), deployment, metav1.CreateOptions{})
require.NoError(t, err)

Expand Down Expand Up @@ -191,34 +137,13 @@ func TestClusterReceiverReception(t *testing.T) {
chartPath := filepath.Join("..", "helm-charts", "splunk-otel-collector")
chart, err := loader.Load(chartPath)
require.NoError(t, err)
values := map[string]interface{}{
"clusterName": "dev-cluster-receiver",
"splunkObservability": map[string]interface{}{ // those values are ignored as we override the exporters.
"realm": "CHANGEME",
"accessToken": "CHANGEME",
},
"clusterReceiver": map[string]interface{}{
"config": map[string]interface{}{
"exporters": map[string]interface{}{
"otlp": map[string]interface{}{
"endpoint": fmt.Sprintf("%s:4317", hostEndpoint(t)),
"tls": map[string]interface{}{
"insecure": true,
},
},
},
"service": map[string]interface{}{
"pipelines": map[string]interface{}{
"metrics": map[string]interface{}{
"exporters": []string{
"otlp",
},
},
},
},
},
},
}

valuesBytes, err := os.ReadFile(filepath.Join("testdata", "cluster_receiver_values.yaml"))
require.NoError(t, err)
valuesStr := strings.Replace(string(valuesBytes), "$ENDPOINT", fmt.Sprintf("%s:4317", hostEndpoint(t)), 1)
var values map[string]interface{}
err = yaml.Unmarshal([]byte(valuesStr), &values)
require.NoError(t, err)

actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(testKubeConfig, "", "default"), "default", os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
Expand Down
16 changes: 16 additions & 0 deletions e2e_tests/testdata/cluster_receiver_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
clusterName: dev-cluster-receiver
splunkObservability:
realm: CHANGEME
accessToken: CHANGEME
clusterReceiver:
config:
exporters:
otlp:
endpoint: $ENDPOINT
tls:
insecure: true
service:
pipelines:
metrics:
exporters:
- otlp
24 changes: 24 additions & 0 deletions e2e_tests/testdata/nodejs/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
objectmeta:
name: nodejs-test
namespace: default
labels:
app: nodejs-test
annotations:
instrumentation.opentelemetry.io/inject-nodejs: "true"
spec:
selector:
matchlabels:
app: nodejs-test
template:
objectmeta:
name: nodejs-test
namespace: default
labels:
app: nodejs-test
spec:
containers:
- name: nodejs-test
image: nodejs_test:latest
imagepullpolicy: Never
restartpolicy: Always
paused: false
22 changes: 22 additions & 0 deletions e2e_tests/testdata/operator_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
clusterName: dev-operator
splunkObservability:
realm: CHANGEME
accessToken: CHANGEME
agent:
config:
exporters:
otlp:
endpoint: $ENDPOINT
tls:
insecure: true
service:
pipelines:
metrics:
exporters:
- otlp
environment: dev
operator:
enabled: true
certmanager:
enabled: true

0 comments on commit 813c9ef

Please sign in to comment.