Skip to content

Commit 1afc25d

Browse files
committed
Change e2e test to use custom ports
1 parent 8702550 commit 1afc25d

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

test/e2e/apimachinery/aggregator.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,17 @@ import (
4242
"k8s.io/kubernetes/test/e2e/framework"
4343
imageutils "k8s.io/kubernetes/test/utils/image"
4444
samplev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1"
45+
"k8s.io/utils/pointer"
4546

4647
. "github.com/onsi/ginkgo"
4748
)
4849

4950
var serverAggregatorVersion = utilversion.MustParseSemantic("v1.10.0")
5051

52+
const (
53+
aggregatorServicePort = 7443
54+
)
55+
5156
var _ = SIGDescribe("Aggregator", func() {
5257
var ns string
5358
var c clientset.Interface
@@ -266,7 +271,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
266271
Ports: []v1.ServicePort{
267272
{
268273
Protocol: "TCP",
269-
Port: 443,
274+
Port: aggregatorServicePort,
270275
TargetPort: intstr.FromInt(443),
271276
},
272277
},
@@ -317,6 +322,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
317322
Service: &apiregistrationv1beta1.ServiceReference{
318323
Namespace: namespace,
319324
Name: "sample-api",
325+
Port: pointer.Int32Ptr(aggregatorServicePort),
320326
},
321327
Group: "wardle.k8s.io",
322328
Version: "v1alpha1",

test/e2e/apimachinery/crd_conversion_webhook.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"k8s.io/kubernetes/test/e2e/framework"
3535
"k8s.io/kubernetes/test/utils/crd"
3636
imageutils "k8s.io/kubernetes/test/utils/image"
37+
"k8s.io/utils/pointer"
3738

3839
. "github.com/onsi/ginkgo"
3940
. "github.com/onsi/gomega"
@@ -44,6 +45,7 @@ const (
4445
secretCRDName = "sample-custom-resource-conversion-webhook-secret"
4546
deploymentCRDName = "sample-crd-conversion-webhook-deployment"
4647
serviceCRDName = "e2e-test-crd-conversion-webhook"
48+
serviceCRDPort = 9443
4749
roleBindingCRDName = "crd-conversion-webhook-auth-reader"
4850
)
4951

@@ -107,7 +109,8 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh
107109
Service: &v1beta1.ServiceReference{
108110
Namespace: f.Namespace.Name,
109111
Name: serviceCRDName,
110-
Path: strPtr("/crdconvert"),
112+
Path: pointer.StringPtr("/crdconvert"),
113+
Port: pointer.Int32Ptr(serviceCRDPort),
111114
}})
112115
if err != nil {
113116
return
@@ -123,7 +126,8 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh
123126
Service: &v1beta1.ServiceReference{
124127
Namespace: f.Namespace.Name,
125128
Name: serviceCRDName,
126-
Path: strPtr("/crdconvert"),
129+
Path: pointer.StringPtr("/crdconvert"),
130+
Port: pointer.Int32Ptr(serviceCRDPort),
127131
}})
128132
if err != nil {
129133
return
@@ -268,7 +272,7 @@ func deployCustomResourceWebhookAndService(f *framework.Framework, image string,
268272
Ports: []v1.ServicePort{
269273
{
270274
Protocol: "TCP",
271-
Port: 443,
275+
Port: serviceCRDPort,
272276
TargetPort: intstr.FromInt(443),
273277
},
274278
},

test/e2e/apimachinery/webhook.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"k8s.io/kubernetes/test/e2e/framework"
4141
"k8s.io/kubernetes/test/utils/crd"
4242
imageutils "k8s.io/kubernetes/test/utils/image"
43+
"k8s.io/utils/pointer"
4344

4445
. "github.com/onsi/ginkgo"
4546
. "github.com/onsi/gomega"
@@ -50,6 +51,7 @@ const (
5051
secretName = "sample-webhook-secret"
5152
deploymentName = "sample-webhook-deployment"
5253
serviceName = "e2e-test-webhook"
54+
servicePort = 8443
5355
roleBindingName = "webhook-auth-reader"
5456

5557
// The webhook configuration names should not be reused between test instances.
@@ -208,17 +210,17 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
208210
policyIgnore := v1beta1.Ignore
209211

210212
By("Setting timeout (1s) shorter than webhook latency (5s)")
211-
slowWebhookCleanup := registerSlowWebhook(f, context, &policyFail, int32Ptr(1))
213+
slowWebhookCleanup := registerSlowWebhook(f, context, &policyFail, pointer.Int32Ptr(1))
212214
testSlowWebhookTimeoutFailEarly(f)
213215
slowWebhookCleanup()
214216

215217
By("Having no error when timeout is shorter than webhook latency and failure policy is ignore")
216-
slowWebhookCleanup = registerSlowWebhook(f, context, &policyIgnore, int32Ptr(1))
218+
slowWebhookCleanup = registerSlowWebhook(f, context, &policyIgnore, pointer.Int32Ptr(1))
217219
testSlowWebhookTimeoutNoError(f)
218220
slowWebhookCleanup()
219221

220222
By("Having no error when timeout is longer than webhook latency")
221-
slowWebhookCleanup = registerSlowWebhook(f, context, &policyFail, int32Ptr(10))
223+
slowWebhookCleanup = registerSlowWebhook(f, context, &policyFail, pointer.Int32Ptr(10))
222224
testSlowWebhookTimeoutNoError(f)
223225
slowWebhookCleanup()
224226

@@ -368,7 +370,7 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
368370
Ports: []v1.ServicePort{
369371
{
370372
Protocol: "TCP",
371-
Port: 443,
373+
Port: servicePort,
372374
TargetPort: intstr.FromInt(443),
373375
},
374376
},
@@ -384,8 +386,6 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
384386

385387
func strPtr(s string) *string { return &s }
386388

387-
func int32Ptr(i int32) *int32 { return &i }
388-
389389
func registerWebhook(f *framework.Framework, context *certContext) func() {
390390
client := f.ClientSet
391391
By("Registering the webhook via the AdmissionRegistration API")
@@ -417,6 +417,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() {
417417
Namespace: namespace,
418418
Name: serviceName,
419419
Path: strPtr("/pods"),
420+
Port: pointer.Int32Ptr(servicePort),
420421
},
421422
CABundle: context.signingCert,
422423
},
@@ -446,6 +447,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() {
446447
Namespace: namespace,
447448
Name: serviceName,
448449
Path: strPtr("/configmaps"),
450+
Port: pointer.Int32Ptr(servicePort),
449451
},
450452
CABundle: context.signingCert,
451453
},
@@ -496,6 +498,7 @@ func registerWebhookForAttachingPod(f *framework.Framework, context *certContext
496498
Namespace: namespace,
497499
Name: serviceName,
498500
Path: strPtr("/pods/attach"),
501+
Port: pointer.Int32Ptr(servicePort),
499502
},
500503
CABundle: context.signingCert,
501504
},
@@ -539,6 +542,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo
539542
Namespace: namespace,
540543
Name: serviceName,
541544
Path: strPtr("/mutating-configmaps"),
545+
Port: pointer.Int32Ptr(servicePort),
542546
},
543547
CABundle: context.signingCert,
544548
},
@@ -558,6 +562,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo
558562
Namespace: namespace,
559563
Name: serviceName,
560564
Path: strPtr("/mutating-configmaps"),
565+
Port: pointer.Int32Ptr(servicePort),
561566
},
562567
CABundle: context.signingCert,
563568
},
@@ -614,6 +619,7 @@ func registerMutatingWebhookForPod(f *framework.Framework, context *certContext)
614619
Namespace: namespace,
615620
Name: serviceName,
616621
Path: strPtr("/mutating-pods"),
622+
Port: pointer.Int32Ptr(servicePort),
617623
},
618624
CABundle: context.signingCert,
619625
},
@@ -786,6 +792,7 @@ func failingWebhook(namespace, name string) v1beta1.Webhook {
786792
Namespace: namespace,
787793
Name: serviceName,
788794
Path: strPtr("/configmaps"),
795+
Port: pointer.Int32Ptr(servicePort),
789796
},
790797
// Without CA bundle, the call to webhook always fails
791798
CABundle: nil,
@@ -892,6 +899,7 @@ func registerValidatingWebhookForWebhookConfigurations(f *framework.Framework, c
892899
Namespace: namespace,
893900
Name: serviceName,
894901
Path: strPtr("/always-deny"),
902+
Port: pointer.Int32Ptr(servicePort),
895903
},
896904
CABundle: context.signingCert,
897905
},
@@ -944,6 +952,7 @@ func registerMutatingWebhookForWebhookConfigurations(f *framework.Framework, con
944952
Namespace: namespace,
945953
Name: serviceName,
946954
Path: strPtr("/add-label"),
955+
Port: pointer.Int32Ptr(servicePort),
947956
},
948957
CABundle: context.signingCert,
949958
},
@@ -997,6 +1006,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) {
9971006
// but because the failure policy is ignore, it will
9981007
// have no effect on admission requests.
9991008
Path: strPtr(""),
1009+
Port: pointer.Int32Ptr(servicePort),
10001010
},
10011011
CABundle: nil,
10021012
},
@@ -1044,6 +1054,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) {
10441054
// but because the failure policy is ignore, it will
10451055
// have no effect on admission requests.
10461056
Path: strPtr(""),
1057+
Port: pointer.Int32Ptr(servicePort),
10471058
},
10481059
CABundle: nil,
10491060
},
@@ -1213,6 +1224,7 @@ func registerWebhookForCustomResource(f *framework.Framework, context *certConte
12131224
Namespace: namespace,
12141225
Name: serviceName,
12151226
Path: strPtr("/custom-resource"),
1227+
Port: pointer.Int32Ptr(servicePort),
12161228
},
12171229
CABundle: context.signingCert,
12181230
},
@@ -1254,6 +1266,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
12541266
Namespace: namespace,
12551267
Name: serviceName,
12561268
Path: strPtr("/mutating-custom-resource"),
1269+
Port: pointer.Int32Ptr(servicePort),
12571270
},
12581271
CABundle: context.signingCert,
12591272
},
@@ -1273,6 +1286,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
12731286
Namespace: namespace,
12741287
Name: serviceName,
12751288
Path: strPtr("/mutating-custom-resource"),
1289+
Port: pointer.Int32Ptr(servicePort),
12761290
},
12771291
CABundle: context.signingCert,
12781292
},
@@ -1401,6 +1415,7 @@ func registerValidatingWebhookForCRD(f *framework.Framework, context *certContex
14011415
Namespace: namespace,
14021416
Name: serviceName,
14031417
Path: strPtr("/crd"),
1418+
Port: pointer.Int32Ptr(servicePort),
14041419
},
14051420
CABundle: context.signingCert,
14061421
},
@@ -1512,6 +1527,7 @@ func registerSlowWebhook(f *framework.Framework, context *certContext, policy *v
15121527
Namespace: namespace,
15131528
Name: serviceName,
15141529
Path: strPtr("/always-allow-delay-5s"),
1530+
Port: pointer.Int32Ptr(servicePort),
15151531
},
15161532
CABundle: context.signingCert,
15171533
},

0 commit comments

Comments
 (0)