diff --git a/tests/e2e/k8s.go b/tests/e2e/k8s.go index b166c3fbc..c020f2690 100644 --- a/tests/e2e/k8s.go +++ b/tests/e2e/k8s.go @@ -424,7 +424,15 @@ func listK8sCRDs(kubectlOptions k8s.KubectlOptions, crdNames ...string) ([]strin return nil, errors.WrapIfWithDetails(err, "listing K8s CRDs failed failed", "crdNames", crdNames) } - return strings.Split(output, "\n"), nil + // Trim the trailing newline before splitting so a trailing empty-string + // element never leaks into the result (see listK8sResourceKinds), and drop + // any warning lines - consistent with the other list helpers. + output = strings.TrimRight(output, "\n") + if output == "" { + return nil, nil + } + + return kubectlRemoveWarnings(strings.Split(output, "\n")), nil } // deleteK8sResourceOpts deletes K8s resources based on the kind and name or kind and selector. @@ -516,13 +524,9 @@ func listK8sResourceKinds(kubectlOptions k8s.KubectlOptions, apiGroupSelector st args = append(args, extraArgs...) - output, err := k8s.RunKubectlAndGetOutputContextE( - ginkgo.GinkgoT(), - context.Background(), - &kubectlOptions, - args..., - ) - + // Execute kubectl directly without terratest's logging: api-resources returns + // one line per resource kind (100+ lines), which otherwise floods the test output. + output, err := runKubectlSilent(kubectlOptions, args...) if err != nil { return nil, err } @@ -533,6 +537,12 @@ func listK8sResourceKinds(kubectlOptions k8s.KubectlOptions, apiGroupSelector st return nil, nil } + // Trim the trailing newline before splitting: runKubectlSilent preserves + // kubectl's trailing "\n" (unlike terratest's runner), which would otherwise + // yield an empty-string element and break callers that join the kinds for + // `kubectl get` (error: the server doesn't have a resource type ""). + output = strings.TrimRight(output, "\n") + return kubectlRemoveWarnings(strings.Split(output, "\n")), nil } @@ -746,20 +756,6 @@ func isKubectlNotFoundError(err error) bool { return err != nil && strings.Contains(err.Error(), kubectlNotFoundErrorMsg) } -// setupReducedLogging configures reduced logging for terratest operations -func setupReducedLogging() { - // Set environment variables to reduce terratest logging verbosity - if os.Getenv("E2E_VERBOSE_LOGGING") != verboseLoggingEnabled { - // Reduce terratest internal logging - os.Setenv("TEST_LOG_LEVEL", "-5") - // Reduce kubectl verbosity - os.Setenv("KUBECTL_VERBOSITY", "0") - // Additional environment variables to reduce terratest kubectl command logging - os.Setenv("TERRATEST_LOG_LEVEL", "INFO") - os.Setenv("KUBECTL_LOG_LEVEL", "0") - } -} - // waitForKafkaClusterWithPodStatusCheck waits for KafkaCluster to be ready and checks pod status every 10 seconds func waitForKafkaClusterWithPodStatusCheck(kubectlOptions k8s.KubectlOptions, clusterName string, timeout time.Duration) error { // Only log if verbose logging is enabled diff --git a/tests/e2e/koperator_suite_test.go b/tests/e2e/koperator_suite_test.go index 3e2c35c3a..dc270d42e 100644 --- a/tests/e2e/koperator_suite_test.go +++ b/tests/e2e/koperator_suite_test.go @@ -32,9 +32,6 @@ func TestKoperator(t *testing.T) { } var _ = ginkgo.BeforeSuite(func() { - // Setup reduced logging for terratest operations - setupReducedLogging() - ginkgo.By("Acquiring K8s cluster") var kubeconfigPath string var kubecontextName string diff --git a/tests/e2e/test_multidisk_removal.go b/tests/e2e/test_multidisk_removal.go index 110d58d8a..fa34a07a9 100644 --- a/tests/e2e/test_multidisk_removal.go +++ b/tests/e2e/test_multidisk_removal.go @@ -132,7 +132,11 @@ func getBrokerConfigMapLogDirs(kubectlOptions k8s.KubectlOptions, configMapName "-n", namespace, "-o", fmt.Sprintf("jsonpath={.data.%s}", kafkautils.ConfigPropertyName), } - output, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, args...) + // Fetch broker-config directly without terratest's logging: the ConfigMap holds the + // entire broker configuration (a multi-line properties blob) and this runs on every + // poll iteration for each broker, so logging the full value would flood the output. + // We only need log.dirs, which we parse out of the properties content below. + output, err := runKubectlSilent(kubectlOptions, args...) if err != nil { return nil, fmt.Errorf("getting configmap %s: %w", configMapName, err) } @@ -153,6 +157,8 @@ func getBrokerConfigMapLogDirs(kubectlOptions k8s.KubectlOptions, configMapName paths = append(paths, q) } } + // Log only the extracted log.dirs (not the whole broker config). + ginkgo.By(fmt.Sprintf("configmap %s log.dirs: %v", configMapName, paths)) return paths, nil } }