Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/framework/functional/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ var TestAPIAdapterConfigVisitor = func(conf string) string {
return conf
}

const (
// UtilContainerName is the name of the util container in functional tests
UtilContainerName = "util"
// imageUbi is the image used for the util container in functional tests
imageUbi = "registry.access.redhat.com/ubi9/ubi"
)

type CollectorFramework interface {
DeployConfigMapForConfig(name, config, clfName, clfYaml string) error
BuildCollectorContainer(*runtime.ContainerBuilder, string) *runtime.ContainerBuilder
Expand Down Expand Up @@ -316,6 +323,13 @@ func (f *CollectorFunctionalFramework) DeployWithVisitors(visitors []runtime.Pod
AddEnvVarFromFieldRef("POD_IPS", "status.podIPs").
WithImagePullPolicy(corev1.PullAlways).ResourceRequirements(resources), FunctionalNodeName).
End()

// Add util container for testing (needed when vector moves to ubi-micro)
b.AddContainer(UtilContainerName, imageUbi).
WithCmd([]string{"/bin/sh", "-c", "sleep infinity"}).
WithImagePullPolicy(corev1.PullIfNotPresent).
End()

for _, visit := range visitors {
if visit != nil {
if err = visit(b); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions test/framework/functional/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/util/wait"

"github.com/openshift/cluster-logging-operator/internal/constants"
"github.com/openshift/cluster-logging-operator/internal/runtime"
)

Expand Down Expand Up @@ -58,7 +57,7 @@ func (f *CollectorFunctionalFramework) CollectMetricLines(metricName, waitFor st
var matched []string
var lastErr error
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
raw, err := f.RunCommand(constants.CollectorName, "bash", "-c",
raw, err := f.RunCommand(UtilContainerName, "bash", "-c",
fmt.Sprintf("curl -ks --max-time 10 -H \"Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)\" https://%s.%s:24231/metrics", f.Name, f.Namespace))
if err != nil {
lastErr = err
Expand Down
2 changes: 1 addition & 1 deletion test/framework/functional/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (f *CollectorFunctionalFramework) WriteAsJsonToHttpInput(inputName string,
func (f *CollectorFunctionalFramework) WriteToHttpInput(inputName, buf string) error {
for _, input := range f.Forwarder.Spec.Inputs {
if input.Receiver != nil && input.Receiver.HTTP != nil && input.Name == inputName {
_, err := f.RunCommand(constants.CollectorName, "curl", "-ksv", fmt.Sprintf("http://localhost:%d", input.Receiver.Port), "-d", string(buf))
_, err := f.RunCommand(UtilContainerName, "curl", "-ksv", fmt.Sprintf("http://localhost:%d", input.Receiver.Port), "-d", string(buf))
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/metrics/discarded_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var _ = Describe("[Functional][Metrics] Discarded source logs metrics", func() {
grepDiscardCmd := fmt.Sprintf(`%s | grep -i discard`, curlCmd)

Eventually(func() string {
metrics, _ := framework.RunCommand(constants.CollectorName, "sh", "-c", grepDiscardCmd)
metrics, _ := framework.RunCommand(functional.UtilContainerName, "sh", "-c", grepDiscardCmd)
return metrics
}, 60*time.Second, 10*time.Second).Should(
And(
Expand Down
5 changes: 2 additions & 3 deletions test/functional/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
obs "github.com/openshift/cluster-logging-operator/api/observability/v1"
"github.com/openshift/cluster-logging-operator/internal/constants"
"github.com/openshift/cluster-logging-operator/internal/runtime"
"github.com/openshift/cluster-logging-operator/test/framework/functional"
testruntime "github.com/openshift/cluster-logging-operator/test/runtime/observability"
Expand Down Expand Up @@ -75,15 +74,15 @@ var _ = Describe("[Functional][Metrics]Function testing of collector metrics", f
Expect(framework.Deploy()).To(BeNil())
metricsURL := fmt.Sprintf("https://%s.%s:24231/metrics", framework.Name, framework.Namespace)
curlCmd := fmt.Sprintf(`curl -ksv -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" %s`, metricsURL)
metrics, _ := framework.RunCommand(constants.CollectorName, "sh", "-c", curlCmd)
metrics, _ := framework.RunCommand(functional.UtilContainerName, "sh", "-c", curlCmd)
Expect(metrics).To(ContainSubstring(sampleMetric))
})

It("should return successfully even when the output is down", func() {
Expect(framework.DeployWithVisitor(func(builder *runtime.PodBuilder) error { return nil })).To(BeNil())
metricsURL := fmt.Sprintf("https://%s.%s:24231/metrics", framework.Name, framework.Namespace)
curlCmd := fmt.Sprintf(`curl -ksv -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" %s`, metricsURL)
metrics, _ := framework.RunCommand(constants.CollectorName, "sh", "-c", curlCmd)
metrics, _ := framework.RunCommand(functional.UtilContainerName, "sh", "-c", curlCmd)
Expect(metrics).To(ContainSubstring(sampleMetric))
})

Expand Down
3 changes: 1 addition & 2 deletions test/functional/misc/vector_api_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
obs "github.com/openshift/cluster-logging-operator/api/observability/v1"
"github.com/openshift/cluster-logging-operator/internal/constants"
"github.com/openshift/cluster-logging-operator/test/framework/functional"
testruntime "github.com/openshift/cluster-logging-operator/test/runtime/observability"
)
Expand All @@ -25,7 +24,7 @@ var _ = Describe("[Functional][Misc][API_CLI] Functional test", func() {
Context("invoking vector CLI commands that talk to the vector API", func() {
It("should work", func() {
Expect(framework.Deploy()).To(BeNil())
out, _ := framework.RunCommand(constants.CollectorName, `curl`, `-sv`, `-m`, `5`, `--connect-timeout`, `3`, `http://127.0.0.1:8686/health`)
out, _ := framework.RunCommand(functional.UtilContainerName, `curl`, `-sv`, `-m`, `5`, `--connect-timeout`, `3`, `http://127.0.0.1:8686/health`)
Expect(out).To(ContainSubstring(`{"ok":true}`))
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/functional/outputs/splunk/403_forbidden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var _ = Describe("Forwarding to Splunk with authorization failures", func() {
// Query metrics from the collector (no auth required since we removed it)
metricsURL := fmt.Sprintf("https://%s.%s:24231/metrics", framework.Name, framework.Namespace)
curlCmd := fmt.Sprintf(`curl -ksv %s`, metricsURL)
metrics, err := framework.RunCommand(constants.CollectorName, "sh", "-c", curlCmd)
metrics, err := framework.RunCommand(functional.UtilContainerName, "sh", "-c", curlCmd)
Expect(err).To(BeNil(), "Expected no errors querying metrics")
Expect(metrics).ToNot(BeEmpty(), "Expected metrics to not be empty")

Expand Down
Loading