fixup! fixup! fixup! fixup! fixup! More fixes, moving from python to golang worker.

This commit is contained in:
2025-12-18 01:46:18 +00:00
parent dae0441043
commit 59a6918eea
2 changed files with 54 additions and 13 deletions
@@ -33,38 +33,73 @@ import (
var _ = Describe("ClusterImage Controller", func() { var _ = Describe("ClusterImage Controller", func() {
Context("When reconciling a resource", func() { Context("When reconciling a resource", func() {
const resourceName = "test-resource" const resourceName = "test-resource"
const exportName = "test-export"
ctx := context.Background() ctx := context.Background()
typeNamespacedName := types.NamespacedName{ typeNamespacedName := types.NamespacedName{
Name: resourceName, Name: resourceName,
Namespace: "default", // TODO(user):Modify as needed Namespace: "default",
}
exportNamespacedName := types.NamespacedName{
Name: exportName,
Namespace: "default",
} }
clusterimage := &raczylocomv1.ClusterImage{} clusterimage := &raczylocomv1.ClusterImage{}
BeforeEach(func() { BeforeEach(func() {
By("creating the ClusterImageExport that the ClusterImage references")
export := &raczylocomv1.ClusterImageExport{}
err := k8sClient.Get(ctx, exportNamespacedName, export)
if err != nil && errors.IsNotFound(err) {
exportResource := &raczylocomv1.ClusterImageExport{
ObjectMeta: metav1.ObjectMeta{
Name: exportName,
Namespace: "default",
},
Spec: raczylocomv1.ClusterImageExportSpec{
Name: exportName,
BasePath: "/backups/test",
MaxConcurrentJobs: 1,
Storage: raczylocomv1.ClusterImageStorageSpec{
StorageTarget: "FILE",
},
},
}
Expect(k8sClient.Create(ctx, exportResource)).To(Succeed())
}
By("creating the custom resource for the Kind ClusterImage") By("creating the custom resource for the Kind ClusterImage")
err := k8sClient.Get(ctx, typeNamespacedName, clusterimage) err = k8sClient.Get(ctx, typeNamespacedName, clusterimage)
if err != nil && errors.IsNotFound(err) { if err != nil && errors.IsNotFound(err) {
resource := &raczylocomv1.ClusterImage{ resource := &raczylocomv1.ClusterImage{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: resourceName, Name: resourceName,
Namespace: "default", Namespace: "default",
}, },
// TODO(user): Specify other spec details if needed. Spec: raczylocomv1.ClusterImageSpec{
ExportName: exportName,
Image: "nginx:latest",
},
} }
Expect(k8sClient.Create(ctx, resource)).To(Succeed()) Expect(k8sClient.Create(ctx, resource)).To(Succeed())
} }
}) })
AfterEach(func() { AfterEach(func() {
// TODO(user): Cleanup logic after each test, like removing the resource instance. By("Cleanup the specific resource instance ClusterImage")
resource := &raczylocomv1.ClusterImage{} resource := &raczylocomv1.ClusterImage{}
err := k8sClient.Get(ctx, typeNamespacedName, resource) err := k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred()) if err == nil {
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
}
By("Cleanup the specific resource instance ClusterImage") By("Cleanup the ClusterImageExport")
Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) export := &raczylocomv1.ClusterImageExport{}
err = k8sClient.Get(ctx, exportNamespacedName, export)
if err == nil {
Expect(k8sClient.Delete(ctx, export)).To(Succeed())
}
}) })
It("should successfully reconcile the resource", func() { It("should successfully reconcile the resource", func() {
By("Reconciling the created resource") By("Reconciling the created resource")
@@ -51,20 +51,26 @@ var _ = Describe("ClusterImageExport Controller", func() {
Name: resourceName, Name: resourceName,
Namespace: "default", Namespace: "default",
}, },
// TODO(user): Specify other spec details if needed. Spec: raczylocomv1.ClusterImageExportSpec{
Name: resourceName,
BasePath: "/backups/test",
MaxConcurrentJobs: 1,
Storage: raczylocomv1.ClusterImageStorageSpec{
StorageTarget: "FILE",
},
},
} }
Expect(k8sClient.Create(ctx, resource)).To(Succeed()) Expect(k8sClient.Create(ctx, resource)).To(Succeed())
} }
}) })
AfterEach(func() { AfterEach(func() {
// TODO(user): Cleanup logic after each test, like removing the resource instance. By("Cleanup the specific resource instance ClusterImageExport")
resource := &raczylocomv1.ClusterImageExport{} resource := &raczylocomv1.ClusterImageExport{}
err := k8sClient.Get(ctx, typeNamespacedName, resource) err := k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred()) if err == nil {
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
By("Cleanup the specific resource instance ClusterImageExport") }
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
}) })
It("should successfully reconcile the resource", func() { It("should successfully reconcile the resource", func() {
By("Reconciling the created resource") By("Reconciling the created resource")