github.com/interconnectedcloud/qdr-operator@v0.0.0-20210826174505-576d2b33dac7/test/e2e/spec_links.go (about) 1 package e2e 2 3 import ( 4 "github.com/interconnectedcloud/qdr-operator/pkg/apis/interconnectedcloud/v1alpha1" 5 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework" 6 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/qdrmanagement/entities" 7 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/qdrmanagement/entities/common" 8 "github.com/interconnectedcloud/qdr-operator/test/e2e/validation" 9 "github.com/onsi/ginkgo" 10 "github.com/onsi/gomega" 11 ) 12 13 var _ = ginkgo.Describe("[spec_links] Link Route and Auto Link manipulation tests", func() { 14 15 var ( 16 icName = "links" 17 size = 3 18 ) 19 20 // Framework instance to be used across test specs 21 f := framework.NewFramework(icName, nil) 22 23 // 24 // Validating manipulation of link routes and auto links 25 // 26 ginkgo.It("Defines link routes and auto links", func() { 27 // Create the Interconnect resource with linkRoutes and autoLinks 28 ic, err := f.CreateInterconnect(f.Namespace, int32(size), specLinkRoutes, specAutoLinks) 29 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 30 31 // Wait for the deployment to finish 32 err = framework.WaitForDeployment(f.KubeClient, f.Namespace, ic.Name, size, framework.RetryInterval, framework.Timeout) 33 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 34 35 // Validating LinkRoute entities 36 ginkgo.By("Validating defined LinkRoutes") 37 validation.ValidateSpecLinkRoute(ic, f, validation.LinkRouteMapByPrefixPattern{ 38 "linkRoutePrefixInConnection": { 39 "Prefix": "linkRoutePrefixInConnection", 40 "Direction": common.DirectionTypeIn, 41 "Connection": "connection", 42 "AddExternalPrefix": "addExternalPrefix", 43 "DelExternalPrefix": "delExternalPrefix", 44 "OperStatus": entities.LinkRouteOperStatusInactive, 45 }, 46 "linkRoutePrefixOutConnection": { 47 "Prefix": "linkRoutePrefixOutConnection", 48 "Direction": common.DirectionTypeOut, 49 "Connection": "connection", 50 "AddExternalPrefix": "addExternalPrefix", 51 "DelExternalPrefix": "delExternalPrefix", 52 "OperStatus": entities.LinkRouteOperStatusInactive, 53 }, 54 "linkRoutePatternInContainerId": { 55 "Pattern": "linkRoutePatternInContainerId", 56 "Direction": common.DirectionTypeIn, 57 "ContainerId": "containerId", 58 "AddExternalPrefix": "addExternalPrefix", 59 "DelExternalPrefix": "delExternalPrefix", 60 "OperStatus": entities.LinkRouteOperStatusInactive, 61 }, 62 "linkRoutePatternOutContainerId": { 63 "Pattern": "linkRoutePatternOutContainerId", 64 "Direction": common.DirectionTypeOut, 65 "ContainerId": "containerId", 66 "AddExternalPrefix": "addExternalPrefix", 67 "DelExternalPrefix": "delExternalPrefix", 68 "OperStatus": entities.LinkRouteOperStatusInactive, 69 }, 70 }) 71 72 // Validating AutoLink entities 73 ginkgo.By("Validating defined AutoLinks") 74 validation.ValidateSpecAutoLink(ic, f, validation.AutoLinkMapByAddress{ 75 "autoLinkConnection": { 76 "Address": "autoLinkConnection", 77 "Direction": common.DirectionTypeIn, 78 "Phase": 1, 79 "Connection": "connection", 80 "ExternalAddress": "externalAddress", 81 "Fallback": true, 82 "OperStatus": entities.AutoLinkOperStatusInactive, 83 }, 84 "autoLinkContainerId": { 85 "Address": "autoLinkContainerId", 86 "Direction": common.DirectionTypeOut, 87 "Phase": 0, 88 "ContainerId": "containerId", 89 "ExternalAddress": "externalAddress", 90 "Fallback": true, 91 "OperStatus": entities.AutoLinkOperStatusInactive, 92 }, 93 }) 94 95 }) 96 }) 97 98 // specLinkRoutes defines a static list of LinkRoutes in 99 // the provided Interconnect instance. 100 func specLinkRoutes(interconnect *v1alpha1.Interconnect) { 101 interconnect.Spec.LinkRoutes = []v1alpha1.LinkRoute{ 102 { 103 Prefix: "linkRoutePrefixInConnection", 104 Direction: "in", 105 Connection: "connection", 106 AddExternalPrefix: "addExternalPrefix", 107 DelExternalPrefix: "delExternalPrefix", 108 }, 109 { 110 Prefix: "linkRoutePrefixOutConnection", 111 Direction: "out", 112 Connection: "connection", 113 AddExternalPrefix: "addExternalPrefix", 114 DelExternalPrefix: "delExternalPrefix", 115 }, 116 { 117 Pattern: "linkRoutePatternInContainerId", 118 Direction: "in", 119 ContainerId: "containerId", 120 AddExternalPrefix: "addExternalPrefix", 121 DelExternalPrefix: "delExternalPrefix", 122 }, 123 { 124 Pattern: "linkRoutePatternOutContainerId", 125 Direction: "out", 126 ContainerId: "containerId", 127 AddExternalPrefix: "addExternalPrefix", 128 DelExternalPrefix: "delExternalPrefix", 129 }, 130 } 131 } 132 133 // specAutoLinks defines a list of AutoLinks in the 134 // provided Interconnect instance 135 func specAutoLinks(interconnect *v1alpha1.Interconnect) { 136 phaseIn := int32(1) 137 phaseOut := int32(0) 138 139 interconnect.Spec.AutoLinks = []v1alpha1.AutoLink{ 140 { 141 Address: "autoLinkConnection", 142 Direction: "in", 143 Connection: "connection", 144 ExternalAddress: "externalAddress", 145 Phase: &phaseIn, 146 Fallback: true, 147 }, 148 { 149 Address: "autoLinkContainerId", 150 Direction: "out", 151 ContainerId: "containerId", 152 ExternalAddress: "externalAddress", 153 Phase: &phaseOut, 154 Fallback: true, 155 }, 156 } 157 }