Skip to content

Commit

Permalink
Merge pull request kubernetes#1307 from pacevedom/readiness-aggregator
Browse files Browse the repository at this point in the history
UPSTREAM: 110039: Add readinessProbe to aggregated api service test
  • Loading branch information
openshift-merge-robot authored Aug 25, 2022
2 parents d6a97e1 + fbaac39 commit c83b5d0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions test/e2e/apimachinery/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ func cleanTest(client clientset.Interface, aggrclient *aggregatorclient.Clientse
// delete the APIService first to avoid causing discovery errors
_ = aggrclient.ApiregistrationV1().APIServices().Delete(context.TODO(), "v1alpha1.wardle.example.com", metav1.DeleteOptions{})

// this simple sleep makes sure that the sample api server was unregistered from all Kube APIs before tearing down the deployment (otherwise it could make the test to fail)
// a more expensive way of doing it would be checking if the sample server was unregistered from all deployed Kube API servers before tearing down the deployment.
framework.Logf("sleeping 45 seconds before deleting the sample-apiserver deployment, see %q for more", "https://bugzilla.redhat.com/show_bug.cgi?id=1933144")
time.Sleep(time.Second * 45)

_ = client.AppsV1().Deployments(namespace).Delete(context.TODO(), "sample-apiserver-deployment", metav1.DeleteOptions{})
_ = client.CoreV1().Secrets(namespace).Delete(context.TODO(), "sample-apiserver-secret", metav1.DeleteOptions{})
_ = client.CoreV1().Services(namespace).Delete(context.TODO(), "sample-api", metav1.DeleteOptions{})
Expand Down Expand Up @@ -150,7 +145,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
},
}
_, err := client.CoreV1().Secrets(namespace).Create(context.TODO(), secret, metav1.CreateOptions{})
framework.ExpectNoError(err, "creating secret %q in namespace %q", secretName, namespace)
framework.ExpectNoError(err, "creating secret %s in namespace %s", secretName, namespace)

// kubectl create -f clusterrole.yaml
_, err = client.RbacV1().ClusterRoles().Create(context.TODO(), &rbacv1.ClusterRole{
Expand Down Expand Up @@ -243,6 +238,19 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
"--audit-log-maxbackup=0",
},
Image: image,
ReadinessProbe: &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Scheme: v1.URISchemeHTTPS,
Port: intstr.FromInt(443),
Path: "/readyz",
},
},
InitialDelaySeconds: 20,
PeriodSeconds: 1,
SuccessThreshold: 1,
FailureThreshold: 3,
},
},
{
Name: "etcd",
Expand Down Expand Up @@ -289,7 +297,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
},
}
_, err = client.CoreV1().Services(namespace).Create(context.TODO(), service, metav1.CreateOptions{})
framework.ExpectNoError(err, "creating service %s in namespace %s", "sample-apiserver", namespace)
framework.ExpectNoError(err, "creating service %s in namespace %s", "sample-api", namespace)

// kubectl create -f serviceAccount.yaml
sa := &v1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: "sample-apiserver"}}
Expand Down Expand Up @@ -317,7 +325,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
},
},
}, metav1.CreateOptions{})
framework.ExpectNoError(err, "creating role binding %s:sample-apiserver to access configMap", namespace)
framework.ExpectNoError(err, "creating role binding %s in namespace %s", "wardler-auth-reader", "kube-system")

// Wait for the extension apiserver to be up and healthy
// kubectl get deployments -n <aggregated-api-namespace> && status == Running
Expand All @@ -342,7 +350,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
VersionPriority: 200,
},
}, metav1.CreateOptions{})
framework.ExpectNoError(err, "creating apiservice %s with namespace %s", "v1alpha1.wardle.example.com", namespace)
framework.ExpectNoError(err, "creating apiservice %s", "v1alpha1.wardle.example.com")

var (
currentAPIService *apiregistrationv1.APIService
Expand Down

0 comments on commit c83b5d0

Please sign in to comment.