e2e: use Ginkgo context
All code must use the context from Ginkgo when doing API calls or polling for a change, otherwise the code would not return immediately when the test gets aborted.
This commit is contained in:
@@ -51,17 +51,17 @@ var _ = SIGDescribe("[Feature:Example]", func() {
|
||||
|
||||
var c clientset.Interface
|
||||
var ns string
|
||||
ginkgo.BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||
c = f.ClientSet
|
||||
ns = f.Namespace.Name
|
||||
|
||||
// this test wants powerful permissions. Since the namespace names are unique, we can leave this
|
||||
// lying around so we don't have to race any caches
|
||||
err := e2eauth.BindClusterRoleInNamespace(c.RbacV1(), "edit", f.Namespace.Name,
|
||||
err := e2eauth.BindClusterRoleInNamespace(ctx, c.RbacV1(), "edit", f.Namespace.Name,
|
||||
rbacv1.Subject{Kind: rbacv1.ServiceAccountKind, Namespace: f.Namespace.Name, Name: "default"})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
err = e2eauth.WaitForAuthorizationUpdate(c.AuthorizationV1(),
|
||||
err = e2eauth.WaitForAuthorizationUpdate(ctx, c.AuthorizationV1(),
|
||||
serviceaccount.MakeUsername(f.Namespace.Name, "default"),
|
||||
f.Namespace.Name, "create", schema.GroupResource{Resource: "pods"}, true)
|
||||
framework.ExpectNoError(err)
|
||||
@@ -80,10 +80,10 @@ var _ = SIGDescribe("[Feature:Example]", func() {
|
||||
var wg sync.WaitGroup
|
||||
passed := true
|
||||
checkRestart := func(podName string, timeout time.Duration) {
|
||||
err := e2epod.WaitForPodNameRunningInNamespace(c, podName, ns)
|
||||
err := e2epod.WaitForPodNameRunningInNamespace(ctx, c, podName, ns)
|
||||
framework.ExpectNoError(err)
|
||||
for t := time.Now(); time.Since(t) < timeout; time.Sleep(framework.Poll) {
|
||||
pod, err := c.CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{})
|
||||
pod, err := c.CoreV1().Pods(ns).Get(ctx, podName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, fmt.Sprintf("getting pod %s", podName))
|
||||
stat := podutil.GetExistingContainerStatus(pod.Status.ContainerStatuses, podName)
|
||||
framework.Logf("Pod: %s, restart count:%d", stat.Name, stat.RestartCount)
|
||||
@@ -125,7 +125,7 @@ var _ = SIGDescribe("[Feature:Example]", func() {
|
||||
ginkgo.By("creating secret and pod")
|
||||
e2ekubectl.RunKubectlOrDieInput(ns, secretYaml, "create", "-f", "-")
|
||||
e2ekubectl.RunKubectlOrDieInput(ns, podYaml, "create", "-f", "-")
|
||||
err := e2epod.WaitForPodNoLongerRunningInNamespace(c, podName, ns)
|
||||
err := e2epod.WaitForPodNoLongerRunningInNamespace(ctx, c, podName, ns)
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("checking if secret was read correctly")
|
||||
@@ -142,7 +142,7 @@ var _ = SIGDescribe("[Feature:Example]", func() {
|
||||
|
||||
ginkgo.By("creating the pod")
|
||||
e2ekubectl.RunKubectlOrDieInput(ns, podYaml, "create", "-f", "-")
|
||||
err := e2epod.WaitForPodNoLongerRunningInNamespace(c, podName, ns)
|
||||
err := e2epod.WaitForPodNoLongerRunningInNamespace(ctx, c, podName, ns)
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("checking if name and namespace were passed correctly")
|
||||
|
Reference in New Issue
Block a user