Skip to content

Commit 2044de4

Browse files
committed
Add HelmRepository timeout test
1 parent 4486ab7 commit 2044de4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

controllers/helmrepository_controller_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,57 @@ var _ = Describe("HelmRepositoryReconciler", func() {
152152
Eventually(exists(got.Status.Artifact.Path), timeout, interval).ShouldNot(BeTrue())
153153
})
154154

155+
It("Handles timeout", func() {
156+
helmServer.Start()
157+
158+
Expect(helmServer.PackageChart(path.Join("testdata/helmchart"))).Should(Succeed())
159+
Expect(helmServer.GenerateIndex()).Should(Succeed())
160+
161+
key := types.NamespacedName{
162+
Name: "helmrepository-sample-" + randStringRunes(5),
163+
Namespace: namespace.Name,
164+
}
165+
created := &sourcev1.HelmRepository{
166+
ObjectMeta: metav1.ObjectMeta{
167+
Name: key.Name,
168+
Namespace: key.Namespace,
169+
},
170+
Spec: sourcev1.HelmRepositorySpec{
171+
URL: helmServer.URL(),
172+
Interval: metav1.Duration{Duration: indexInterval},
173+
},
174+
}
175+
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
176+
177+
By("Expecting index download to succeed")
178+
Eventually(func() bool {
179+
got := &sourcev1.HelmRepository{}
180+
_ = k8sClient.Get(context.Background(), key, got)
181+
for _, condition := range got.Status.Conditions {
182+
if condition.Reason == sourcev1.IndexationSucceededReason {
183+
return true
184+
}
185+
}
186+
return false
187+
}, timeout, interval).Should(BeTrue())
188+
189+
By("Expecting index download to timeout")
190+
updated := &sourcev1.HelmRepository{}
191+
Expect(k8sClient.Get(context.Background(), key, updated)).Should(Succeed())
192+
updated.Spec.Timeout = &metav1.Duration{Duration: time.Microsecond}
193+
Expect(k8sClient.Update(context.Background(), updated)).Should(Succeed())
194+
Eventually(func() string {
195+
got := &sourcev1.HelmRepository{}
196+
_ = k8sClient.Get(context.Background(), key, got)
197+
for _, condition := range got.Status.Conditions {
198+
if condition.Reason == sourcev1.IndexationFailedReason {
199+
return condition.Message
200+
}
201+
}
202+
return ""
203+
}, timeout, interval).Should(MatchRegexp("(?i)timeout"))
204+
})
205+
155206
It("Authenticates when basic auth credentials are provided", func() {
156207
helmServer, err = testserver.NewTempHelmServer()
157208
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)