mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Change e2e test to use custom ports
This commit is contained in:
parent
8702550beb
commit
1afc25d575
@ -42,12 +42,17 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
samplev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1"
|
samplev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
var serverAggregatorVersion = utilversion.MustParseSemantic("v1.10.0")
|
var serverAggregatorVersion = utilversion.MustParseSemantic("v1.10.0")
|
||||||
|
|
||||||
|
const (
|
||||||
|
aggregatorServicePort = 7443
|
||||||
|
)
|
||||||
|
|
||||||
var _ = SIGDescribe("Aggregator", func() {
|
var _ = SIGDescribe("Aggregator", func() {
|
||||||
var ns string
|
var ns string
|
||||||
var c clientset.Interface
|
var c clientset.Interface
|
||||||
@ -266,7 +271,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
|
|||||||
Ports: []v1.ServicePort{
|
Ports: []v1.ServicePort{
|
||||||
{
|
{
|
||||||
Protocol: "TCP",
|
Protocol: "TCP",
|
||||||
Port: 443,
|
Port: aggregatorServicePort,
|
||||||
TargetPort: intstr.FromInt(443),
|
TargetPort: intstr.FromInt(443),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -317,6 +322,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
|
|||||||
Service: &apiregistrationv1beta1.ServiceReference{
|
Service: &apiregistrationv1beta1.ServiceReference{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: "sample-api",
|
Name: "sample-api",
|
||||||
|
Port: pointer.Int32Ptr(aggregatorServicePort),
|
||||||
},
|
},
|
||||||
Group: "wardle.k8s.io",
|
Group: "wardle.k8s.io",
|
||||||
Version: "v1alpha1",
|
Version: "v1alpha1",
|
||||||
|
@ -34,6 +34,7 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
"k8s.io/kubernetes/test/utils/crd"
|
"k8s.io/kubernetes/test/utils/crd"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -44,6 +45,7 @@ const (
|
|||||||
secretCRDName = "sample-custom-resource-conversion-webhook-secret"
|
secretCRDName = "sample-custom-resource-conversion-webhook-secret"
|
||||||
deploymentCRDName = "sample-crd-conversion-webhook-deployment"
|
deploymentCRDName = "sample-crd-conversion-webhook-deployment"
|
||||||
serviceCRDName = "e2e-test-crd-conversion-webhook"
|
serviceCRDName = "e2e-test-crd-conversion-webhook"
|
||||||
|
serviceCRDPort = 9443
|
||||||
roleBindingCRDName = "crd-conversion-webhook-auth-reader"
|
roleBindingCRDName = "crd-conversion-webhook-auth-reader"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -107,7 +109,8 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh
|
|||||||
Service: &v1beta1.ServiceReference{
|
Service: &v1beta1.ServiceReference{
|
||||||
Namespace: f.Namespace.Name,
|
Namespace: f.Namespace.Name,
|
||||||
Name: serviceCRDName,
|
Name: serviceCRDName,
|
||||||
Path: strPtr("/crdconvert"),
|
Path: pointer.StringPtr("/crdconvert"),
|
||||||
|
Port: pointer.Int32Ptr(serviceCRDPort),
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -123,7 +126,8 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh
|
|||||||
Service: &v1beta1.ServiceReference{
|
Service: &v1beta1.ServiceReference{
|
||||||
Namespace: f.Namespace.Name,
|
Namespace: f.Namespace.Name,
|
||||||
Name: serviceCRDName,
|
Name: serviceCRDName,
|
||||||
Path: strPtr("/crdconvert"),
|
Path: pointer.StringPtr("/crdconvert"),
|
||||||
|
Port: pointer.Int32Ptr(serviceCRDPort),
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -268,7 +272,7 @@ func deployCustomResourceWebhookAndService(f *framework.Framework, image string,
|
|||||||
Ports: []v1.ServicePort{
|
Ports: []v1.ServicePort{
|
||||||
{
|
{
|
||||||
Protocol: "TCP",
|
Protocol: "TCP",
|
||||||
Port: 443,
|
Port: serviceCRDPort,
|
||||||
TargetPort: intstr.FromInt(443),
|
TargetPort: intstr.FromInt(443),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -40,6 +40,7 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
"k8s.io/kubernetes/test/utils/crd"
|
"k8s.io/kubernetes/test/utils/crd"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -50,6 +51,7 @@ const (
|
|||||||
secretName = "sample-webhook-secret"
|
secretName = "sample-webhook-secret"
|
||||||
deploymentName = "sample-webhook-deployment"
|
deploymentName = "sample-webhook-deployment"
|
||||||
serviceName = "e2e-test-webhook"
|
serviceName = "e2e-test-webhook"
|
||||||
|
servicePort = 8443
|
||||||
roleBindingName = "webhook-auth-reader"
|
roleBindingName = "webhook-auth-reader"
|
||||||
|
|
||||||
// The webhook configuration names should not be reused between test instances.
|
// The webhook configuration names should not be reused between test instances.
|
||||||
@ -208,17 +210,17 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
|
|||||||
policyIgnore := v1beta1.Ignore
|
policyIgnore := v1beta1.Ignore
|
||||||
|
|
||||||
By("Setting timeout (1s) shorter than webhook latency (5s)")
|
By("Setting timeout (1s) shorter than webhook latency (5s)")
|
||||||
slowWebhookCleanup := registerSlowWebhook(f, context, &policyFail, int32Ptr(1))
|
slowWebhookCleanup := registerSlowWebhook(f, context, &policyFail, pointer.Int32Ptr(1))
|
||||||
testSlowWebhookTimeoutFailEarly(f)
|
testSlowWebhookTimeoutFailEarly(f)
|
||||||
slowWebhookCleanup()
|
slowWebhookCleanup()
|
||||||
|
|
||||||
By("Having no error when timeout is shorter than webhook latency and failure policy is ignore")
|
By("Having no error when timeout is shorter than webhook latency and failure policy is ignore")
|
||||||
slowWebhookCleanup = registerSlowWebhook(f, context, &policyIgnore, int32Ptr(1))
|
slowWebhookCleanup = registerSlowWebhook(f, context, &policyIgnore, pointer.Int32Ptr(1))
|
||||||
testSlowWebhookTimeoutNoError(f)
|
testSlowWebhookTimeoutNoError(f)
|
||||||
slowWebhookCleanup()
|
slowWebhookCleanup()
|
||||||
|
|
||||||
By("Having no error when timeout is longer than webhook latency")
|
By("Having no error when timeout is longer than webhook latency")
|
||||||
slowWebhookCleanup = registerSlowWebhook(f, context, &policyFail, int32Ptr(10))
|
slowWebhookCleanup = registerSlowWebhook(f, context, &policyFail, pointer.Int32Ptr(10))
|
||||||
testSlowWebhookTimeoutNoError(f)
|
testSlowWebhookTimeoutNoError(f)
|
||||||
slowWebhookCleanup()
|
slowWebhookCleanup()
|
||||||
|
|
||||||
@ -368,7 +370,7 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
|
|||||||
Ports: []v1.ServicePort{
|
Ports: []v1.ServicePort{
|
||||||
{
|
{
|
||||||
Protocol: "TCP",
|
Protocol: "TCP",
|
||||||
Port: 443,
|
Port: servicePort,
|
||||||
TargetPort: intstr.FromInt(443),
|
TargetPort: intstr.FromInt(443),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -384,8 +386,6 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
|
|||||||
|
|
||||||
func strPtr(s string) *string { return &s }
|
func strPtr(s string) *string { return &s }
|
||||||
|
|
||||||
func int32Ptr(i int32) *int32 { return &i }
|
|
||||||
|
|
||||||
func registerWebhook(f *framework.Framework, context *certContext) func() {
|
func registerWebhook(f *framework.Framework, context *certContext) func() {
|
||||||
client := f.ClientSet
|
client := f.ClientSet
|
||||||
By("Registering the webhook via the AdmissionRegistration API")
|
By("Registering the webhook via the AdmissionRegistration API")
|
||||||
@ -417,6 +417,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/pods"),
|
Path: strPtr("/pods"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -446,6 +447,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/configmaps"),
|
Path: strPtr("/configmaps"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -496,6 +498,7 @@ func registerWebhookForAttachingPod(f *framework.Framework, context *certContext
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/pods/attach"),
|
Path: strPtr("/pods/attach"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -539,6 +542,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/mutating-configmaps"),
|
Path: strPtr("/mutating-configmaps"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -558,6 +562,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/mutating-configmaps"),
|
Path: strPtr("/mutating-configmaps"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -614,6 +619,7 @@ func registerMutatingWebhookForPod(f *framework.Framework, context *certContext)
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/mutating-pods"),
|
Path: strPtr("/mutating-pods"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -786,6 +792,7 @@ func failingWebhook(namespace, name string) v1beta1.Webhook {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/configmaps"),
|
Path: strPtr("/configmaps"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
// Without CA bundle, the call to webhook always fails
|
// Without CA bundle, the call to webhook always fails
|
||||||
CABundle: nil,
|
CABundle: nil,
|
||||||
@ -892,6 +899,7 @@ func registerValidatingWebhookForWebhookConfigurations(f *framework.Framework, c
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/always-deny"),
|
Path: strPtr("/always-deny"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -944,6 +952,7 @@ func registerMutatingWebhookForWebhookConfigurations(f *framework.Framework, con
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/add-label"),
|
Path: strPtr("/add-label"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -997,6 +1006,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) {
|
|||||||
// but because the failure policy is ignore, it will
|
// but because the failure policy is ignore, it will
|
||||||
// have no effect on admission requests.
|
// have no effect on admission requests.
|
||||||
Path: strPtr(""),
|
Path: strPtr(""),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: nil,
|
CABundle: nil,
|
||||||
},
|
},
|
||||||
@ -1044,6 +1054,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) {
|
|||||||
// but because the failure policy is ignore, it will
|
// but because the failure policy is ignore, it will
|
||||||
// have no effect on admission requests.
|
// have no effect on admission requests.
|
||||||
Path: strPtr(""),
|
Path: strPtr(""),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: nil,
|
CABundle: nil,
|
||||||
},
|
},
|
||||||
@ -1213,6 +1224,7 @@ func registerWebhookForCustomResource(f *framework.Framework, context *certConte
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/custom-resource"),
|
Path: strPtr("/custom-resource"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -1254,6 +1266,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/mutating-custom-resource"),
|
Path: strPtr("/mutating-custom-resource"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -1273,6 +1286,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/mutating-custom-resource"),
|
Path: strPtr("/mutating-custom-resource"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -1401,6 +1415,7 @@ func registerValidatingWebhookForCRD(f *framework.Framework, context *certContex
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/crd"),
|
Path: strPtr("/crd"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
@ -1512,6 +1527,7 @@ func registerSlowWebhook(f *framework.Framework, context *certContext, policy *v
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Path: strPtr("/always-allow-delay-5s"),
|
Path: strPtr("/always-allow-delay-5s"),
|
||||||
|
Port: pointer.Int32Ptr(servicePort),
|
||||||
},
|
},
|
||||||
CABundle: context.signingCert,
|
CABundle: context.signingCert,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user