github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+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/api/cloudcontroller/ccversion"
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  	"code.cloudfoundry.org/cli/integration/helpers/fakeservicebroker"
    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  func CommonTestIsolated(t *testing.T) {
    23  	RegisterFailHandler(Fail)
    24  	RunSpecs(t, "Isolated Integration Suite")
    25  }
    26  
    27  func CommonGinkgoSetup(
    28  	// Per suite Level
    29  	failureSummaryFilename string,
    30  	apiURL *string,
    31  	skipSSLValidation *bool,
    32  	readOnlyOrg *string,
    33  	readOnlySpace *string,
    34  
    35  	// Per test level
    36  	homeDir *string,
    37  ) interface{} {
    38  	var _ = SynchronizedBeforeSuite(func() []byte {
    39  		_, _ = GinkgoWriter.Write([]byte("==============================Global FIRST Node Synchronized Before Each=============================="))
    40  		SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    41  		SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    42  
    43  		helpers.SetupSynchronizedSuite(func() {
    44  			helpers.EnableFeatureFlag("diego_docker")
    45  
    46  			if helpers.IsVersionMet(ccversion.MinVersionShareServiceV3) {
    47  				helpers.EnableFeatureFlag("service_instance_sharing")
    48  			}
    49  		})
    50  
    51  		fakeservicebroker.Setup()
    52  
    53  		_, _ = GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each=============================="))
    54  
    55  		return nil
    56  	}, func(_ []byte) {
    57  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    58  		// Ginkgo Globals
    59  		SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    60  		SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    61  
    62  		// Setup common environment variables
    63  		helpers.TurnOffColors()
    64  
    65  		*readOnlyOrg, *readOnlySpace = helpers.SetupReadOnlyOrgAndSpace()
    66  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    67  	})
    68  
    69  	var _ = SynchronizedAfterSuite(func() {
    70  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    71  		*homeDir = helpers.SetHomeDir()
    72  		helpers.SetAPI()
    73  		helpers.LoginCF()
    74  		fakeservicebroker.Cleanup()
    75  		helpers.QuickDeleteOrg(*readOnlyOrg)
    76  		helpers.DestroyHomeDir(*homeDir)
    77  		_, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    78  	}, func() {})
    79  
    80  	var _ = BeforeEach(func() {
    81  		_, _ = GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
    82  		*homeDir = helpers.SetHomeDir()
    83  		*apiURL, *skipSSLValidation = helpers.SetAPI()
    84  		_, _ = GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
    85  	})
    86  
    87  	var _ = AfterEach(func() {
    88  		_, _ = GinkgoWriter.Write([]byte("==============================Global After Each==============================\n"))
    89  		helpers.DestroyHomeDir(*homeDir)
    90  		_, _ = GinkgoWriter.Write([]byte("==============================End of Global After Each=============================="))
    91  	})
    92  
    93  	return nil
    94  }