github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/v7/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  	PushCommandName       = "push"
    20  	PublicDockerImage     = "cloudfoundry/diego-docker-app-custom"
    21  )
    22  
    23  var (
    24  	// Suite Level
    25  	organization string
    26  	space        string
    27  	realDir      string
    28  
    29  	// Per Test Level
    30  	homeDir string
    31  )
    32  
    33  func TestPush(t *testing.T) {
    34  	RegisterFailHandler(Fail)
    35  	RunSpecs(t, "Push Integration Suite")
    36  }
    37  
    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  	GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each=============================="))
    52  
    53  	return nil
    54  }, func(_ []byte) {
    55  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    56  	// Ginkgo Globals
    57  	SetDefaultEventuallyTimeout(CFEventuallyTimeout)
    58  	SetDefaultConsistentlyDuration(CFConsistentlyTimeout)
    59  
    60  	// Setup common environment variables
    61  	helpers.TurnOffColors()
    62  
    63  	homeDir = helpers.SetHomeDir()
    64  	helpers.SetAPI()
    65  	helpers.LoginCF()
    66  
    67  	organization = helpers.NewOrgName()
    68  	helpers.CreateOrg(organization)
    69  	helpers.TargetOrg(organization)
    70  	helpers.CreateSpace("empty-space")
    71  	helpers.DestroyHomeDir(homeDir)
    72  
    73  	var err error
    74  	realDir, err = ioutil.TempDir("", "push-real-dir")
    75  	Expect(err).ToNot(HaveOccurred())
    76  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode())))
    77  })
    78  
    79  var _ = SynchronizedAfterSuite(func() {
    80  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    81  	homeDir = helpers.SetHomeDir()
    82  	helpers.SetAPI()
    83  	helpers.LoginCF()
    84  	helpers.QuickDeleteOrg(organization)
    85  	Expect(os.RemoveAll(realDir)).ToNot(HaveOccurred())
    86  	helpers.DestroyHomeDir(homeDir)
    87  	GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode())))
    88  }, func() {
    89  })
    90  
    91  var _ = BeforeEach(func() {
    92  	GinkgoWriter.Write([]byte("==============================Global Before Each=============================="))
    93  	homeDir = helpers.SetHomeDir()
    94  	helpers.SetAPI()
    95  	space = helpers.NewSpaceName()
    96  	helpers.SetupCF(organization, space)
    97  	GinkgoWriter.Write([]byte("==============================End of Global Before Each=============================="))
    98  })
    99  
   100  var _ = AfterEach(func() {
   101  	GinkgoWriter.Write([]byte("==============================Global After Each=============================="))
   102  	helpers.SetAPI()
   103  	helpers.SetupCF(organization, space)
   104  	helpers.QuickDeleteSpace(space)
   105  	helpers.DestroyHomeDir(homeDir)
   106  })