From c93dd3cbb189fae0904d727c86550cdde18d3dff Mon Sep 17 00:00:00 2001 From: Andreas Fritzler Date: Wed, 30 Oct 2024 13:57:06 +0100 Subject: [PATCH] Fix default webhook port in test suite --- api/v1alpha1/webhook_suite_test.go | 12 ++++++------ internal/controller/suite_test.go | 15 ++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/api/v1alpha1/webhook_suite_test.go b/api/v1alpha1/webhook_suite_test.go index b73856a..4449ccf 100644 --- a/api/v1alpha1/webhook_suite_test.go +++ b/api/v1alpha1/webhook_suite_test.go @@ -13,14 +13,11 @@ import ( "testing" "time" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - admissionv1 "k8s.io/api/admission/v1" - //+kubebuilder:scaffold:imports + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apimachineryruntime "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" @@ -31,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" + //+kubebuilder:scaffold:imports ) const ( @@ -110,7 +108,9 @@ var _ = BeforeSuite(func() { CertDir: webhookInstallOptions.LocalServingCertDir, }), LeaderElection: false, - Metrics: metricsserver.Options{BindAddress: ":8081"}, + Metrics: metricsserver.Options{ + BindAddress: "0", + }, }) Expect(err).NotTo(HaveOccurred()) diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index d21bbbe..76e36e9 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -11,26 +11,24 @@ import ( "testing" "time" - "k8s.io/utils/ptr" - "sigs.k8s.io/controller-runtime/pkg/config" - - "github.com/ironcore-dev/metal-operator/internal/registry" - + metalv1alpha1 "github.com/ironcore-dev/metal-operator/api/v1alpha1" "github.com/ironcore-dev/metal-operator/internal/api/macdb" + "github.com/ironcore-dev/metal-operator/internal/registry" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/config" "sigs.k8s.io/controller-runtime/pkg/envtest" . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - - metalv1alpha1 "github.com/ironcore-dev/metal-operator/api/v1alpha1" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" //+kubebuilder:scaffold:imports ) @@ -130,6 +128,9 @@ func SetupTest() *corev1.Namespace { // since all tests need a dedicated controller SkipNameValidation: ptr.To(true), }, + Metrics: metricsserver.Options{ + BindAddress: "0", + }, }) Expect(err).ToNot(HaveOccurred())