github.com/metaprov/modela-operator@v0.0.0-20240118193048-f378be8b74d2/controllers/components/object_storage_test.go (about)

     1  package components
     2  
     3  import (
     4  	"context"
     5  	"github.com/metaprov/modela-operator/api/v1alpha1"
     6  	"github.com/metaprov/modela-operator/pkg/kube"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	k8serr "k8s.io/apimachinery/pkg/api/errors"
    10  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    11  )
    12  
    13  const ObjectVersion = ""
    14  
    15  var _ = Describe("Object storage installer", func() {
    16  	objectStorage := NewObjectStorage()
    17  
    18  	It("Should install minio", func() {
    19  		if installed, err := objectStorage.Installed(context.Background()); err == v1alpha1.ComponentNotInstalledByModelaError || installed {
    20  			Skip("Test should be run on an empty cluster")
    21  			return
    22  		}
    23  
    24  		Expect(objectStorage.Install(context.Background(), &v1alpha1.Modela{
    25  			ObjectMeta: v1.ObjectMeta{Name: "modela-test"},
    26  		})).To(BeNil())
    27  
    28  		By("Checking if it was installed")
    29  		installed, err := objectStorage.Installed(context.Background())
    30  		Expect(err).NotTo(HaveOccurred())
    31  		Expect(installed).To(BeTrue())
    32  
    33  		changeDeploymentModelaOperatorLabel(false, "modela-system", "modela-storage-minio")
    34  		installed, err = objectStorage.Installed(context.Background())
    35  		Expect(err).To(Equal(v1alpha1.ComponentNotInstalledByModelaError))
    36  
    37  		By("Uninstalling minio")
    38  		Expect(objectStorage.Uninstall(context.Background(), &v1alpha1.Modela{})).To(BeNil())
    39  		_, err = kube.IsDeploymentCreatedByModela("modela-system", "modela-storage-minio")
    40  		Expect(k8serr.IsNotFound(err)).To(BeTrue())
    41  
    42  		By("Checking if it was uninstalled")
    43  		installed, err = objectStorage.Installed(context.Background())
    44  		Expect(err).NotTo(HaveOccurred())
    45  		Expect(installed).To(BeFalse())
    46  	})
    47  })