This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#163823994] Signed-off-by: Steffen Uhlig <[email protected]>
- Loading branch information
Showing
10 changed files
with
194 additions
and
3 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
File renamed without changes.
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
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
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,9 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
export GOPATH="$PWD" | ||
mkdir -p src/code.cloudfoundry.org | ||
cp -r eirinifs src/code.cloudfoundry.org/ | ||
cd src/code.cloudfoundry.org/eirinifs | ||
ginkgo -v launchcmd |
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,14 @@ | ||
--- | ||
platform: linux | ||
|
||
image_resource: | ||
type: docker-image | ||
source: | ||
repository: eirini/ci | ||
|
||
inputs: | ||
- name: eirinifs | ||
|
||
run: | ||
path: eirinifs/ci/run-integration-tests/task.sh | ||
|
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,13 @@ | ||
package main_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestLaunch(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Launch Suite") | ||
} |
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,133 @@ | ||
package main_test | ||
|
||
import ( | ||
"os/exec" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
"github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("Launch", func() { | ||
var ( | ||
launchPath string | ||
session *gexec.Session | ||
err error | ||
envs []string | ||
mockLauncher string | ||
) | ||
|
||
Context("When launcher is provided", func() { | ||
|
||
BeforeEach(func() { | ||
envs = []string{"START_COMMAND=dummy"} | ||
launchPath, err = gexec.Build("code.cloudfoundry.org/eirinifs/launchcmd") | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
cmd := exec.Command(launchPath, mockLauncher) //#nosec | ||
cmd.Env = envs | ||
session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
Context("Launcher args", func() { | ||
BeforeEach(func() { | ||
mockLauncher = "mock-launchers/verify-args.sh" | ||
envs = append(envs, "POD_NAME=my-super-pod-42") | ||
}) | ||
|
||
Context("when START_COMMAND env var is provided", func() { | ||
It("should exit with a zero exit code", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).To(Equal(0)) | ||
}) | ||
}) | ||
|
||
Context("when START_COMMAND env var is NOT provided", func() { | ||
BeforeEach(func() { | ||
envs = []string{} | ||
}) | ||
|
||
It("should exit with a non-zero exit code", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).ToNot(Equal(0)) | ||
}) | ||
}) | ||
}) | ||
|
||
Context("Environment variables", func() { | ||
BeforeEach(func() { | ||
mockLauncher = "mock-launchers/verify-env-vars.sh" | ||
}) | ||
|
||
Context("when CF_INSTANCE_INDEX is provided", func() { | ||
BeforeEach(func() { | ||
envs = append(envs, "POD_NAME=my-super-pod-42") | ||
}) | ||
|
||
It("should exit with a zero exit code", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).To(Equal(0)) | ||
}) | ||
|
||
It("should expose the INSTANCE_INDEX as environment name", func() { | ||
Eventually(session.Out, 5*time.Second).Should(gbytes.Say("INSTANCE_INDEX:42")) | ||
}) | ||
}) | ||
|
||
Context("when INSTANCE_INDEX is NOT provided", func() { | ||
It("should exit with a non-zero exit code", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).ToNot(Equal(0)) | ||
}) | ||
}) | ||
|
||
Context("when CF_INSTANCE_INDEX is provided", func() { | ||
BeforeEach(func() { | ||
envs = append(envs, "POD_NAME=my-super-pod-11") | ||
}) | ||
|
||
It("should exit with a zero exit code", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).To(Equal(0)) | ||
}) | ||
|
||
It("should expose the CF_INSTANCE_INDEX as environment name", func() { | ||
Eventually(session.Out, 5*time.Second).Should(gbytes.Say("CF_INSTANCE_INDEX:11")) | ||
}) | ||
}) | ||
|
||
Context("when CF_INSTANCE_INDEX is NOT provided", func() { | ||
It("should exit with a non-zero exit code", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).ToNot(Equal(0)) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
Context("When no launcher is provided", func() { | ||
BeforeEach(func() { | ||
envs = []string{"START_COMMAND=run-it", "POD_NAME=my-super-pod-11"} | ||
launchPath, err = gexec.Build("code.cloudfoundry.org/eirinifs/launchcmd") | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
cmd := exec.Command(launchPath) //#nosec | ||
cmd.Env = envs | ||
session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("should fallback to the default command, which is not present on your machine", func() { | ||
<-session.Exited | ||
Expect(session.ExitCode()).ToNot(Equal(0)) | ||
}) | ||
}) | ||
|
||
}) |
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,4 @@ | ||
#!/bin/bash | ||
|
||
[ "$1" = /home/vcap/app ] || exit 1 | ||
[ "$2" = dummy ] || exit 2 |
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,4 @@ | ||
#!/bin/bash | ||
|
||
echo "INSTANCE_INDEX:$INSTANCE_INDEX" | ||
echo "CF_INSTANCE_INDEX:$CF_INSTANCE_INDEX" |