github.com/willmadison/cli@v6.40.1-0.20181018160101-29d5937903ff+incompatible/integration/v6/push/app_flags_test.go (about)

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"regexp"
     6  	"time"
     7  
     8  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  	. "github.com/onsi/gomega/gbytes"
    14  	. "github.com/onsi/gomega/gexec"
    15  )
    16  
    17  var _ = Describe("push with various flags and no manifest", func() {
    18  	var (
    19  		appName string
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		appName = helpers.NewAppName()
    24  	})
    25  
    26  	When("the API version is below 3.27.0 and health check type is not http", func() {
    27  		BeforeEach(func() {
    28  			helpers.SkipIfVersionAtLeast(ccversion.MinVersionApplicationFlowV3)
    29  		})
    30  
    31  		It("creates the app with the specified settings, with the health check type", func() {
    32  			helpers.WithHelloWorldApp(func(dir string) {
    33  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    34  					PushCommandName, appName,
    35  					"-b", "staticfile_buildpack",
    36  					"-c", fmt.Sprintf("echo 'hi' && %s", helpers.StaticfileBuildpackStartCommand),
    37  					"-u", "port", //works if this stuff is commentted out
    38  					"-k", "300M",
    39  					"-i", "2",
    40  					"-m", "70M",
    41  					"-s", "cflinuxfs2",
    42  					"-t", "180",
    43  				)
    44  				Eventually(session).Should(Say("Getting app info\\.\\.\\."))
    45  				Eventually(session).Should(Say("Creating app with these attributes\\.\\.\\."))
    46  				Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
    47  				Eventually(session).Should(Say("(?m)\\s+buildpacks:\\s+\\+\\s+staticfile_buildpack"))
    48  				Eventually(session).Should(Say("\\s+command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
    49  				Eventually(session).Should(Say("\\s+disk quota:\\s+300M"))
    50  				Eventually(session).Should(Say("\\s+health check timeout:\\s+180"))
    51  				Eventually(session).Should(Say("\\s+health check type:\\s+port"))
    52  				Eventually(session).Should(Say("\\s+instances:\\s+2"))
    53  				Eventually(session).Should(Say("\\s+memory:\\s+70M"))
    54  				Eventually(session).Should(Say("\\s+stack:\\s+cflinuxfs2"))
    55  				Eventually(session).Should(Say("\\s+routes:"))
    56  				Eventually(session).Should(Say("(?i)\\+\\s+%s.%s", appName, helpers.DefaultSharedDomain()))
    57  				Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
    58  				Eventually(session).Should(Say("Uploading files\\.\\.\\."))
    59  				Eventually(session).Should(Say("100.00%"))
    60  				Eventually(session).Should(Say("Waiting for API to complete processing files\\.\\.\\."))
    61  				helpers.ConfirmStagingLogs(session)
    62  				Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
    63  				Eventually(session).Should(Say("requested state:\\s+started"))
    64  				Eventually(session).Should(Say("start command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
    65  				Eventually(session).Should(Exit(0))
    66  			})
    67  
    68  			// output is different from when API version is above 3.27.0
    69  			session := helpers.CF("app", appName)
    70  			Eventually(session).Should(Say("name:\\s+%s", appName))
    71  			Eventually(session).Should(Say("instances:\\s+\\d/2"))
    72  			Eventually(session).Should(Say("usage:\\s+70M x 2"))
    73  			Eventually(session).Should(Say("stack:\\s+cflinuxfs2"))
    74  			Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack"))
    75  			Eventually(session).Should(Say("#0.* of 70M"))
    76  			Eventually(session).Should(Exit(0))
    77  		})
    78  	})
    79  
    80  	When("the API version is above 3.27.0 and health check type is not http", func() {
    81  		BeforeEach(func() {
    82  			helpers.SkipIfVersionLessThan(ccversion.MinVersionApplicationFlowV3)
    83  		})
    84  
    85  		It("creates the app with the specified settings, with the health check type", func() {
    86  			helpers.WithHelloWorldApp(func(dir string) {
    87  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    88  					PushCommandName, appName,
    89  					"-b", "staticfile_buildpack",
    90  					"-c", fmt.Sprintf("echo 'hi' && %s", helpers.StaticfileBuildpackStartCommand),
    91  					"-u", "port", //works if this stuff is commentted out
    92  					"-k", "300M",
    93  					"-i", "2",
    94  					"-m", "70M",
    95  					"-s", "cflinuxfs2",
    96  					"-t", "180",
    97  				)
    98  				Eventually(session).Should(Say("Getting app info\\.\\.\\."))
    99  				Eventually(session).Should(Say("Creating app with these attributes\\.\\.\\."))
   100  				Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
   101  				Eventually(session).Should(Say("(?m)\\s+buildpacks:\\s+\\+\\s+staticfile_buildpack"))
   102  				Eventually(session).Should(Say("\\s+command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
   103  				Eventually(session).Should(Say("\\s+disk quota:\\s+300M"))
   104  				Eventually(session).Should(Say("\\s+health check timeout:\\s+180"))
   105  				Eventually(session).Should(Say("\\s+health check type:\\s+port"))
   106  				Eventually(session).Should(Say("\\s+instances:\\s+2"))
   107  				Eventually(session).Should(Say("\\s+memory:\\s+70M"))
   108  				Eventually(session).Should(Say("\\s+stack:\\s+cflinuxfs2"))
   109  				Eventually(session).Should(Say("\\s+routes:"))
   110  				Eventually(session).Should(Say("(?i)\\+\\s+%s.%s", appName, helpers.DefaultSharedDomain()))
   111  				Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
   112  				Eventually(session).Should(Say("Uploading files\\.\\.\\."))
   113  				Eventually(session).Should(Say("100.00%"))
   114  				Eventually(session).Should(Say("Waiting for API to complete processing files\\.\\.\\."))
   115  				helpers.ConfirmStagingLogs(session)
   116  				Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
   117  				Eventually(session).Should(Say("requested state:\\s+started"))
   118  				Eventually(session).Should(Say("start command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
   119  				Eventually(session).Should(Exit(0))
   120  			})
   121  
   122  			// output is different from when API version is below 3.27.0
   123  			time.Sleep(5 * time.Second)
   124  			session := helpers.CF("app", appName)
   125  			Eventually(session).Should(Say("name:\\s+%s", appName))
   126  			Eventually(session).Should(Say("last uploaded:\\s+\\w{3} \\d{1,2} \\w{3} \\d{2}:\\d{2}:\\d{2} \\w{3} \\d{4}"))
   127  			Eventually(session).Should(Say("stack:\\s+cflinuxfs2"))
   128  			Eventually(session).Should(Say("buildpacks:\\s+staticfile"))
   129  			Eventually(session).Should(Say("type:\\s+web"))
   130  			Eventually(session).Should(Say("instances:\\s+2/2"))
   131  			Eventually(session).Should(Say("memory usage:\\s+70M"))
   132  			Eventually(session).Should(Say("\\s+state\\s+since\\s+cpu\\s+memory\\s+disk"))
   133  			Eventually(session).Should(Say("#0\\s+running\\s+\\d{4}-[01]\\d-[0-3]\\dT[0-2][0-9]:[0-5]\\d:[0-5]\\dZ"))
   134  			Eventually(session).Should(Exit(0))
   135  		})
   136  	})
   137  
   138  	When("the API version is below 3.27.0 and health check type is http", func() {
   139  		BeforeEach(func() {
   140  			helpers.SkipIfVersionAtLeast(ccversion.MinVersionApplicationFlowV3)
   141  		})
   142  
   143  		It("creates the app with the specified settings, with the health check type being 'http'", func() {
   144  			helpers.WithHelloWorldApp(func(dir string) {
   145  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
   146  					PushCommandName, appName,
   147  					"-b", "staticfile_buildpack",
   148  					"-c", fmt.Sprintf("echo 'hi' && %s", helpers.StaticfileBuildpackStartCommand),
   149  					"-u", "http",
   150  					"-k", "300M",
   151  					"-i", "2",
   152  					"-m", "70M",
   153  					"-s", "cflinuxfs2",
   154  					"-t", "180",
   155  				)
   156  
   157  				Eventually(session).Should(Say("Getting app info\\.\\.\\."))
   158  				Eventually(session).Should(Say("Creating app with these attributes\\.\\.\\."))
   159  				Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
   160  				Eventually(session).Should(Say("(?m)\\s+buildpacks:\\s+\\+\\s+staticfile_buildpack"))
   161  				Eventually(session).Should(Say("\\s+command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
   162  				Eventually(session).Should(Say("\\s+disk quota:\\s+300M"))
   163  				Eventually(session).Should(Say("\\s+health check http endpoint:\\s+/"))
   164  				Eventually(session).Should(Say("\\s+health check timeout:\\s+180"))
   165  				Eventually(session).Should(Say("\\s+health check type:\\s+http"))
   166  				Eventually(session).Should(Say("\\s+instances:\\s+2"))
   167  				Eventually(session).Should(Say("\\s+memory:\\s+70M"))
   168  				Eventually(session).Should(Say("\\s+stack:\\s+cflinuxfs2"))
   169  				Eventually(session).Should(Say("\\s+routes:"))
   170  				Eventually(session).Should(Say("(?i)\\+\\s+%s.%s", appName, helpers.DefaultSharedDomain()))
   171  				Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
   172  				Eventually(session).Should(Say("Uploading files\\.\\.\\."))
   173  				Eventually(session).Should(Say("100.00%"))
   174  				Eventually(session).Should(Say("Waiting for API to complete processing files\\.\\.\\."))
   175  				helpers.ConfirmStagingLogs(session)
   176  				Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
   177  				Eventually(session).Should(Say("requested state:\\s+started"))
   178  				Eventually(session).Should(Say("start command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
   179  				Eventually(session).Should(Exit(0))
   180  			})
   181  
   182  			// output is different from when API version is above 3.27.0
   183  			session := helpers.CF("app", appName)
   184  			Eventually(session).Should(Say("name:\\s+%s", appName))
   185  			Eventually(session).Should(Say("instances:\\s+\\d/2"))
   186  			Eventually(session).Should(Say("usage:\\s+70M x 2"))
   187  			Eventually(session).Should(Say("stack:\\s+cflinuxfs2"))
   188  			Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack"))
   189  			Eventually(session).Should(Say("#0.* of 70M"))
   190  			Eventually(session).Should(Exit(0))
   191  		})
   192  	})
   193  
   194  	When("the API version is above 3.27.0 and health check type is http", func() {
   195  		BeforeEach(func() {
   196  			helpers.SkipIfVersionLessThan(ccversion.MinVersionApplicationFlowV3)
   197  		})
   198  
   199  		It("creates the app with the specified settings, with the health check type being 'http'", func() {
   200  			helpers.WithHelloWorldApp(func(dir string) {
   201  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
   202  					PushCommandName, appName,
   203  					"-b", "staticfile_buildpack",
   204  					"-c", fmt.Sprintf("echo 'hi' && %s", helpers.StaticfileBuildpackStartCommand),
   205  					"-u", "http",
   206  					"-k", "300M",
   207  					"-i", "2",
   208  					"-m", "70M",
   209  					"-s", "cflinuxfs2",
   210  					"-t", "180",
   211  				)
   212  
   213  				Eventually(session).Should(Say("Getting app info\\.\\.\\."))
   214  				Eventually(session).Should(Say("Creating app with these attributes\\.\\.\\."))
   215  				Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
   216  				Eventually(session).Should(Say("(?m)\\s+buildpacks:\\s+\\+\\s+staticfile_buildpack"))
   217  				Eventually(session).Should(Say("\\s+command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
   218  				Eventually(session).Should(Say("\\s+disk quota:\\s+300M"))
   219  				Eventually(session).Should(Say("\\s+health check http endpoint:\\s+/"))
   220  				Eventually(session).Should(Say("\\s+health check timeout:\\s+180"))
   221  				Eventually(session).Should(Say("\\s+health check type:\\s+http"))
   222  				Eventually(session).Should(Say("\\s+instances:\\s+2"))
   223  				Eventually(session).Should(Say("\\s+memory:\\s+70M"))
   224  				Eventually(session).Should(Say("\\s+stack:\\s+cflinuxfs2"))
   225  				Eventually(session).Should(Say("\\s+routes:"))
   226  				Eventually(session).Should(Say("(?i)\\+\\s+%s.%s", appName, helpers.DefaultSharedDomain()))
   227  				Eventually(session).Should(Say("Mapping routes\\.\\.\\."))
   228  				Eventually(session).Should(Say("Uploading files\\.\\.\\."))
   229  				Eventually(session).Should(Say("100.00%"))
   230  				Eventually(session).Should(Say("Waiting for API to complete processing files\\.\\.\\."))
   231  				helpers.ConfirmStagingLogs(session)
   232  				Eventually(session).Should(Say("Waiting for app to start\\.\\.\\."))
   233  				Eventually(session).Should(Say("requested state:\\s+started"))
   234  				Eventually(session).Should(Say("start command:\\s+echo 'hi' && %s", regexp.QuoteMeta(helpers.StaticfileBuildpackStartCommand)))
   235  				Eventually(session).Should(Exit(0))
   236  			})
   237  
   238  			// output is different from when API version is below 3.27.0
   239  
   240  			time.Sleep(5 * time.Second)
   241  			session := helpers.CF("app", appName)
   242  			Eventually(session).Should(Say("name:\\s+%s", appName))
   243  			Eventually(session).Should(Say("last uploaded:\\s+\\w{3} \\d{1,2} \\w{3} \\d{2}:\\d{2}:\\d{2} \\w{3} \\d{4}"))
   244  			Eventually(session).Should(Say("stack:\\s+cflinuxfs2"))
   245  			Eventually(session).Should(Say("buildpacks:\\s+staticfile"))
   246  			Eventually(session).Should(Say("type:\\s+web"))
   247  			Eventually(session).Should(Say("instances:\\s+2/2"))
   248  			Eventually(session).Should(Say("memory usage:\\s+70M"))
   249  			Eventually(session).Should(Say("\\s+state\\s+since\\s+cpu\\s+memory\\s+disk"))
   250  			Eventually(session).Should(Say("#0\\s+running\\s+\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z"))
   251  			Eventually(session).Should(Exit(0))
   252  		})
   253  	})
   254  })