github.com/interconnectedcloud/qdr-operator@v0.0.0-20210826174505-576d2b33dac7/test/e2e/validation/address.go (about) 1 package validation 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" 7 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/qdrmanagement/entities" 8 "github.com/onsi/gomega" 9 "k8s.io/api/core/v1" 10 ) 11 12 // ValidateDefaultAddresses verifies that the created addresses match expected ones 13 func ValidateDefaultAddresses(ic *v1alpha1.Interconnect, f *framework.Framework, pods []v1.Pod) { 14 15 const expectedAddresses = 5 16 17 for _, pod := range pods { 18 var defaultAddressesFound = 0 19 20 // Querying addresses on given pod 21 addrs, err := qdrmanagement.QdmanageQuery(f, pod.Name, entities.Address{}, nil) 22 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 23 gomega.Expect(len(addrs)).To(gomega.Equal(expectedAddresses)) 24 25 // Validates all addresses are present and match expected definition 26 for _, entity := range addrs { 27 addr := entity.(entities.Address) 28 switch addr.Prefix { 29 case "closest": 30 fallthrough 31 case "unicast": 32 fallthrough 33 case "exclusive": 34 ValidateEntityValues(addr, map[string]interface{}{ 35 "Distribution": entities.DistributionClosest, 36 }) 37 defaultAddressesFound++ 38 case "multicast": 39 fallthrough 40 case "broadcast": 41 ValidateEntityValues(addr, map[string]interface{}{ 42 "Distribution": entities.DistributionMulticast, 43 }) 44 defaultAddressesFound++ 45 } 46 } 47 48 // Assert default addresses have been found 49 gomega.Expect(expectedAddresses).To(gomega.Equal(defaultAddressesFound)) 50 } 51 52 }