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

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"os"
     7  	"testing"
     8  	"time"
     9  
    10  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
    11  	"code.cloudfoundry.org/cli/integration/helpers"
    12  	. "github.com/onsi/ginkgo"
    13  	. "github.com/onsi/gomega"
    14  )
    15  
    16  const (
    17  	CFEventuallyTimeout   = 300 * time.Second
    18  	CFConsistentlyTimeout = 500 * time.Millisecond
    19  	RealIsolationSegment  = "persistent_isolation_segment"
    20  	PushCommandName       = "push"
    21  	PublicDockerImage     = "cloudfoundry/diego-docker-app-custom"
    22  )
    23  
    24  var (
    25  	// Suite Level
    26  	organization string
    27  	space        string
    28  	realDir      string
    29  
    30  	// Per Test Level
    31  	homeDir string
    32  )
    33  
    34  func TestPush(t *testing.T) {
    35  	RegisterFailHandler(Fail)
    36  	reporters := []Reporter{}
    37  
    38  	prBuilderReporter := helpers.GetPRBuilderReporter()
    39  	if prBuilderReporter != nil {
    40  		reporters = append(reporters, prBuilderReporter)
    41  	}
    42  
    43  	RunSpecsWithDefaultAndCustomReporters(t, "Push Integration Suite", reporters)
    44  }
    45  
    46  var _ = SynchronizedBeforeSuite(func() []byte {
    47  	GinkgoWriter.Write([]byte("==============================Global FIRST Node Synchronized Before Each=============================="))
    48  	SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    49  	SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    50  
    51  	helpers.SetupSynchronizedSuite(func() {
    52  		helpers.EnableFeatureFlag("diego_docker")
    53  
    54  		if helpers.IsVersionMet(ccversion.MinVersionShareServiceV3) {
    55  			helpers.EnableFeatureFlag("service_instance_sharing")
    56  		}
    57  	})
    58  
    59  	GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each=============================="))
    60  
    61  	return nil
    62  }, func(_ []byte) {
    63  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    64  	// Ginkgo Globals
    65  	SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    66  	SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    67  
    68  	// Setup common environment variables
    69  	helpers.TurnOffColors()
    70  
    71  	homeDir = helpers.SetHomeDir()
    72  	helpers.SetAPI()
    73  	helpers.LoginCF()
    74  
    75  	organization = helpers.NewOrgName()
    76  	helpers.CreateOrg(organization)
    77  	helpers.TargetOrg(organization)
    78  	helpers.CreateSpace("empty-space")
    79  	helpers.DestroyHomeDir(homeDir)
    80  
    81  	var err error
    82  	realDir, err = ioutil.TempDir("", "push-real-dir")
    83  	Expect(err).ToNot(HaveOccurred())
    84  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    85  })
    86  
    87  var _ = SynchronizedAfterSuite(func() {
    88  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    89  	homeDir = helpers.SetHomeDir()
    90  	helpers.SetAPI()
    91  	helpers.LoginCF()
    92  	helpers.QuickDeleteOrg(organization)
    93  	Expect(os.RemoveAll(realDir)).ToNot(HaveOccurred())
    94  	helpers.DestroyHomeDir(homeDir)
    95  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    96  }, func() {
    97  	outputRoot := os.Getenv(helpers.PRBuilderOutputEnvVar)
    98  	if outputRoot != "" {
    99  		helpers.WriteFailureSummary(outputRoot, "summary_ivp.txt")
   100  	}
   101  })
   102  
   103  var _ = BeforeEach(func() {
   104  	GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
   105  	homeDir = helpers.SetHomeDir()
   106  	helpers.SetAPI()
   107  	space = helpers.NewSpaceName()
   108  	helpers.SetupCF(organization, space)
   109  	GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
   110  })
   111  
   112  var _ = AfterEach(func() {
   113  	GinkgoWriter.Write([]byte("==============================Global After Each=============================="))
   114  	helpers.SetAPI()
   115  	helpers.SetupCF(organization, space)
   116  	helpers.QuickDeleteSpace(space)
   117  	helpers.DestroyHomeDir(homeDir)
   118  })