github.com/metaprov/modela-operator@v0.0.0-20240118193048-f378be8b74d2/controllers/components/vault_test.go (about) 1 package components 2 3 import ( 4 "context" 5 "github.com/metaprov/modela-operator/api/v1alpha1" 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 9 "os/exec" 10 "time" 11 ) 12 13 var _ = Describe("Vault installer", func() { 14 It("Should install vault", func() { 15 vault := NewVault() 16 if installed, err := vault.Installed(context.Background()); err == v1alpha1.ComponentNotInstalledByModelaError || installed { 17 Skip("Test should be run on an empty cluster") 18 return 19 } 20 21 Expect(vault.Install(context.Background(), &v1alpha1.Modela{ 22 ObjectMeta: v1.ObjectMeta{Name: "modela-test"}, 23 })).To(BeNil()) 24 25 By("Checking if it was installed") 26 installed, err := vault.Installed(context.Background()) 27 Expect(err).NotTo(HaveOccurred()) 28 Expect(installed).To(BeTrue()) 29 Eventually(func() bool { t, _ := vault.Ready(context.Background()); return t }, time.Second*60, time.Second*1).Should(BeTrue()) 30 }) 31 32 It("Should configure vault", func() { 33 // Port forward the vault server 34 port_forward := exec.Command("kubectl", "port-forward", "-n", "modela-system", "svc/modela-vault", "8200:8200") 35 Expect(port_forward.Start()).To(Succeed()) 36 37 vault := NewVault() 38 Expect(vault.ConfigureVault(context.Background(), &v1alpha1.Modela{})).To(Succeed()) 39 40 _ = port_forward.Process.Kill() 41 42 }) 43 })