diff --git a/integration/isolated/app_command_test.go b/integration/isolated/app_command_test.go index 3219841531e..146061c8a10 100644 --- a/integration/isolated/app_command_test.go +++ b/integration/isolated/app_command_test.go @@ -116,14 +116,14 @@ applications: disk_quota: 128M routes: - route: %s.%s - - route: %s:0 + - route: %s:1024 `, appName, appName, domainName, tcpDomain.Name)) manifestPath := filepath.Join(appDir, "manifest.yml") err := ioutil.WriteFile(manifestPath, manifestContents, 0666) Expect(err).ToNot(HaveOccurred()) // Create manifest - Eventually(helpers.CF("push", appName, "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack", "--random-route")).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) }) }) @@ -135,7 +135,7 @@ applications: Eventually(session).Should(Say("instances:\\s+2/2")) Eventually(session).Should(Say("isolation segment:\\s+%s", RealIsolationSegment)) Eventually(session).Should(Say("usage:\\s+128M x 2 instances")) - Eventually(session).Should(Say("routes:\\s+[a-z-]+\\.%s, %s:\\d+", domainName, tcpDomain.Name)) + Eventually(session).Should(Say("routes:\\s+[\\w\\d-]+\\.%s, %s:1024", domainName, tcpDomain.Name)) Eventually(session).Should(Say("last uploaded:\\s+\\w{3} [0-3]\\d \\w{3} [0-2]\\d:[0-5]\\d:[0-5]\\d \\w+ \\d{4}")) Eventually(session).Should(Say("stack:\\s+cflinuxfs2")) Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack")) @@ -158,7 +158,7 @@ applications: Eventually(session).Should(Say("requested state:\\s+stopped")) Eventually(session).Should(Say("instances:\\s+0/2")) Eventually(session).Should(Say("usage:\\s+128M x 2 instances")) - Eventually(session).Should(Say("routes:\\s+[a-z-]+.%s, %s:\\d+", domainName, tcpDomain.Name)) + Eventually(session).Should(Say("routes:\\s+[\\w\\d-]+.%s, %s:1024", domainName, tcpDomain.Name)) Eventually(session).Should(Say("last uploaded:")) Eventually(session).Should(Say("stack:\\s+cflinuxfs2")) Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack")) @@ -179,7 +179,7 @@ applications: Eventually(session).Should(Say("requested state:\\s+started")) Eventually(session).Should(Say("instances:\\s+0/0")) Eventually(session).Should(Say("usage:\\s+128M x 0 instances")) - Eventually(session).Should(Say("routes:\\s+[a-z-]+\\.%s, %s:\\d+", domainName, tcpDomain.Name)) + Eventually(session).Should(Say("routes:\\s+[\\w\\d-]+\\.%s, %s:1024", domainName, tcpDomain.Name)) Eventually(session).Should(Say("last uploaded:")) Eventually(session).Should(Say("stack:\\s+cflinuxfs2")) Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack")) diff --git a/integration/isolated/manifest_inheritance_test.go b/integration/isolated/manifest_inheritance_test.go deleted file mode 100644 index f6cedc3d786..00000000000 --- a/integration/isolated/manifest_inheritance_test.go +++ /dev/null @@ -1,1725 +0,0 @@ -package isolated - -import ( - "fmt" - "io/ioutil" - "path/filepath" - "strings" - "time" - - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" -) - -// pushes app with multiple manifests, children being passed in first in the -// array -func pushHelloWorldAppWithManifests(manifests []string) { - helpers.WithHelloWorldApp(func(appDir string) { - pushPath := filepath.Join(appDir, "manifest-0.yml") - for i, manifest := range manifests { - manifestPath := filepath.Join(appDir, fmt.Sprintf("manifest-%d.yml", i)) - manifest = strings.Replace(manifest, "inherit: {some-parent}", fmt.Sprintf("inherit: manifest-%d.yml", i+1), 1) - manifest = strings.Replace(manifest, "path: {some-dir}", fmt.Sprintf("path: %s", appDir), -1) - err := ioutil.WriteFile(manifestPath, []byte(manifest), 0666) - Expect(err).ToNot(HaveOccurred()) - } - Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", "-f", pushPath)).Should(Exit(0)) - }) -} - -func pushDockerWithManifests(manifests []string) { - helpers.WithHelloWorldApp(func(appDir string) { - pushPath := filepath.Join(appDir, "manifest-0.yml") - for i, manifest := range manifests { - manifestPath := filepath.Join(appDir, fmt.Sprintf("manifest-%d.yml", i)) - manifest = strings.Replace(manifest, "inherit: {some-parent}", fmt.Sprintf("inherit: manifest-%d.yml", i+1), 1) - manifest = strings.Replace(manifest, "path: {some-dir}", fmt.Sprintf("path: %s", appDir), -1) - err := ioutil.WriteFile(manifestPath, []byte(manifest), 0666) - Expect(err).ToNot(HaveOccurred()) - } - Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", "-f", pushPath)).Should(Exit()) - }) -} - -// CASE 1: child manifest (no inheritance) -// -// APPLICATION params: -// values (memory, disk), list (routes), map (env vars) -// -// GLOBAL params: -// value, list, map types -// -// APPLICATION and GLOBAL params: -// value: application values override global values -// list: application lists append to global lists -// map: application maps merge & override global maps -// -// -// CASE 2: child + parent manifests (1 level inheritance) -// -// Parent Application & Child Application -// Parent Global & Child Application -// Parent Application & Child Global -// Parent Global & Child Global -// -// Parent Global & Child Global & Child Application -// Parent Application & Child Global & Child Application -// Parent Global & Parent Application & Child Application -// Parent Global & Parent Application & Child Global -// -// Parent Global & Parent Application & Child Global & Child Application -// -// CASE 3: child + parent + super-parent manifests (n+ inheritance) -// Super-parent Global & Parent Global & Parent Application & Child Global -// Super-parent Global & Parent Global & Child Global & Child Application - -var _ = Describe("manifest inheritance in push command", func() { - var ( - orgName string - spaceName string - domainName string - app1Name string - app2Name string - app1MemSize int - app2MemSize int - ) - - BeforeEach(func() { - orgName = helpers.NewOrgName() - spaceName = helpers.NewSpaceName() - app1Name = helpers.PrefixedRandomName("app") - app2Name = helpers.PrefixedRandomName("app") - app1MemSize = 32 - app2MemSize = 32 - - setupCF(orgName, spaceName) - - domainName = fmt.Sprintf("%s.com", helpers.PrefixedRandomName("DOMAIN")) - helpers.NewDomain(orgName, domainName).Create() - }) - - AfterEach(func() { - helpers.QuickDeleteOrg(orgName) - }) - - Context("when there is only one manifest", func() { - Context("when the manifest contains only applications properties", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{fmt.Sprintf(` ---- -applications: -- name: %s - memory: %dM - disk_quota: 128M - buildpack: staticfile_buildpack - path: {some-dir} - routes: - - route: hello.%s - - route: hi.%s - env: - BAR: bar - FOO: foo -- name: %s - memory: %dM - disk_quota: 128M - buildpack: staticfile_buildpack - path: {some-dir} - routes: - - route: hello.%s - - route: hi.%s - env: - BAR: bar - FOO: foo -`, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName)}) - }) - - It("pushes the same applications properties", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "hello\.%s"\, - "hi\.%s" - \]`, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: bar -FOO: foo - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "hello\.%s"\, - "hi\.%s" - \]`, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: bar -FOO: foo - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the manifest contains mainly global properties", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{fmt.Sprintf(` ---- -memory: %dM -disk_quota: 128M -buildpack: staticfile_buildpack -path: {some-dir} -routes: -- route: hello.%s -- route: hi.%s -env: - BAR: bar - FOO: foo -applications: -- name: %s -- name: %s -`, app1MemSize, domainName, domainName, app1Name, app2Name)}) - }) - - It("pushes the same global properties", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "hello\.%s"\, - "hi\.%s" - \]`, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: bar -FOO: foo - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "hello\.%s"\, - "hi\.%s" - \]`, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: bar -FOO: foo - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the manifest contains both applications and global properties", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 64M -disk_quota: 256M -routes: -- route: global-1.%s -- route: global-2.%s -env: - BAR: global - FOO: global -applications: -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: app-1.%s - - route: app-2.%s - env: - BAR: app - BAZ: app -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: app-1.%s - - route: app-2.%s - env: - BAR: app - BAZ: app -`, domainName, domainName, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName)}) - }) - - It("pushes with application properties taking precedence; values are overwritten, lists are appended, and maps are merged", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "global-1\.%s"\, - "global-2\.%s", - "app-1\.%s", - "app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: app -BAZ: app -FOO: global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "global-1\.%s"\, - "global-2\.%s", - "app-1\.%s", - "app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: app -BAZ: app -FOO: global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when there are two manifests", func() { - Context("when the child has applications properties; and the parent has applications properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - BAZ: child-app -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - BAZ: child-app -`, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - fmt.Sprintf(` ---- -applications: -- name: %s - buildpack: staticfile_buildpack - memory: %dM - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - BAZ: parent-app - FOO: parent-app -- name: %s - buildpack: staticfile_buildpack - memory: %dM - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - BAZ: parent-app - FOO: parent-app -`, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - }) - }) - - It("pushes with child application properties taking precedence; values are overwritten, lists are appended, and maps are merged", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-app-1\.%s", - "parent-app-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: child-app -FOO: parent-app - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-app-1\.%s", - "parent-app-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: child-app -FOO: parent-app - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - docker: - image: child-application-image -`, app1Name), - fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: %s -`, app1Name, DockerImage), - }) - }) - - It("pushes with child application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has applications properties; and the parent has global properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - BAZ: child-app -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - BAZ: child-app -`, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 64M -disk_quota: 256M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - BAR: parent-global - BAZ: parent-global - FOO: parent-global -`, domainName, domainName), - }) - SetDefaultEventuallyTimeout(300 * time.Second) - }) - - It("pushes with child application properties taking precedence", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: child-app -FOO: parent-global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: child-app -FOO: parent-global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - docker: - image: child-application-image -`, app1Name), - fmt.Sprintf(` ---- -docker: - image: parent-global-image -`), - }) - }) - - It("pushes with child application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has global properties; and the parent has applications properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -buildpack: staticfile_buildpack -memory: 64M -disk_quota: 256M -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - BAR: child-global - BAZ: child-global -`, domainName, domainName), - fmt.Sprintf(` ---- -applications: -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - BAZ: parent-app - FOO: parent-app -- name: %s - memory: %dM - disk_quota: 128M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - BAZ: parent-app - FOO: parent-app -`, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - }) - SetDefaultEventuallyTimeout(300 * time.Second) - }) - - It("pushes with parent application properties taking precedence", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "child-global-1\.%s"\, - "child-global-2\.%s", - "parent-app-1\.%s", - "parent-app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: parent-app -BAZ: parent-app -FOO: parent-app -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "child-global-1\.%s"\, - "child-global-2\.%s", - "parent-app-1\.%s", - "parent-app-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: parent-app -BAZ: parent-app -FOO: parent-app -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -docker: - image: child-global-image -`), - fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: parent-application-image -`, app1Name), - }) - }) - - It("pushes with parent application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*parent-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has global properties; and the parent has global properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -memory: %dM -disk_quota: 128M -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - BAR: child-global - FOO: child-global -`, app1MemSize, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 64M -disk_quota: 256M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - BAR: parent-global - FOO: parent-global - BAZ: parent-global -applications: -- name: %s -- name: %s -`, domainName, domainName, app1Name, app2Name), - }) - }) - - It("pushes with child global properties taking precedence;", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s"\, - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-global -BAZ: parent-global -FOO: child-global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s"\, - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s" - \]`, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 128`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-global -BAZ: parent-global -FOO: child-global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -docker: - image: child-global-image -`), - fmt.Sprintf(` ---- -docker: - image: %s -applications: -- name: %s -`, DockerImage, app1Name), - }) - }) - - It("pushes with child global docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-global-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has applications and global properties; and the parent has global properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -memory: 128M -disk_quota: 128M -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - FOO: child-global - FIZ: child-global -applications: -- name: %s - memory: %dM - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - FOO: child-app -- name: %s - memory: %dM - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - FOO: child-app -`, domainName, domainName, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 256M -disk_quota: 256M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - BAR: parent-global - FOO: parent-global - FIZ: parent-global - BAZ: parent-global -applications: -- name: %s -- name: %s -`, domainName, domainName, app1Name, app2Name), - }) - }) - - It("pushes with child application taking precedence over child global over parent global", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s"\, - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "child-app-1\.%s", - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-global -FIZ: child-global -FOO: child-app - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s"\, - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "child-app-1\.%s", - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-global -FIZ: child-global -FOO: child-app - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - docker: - image: child-application-image -docker: - image: child-global-image -`, app1Name), - fmt.Sprintf(` ---- -docker: - image: parent-image -`), - }) - }) - - It("pushes with child application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has applications and global properties; and the parent has applications properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -memory: %dM -disk_quota: 128M -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - FOO: child-global - FIZ: child-global -applications: -- name: %s - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - FOO: child-app -- name: %s - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - FOO: child-app -`, app1MemSize, domainName, domainName, app1Name, domainName, domainName, app2Name, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -applications: -- name: %s - memory: 256M - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - FOO: parent-app - FIZ: parent-app - BAZ: parent-app -- name: %s - memory: 256M - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - FOO: parent-app - FIZ: parent-app - BAZ: parent-app -`, app1Name, domainName, domainName, app2Name, domainName, domainName), - }) - }) - - It("pushes with child application taking precedence over child global over parent application", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s", - "child-app-1\.%s", - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-app -FIZ: child-global -FOO: child-app - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s", - "child-app-1\.%s", - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-app -FIZ: child-global -FOO: child-app - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - docker: - image: child-application-image -docker: - image: child-global-image -`, app1Name), - fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: %s -`, app1Name, DockerImage), - }) - }) - - It("pushes with child application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has applications properties; and the parent has applications and global properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - memory: %dM - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - FOO: child-app -- name: %s - memory: %dM - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - BAR: child-app - FOO: child-app -`, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 128M -disk_quota: 128M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - FOO: parent-global - FIZ: parent-global -applications: -- name: %s - memory: 256M - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - FOO: parent-app - FIZ: parent-app - BAZ: parent-app -- name: %s - memory: 256M - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - BAR: parent-app - FOO: parent-app - FIZ: parent-app - BAZ: parent-app -`, domainName, domainName, app1Name, domainName, domainName, app2Name, domainName, domainName), - }) - }) - - It("pushes with child application taking precedence over parent application over child global", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s", - "child-app-1\.%s", - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-app -FIZ: parent-global -FOO: child-app - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s", - "child-app-1\.%s", - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-app -FIZ: parent-global -FOO: child-app - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - docker: - image: child-application-image -`, app1Name), - fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: %s -docker: - image: %s -`, app1Name, DockerImage, DockerImage), - }) - }) - - It("pushes with child application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has global properties; and the parent has applications and global properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -memory: 128M -disk_quota: 128M -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - FOO: child-global - FIZ: child-global -`, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - FIZ: parent-global - ZOOM: parent-global -applications: -- name: %s - memory: %dM - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - FOO: parent-app - BAZ: parent-app -- name: %s - memory: %dM - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - FOO: parent-app - BAZ: parent-app -`, domainName, domainName, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - }) - }) - - It("pushes with parent application taking precedence over child global over parent global", func() { - session := helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 256`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAZ: parent-app -FIZ: child-global -FOO: parent-app -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 256`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAZ: parent-app -FIZ: child-global -FOO: parent-app -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -docker: - image: child-global-image -`), - fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: parent-application-image -docker: - image: parent-global-image -`, app1Name), - }) - }) - - It("pushes with parent application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*parent-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the child has applications and global properties; and the parent has applications and global properties", func() { - Context("when the app is a buildpack app", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -instances: 2 -memory: 128M -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - FOO: child-global - FIZ: child-global -applications: -- name: %s - memory: %dM - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - FOO: child-app - BAR: child-app -- name: %s - memory: %dM - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - FOO: child-app - BAR: child-app -`, domainName, domainName, app1Name, app1MemSize, domainName, domainName, app2Name, app2MemSize, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 256M -disk_quota: 256M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - FIZ: parent-global - ZOOM: parent-global -applications: -- name: %s - memory: 256M - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - FIZ: parent-app - BAZ: parent-app -- name: %s - memory: 256M - disk_quota: 256M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - FIZ: parent-app - BAZ: parent-app -`, domainName, domainName, app1Name, domainName, domainName, app2Name, domainName, domainName), - }) - }) - - It("pushes with parent application taking precedence over child global", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say("instances.*2")) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-app -FIZ: child-global -FOO: child-app -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("app", app2Name) - Eventually(session.Out).Should(Say("instances.*2")) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app2MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -BAZ: parent-app -FIZ: child-global -FOO: child-app -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app is a Docker app", func() { - BeforeEach(func() { - pushDockerWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -applications: -- name: %s - docker: - image: child-application-image -docker: - image: child-global-image -`, app1Name), - fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: %s -docker: - image: %s -`, app1Name, DockerImage, DockerImage), - }) - }) - - It("pushes with child application docker image properties taking precedence", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say(`docker image:\s*child-application-image`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - }) - - Context("when there are 3 manifests", func() { - Context("when super-parent has globals, parent has globals, and child has app and globals", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -memory: %dM -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - FOO: child-global - FIZ: child-global -applications: -- name: %s - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - FOO: child-app - BAR: child-app -- name: %s - disk_quota: 64M - path: {some-dir} - routes: - - route: child-app-1.%s - - route: child-app-2.%s - env: - FOO: child-app - BAR: child-app -`, app1MemSize, domainName, domainName, app1Name, domainName, domainName, app2Name, domainName, domainName), - fmt.Sprintf(` ---- -inherit: {some-parent} -instances: 2 -memory: 256M -disk_quota: 256M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - ZOOM: parent-global - FIZ: parent-global -`, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 512M -disk_quota: 512M -path: {some-dir} -routes: -- route: super-parent-global-1.%s -- route: super-parent-global-2.%s -env: - MOON: super-parent-global - ZOOM: super-parent-global -`, domainName, domainName), - }) - }) - - It("pushes with child application taking precedence over child global over parent global over super-parent global", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say("instances.*2")) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "super-parent-global-1\.%s", - "super-parent-global-2\.%s", - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -FIZ: child-global -FOO: child-app -MOON: super-parent-global -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("app", app2Name) - Eventually(session.Out).Should(Say("instances.*2")) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "super-parent-global-1\.%s", - "super-parent-global-2\.%s", - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "child-app-1\.%s"\, - "child-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: child-app -FIZ: child-global -FOO: child-app -MOON: super-parent-global -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when super-parent has globals, parent has app and globals, and child has globals", func() { - BeforeEach(func() { - pushHelloWorldAppWithManifests([]string{ - fmt.Sprintf(` ---- -inherit: {some-parent} -memory: %dM -path: {some-dir} -routes: -- route: child-global-1.%s -- route: child-global-2.%s -env: - FOO: child-global - FIZ: child-global - JUNE: child-global -`, app1MemSize, domainName, domainName), - fmt.Sprintf(` ---- -inherit: {some-parent} -instances: 2 -memory: 256M -disk_quota: 256M -path: {some-dir} -routes: -- route: parent-global-1.%s -- route: parent-global-2.%s -env: - ZOOM: parent-global - FIZ: parent-global -applications: -- name: %s - disk_quota: 64M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - FOO: parent-app - BAR: parent-app -- name: %s - disk_quota: 64M - path: {some-dir} - routes: - - route: parent-app-1.%s - - route: parent-app-2.%s - env: - FOO: parent-app - BAR: parent-app -`, domainName, domainName, app1Name, domainName, domainName, app2Name, domainName, domainName), - fmt.Sprintf(` ---- -buildpack: staticfile_buildpack -memory: 512M -disk_quota: 512M -path: {some-dir} -routes: -- route: super-parent-global-1.%s -- route: super-parent-global-2.%s -env: - MOON: super-parent-global - ZOOM: super-parent-global - JUNE: super-parent-global -`, domainName, domainName), - }) - }) - - It("pushes with child application taking precedence over child global over parent global over super-parent global", func() { - session := helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say("instances.*2")) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app1Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "super-parent-global-1\.%s", - "super-parent-global-2\.%s", - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: parent-app -FIZ: child-global -FOO: parent-app -JUNE: child-global -MOON: super-parent-global -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("app", app1Name) - Eventually(session.Out).Should(Say("instances.*2")) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("env", app2Name) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say(`"application_uris": \[ - "super-parent-global-1\.%s", - "super-parent-global-2\.%s", - "parent-global-1\.%s", - "parent-global-2\.%s", - "child-global-1\.%s", - "child-global-2\.%s", - "parent-app-1\.%s"\, - "parent-app-2\.%s" - \]`, domainName, domainName, domainName, domainName, domainName, domainName, domainName, domainName)) - Eventually(session.Out).Should(Say(`"disk": 64`)) - Eventually(session.Out).Should(Say(`"mem": %d`, app1MemSize)) - Eventually(session.Out).Should(Say(`User-Provided: -BAR: parent-app -FIZ: child-global -FOO: parent-app -JUNE: child-global -MOON: super-parent-global -ZOOM: parent-global - -`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) -}) diff --git a/integration/isolated/push_command_test.go b/integration/isolated/push_command_test.go deleted file mode 100644 index 8db0578632f..00000000000 --- a/integration/isolated/push_command_test.go +++ /dev/null @@ -1,200 +0,0 @@ -package isolated - -import ( - "crypto/rand" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "runtime" - - "code.cloudfoundry.org/cli/integration/helpers" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" -) - -var _ = Describe("Push", func() { - Context("when the environment is set up correctly", func() { - var ( - orgName string - spaceName string - ) - - BeforeEach(func() { - orgName = helpers.NewOrgName() - spaceName = helpers.NewSpaceName() - setupCF(orgName, spaceName) - }) - - AfterEach(func() { - helpers.QuickDeleteOrg(orgName) - }) - - Context("when manifest contains non-string env values", func() { - var appName string - - BeforeEach(func() { - appName = helpers.PrefixedRandomName("app") - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - env: - big_float: 123456789.12345678 - big_int: 123412341234 - bool: true - small_int: 7 - string: "some-string" -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - // Create manifest and add big numbers - Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - }) - - It("converts all env values to string", func() { - session := helpers.CF("env", appName) - Eventually(session.Out).Should(Say("OK")) - Eventually(session.Out).Should(Say("big_float: 123456789.12345678")) - Eventually(session.Out).Should(Say("big_int: 123412341234")) - Eventually(session.Out).Should(Say("bool: true")) - Eventually(session.Out).Should(Say("small_int: 7")) - Eventually(session.Out).Should(Say("string: some-string")) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app has over 260 character paths", func() { - var tmpDir string - - BeforeEach(func() { - Skip("Unskip when #134888875 is complete") - var err error - tmpDir, err = ioutil.TempDir("", "") - Expect(err).ToNot(HaveOccurred()) - - dirName := "dir_name" - dirNames := []string{} - for i := 0; i < 32; i++ { // minimum 300 chars, including separators - dirNames = append(dirNames, dirName) - } - - fullPath := filepath.Join(tmpDir, filepath.Join(dirNames...)) - if runtime.GOOS == "windows" { - // `\\?\` is used to skip Windows' file name processor, which imposes - // length limits. Search MSDN for 'Maximum Path Length Limitation' for - // more. - fullPath = `\\?\` + fullPath - } - err = os.MkdirAll(fullPath, os.ModeDir|os.ModePerm) - Expect(err).NotTo(HaveOccurred()) - - err = ioutil.WriteFile(filepath.Join(fullPath, "index.html"), []byte("hello world"), 0666) - Expect(err).ToNot(HaveOccurred()) - }) - - It("successfully pushes the app", func() { - defer os.RemoveAll(tmpDir) - appName := helpers.PrefixedRandomName("APP") - session := helpers.CF("push", appName, "-p", tmpDir, "-b", "staticfile_buildpack") - Eventually(session).Should(Say("1 of 1 instances running")) - Eventually(session).Should(Say("App %s was started using this command", appName)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when pushing with manifest routes and specifying the -n flag", func() { - var ( - quotaName string - appDir string - manifestPath string - privateDomain helpers.Domain - sharedDomain helpers.Domain - tcpDomain helpers.Domain - ) - - BeforeEach(func() { - quotaName = helpers.PrefixedRandomName("INTEGRATION-QUOTA") - - session := helpers.CF("create-quota", quotaName, "-m", "10G", "-r", "10", "--reserved-route-ports", "4") - Eventually(session).Should(Exit(0)) - session = helpers.CF("set-quota", orgName, quotaName) - Eventually(session).Should(Exit(0)) - - privateDomain = helpers.NewDomain(orgName, helpers.DomainName("private")) - privateDomain.Create() - sharedDomain = helpers.NewDomain(orgName, helpers.DomainName("shared")) - sharedDomain.CreateShared() - tcpDomain = helpers.NewDomain(orgName, helpers.DomainName("tcp")) - tcpDomain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode())) - - var err error - appDir, err = ioutil.TempDir("", "simple-app") - Expect(err).ToNot(HaveOccurred()) - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: app-with-routes - memory: 100M - instances: 1 - path: . - routes: - - route: %s - - route: %s - - route: manifest-host.%s/path - - route: %s:0 -`, privateDomain.Name, sharedDomain.Name, sharedDomain.Name, tcpDomain.Name)) - manifestPath = filepath.Join(appDir, "manifest.yml") - err = ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - err = ioutil.WriteFile(filepath.Join(appDir, "index.html"), []byte("hello world"), 0666) - Expect(err).ToNot(HaveOccurred()) - }) - - It("should set or replace the route's hostname with the flag value", func() { - defer os.RemoveAll(appDir) - var session *Session - session = helpers.CF("push", helpers.PrefixedRandomName("APP"), "-p", appDir, "-n", "flag-hostname", "-b", "staticfile_buildpack", "-f", manifestPath, "--random-route") - - Eventually(session).Should(Say("Creating route flag-hostname.%s...\nOK", privateDomain.Name)) - Eventually(session).Should(Say("Creating route flag-hostname.%s...\nOK", sharedDomain.Name)) - Eventually(session).Should(Say("Creating route flag-hostname.%s/path...\nOK", sharedDomain.Name)) - Eventually(session).Should(Say("Creating random route for %s...\nOK", tcpDomain.Name)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("pushing an app that already exists", func() { - It("uses resource matching", func() { - randomBytes := make([]byte, 65537) - _, err := rand.Read(randomBytes) - Expect(err).ToNot(HaveOccurred()) - - appName := helpers.PrefixedRandomName("app") - - helpers.WithHelloWorldApp(func(appDir string) { - path := filepath.Join(appDir, "large.txt") - err = ioutil.WriteFile(path, randomBytes, 0666) - Expect(err).ToNot(HaveOccurred()) - - session := helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack") - Eventually(session.Out).Should(Say("Uploading .+, 3 files")) - Eventually(session).Should(Exit(0)) - - session = helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack") - Eventually(session.Out).Should(Say("Uploading .+, 2 files")) - Eventually(session).Should(Exit(0)) - }) - }) - }) - }) -}) diff --git a/integration/isolated/push_command_with_app_dir_test.go b/integration/isolated/push_command_with_app_dir_test.go deleted file mode 100644 index 6d0d69340dd..00000000000 --- a/integration/isolated/push_command_with_app_dir_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package isolated - -import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" -) - -var _ = Describe("Push with app directory", func() { - Context("when the specified app directory does not exist", func() { - It("displays a path does not exist error, help, and exits 1", func() { - session := helpers.CF("push", "-f", "./non-existant-dir/") - Eventually(session.Err).Should(Say("Incorrect Usage: The specified path './non-existant-dir/' does not exist.")) - Eventually(session.Out).Should(Say("NAME:")) - Eventually(session.Out).Should(Say("USAGE:")) - Eventually(session).Should(Exit(1)) - }) - }) -}) diff --git a/integration/isolated/push_command_with_health_check_test.go b/integration/isolated/push_command_with_health_check_test.go deleted file mode 100644 index 716c6b63157..00000000000 --- a/integration/isolated/push_command_with_health_check_test.go +++ /dev/null @@ -1,354 +0,0 @@ -package isolated - -import ( - "fmt" - "io/ioutil" - "path/filepath" - - "code.cloudfoundry.org/cli/integration/helpers" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" -) - -var _ = Describe("Push with health check", func() { - Context("help", func() { - Context("when displaying help in the refactor", func() { - It("displays command usage to output", func() { - session := helpers.CF("push", "--help") - Eventually(session).Should(Say("--health-check-type, -u\\s+Application health check type \\(Default: 'port', 'none' accepted for 'process', 'http' implies endpoint '/'\\)")) - Eventually(session).Should(Exit(0)) - }) - - It("displays health check timeout (-t) flag description", func() { - session := helpers.CF("push", "--help") - Eventually(session).Should(Say("-t\\s+Time \\(in seconds\\) allowed to elapse between starting up an app and the first healthy response from the app")) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the environment is set up correctly", func() { - var ( - appName string - orgName string - spaceName string - ) - - BeforeEach(func() { - orgName = helpers.NewOrgName() - spaceName = helpers.NewSpaceName() - - setupCF(orgName, spaceName) - - appName = helpers.PrefixedRandomName("app") - }) - - AfterEach(func() { - helpers.QuickDeleteOrg(orgName) - }) - - Context("when displaying help in the old code", func() { - It("displays command usage to output", func() { - session := helpers.CF("push") - Eventually(session).Should(Say("--health-check-type, -u\\s+Application health check type \\(Default: 'port', 'none' accepted for 'process', 'http' implies endpoint '/'\\)")) - Eventually(session).Should(Exit(1)) - }) - - It("displays health check timeout (-t) flag description", func() { - session := helpers.CF("push") - Eventually(session).Should(Say("-t\\s+Time \\(in seconds\\) allowed to elapse between starting up an app and the first healthy response from the app")) - Eventually(session).Should(Exit(1)) - }) - }) - - Context("when pushing app without a manifest", func() { - Context("when the app doesn't already exist", func() { - DescribeTable("displays the correct health check type", - func(healthCheckType string, endpoint string) { - helpers.WithHelloWorldApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "-u", healthCheckType)).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+%s", healthCheckType)) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+%s\n", endpoint)) - Eventually(session).Should(Exit(0)) - }, - - Entry("when the health check type is none", "none", ""), - Entry("when the health check type is process", "process", ""), - Entry("when the health check type is port", "port", ""), - Entry("when the health check type is http", "http", "/"), - ) - }) - - Context("when the app already exists", func() { - BeforeEach(func() { - helpers.WithHelloWorldApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "-u", "port")).Should(Exit(0)) - }) - }) - - Context("when the app does not already have a health-check-http-endpoint' configured", func() { - Context("when setting the health check type to 'http'", func() { - BeforeEach(func() { - helpers.WithHelloWorldApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "-u", "http")).Should(Exit(0)) - }) - }) - - It("sets the endpoint to /", func() { - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+\\/\n")) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the app already has a health check 'http' endpoint set", func() { - BeforeEach(func() { - Eventually(helpers.CF("set-health-check", appName, "http", "--endpoint", "/some-endpoint")).Should(Exit(0)) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+/some-endpoint")) - Eventually(session).Should(Exit(0)) - }) - - Context("when the health check type to 'http'", func() { - BeforeEach(func() { - helpers.WithHelloWorldApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "-u", "http")).Should(Exit(0)) - }) - }) - - It("preserves the existing endpoint", func() { - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+\\/some-endpoint\n")) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when updating the health check type to something other than 'http'", func() { - BeforeEach(func() { - helpers.WithHelloWorldApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "-u", "port")).Should(Exit(0)) - }) - }) - - It("preserves the existing endpoint", func() { - session := helpers.CF("get-health-check", appName, "-v") - Eventually(session).Should(Say(`"health_check_http_endpoint": "/some-endpoint"`)) - Eventually(session).Should(Exit(0)) - }) - }) - }) - }) - }) - - Context("when pushing with manifest", func() { - DescribeTable("displays the correct health check type", - func(healthCheckType string, endpoint string) { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: %s -`, appName, healthCheckType)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+%s", healthCheckType)) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+%s\n", endpoint)) - Eventually(session).Should(Exit(0)) - }, - - Entry("when the health check type is none", "none", ""), - Entry("when the health check type is process", "process", ""), - Entry("when the health check type is port", "port", ""), - Entry("when the health check type is http", "http", "/"), - ) - - Context("when the health check type is not 'http' but an endpoint is provided", func() { - It("displays an error", func() { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: port - health-check-http-endpoint: /some-endpoint -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - session := helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack") - Eventually(session).Should(Say("Health check type must be 'http' to set a health check HTTP endpoint.")) - Eventually(session).Should(Exit(1)) - }) - }) - }) - - Context("when the health check type is http and an endpoint is provided", func() { - It("sets the health check type and endpoint", func() { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: http - health-check-http-endpoint: /some-endpoint -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+http")) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+/some-endpoint\n")) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the app already exists", func() { - It("updates the health check type and endpoint", func() { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: http - health-check-http-endpoint: /some-endpoint -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: http - health-check-http-endpoint: /new-endpoint -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+http")) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+/new-endpoint\n")) - Eventually(session).Should(Exit(0)) - }) - - It("uses the existing endpoint if one isn't provided", func() { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: http - health-check-http-endpoint: /some-endpoint -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: http -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+http")) - Eventually(session).Should(Say("endpoint \\(for http type\\):\\s+/some-endpoint\n")) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when also pushing app with -u option", func() { - Context("when the -u option is 'port'", func() { - It("overrides the health check type in the manifest", func() { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: http -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack", "-u", "port")).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+port")) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the -u option is 'http'", func() { - It("uses the endpoint in the manifest", func() { - helpers.WithHelloWorldApp(func(appDir string) { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - memory: 128M - health-check-type: port -`, appName)) - manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) - Expect(err).ToNot(HaveOccurred()) - - Eventually(helpers.CF("push", "--no-start", "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack", "-u", "http")).Should(Exit(0)) - }) - - session := helpers.CF("get-health-check", appName) - Eventually(session).Should(Say("health check type:\\s+http")) - Eventually(session).Should(Say("(?m)endpoint \\(for http type\\):\\s+/$")) - Eventually(session).Should(Exit(0)) - }) - }) - }) - }) - }) -}) diff --git a/integration/isolated/push_command_with_manifest_test.go b/integration/isolated/push_command_with_manifest_test.go deleted file mode 100644 index 0bcadd7d025..00000000000 --- a/integration/isolated/push_command_with_manifest_test.go +++ /dev/null @@ -1,249 +0,0 @@ -package isolated - -import ( - "fmt" - "io/ioutil" - "os" - - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" -) - -var _ = Describe("Push with manifest", func() { - var ( - appName string - orgName string - tempFile string - oldDockerPassword string - ) - - BeforeEach(func() { - orgName = helpers.NewOrgName() - spaceName := helpers.NewSpaceName() - setupCF(orgName, spaceName) - - appName = helpers.PrefixedRandomName("app") - f, err := ioutil.TempFile("", "combination-manifest-with-p") - Expect(err).ToNot(HaveOccurred()) - Expect(f.Close()).To(Succeed()) - tempFile = f.Name() - - oldDockerPassword = os.Getenv("CF_DOCKER_PASSWORD") - Expect(os.Setenv("CF_DOCKER_PASSWORD", "my-docker-password")).To(Succeed()) - }) - - AfterEach(func() { - Expect(os.Setenv("CF_DOCKER_PASSWORD", oldDockerPassword)).To(Succeed()) - Expect(os.Remove(tempFile)).ToNot(HaveOccurred()) - - helpers.QuickDeleteOrg(orgName) - }) - - Context("when the specified manifest file does not exist", func() { - It("displays a path does not exist error, help, and exits 1", func() { - session := helpers.CF("push", "-f", "./non-existent-file") - Eventually(session.Err).Should(Say("Incorrect Usage: The specified path './non-existent-file' does not exist.")) - Eventually(session.Out).Should(Say("NAME:")) - Eventually(session.Out).Should(Say("USAGE:")) - Eventually(session).Should(Exit(1)) - }) - }) - - Context("when the same docker property is provided via both manifest and command line", func() { - Context("when manifest contains 'docker.image' and the '--docker-image' flag is provided", func() { - BeforeEach(func() { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: some-image -`, appName)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("overrides 'docker.image' in the manifest with the '-o' flag value", func() { - Eventually(helpers.CF("push", "-o", DockerImage, "-f", tempFile)).Should(Exit(0)) - - appGUID := helpers.AppGUID(appName) - session := helpers.CF("curl", fmt.Sprintf("/v2/apps/%s", appGUID)) - Eventually(session.Out).Should(Say(DockerImage)) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when manifest contains 'docker.username' and the '--docker-username' flag is provided", func() { - var buffer *Buffer - - BeforeEach(func() { - buffer = NewBuffer() - _, err := buffer.Write([]byte("n\n")) - Expect(err).NotTo(HaveOccurred()) - - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: some-image - username: some-user -`, appName)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("overrides 'docker.username' in the manifest with the '--docker-username' flag value", func() { - Eventually(helpers.CFWithStdin(buffer, "push", "--docker-username", "some-other-user", "-f", tempFile)).Should(Exit()) - - appGUID := helpers.AppGUID(appName) - session := helpers.CF("curl", fmt.Sprintf("/v2/apps/%s", appGUID)) - Eventually(session.Out).Should(Say("some-other-user")) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the docker password is set in the environment", func() { - Context("when the docker image is provided via the command line and docker username is provided via the manifest", func() { - BeforeEach(func() { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - docker: - username: some-other-user -`, appName)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("pushes the app using the docker image from command line and username from manifest", func() { - Eventually(helpers.CF("push", "-o", DockerImage, "-f", tempFile)).Should(Exit()) - - appGUID := helpers.AppGUID(appName) - session := helpers.CF("curl", fmt.Sprintf("/v2/apps/%s", appGUID)) - Eventually(session.Out).Should(Say(DockerImage)) - Eventually(session.Out).Should(Say("some-other-user")) - Eventually(session).Should(Exit(0)) - }) - }) - - Context("when the docker image is provided via the manifest and docker username is provided via the command line", func() { - var buffer *Buffer - - BeforeEach(func() { - buffer = NewBuffer() - _, err := buffer.Write([]byte("my-voice-is-my-passport\n")) - Expect(err).NotTo(HaveOccurred()) - - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: %s -`, appName, DockerImage)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("pushes the app using the docker image from manifest and username from command line", func() { - Eventually(helpers.CFWithStdin(buffer, "push", "--docker-username", "some-user", "-f", tempFile)).Should(Exit()) - - appGUID := helpers.AppGUID(appName) - session := helpers.CF("curl", fmt.Sprintf("/v2/apps/%s", appGUID)) - Eventually(session.Out).Should(Say(DockerImage)) - Eventually(session.Out).Should(Say("some-user")) - Eventually(session).Should(Exit(0)) - }) - }) - }) - - Context("when the docker password is not set in the environment", func() { - BeforeEach(func() { - Expect(os.Unsetenv("CF_DOCKER_PASSWORD")).To(Succeed()) - }) - - Context("when the docker username is provided via the command line", func() { - var buffer *Buffer - - BeforeEach(func() { - buffer = NewBuffer() - _, err := buffer.Write([]byte("my-voice-is-my-passport\n")) - Expect(err).NotTo(HaveOccurred()) - }) - - It("prompts the user for the docker password", func() { - session := helpers.CFWithStdin(buffer, "push", appName, "--docker-image", DockerImage, "--docker-username", "some-user") - Eventually(session).Should(Say("Environment variable CF_DOCKER_PASSWORD not set\\.")) - Eventually(session).Should(Exit()) - }) - }) - - Context("when the docker username is provided via the manifest", func() { - BeforeEach(func() { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - docker: - image: some-image - username: some-user -`, appName)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("displays an error and exits 1", func() { - session := helpers.CF("push", "-f", tempFile) - Eventually(session).Should(Say("No Docker password was provided\\. Please provide the password by setting the CF_DOCKER_PASSWORD environment variable\\.")) - Eventually(session).Should(Exit(1)) - }) - }) - }) - - Context("when invalid manifest properties are provided together", func() { - Context("manifest contains both 'buildpack' and 'docker.image'", func() { - BeforeEach(func() { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - buildpack: staticfile_buildpack - docker: - image: %s -`, appName, DockerImage)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("displays an error and exits 1", func() { - session := helpers.CF("push", appName, "-f", tempFile) - Eventually(session).Should(Say("FAILED")) - Eventually(session).Should(Say("Invalid application configuration:")) - Eventually(session).Should(Say("Application %s must not be configured with both 'buildpack' and 'docker'", appName)) - Eventually(session).Should(Exit(1)) - }) - }) - - Context("manifest contains both 'docker.image' and 'path'", func() { - BeforeEach(func() { - manifestContents := []byte(fmt.Sprintf(` ---- -applications: -- name: %s - path: . - docker: - image: %s -`, appName, DockerImage)) - Expect(ioutil.WriteFile(tempFile, manifestContents, 0666)).To(Succeed()) - }) - - It("displays an error and exits 1", func() { - session := helpers.CF("push", appName, "-f", tempFile) - Eventually(session).Should(Say("FAILED")) - Eventually(session).Should(Say("Invalid application configuration:")) - Eventually(session).Should(Say("Application %s must not be configured with both 'docker' and 'path'", appName)) - Eventually(session).Should(Exit(1)) - }) - }) - }) -}) diff --git a/integration/isolated/ssh_command_test.go b/integration/isolated/ssh_command_test.go index 21529d230fd..9d21f76b0d0 100644 --- a/integration/isolated/ssh_command_test.go +++ b/integration/isolated/ssh_command_test.go @@ -44,7 +44,6 @@ var _ = Describe("ssh command", func() { domainName string orgName string spaceName string - tcpDomain helpers.Domain ) BeforeEach(func() { @@ -56,8 +55,6 @@ var _ = Describe("ssh command", func() { setupCF(orgName, spaceName) appName = helpers.PrefixedRandomName("app") domainName = defaultSharedDomain() - tcpDomain = helpers.NewDomain(orgName, helpers.DomainName("tcp")) - tcpDomain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode())) helpers.WithHelloWorldApp(func(appDir string) { manifestContents := []byte(fmt.Sprintf(` --- @@ -68,8 +65,7 @@ applications: disk_quota: 128M routes: - route: %s.%s - - route: %s:0 -`, appName, appName, domainName, tcpDomain.Name)) +`, appName, appName, domainName)) manifestPath := filepath.Join(appDir, "manifest.yml") err := ioutil.WriteFile(manifestPath, manifestContents, 0666) Expect(err).ToNot(HaveOccurred()) diff --git a/integration/push/simple_manifest_only_test.go b/integration/push/simple_manifest_only_test.go index c9f6b0b5891..d3a6f049c09 100644 --- a/integration/push/simple_manifest_only_test.go +++ b/integration/push/simple_manifest_only_test.go @@ -41,6 +41,8 @@ var _ = Describe("push with a simple manifest and no flags", func() { "key1": "val1", "key2": 2, "key3": true, + "key4": 123412341234, + "key5": 123456789.12345678, }, "instances": 2, "memory": "70M", @@ -71,6 +73,8 @@ var _ = Describe("push with a simple manifest and no flags", func() { Eventually(session).Should(Say("\\+\\s+key1")) Eventually(session).Should(Say("\\+\\s+key2")) Eventually(session).Should(Say("\\+\\s+key3")) + Eventually(session).Should(Say("\\+\\s+key4")) + Eventually(session).Should(Say("\\+\\s+key5")) Eventually(session).Should(Say("\\s+routes:")) Eventually(session).Should(Say("(?i)\\+\\s+%s.%s", appName, defaultSharedDomain())) Eventually(session).Should(Say("Mapping routes\\.\\.\\.")) @@ -92,6 +96,14 @@ var _ = Describe("push with a simple manifest and no flags", func() { Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack")) Eventually(session).Should(Say("#0.* of 70M")) Eventually(session).Should(Exit(0)) + + session = helpers.CF("env", appName) + Eventually(session).Should(Say("key1:\\s+val1")) + Eventually(session).Should(Say("key2:\\s+2")) + Eventually(session).Should(Say("key3:\\s+true")) + Eventually(session).Should(Say("key4:\\s+123412341234")) + Eventually(session).Should(Say("key5:\\s+123456789.12345678")) + Eventually(session).Should(Exit(0)) }) Context("when health-check-type is http and no endpoint is provided", func() {