Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/operator/internal/manifests/query-frontend_test.go

66 lines
1.7 KiB

package manifests
import (
"testing"
lokiv1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/stretchr/testify/require"
)
func TestNewQueryFrontendDeployment_SelectorMatchesLabels(t *testing.T) {
ss := NewQueryFrontendDeployment(Options{
Name: "abcd",
Namespace: "efgh",
Stack: lokiv1.LokiStackSpec{
Template: &lokiv1.LokiTemplateSpec{
QueryFrontend: &lokiv1.LokiComponentSpec{
Replicas: 1,
},
},
},
})
l := ss.Spec.Template.GetObjectMeta().GetLabels()
for key, value := range ss.Spec.Selector.MatchLabels {
require.Contains(t, l, key)
require.Equal(t, l[key], value)
}
}
func TestNewQueryFrontendDeployment_HasTemplateConfigHashAnnotation(t *testing.T) {
ss := NewQueryFrontendDeployment(Options{
Name: "abcd",
Namespace: "efgh",
ConfigSHA1: "deadbeef",
Stack: lokiv1.LokiStackSpec{
Template: &lokiv1.LokiTemplateSpec{
QueryFrontend: &lokiv1.LokiComponentSpec{
Replicas: 1,
},
},
},
})
expected := "loki.grafana.com/config-hash"
annotations := ss.Spec.Template.Annotations
require.Contains(t, annotations, expected)
require.Equal(t, annotations[expected], "deadbeef")
}
func TestNewQueryFrontendDeployment_HasTemplateCertRotationRequiredAtAnnotation(t *testing.T) {
ss := NewQueryFrontendDeployment(Options{
Name: "abcd",
Namespace: "efgh",
CertRotationRequiredAt: "deadbeef",
Stack: lokiv1.LokiStackSpec{
Template: &lokiv1.LokiTemplateSpec{
QueryFrontend: &lokiv1.LokiComponentSpec{
Replicas: 1,
},
},
},
})
expected := "loki.grafana.com/certRotationRequiredAt"
annotations := ss.Spec.Template.Annotations
require.Contains(t, annotations, expected)
require.Equal(t, annotations[expected], "deadbeef")
}