Remove dependency of https://grpcb.in
This commit is contained in:
parent
acd5b4c852
commit
b4dba519fc
5 changed files with 121 additions and 10 deletions
|
|
@ -174,6 +174,102 @@ server {
|
|||
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,
|
||||
volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment {
|
||||
probe := &corev1.Probe{
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ func (f *Framework) BeforeEach() {
|
|||
// AfterEach deletes the namespace, after reading its events.
|
||||
func (f *Framework) AfterEach() {
|
||||
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 {
|
||||
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
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue