github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/shared/isolated/isolated_suite_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  	"time"
     7  
     8  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  )
    13  
    14  const (
    15  	CFEventuallyTimeout   = 300 * time.Second
    16  	CFConsistentlyTimeout = 500 * time.Millisecond
    17  	RealIsolationSegment  = "persistent_isolation_segment"
    18  	DockerImage           = "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  	reporters := []Reporter{}
    35  
    36  	honeyCombReporter := helpers.GetHoneyCombReporter("Isolated Test Suite")
    37  
    38  	if honeyCombReporter != nil {
    39  		reporters = append(reporters, honeyCombReporter)
    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  })
    83  
    84  var _ = BeforeEach(func() {
    85  	GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
    86  	homeDir = helpers.SetHomeDir()
    87  	apiURL, skipSSLValidation = helpers.SetAPI()
    88  	GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
    89  })
    90  
    91  var _ = AfterEach(func() {
    92  	GinkgoWriter.Write([]byte("==============================Global After Each==============================\n"))
    93  	helpers.DestroyHomeDir(homeDir)
    94  	GinkgoWriter.Write([]byte("==============================End of Global After Each=============================="))
    95  })