github.com/interconnectedcloud/qdr-operator@v0.0.0-20210826174505-576d2b33dac7/test/e2e/upgrade_test.go (about) 1 package e2e 2 3 import ( 4 "context" 5 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/log" 6 "strings" 7 8 "github.com/interconnectedcloud/qdr-operator/pkg/apis/interconnectedcloud/v1alpha1" 9 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework" 10 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/qdrmanagement" 11 12 . "github.com/onsi/ginkgo" 13 . "github.com/onsi/gomega" 14 ) 15 16 var _ = Describe("[upgrade_test] Interconnect upgrade deployment tests", func() { 17 f := framework.NewFramework("upgrade", nil) 18 19 It("Should be able to upgrade the qdrouterd image for an interior deployment", func() { 20 testInteriorImageUpgrade(f) 21 }) 22 23 }) 24 25 func testInteriorImageUpgrade(f *framework.Framework) { 26 var ( 27 name = "interior-interconnect" 28 image = "quay.io/interconnectedcloud/qdrouterd" 29 initialVersion = "1.12.0" 30 finalVersion = "1.13.0" 31 size = 3 32 skipVersion = !strings.HasPrefix(framework.TestContext.QdrImage, image) 33 ) 34 35 By("Creating an interior interconnect with size 3") 36 fullImage := image + ":" + initialVersion 37 // When using a custom image (with a different version from expected, when using static upstream images above) 38 if skipVersion { 39 fullImage = framework.TestContext.QdrImage 40 } 41 ei, err := f.CreateInterconnect(f.Namespace, int32(size), func(ei *v1alpha1.Interconnect) { 42 ei.Name = name 43 ei.Spec.DeploymentPlan.Image = fullImage 44 }) 45 log.Logf("Creating using image: %s", fullImage) 46 Expect(err).NotTo(HaveOccurred()) 47 48 // Make sure we cleanup the Interconnect resource after we're done testing. 49 defer func() { 50 err = f.DeleteInterconnect(ei) 51 Expect(err).NotTo(HaveOccurred()) 52 }() 53 54 By("Creating an Interconnect resource in the namespace") 55 ei, err = f.GetInterconnect(name) 56 Expect(err).NotTo(HaveOccurred()) 57 58 By("Waiting until full interconnect with size and initial version") 59 ctx1, fn := context.WithTimeout(context.Background(), framework.Timeout) 60 defer fn() 61 if !skipVersion { 62 err = f.WaitUntilFullInterconnectWithVersion(ctx1, ei, size, initialVersion) 63 } else { 64 err = f.WaitUntilFullInterconnectWithSize(ctx1, ei, size) 65 } 66 Expect(err).NotTo(HaveOccurred()) 67 68 By("Waiting until full interconnect initial qdr entities") 69 ctx2, fn := context.WithTimeout(context.Background(), framework.Timeout) 70 defer fn() 71 err = qdrmanagement.WaitUntilFullInterconnectWithQdrEntities(ctx2, f, ei) 72 Expect(err).NotTo(HaveOccurred()) 73 74 By("Retrieving the Interconnect resource in the namespace") 75 ei, err = f.GetInterconnect(name) 76 Expect(err).NotTo(HaveOccurred()) 77 78 By("Upgrading the qdrouterd image version") 79 fullImage = image + ":" + finalVersion 80 // When using a custom image (with a different version from expected, when using static upstream images above) 81 // then we remove an existing tag and use the ":latest" 82 if skipVersion { 83 fullImage = framework.TestContext.QdrImage 84 if strings.Contains(fullImage, ":") { 85 fullImage = fullImage[:strings.Index(fullImage, ":")] + ":latest" 86 } 87 } 88 ei.Spec.DeploymentPlan.Image = fullImage 89 log.Logf("Upgrading using image: %s", fullImage) 90 _, err = f.UpdateInterconnect(ei) 91 Expect(err).NotTo(HaveOccurred()) 92 93 By("Waiting until full interconnect with size and final version") 94 ctx3, fn := context.WithTimeout(context.Background(), framework.Timeout) 95 defer fn() 96 if !skipVersion { 97 err = f.WaitUntilFullInterconnectWithVersion(ctx3, ei, size, finalVersion) 98 } else { 99 err = f.WaitUntilFullInterconnectWithSize(ctx3, ei, size) 100 } 101 Expect(err).NotTo(HaveOccurred()) 102 103 By("Waiting until full interconnect with final qdr entities") 104 ctx4, fn := context.WithTimeout(context.Background(), framework.Timeout) 105 defer fn() 106 err = qdrmanagement.WaitUntilFullInterconnectWithQdrEntities(ctx4, f, ei) 107 Expect(err).NotTo(HaveOccurred()) 108 109 }