github.com/orange-cloudfoundry/cli@v7.1.0+incompatible/integration/helpers/commonisolated/common_isolated_setup.go (about)

     1  package commonisolated
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  	"time"
     7  
     8  	"code.cloudfoundry.org/cli/integration/helpers"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  const (
    14  	CFEventuallyTimeout   = 300 * time.Second
    15  	CFConsistentlyTimeout = 500 * time.Millisecond
    16  	RealIsolationSegment  = "persistent_isolation_segment"
    17  	DockerImage           = "cloudfoundry/diego-docker-app-custom"
    18  )
    19  
    20  func CommonTestIsolated(t *testing.T) {
    21  	RegisterFailHandler(Fail)
    22  	RunSpecs(t, "Isolated Integration Suite")
    23  }
    24  
    25  func CommonGinkgoSetup(
    26  	// Per suite Level
    27  	failureSummaryFilename string,
    28  	apiURL *string,
    29  	skipSSLValidation *bool,
    30  	readOnlyOrg *string,
    31  	readOnlySpace *string,
    32  
    33  	// Per test level
    34  	homeDir *string,
    35  ) interface{} {
    36  	var _ = SynchronizedBeforeSuite(func() []byte {
    37  		_, _ = GinkgoWriter.Write([]byte("==============================Global FIRST Node Synchronized Before Each=============================="))
    38  		SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    39  		SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    40  
    41  		helpers.SetupSynchronizedSuite(func() {
    42  			helpers.EnableFeatureFlag("diego_docker")
    43  			helpers.EnableFeatureFlag("service_instance_sharing")
    44  		})
    45  
    46  		_, _ = GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each=============================="))
    47  
    48  		return nil
    49  	}, func(_ []byte) {
    50  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    51  		// Ginkgo Globals
    52  		SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    53  		SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    54  
    55  		// Setup common environment variables
    56  		helpers.TurnOffColors()
    57  
    58  		*readOnlyOrg, *readOnlySpace = helpers.SetupReadOnlyOrgAndSpace()
    59  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    60  	})
    61  
    62  	var _ = SynchronizedAfterSuite(func() {
    63  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    64  		*homeDir = helpers.SetHomeDir()
    65  		helpers.SetAPI()
    66  		helpers.LoginCF()
    67  		helpers.QuickDeleteOrg(*readOnlyOrg)
    68  		helpers.DestroyHomeDir(*homeDir)
    69  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    70  	}, func() {})
    71  
    72  	var _ = BeforeEach(func() {
    73  		_, _ = GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
    74  		*homeDir = helpers.SetHomeDir()
    75  		*apiURL, *skipSSLValidation = helpers.SetAPI()
    76  		_, _ = GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
    77  	})
    78  
    79  	var _ = AfterEach(func() {
    80  		_, _ = GinkgoWriter.Write([]byte("==============================Global After Each==============================\n"))
    81  		helpers.DestroyHomeDir(*homeDir)
    82  		_, _ = GinkgoWriter.Write([]byte("==============================End of Global After Each=============================="))
    83  	})
    84  
    85  	return nil
    86  }