Skip to content

Commit

Permalink
Run e2e tests with a webhook on a random port
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpiritXIII committed Oct 2, 2023
1 parent f80044d commit 078c4ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion e2e/operator_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"

"github.com/GoogleCloudPlatform/prometheus-engine/pkg/operator"
clientset "github.com/GoogleCloudPlatform/prometheus-engine/pkg/operator/generated/clientset/versioned"
Expand Down Expand Up @@ -75,6 +76,9 @@ var (

func init() {
ctrl.SetLogger(globalLogger)

// Allow tests to run on random webhook ports to allow parallelism.
webhook.DefaultPort = 0
}

func newClient() (client.Client, error) {
Expand Down Expand Up @@ -196,7 +200,8 @@ func newOperatorContext(t *testing.T) *OperatorContext {
Location: location,
OperatorNamespace: tctx.namespace,
PublicNamespace: tctx.pubNamespace,
ListenAddr: ":10250",
// Pick a random available port.
ListenAddr: ":0",
})
if err != nil {
t.Fatalf("instantiating operator: %s", err)
Expand Down

0 comments on commit 078c4ab

Please sign in to comment.