github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/experimental/experimental_suite_test.go (about) 1 package experimental 2 3 import ( 4 "regexp" 5 "testing" 6 "time" 7 8 "code.cloudfoundry.org/cli/integration/helpers" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 const ( 15 CFEventuallyTimeout = 300 * time.Second 16 CFConsistentlyTimeout = 500 * time.Millisecond 17 RealIsolationSegment = "persistent_isolation_segment" 18 PublicDockerImage = "cloudfoundry/diego-docker-app-custom" 19 ) 20 21 var ( 22 // Suite Level 23 apiURL string 24 skipSSLValidation string 25 ReadOnlyOrg string 26 ReadOnlySpace string 27 28 // Per Test Level 29 homeDir string 30 ) 31 32 func TestIsolated(t *testing.T) { 33 RegisterFailHandler(Fail) 34 RunSpecs(t, "Experimental Integration Suite") 35 } 36 37 var _ = SynchronizedBeforeSuite(func() []byte { 38 return nil 39 }, func(_ []byte) { 40 // Ginkgo Globals 41 SetDefaultEventuallyTimeout(CFEventuallyTimeout) 42 SetDefaultConsistentlyDuration(CFConsistentlyTimeout) 43 44 // Setup common environment variables 45 helpers.TurnOffColors() 46 47 // Enable Experimental Flag 48 helpers.TurnOnExperimental() 49 50 helpers.SetupSynchronizedSuite(func() { 51 helpers.EnableFeatureFlag("diego_docker") 52 helpers.EnableFeatureFlag("service_instance_sharing") 53 }) 54 55 ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace() 56 }) 57 58 var _ = SynchronizedAfterSuite(func() { 59 helpers.SetAPI() 60 helpers.LoginCF() 61 helpers.QuickDeleteOrg(ReadOnlyOrg) 62 }, func() { 63 }) 64 65 var _ = BeforeEach(func() { 66 homeDir = helpers.SetHomeDir() 67 apiURL, skipSSLValidation = helpers.SetAPI() 68 }) 69 70 var _ = AfterEach(func() { 71 GinkgoWriter.Write([]byte("==============================Global After Each==============================")) 72 helpers.DestroyHomeDir(homeDir) 73 }) 74 75 var foundDefaultDomain string 76 77 func defaultSharedDomain() string { 78 // TODO: Move this into helpers when other packages need it, figure out how 79 // to cache cuz this is a wacky call otherwise 80 if foundDefaultDomain == "" { 81 session := helpers.CF("domains") 82 Eventually(session).Should(Exit(0)) 83 84 regex, err := regexp.Compile(`(.+?)\s+shared`) 85 Expect(err).ToNot(HaveOccurred()) 86 87 matches := regex.FindStringSubmatch(string(session.Out.Contents())) 88 Expect(matches).To(HaveLen(2)) 89 90 foundDefaultDomain = matches[1] 91 } 92 return foundDefaultDomain 93 } 94 95 func setupCF(org string, space string) { 96 helpers.LoginCF() 97 if org != ReadOnlyOrg && space != ReadOnlySpace { 98 helpers.CreateOrgAndSpace(org, space) 99 } 100 helpers.TargetOrgAndSpace(org, space) 101 }