github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v6/isolated/isolated_suite_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"testing"
     7  	"time"
     8  
     9  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
    10  	"code.cloudfoundry.org/cli/integration/helpers"
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  )
    14  
    15  const (
    16  	CFEventuallyTimeout   = 300 * time.Second
    17  	CFConsistentlyTimeout = 500 * time.Millisecond
    18  	RealIsolationSegment  = "persistent_isolation_segment"
    19  	DockerImage           = "cloudfoundry/diego-docker-app-custom"
    20  )
    21  
    22  var (
    23  	// Suite Level
    24  	apiURL            string
    25  	skipSSLValidation bool
    26  	ReadOnlyOrg       string
    27  	ReadOnlySpace     string
    28  
    29  	// Per Test Level
    30  	homeDir string
    31  )
    32  
    33  func TestIsolated(t *testing.T) {
    34  	RegisterFailHandler(Fail)
    35  	reporters := []Reporter{}
    36  
    37  	prBuilderReporter := helpers.GetPRBuilderReporter()
    38  	if prBuilderReporter != nil {
    39  		reporters = append(reporters, prBuilderReporter)
    40  	}
    41  
    42  	RunSpecsWithDefaultAndCustomReporters(t, "Isolated Integration Suite", reporters)
    43  }
    44  
    45  var _ = SynchronizedBeforeSuite(func() []byte {
    46  	GinkgoWriter.Write([]byte("==============================Global FIRST Node Synchronized Before Each=============================="))
    47  	SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    48  	SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    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  	GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each=============================="))
    58  
    59  	return nil
    60  }, func(_ []byte) {
    61  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    62  	// Ginkgo Globals
    63  	SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    64  	SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    65  
    66  	// Setup common environment variables
    67  	helpers.TurnOffColors()
    68  
    69  	ReadOnlyOrg, ReadOnlySpace = helpers.SetupReadOnlyOrgAndSpace()
    70  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    71  })
    72  
    73  var _ = SynchronizedAfterSuite(func() {
    74  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    75  	homeDir = helpers.SetHomeDir()
    76  	helpers.SetAPI()
    77  	helpers.LoginCF()
    78  	helpers.QuickDeleteOrg(ReadOnlyOrg)
    79  	helpers.DestroyHomeDir(homeDir)
    80  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    81  }, func() {
    82  	outputRoot := os.Getenv(helpers.PRBuilderOutputEnvVar)
    83  	if outputRoot != "" {
    84  		helpers.WriteFailureSummary(outputRoot, "summary_ivi.txt")
    85  	}
    86  })
    87  
    88  var _ = BeforeEach(func() {
    89  	GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
    90  	homeDir = helpers.SetHomeDir()
    91  	apiURL, skipSSLValidation = helpers.SetAPI()
    92  	GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
    93  })
    94  
    95  var _ = AfterEach(func() {
    96  	GinkgoWriter.Write([]byte("==============================Global After Each==============================\n"))
    97  	helpers.DestroyHomeDir(homeDir)
    98  	GinkgoWriter.Write([]byte("==============================End of Global After Each=============================="))
    99  })