Skip to content

Commit

Permalink
Organize into its own context
Browse files Browse the repository at this point in the history
Signed-off-by: Laura Lorenz <[email protected]>
  • Loading branch information
lauralorenz committed Nov 11, 2024
1 parent f913b7a commit 6337a28
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/e2e_node/criproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ var _ = SIGDescribe(feature.CriProxy, framework.WithSerial(), func() {
isExpectedErrMsg := strings.Contains(eventMsg, expectedErr.Error())
gomega.Expect(isExpectedErrMsg).To(gomega.BeTrueBecause("we injected an exception into the PullImage interface of the cri proxy"))
})
})

ginkgo.Context("Inject a pull image error exception, then reset it, into the CriProxy", func() {
ginkgo.BeforeEach(func() {
if err := resetCRIProxyInjector(); err != nil {
ginkgo.Skip("Skip the test since the CRI Proxy is undefined.")
}
})

ginkgo.AfterEach(func() {
err := resetCRIProxyInjector()
framework.ExpectNoError(err)
})

ginkgo.It("Image pull retry backs off on error.", func(ctx context.Context) {
expectedErr := fmt.Errorf("PullImage failed")
err := addCRIProxyInjector(func(apiName string) error {
Expand All @@ -107,7 +121,7 @@ var _ = SIGDescribe(feature.CriProxy, framework.WithSerial(), func() {
gomega.Expect(isExpectedErrMsg).To(gomega.BeTrueBecause("we injected an exception into the PullImage interface of the cri proxy"))

// remove error so after backoff we will succeed
resetCRIProxyInjector()
_ = resetCRIProxyInjector()

podErr = e2epod.WaitForPodRunningInNamespace(ctx, f.ClientSet, pod)
framework.ExpectNoError(podErr)
Expand Down Expand Up @@ -189,11 +203,13 @@ func getImageBackOffDurations(ctx context.Context, f *framework.Framework, podNa
var r *BackOffRecord
for _, event := range events.Items {
if event.InvolvedObject.Name == podName {

switch event.Reason {
case kubeletevents.PullingImage:
if !pullTime.IsZero() {
if event.FirstTimestamp.Time.After(pullTime) {
r = records[backoffCount]
r.podName = podName
r.duration = r.initialEventTime.Sub(r.backoffEventTimes[len(r.backoffEventTimes)-1])
backoffs = append(backoffs, r.duration)
backoffCount++
Expand Down

0 comments on commit 6337a28

Please sign in to comment.