github.com/interconnectedcloud/qdr-operator@v0.0.0-20210826174505-576d2b33dac7/test/e2e/resize_test.go (about) 1 package e2e 2 3 import ( 4 "context" 5 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/qdrmanagement" 6 7 "github.com/interconnectedcloud/qdr-operator/pkg/apis/interconnectedcloud/v1alpha1" 8 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework" 9 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("[resize_test] Interconnect resize deployment tests", func() { 15 f := framework.NewFramework("resize", nil) 16 17 It("Should be able to resize an interior deployment from 3 to 5", func() { 18 testInteriorResize(f, 3, 5) 19 }) 20 21 It("Should be able to resize an interior deployment from 5 to 3", func() { 22 testInteriorResize(f, 5, 3) 23 }) 24 }) 25 26 func testInteriorResize(f *framework.Framework, initialSize int, finalSize int) { 27 var ( 28 name = "interior-interconnect" 29 ) 30 31 By("Creating an interior interconnect with initial size") 32 ei, err := f.CreateInterconnect(f.Namespace, int32(initialSize), func(ei *v1alpha1.Interconnect) { 33 ei.Name = name 34 }) 35 Expect(err).NotTo(HaveOccurred()) 36 37 // Make sure we cleanup the Interconnect resource after we're done testing. 38 defer func() { 39 err = f.DeleteInterconnect(ei) 40 Expect(err).NotTo(HaveOccurred()) 41 }() 42 43 By("Creating an Interconnect resource in the namespace") 44 ei, err = f.GetInterconnect(name) 45 Expect(err).NotTo(HaveOccurred()) 46 47 By("Waiting until full interconnect with initial size and version") 48 ctx1, fn := context.WithTimeout(context.Background(), framework.Timeout) 49 defer fn() 50 err = f.WaitUntilFullInterconnectWithSize(ctx1, ei, initialSize) 51 Expect(err).NotTo(HaveOccurred()) 52 53 By("Waiting until full interconnect initial qdr entities") 54 ctx2, fn := context.WithTimeout(context.Background(), framework.Timeout) 55 defer fn() 56 err = qdrmanagement.WaitUntilFullInterconnectWithQdrEntities(ctx2, f, ei) 57 Expect(err).NotTo(HaveOccurred()) 58 59 By("Retrieving the Interconnect resource in the namespace") 60 ei, err = f.GetInterconnect(name) 61 Expect(err).NotTo(HaveOccurred()) 62 63 By("Scaling the interior interconnect to final size") 64 ei.Spec.DeploymentPlan.Size = int32(finalSize) 65 _, err = f.UpdateInterconnect(ei) 66 Expect(err).NotTo(HaveOccurred()) 67 68 By("Waiting until full interconnect with final size and version") 69 ctx3, fn := context.WithTimeout(context.Background(), framework.Timeout) 70 defer fn() 71 err = f.WaitUntilFullInterconnectWithSize(ctx3, ei, finalSize) 72 Expect(err).NotTo(HaveOccurred()) 73 74 By("Waiting until full interconnect with final qdr entities") 75 ctx4, fn := context.WithTimeout(context.Background(), framework.Timeout) 76 defer fn() 77 err = qdrmanagement.WaitUntilFullInterconnectWithQdrEntities(ctx4, f, ei) 78 Expect(err).NotTo(HaveOccurred()) 79 80 }