controllers: slightly restructure HelmRepository tests
This commit is contained in:
parent
6083d886ce
commit
d36efa70dd
|
@ -39,8 +39,10 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
const (
|
const (
|
||||||
timeout = time.Second * 30
|
timeout = time.Second * 30
|
||||||
interval = time.Second * 1
|
interval = time.Second * 1
|
||||||
|
indexInterval = time.Second * 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Context("HelmRepository", func() {
|
||||||
var (
|
var (
|
||||||
namespace *corev1.Namespace
|
namespace *corev1.Namespace
|
||||||
helmServer *testserver.Helm
|
helmServer *testserver.Helm
|
||||||
|
@ -53,19 +55,21 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
}
|
}
|
||||||
err = k8sClient.Create(context.Background(), namespace)
|
err = k8sClient.Create(context.Background(), namespace)
|
||||||
Expect(err).NotTo(HaveOccurred(), "failed to create test namespace")
|
Expect(err).NotTo(HaveOccurred(), "failed to create test namespace")
|
||||||
|
|
||||||
|
helmServer, err = testserver.NewTempHelmServer()
|
||||||
|
Expect(err).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
err = k8sClient.Delete(context.Background(), namespace)
|
os.RemoveAll(helmServer.Root())
|
||||||
Expect(err).NotTo(HaveOccurred(), "failed to delete test namespace")
|
helmServer.Stop()
|
||||||
|
|
||||||
|
Eventually(func() error {
|
||||||
|
return k8sClient.Delete(context.Background(), namespace)
|
||||||
|
}, timeout, interval).Should(Succeed(), "failed to delete test namespace")
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("HelmRepository", func() {
|
|
||||||
It("Creates artifacts for", func() {
|
It("Creates artifacts for", func() {
|
||||||
helmServer, err = testserver.NewTempHelmServer()
|
|
||||||
Expect(err).To(Succeed())
|
|
||||||
defer os.RemoveAll(helmServer.Root())
|
|
||||||
defer helmServer.Stop()
|
|
||||||
helmServer.Start()
|
helmServer.Start()
|
||||||
|
|
||||||
Expect(helmServer.PackageChart(path.Join("testdata/helmchart"))).Should(Succeed())
|
Expect(helmServer.PackageChart(path.Join("testdata/helmchart"))).Should(Succeed())
|
||||||
|
@ -82,7 +86,7 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
},
|
},
|
||||||
Spec: sourcev1.HelmRepositorySpec{
|
Spec: sourcev1.HelmRepositorySpec{
|
||||||
URL: helmServer.URL(),
|
URL: helmServer.URL(),
|
||||||
Interval: metav1.Duration{Duration: interval},
|
Interval: metav1.Duration{Duration: indexInterval},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
|
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
|
||||||
|
@ -97,6 +101,8 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
By("Updating the chart index")
|
By("Updating the chart index")
|
||||||
// Regenerating the index is sufficient to make the revision change
|
// Regenerating the index is sufficient to make the revision change
|
||||||
Expect(helmServer.GenerateIndex()).Should(Succeed())
|
Expect(helmServer.GenerateIndex()).Should(Succeed())
|
||||||
|
|
||||||
|
By("Expecting revision change and GC")
|
||||||
Eventually(func() bool {
|
Eventually(func() bool {
|
||||||
now := &sourcev1.HelmRepository{}
|
now := &sourcev1.HelmRepository{}
|
||||||
_ = k8sClient.Get(context.Background(), key, now)
|
_ = k8sClient.Get(context.Background(), key, now)
|
||||||
|
@ -132,6 +138,8 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
r := &sourcev1.HelmRepository{}
|
r := &sourcev1.HelmRepository{}
|
||||||
return k8sClient.Get(context.Background(), key, r)
|
return k8sClient.Get(context.Background(), key, r)
|
||||||
}).ShouldNot(Succeed())
|
}).ShouldNot(Succeed())
|
||||||
|
|
||||||
|
By("Expecting GC after delete")
|
||||||
Eventually(storage.ArtifactExist(*got.Status.Artifact), timeout, interval).ShouldNot(BeTrue())
|
Eventually(storage.ArtifactExist(*got.Status.Artifact), timeout, interval).ShouldNot(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -184,7 +192,7 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
SecretRef: &corev1.LocalObjectReference{
|
SecretRef: &corev1.LocalObjectReference{
|
||||||
Name: secretKey.Name,
|
Name: secretKey.Name,
|
||||||
},
|
},
|
||||||
Interval: metav1.Duration{Duration: interval},
|
Interval: metav1.Duration{Duration: indexInterval},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
|
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
|
||||||
|
@ -240,13 +248,8 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
}, timeout, interval).Should(BeTrue())
|
}, timeout, interval).Should(BeTrue())
|
||||||
Expect(got.Status.Artifact).ShouldNot(BeNil())
|
Expect(got.Status.Artifact).ShouldNot(BeNil())
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
It("Authenticates when TLS credentials are provided", func() {
|
It("Authenticates when TLS credentials are provided", func() {
|
||||||
helmServer, err = testserver.NewTempHelmServer()
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
defer os.RemoveAll(helmServer.Root())
|
|
||||||
defer helmServer.Stop()
|
|
||||||
err = helmServer.StartTLS(examplePublicKey, examplePrivateKey, exampleCA)
|
err = helmServer.StartTLS(examplePublicKey, examplePrivateKey, exampleCA)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
@ -280,7 +283,7 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
SecretRef: &corev1.LocalObjectReference{
|
SecretRef: &corev1.LocalObjectReference{
|
||||||
Name: secretKey.Name,
|
Name: secretKey.Name,
|
||||||
},
|
},
|
||||||
Interval: metav1.Duration{Duration: interval},
|
Interval: metav1.Duration{Duration: indexInterval},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
|
Expect(k8sClient.Create(context.Background(), created)).Should(Succeed())
|
||||||
|
@ -338,3 +341,4 @@ var _ = Describe("HelmRepositoryReconciler", func() {
|
||||||
Expect(got.Status.Artifact).ShouldNot(BeNil())
|
Expect(got.Status.Artifact).ShouldNot(BeNil())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue