forked from cloudfoundry/cf-acceptance-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to verify ruby version used for staging
[#71367862] Signed-off-by: Michael Fraenkel <[email protected]>
- Loading branch information
Showing
1 changed file
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package apps | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
|
||
. "github.com/cloudfoundry-incubator/cf-test-helpers/cf" | ||
. "github.com/cloudfoundry-incubator/cf-test-helpers/generator" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gbytes" | ||
. "github.com/onsi/gomega/gexec" | ||
archive_helpers "github.com/pivotal-golang/archiver/extractor/test_helper" | ||
) | ||
|
||
var _ = Describe("Buildpack Environment", func() { | ||
var ( | ||
appName string | ||
BuildpackName string | ||
|
||
appPath string | ||
|
||
buildpackPath string | ||
buildpackArchivePath string | ||
|
||
tmpdir string | ||
) | ||
|
||
matchingFilename := func(appName string) string { | ||
return fmt.Sprintf("buildpack-environment-match-%s", appName) | ||
} | ||
|
||
BeforeEach(func() { | ||
AsUser(context.AdminUserContext(), func() { | ||
BuildpackName = RandomName() | ||
appName = RandomName() | ||
|
||
var err error | ||
tmpdir, err = ioutil.TempDir("", "buildpack_env") | ||
Expect(err).ToNot(HaveOccurred()) | ||
appPath, err = ioutil.TempDir(tmpdir, "matching-app") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
buildpackPath, err = ioutil.TempDir(tmpdir, "matching-buildpack") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
buildpackArchivePath = path.Join(buildpackPath, "buildpack.zip") | ||
|
||
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{ | ||
{ | ||
Name: "bin/compile", | ||
Body: `#!/usr/bin/env bash | ||
echo RUBY_LOCATION=$(which ruby) | ||
echo RUBY_VERSION=$(ruby --version) | ||
sleep 10 | ||
`, | ||
}, | ||
{ | ||
Name: "bin/detect", | ||
Body: fmt.Sprintf(`#!/bin/bash | ||
if [ -f "${1}/%s" ]; then | ||
echo Simple | ||
else | ||
echo no | ||
exit 1 | ||
fi | ||
`, matchingFilename(appName)), | ||
}, | ||
{ | ||
Name: "bin/release", | ||
Body: `#!/usr/bin/env bash | ||
cat <<EOF | ||
--- | ||
config_vars: | ||
PATH: bin:/usr/local/bin:/usr/bin:/bin | ||
FROM_BUILD_PACK: "yes" | ||
default_process_types: | ||
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "hi from a simple admin buildpack"; } | nc -l \$PORT; done | ||
EOF | ||
`, | ||
}, | ||
}) | ||
_, err = os.Create(path.Join(appPath, matchingFilename(appName))) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
_, err = os.Create(path.Join(appPath, "some-file")) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
createBuildpack := Cf("create-buildpack", BuildpackName, buildpackArchivePath, "0").Wait(DEFAULT_TIMEOUT) | ||
Expect(createBuildpack).Should(Exit(0)) | ||
Expect(createBuildpack).Should(Say("Creating")) | ||
Expect(createBuildpack).Should(Say("OK")) | ||
Expect(createBuildpack).Should(Say("Uploading")) | ||
Expect(createBuildpack).Should(Say("OK")) | ||
}) | ||
}) | ||
|
||
AfterEach(func() { | ||
AsUser(context.AdminUserContext(), func() { | ||
Expect(Cf("delete-buildpack", BuildpackName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0)) | ||
}) | ||
|
||
os.RemoveAll(tmpdir) | ||
}) | ||
|
||
It("uses ruby 1.9.3-p547 for staging", func() { | ||
push := Cf("push", appName, "-p", appPath).Wait(CF_PUSH_TIMEOUT) | ||
Expect(push).To(Exit(0)) | ||
Expect(push).To(Say("RUBY_LOCATION=/usr/bin/ruby")) | ||
Expect(push).To(Say("RUBY_VERSION=ruby 1.9.3p547")) | ||
}) | ||
|
||
}) |