Remove dependency of https://grpcb.in
This commit is contained in:
parent
acd5b4c852
commit
b4dba519fc
5 changed files with 121 additions and 10 deletions
|
@ -39,9 +39,11 @@ import (
|
||||||
var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() {
|
var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() {
|
||||||
f := framework.NewDefaultFramework("grpc")
|
f := framework.NewDefaultFramework("grpc")
|
||||||
|
|
||||||
It("should use grpc_pass in the configuration file", func() {
|
BeforeEach(func() {
|
||||||
f.NewGRPCFortuneTellerDeployment()
|
f.NewGRPCFortuneTellerDeployment()
|
||||||
|
})
|
||||||
|
|
||||||
|
It("should use grpc_pass in the configuration file", func() {
|
||||||
host := "grpc"
|
host := "grpc"
|
||||||
|
|
||||||
annotations := map[string]string{
|
annotations := map[string]string{
|
||||||
|
@ -65,15 +67,19 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should return OK for service with backend protocol GRPC", func() {
|
It("should return OK for service with backend protocol GRPC", func() {
|
||||||
|
Skip("GRPC test temporarily disabled")
|
||||||
|
|
||||||
|
f.NewGRPCBinDeployment()
|
||||||
|
|
||||||
host := "echo"
|
host := "echo"
|
||||||
|
|
||||||
svc := &core.Service{
|
svc := &core.Service{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "grpcbin",
|
Name: "grpcbin-test",
|
||||||
Namespace: f.Namespace,
|
Namespace: f.Namespace,
|
||||||
},
|
},
|
||||||
Spec: corev1.ServiceSpec{
|
Spec: corev1.ServiceSpec{
|
||||||
ExternalName: "grpcb.in",
|
ExternalName: fmt.Sprintf("grpcbin.%v.svc.cluster.local", f.Namespace),
|
||||||
Type: corev1.ServiceTypeExternalName,
|
Type: corev1.ServiceTypeExternalName,
|
||||||
Ports: []corev1.ServicePort{
|
Ports: []corev1.ServicePort{
|
||||||
{
|
{
|
||||||
|
@ -91,7 +97,7 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() {
|
||||||
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
|
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
|
||||||
}
|
}
|
||||||
|
|
||||||
ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin", 9000, annotations)
|
ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin-test", 9000, annotations)
|
||||||
|
|
||||||
f.EnsureIngress(ing)
|
f.EnsureIngress(ing)
|
||||||
|
|
||||||
|
@ -121,15 +127,19 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should return OK for service with backend protocol GRPCS", func() {
|
It("should return OK for service with backend protocol GRPCS", func() {
|
||||||
|
Skip("GRPC test temporarily disabled")
|
||||||
|
|
||||||
|
f.NewGRPCBinDeployment()
|
||||||
|
|
||||||
host := "echo"
|
host := "echo"
|
||||||
|
|
||||||
svc := &core.Service{
|
svc := &core.Service{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "grpcbin",
|
Name: "grpcbin-test",
|
||||||
Namespace: f.Namespace,
|
Namespace: f.Namespace,
|
||||||
},
|
},
|
||||||
Spec: corev1.ServiceSpec{
|
Spec: corev1.ServiceSpec{
|
||||||
ExternalName: "grpcb.in",
|
ExternalName: fmt.Sprintf("grpcbin.%v.svc.cluster.local", f.Namespace),
|
||||||
Type: corev1.ServiceTypeExternalName,
|
Type: corev1.ServiceTypeExternalName,
|
||||||
Ports: []corev1.ServicePort{
|
Ports: []corev1.ServicePort{
|
||||||
{
|
{
|
||||||
|
@ -153,7 +163,7 @@ var _ = framework.IngressNginxDescribe("Annotations - GRPC", func() {
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin", 9001, annotations)
|
ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, "grpcbin-test", 9001, annotations)
|
||||||
f.EnsureIngress(ing)
|
f.EnsureIngress(ing)
|
||||||
|
|
||||||
f.WaitForNginxServer(host,
|
f.WaitForNginxServer(host,
|
||||||
|
|
|
@ -174,6 +174,102 @@ server {
|
||||||
Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready")
|
Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewGRPCBinDeployment creates a new deployment of the
|
||||||
|
// moul/grpcbin image for GRPC tests
|
||||||
|
func (f *Framework) NewGRPCBinDeployment() {
|
||||||
|
name := "grpcbin"
|
||||||
|
|
||||||
|
probe := &corev1.Probe{
|
||||||
|
InitialDelaySeconds: 5,
|
||||||
|
PeriodSeconds: 10,
|
||||||
|
SuccessThreshold: 2,
|
||||||
|
TimeoutSeconds: 1,
|
||||||
|
Handler: corev1.Handler{
|
||||||
|
TCPSocket: &corev1.TCPSocketAction{
|
||||||
|
Port: intstr.FromInt(9000),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
deployment := &appsv1.Deployment{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: f.Namespace,
|
||||||
|
},
|
||||||
|
Spec: appsv1.DeploymentSpec{
|
||||||
|
Replicas: NewInt32(1),
|
||||||
|
Selector: &metav1.LabelSelector{
|
||||||
|
MatchLabels: map[string]string{
|
||||||
|
"app": name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Template: corev1.PodTemplateSpec{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"app": name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Spec: corev1.PodSpec{
|
||||||
|
TerminationGracePeriodSeconds: NewInt64(0),
|
||||||
|
Containers: []corev1.Container{
|
||||||
|
{
|
||||||
|
Name: name,
|
||||||
|
Image: "moul/grpcbin",
|
||||||
|
Ports: []corev1.ContainerPort{
|
||||||
|
{
|
||||||
|
Name: "insecure",
|
||||||
|
ContainerPort: 9000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "secure",
|
||||||
|
ContainerPort: 9001,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ReadinessProbe: probe,
|
||||||
|
LivenessProbe: probe,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
d := f.EnsureDeployment(deployment)
|
||||||
|
Expect(d).NotTo(BeNil(), "expected a deployment but none returned")
|
||||||
|
|
||||||
|
service := &corev1.Service{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Namespace: f.Namespace,
|
||||||
|
},
|
||||||
|
Spec: corev1.ServiceSpec{
|
||||||
|
Ports: []corev1.ServicePort{
|
||||||
|
{
|
||||||
|
Name: "insecure",
|
||||||
|
Port: 9000,
|
||||||
|
TargetPort: intstr.FromInt(9000),
|
||||||
|
Protocol: corev1.ProtocolTCP,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "secure",
|
||||||
|
Port: 9001,
|
||||||
|
TargetPort: intstr.FromInt(9000),
|
||||||
|
Protocol: corev1.ProtocolTCP,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Selector: map[string]string{
|
||||||
|
"app": name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s := f.EnsureService(service)
|
||||||
|
Expect(s).NotTo(BeNil(), "expected a service but none returned")
|
||||||
|
|
||||||
|
err := WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, 1)
|
||||||
|
Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready")
|
||||||
|
}
|
||||||
|
|
||||||
func newDeployment(name, namespace, image string, port int32, replicas int32, command []string,
|
func newDeployment(name, namespace, image string, port int32, replicas int32, command []string,
|
||||||
volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment {
|
volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment {
|
||||||
probe := &corev1.Probe{
|
probe := &corev1.Probe{
|
||||||
|
|
|
@ -104,7 +104,7 @@ func (f *Framework) BeforeEach() {
|
||||||
// AfterEach deletes the namespace, after reading its events.
|
// AfterEach deletes the namespace, after reading its events.
|
||||||
func (f *Framework) AfterEach() {
|
func (f *Framework) AfterEach() {
|
||||||
err := DeleteKubeNamespace(f.KubeClientSet, f.Namespace)
|
err := DeleteKubeNamespace(f.KubeClientSet, f.Namespace)
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "unexpected error deleting namespace %v", f.Namespace)
|
||||||
|
|
||||||
if ginkgo.CurrentGinkgoTestDescription().Failed {
|
if ginkgo.CurrentGinkgoTestDescription().Failed {
|
||||||
log, err := f.NginxLogs()
|
log, err := f.NginxLogs()
|
||||||
|
|
|
@ -117,7 +117,12 @@ func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error
|
||||||
|
|
||||||
// DeleteKubeNamespace deletes a namespace and all the objects inside
|
// DeleteKubeNamespace deletes a namespace and all the objects inside
|
||||||
func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error {
|
func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error {
|
||||||
return c.CoreV1().Namespaces().Delete(namespace, metav1.NewDeleteOptions(0))
|
grace := int64(0)
|
||||||
|
pb := metav1.DeletePropagationBackground
|
||||||
|
return c.CoreV1().Namespaces().Delete(namespace, &metav1.DeleteOptions{
|
||||||
|
GracePeriodSeconds: &grace,
|
||||||
|
PropagationPolicy: &pb,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpectNoError tests whether an error occurred.
|
// ExpectNoError tests whether an error occurred.
|
||||||
|
|
|
@ -115,7 +115,7 @@ var _ = framework.IngressNginxDescribe("Shutdown ingress controller", func() {
|
||||||
case res := <-result:
|
case res := <-result:
|
||||||
Expect(res.errs).Should(BeEmpty())
|
Expect(res.errs).Should(BeEmpty())
|
||||||
Expect(res.status).To(Equal(http.StatusOK), "expecting a valid response from HTTP request")
|
Expect(res.status).To(Equal(http.StatusOK), "expecting a valid response from HTTP request")
|
||||||
Expect(time.Since(startTime).Seconds()).To(BeNumerically(">", 70), "waiting shutdown")
|
Expect(time.Since(startTime).Seconds()).To(BeNumerically(">", 60), "waiting shutdown")
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
Loading…
Reference in a new issue