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