Skip to content

Commit

Permalink
chore: added e2e tests for extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit152 <[email protected]>
  • Loading branch information
Ankit152 committed Nov 14, 2024
1 parent 07787f4 commit e27c2a1
Show file tree
Hide file tree
Showing 6 changed files with 330 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .chloggen/service-extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: collector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: support for creating a service for extensions when ports are specified.

# One or more tracking issues related to the change
issues: [3460]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
4 changes: 1 addition & 3 deletions internal/manifests/collector/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
const (
headlessLabel = "operator.opentelemetry.io/collector-headless-service"
monitoringLabel = "operator.opentelemetry.io/collector-monitoring-service"
extensionService = "operator.opentelemetry.io/collector-extension-service"
serviceTypeLabel = "operator.opentelemetry.io/collector-service-type"
valueExists = "Exists"
)
Expand Down Expand Up @@ -111,9 +110,8 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) {
}

func ExtensionService(params manifests.Params) (*corev1.Service, error) {
name := naming.Service(params.OtelCol.Name)
name := naming.ExtensionService(params.OtelCol.Name)
labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{})
labels[extensionService] = valueExists
labels[serviceTypeLabel] = ExtensionServiceType.String()

annotations, err := manifestutils.Annotations(params.OtelCol, params.Config.AnnotationsFilter())
Expand Down
5 changes: 5 additions & 0 deletions internal/naming/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func MonitoringService(otelcol string) string {
return DNSName(Truncate("%s-monitoring", 63, Service(otelcol)))
}

// ExtensionService builds the name for the extension service based on the instance.
func ExtensionService(otelcol string) string {
return DNSName(Truncate("%s-extension", 63, Service(otelcol)))
}

// Service builds the service name based on the instance.
func Service(otelcol string) string {
return DNSName(Truncate("%s-collector", 63, otelcol))
Expand Down
264 changes: 264 additions & 0 deletions tests/e2e/extension/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
apiVersion: v1
items:
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
generation: 1
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: jaeger-inmemory-collector
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
name: jaeger-inmemory-collector
ownerReferences:
- apiVersion: opentelemetry.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: OpenTelemetryCollector
name: jaeger-inmemory
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
prometheus.io/path: /metrics
prometheus.io/port: "8888"
prometheus.io/scrape: "true"
creationTimestamp: null
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: jaeger-inmemory-collector
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
spec:
containers:
- args:
- --config=/conf/collector.yaml
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: jaegertracing/jaeger-snapshot:latest
imagePullPolicy: Always
name: otc-container
ports:
- containerPort: 16686
name: jaeger
protocol: TCP
- containerPort: 8888
name: metrics
protocol: TCP
- containerPort: 4317
name: otlp-grpc
protocol: TCP
- containerPort: 4318
name: otlp-http
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /conf
name: otc-internal
dnsConfig: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: jaeger-inmemory-collector
serviceAccountName: jaeger-inmemory-collector
shareProcessNamespace: false
terminationGracePeriodSeconds: 30
kind: List
metadata:
resourceVersion: ""
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: jaeger-inmemory-collector
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
name: jaeger-inmemory-collector
ownerReferences:
- apiVersion: opentelemetry.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: OpenTelemetryCollector
name: jaeger-inmemory
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: jaeger-inmemory-collector
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
operator.opentelemetry.io/collector-service-type: base
name: jaeger-inmemory-collector
ownerReferences:
- apiVersion: opentelemetry.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: OpenTelemetryCollector
name: jaeger-inmemory
spec:
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: jaeger
port: 16686
protocol: TCP
targetPort: 16686
- appProtocol: grpc
name: otlp-grpc
port: 4317
protocol: TCP
targetPort: 4317
- appProtocol: http
name: otlp-http
port: 4318
protocol: TCP
targetPort: 4318
selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.openshift.io/serving-cert-secret-name: jaeger-inmemory-collector-headless-tls
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: jaeger-inmemory-collector
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
operator.opentelemetry.io/collector-headless-service: Exists
operator.opentelemetry.io/collector-service-type: headless
name: jaeger-inmemory-collector-headless
ownerReferences:
- apiVersion: opentelemetry.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: OpenTelemetryCollector
name: jaeger-inmemory
spec:
clusterIP: None
clusterIPs:
- None
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: jaeger
port: 16686
protocol: TCP
targetPort: 16686
- appProtocol: grpc
name: otlp-grpc
port: 4317
protocol: TCP
targetPort: 4317
- appProtocol: http
name: otlp-http
port: 4318
protocol: TCP
targetPort: 4318
selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: jaeger-inmemory-collector-monitoring
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
operator.opentelemetry.io/collector-monitoring-service: Exists
operator.opentelemetry.io/collector-service-type: monitoring
name: jaeger-inmemory-collector-monitoring
ownerReferences:
- apiVersion: opentelemetry.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: OpenTelemetryCollector
name: jaeger-inmemory
spec:
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: monitoring
port: 8888
protocol: TCP
targetPort: 8888
selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
name: "jaeger-inmemory-collector-extension"
labels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
operator.opentelemetry.io/collector-service-type: extension
spec:
selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
ports:
- name: "jaeger-query"
port: 16686
targetPort: 16686
status:
loadBalancer: {}
30 changes: 30 additions & 0 deletions tests/e2e/extension/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: jaeger-inmemory
spec:
image: jaegertracing/jaeger-snapshot:latest
config:
service:
extensions: [jaeger_storage, jaeger_query]
pipelines:
traces:
receivers: [otlp]
exporters: [jaeger_storage_exporter]
extensions:
jaeger_query:
storage:
traces: memstore
jaeger_storage:
backends:
memstore:
memory:
max_traces: 100000
receivers:
otlp:
protocols:
grpc:
http:
exporters:
jaeger_storage_exporter:
trace_storage: memstore
14 changes: 14 additions & 0 deletions tests/e2e/extension/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
creationTimestamp: null
name: extension-test
spec:
steps:
- name: step-00
try:
- apply:
file: 00-install.yaml
- assert:
file: 00-assert.yaml

0 comments on commit e27c2a1

Please sign in to comment.