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