Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kristof Gyuracz <kristof.gyuracz@gmail.com>
  • Loading branch information
kristofgyuracz committed Feb 22, 2024
1 parent c66a1df commit 0548067
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
19 changes: 14 additions & 5 deletions internal/controller/telemetry/controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/yaml"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -119,14 +120,14 @@ var _ = Describe("Telemetry controller integration test", func() {
SubscriptionNamespaceSelectors: []metav1.LabelSelector{
{
MatchLabels: map[string]string{
"nsSelector": "tenant-1-ctrl",
"kubernetes.io/metadata.name": "tenant-1-ctrl",
},
},
},
LogSourceNamespaceSelectors: []metav1.LabelSelector{
{
MatchLabels: map[string]string{
"nsSelector": "tenant-1-workload",
"kubernetes.io/metadata.name": "tenant-1-workload",
},
},
},
Expand All @@ -145,14 +146,14 @@ var _ = Describe("Telemetry controller integration test", func() {
SubscriptionNamespaceSelectors: []metav1.LabelSelector{
{
MatchLabels: map[string]string{
"nsSelector": "tenant-2-all",
"kubernetes.io/metadata.name": "tenant-2-all",
},
},
},
LogSourceNamespaceSelectors: []metav1.LabelSelector{
{
MatchLabels: map[string]string{
"nsSelector": "tenant-2-all",
"kubernetes.io/metadata.name": "tenant-2-all",
},
},
},
Expand Down Expand Up @@ -283,7 +284,15 @@ var _ = Describe("Telemetry controller integration test", func() {
return err == nil
}, timeout, interval).Should(BeTrue())

Expect(createdOtelCollector.Spec.Config).To(Equal(exptectedOtelCollector.Spec.Config))
expectedMap := map[string]any{}
err = yaml.Unmarshal([]byte(exptectedOtelCollector.Spec.Config), expectedMap)
Expect(err).NotTo(HaveOccurred())

createdMap := map[string]any{}
err = yaml.Unmarshal([]byte(createdOtelCollector.Spec.Config), createdMap)
Expect(err).NotTo(HaveOccurred())

Expect(createdMap).To(Equal(expectedMap))

})
})
Expand Down
16 changes: 14 additions & 2 deletions internal/controller/telemetry/envtest_testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ processors:
from: resource_attribute
connectors:
routing/tenant_tenant-1_subscriptions:
table: []
table:
- statement: route()
pipelines: [logs/tenant_tenant-1_subscription_subscription-example-1]
routing/tenant_tenant-2_subscriptions:
table: []
table:
- statement: route()
pipelines: [logs/tenant_tenant-2_subscription_subscription-example-2]
routing/tenants:
table:
- statement: 'route() where '
Expand All @@ -123,3 +127,11 @@ service:
receivers: [routing/tenants]
processors: [attributes/tenant_tenant-2]
exporters: [routing/tenant_tenant-2_subscriptions]
logs/tenant_tenant-1_subscription_subscription-example-1:
receivers: [routing/tenant_tenant-1_subscriptions]
processors: [attributes/subscription_subscription-example-1]
exporters: [otlp/collector_otlp-test-output-1]
logs/tenant_tenant-2_subscription_subscription-example-2:
receivers: [routing/tenant_tenant-2_subscriptions]
processors: [attributes/subscription_subscription-example-2]
exporters: [otlp/collector_otlp-test-output-2]

0 comments on commit 0548067

Please sign in to comment.