github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v7/global/global_suite_test.go (about) 1 package global 2 3 import ( 4 "fmt" 5 "os" 6 "time" 7 8 "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" 9 "code.cloudfoundry.org/cli/integration/helpers" 10 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/gomega" 13 14 "testing" 15 ) 16 17 const ( 18 CFEventuallyTimeout = 300 * time.Second 19 CFConsistentlyTimeout = 500 * time.Millisecond 20 ) 21 22 var ( 23 // Per Test Level 24 homeDir string 25 ReadOnlyOrg string 26 ReadOnlySpace string 27 ) 28 29 func TestGlobal(t *testing.T) { 30 RegisterFailHandler(Fail) 31 reporters := []Reporter{} 32 33 prBuilderReporter := helpers.GetPRBuilderReporter() 34 if prBuilderReporter != nil { 35 reporters = append(reporters, prBuilderReporter) 36 } 37 38 RunSpecsWithDefaultAndCustomReporters(t, "Global Suite", reporters) 39 } 40 41 var _ = SynchronizedBeforeSuite(func() []byte { 42 GinkgoWriter.Write([]byte("==============================Global FIRST Node Synchronized Before Each==============================")) 43 // Ginkgo Globals 44 SetDefaultEventuallyTimeout(CFEventuallyTimeout) 45 SetDefaultConsistentlyDuration(CFConsistentlyTimeout) 46 47 // Setup common environment variables 48 helpers.TurnOffColors() 49 50 helpers.SetupSynchronizedSuite(func() { 51 helpers.EnableFeatureFlag("diego_docker") 52 53 if helpers.IsVersionMet(ccversion.MinVersionShareServiceV3) { 54 helpers.EnableFeatureFlag("service_instance_sharing") 55 } 56 }) 57 58 ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace() 59 60 GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each==============================")) 61 return nil 62 }, func(_ []byte) { 63 GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) 64 if GinkgoParallelNode() != 1 { 65 Fail("Test suite cannot run in parallel") 66 } 67 GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) 68 }) 69 70 var _ = AfterSuite(func() { 71 outputRoot := os.Getenv(helpers.PRBuilderOutputEnvVar) 72 if outputRoot != "" { 73 helpers.WriteFailureSummary(outputRoot, "summary_isg.txt") 74 } 75 }) 76 77 var _ = BeforeEach(func() { 78 GinkgoWriter.Write([]byte("==============================Global Before Each==============================")) 79 homeDir = helpers.SetHomeDir() 80 helpers.SetAPI() 81 GinkgoWriter.Write([]byte("==============================End of Global Before Each==============================")) 82 }) 83 84 var _ = AfterEach(func() { 85 GinkgoWriter.Write([]byte("==============================Global After Each==============================")) 86 helpers.DestroyHomeDir(homeDir) 87 GinkgoWriter.Write([]byte("==============================End of Global After Each==============================")) 88 })