-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: new command
werf kube-run
, refactor
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
- Loading branch information
1 parent
ebdf08b
commit bb1a4ff
Showing
5 changed files
with
209 additions
and
14 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
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,6 @@ | ||
project: werf-e2e-kube-run-test | ||
configVersion: 1 | ||
|
||
--- | ||
image: main | ||
from: alpine:3 |
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,76 @@ | ||
package e2e_kube_run_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/ginkgo/extensions/table" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/werf/werf/test/pkg/werf" | ||
) | ||
|
||
var _ = Describe("kube-run", func() { | ||
DescribeTable("should succeed/fail and produce expected output", | ||
func(kubeRunOpts *werf.KubeRunOptions, outputExpectationsFunc func(out string)) { | ||
repoDirname := "repo0" | ||
fixtureRelPath := "state0" | ||
|
||
By("preparing test repo") | ||
SuiteData.InitTestRepo(repoDirname, fixtureRelPath) | ||
werfProject := werf.NewProject(SuiteData.WerfBinPath, SuiteData.GetTestRepoPath(repoDirname)) | ||
|
||
By("execute kube-run") | ||
combinedOut := werfProject.KubeRun(kubeRunOpts) | ||
outputExpectationsFunc(combinedOut) | ||
}, | ||
Entry( | ||
"show output and succeed, running non-interactively", | ||
&werf.KubeRunOptions{ | ||
Command: `sh -c "cat /etc/os-release"`, | ||
Image: "main", | ||
}, | ||
func(out string) { | ||
Expect(out).To(ContainSubstring("ID=alpine")) | ||
}, | ||
), | ||
Entry( | ||
"show output and succeed, running interactively with TTY", | ||
&werf.KubeRunOptions{ | ||
Command: `sh -c "cat /etc/os-release"`, | ||
Image: "main", | ||
CommonOptions: werf.CommonOptions{ | ||
ExtraArgs: []string{"-i", "-t"}, | ||
}, | ||
}, | ||
func(out string) { | ||
Expect(out).To(ContainSubstring("ID=alpine")) | ||
}, | ||
), | ||
Entry( | ||
"show output and fail, running non-interactively", | ||
&werf.KubeRunOptions{ | ||
Command: `sh -c "cat /etc/os-release; exit 1"`, | ||
Image: "main", | ||
CommonOptions: werf.CommonOptions{ | ||
ShouldFail: true, | ||
}, | ||
}, | ||
func(out string) { | ||
Expect(out).To(ContainSubstring("ID=alpine")) | ||
}, | ||
), | ||
Entry( | ||
"show output and fail, running interactively with TTY", | ||
&werf.KubeRunOptions{ | ||
Command: `sh -c "cat /etc/os-release; exit 1"`, | ||
Image: "main", | ||
CommonOptions: werf.CommonOptions{ | ||
ShouldFail: true, | ||
ExtraArgs: []string{"-i", "-t"}, | ||
}, | ||
}, | ||
func(out string) { | ||
Expect(out).To(ContainSubstring("ID=alpine")) | ||
}, | ||
), | ||
) | ||
}) |
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,29 @@ | ||
package e2e_kube_run_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/werf/werf/test/pkg/suite_init" | ||
) | ||
|
||
func TestSuite(t *testing.T) { | ||
suite_init.MakeTestSuiteEntrypointFunc("E2E kube-run suite", suite_init.TestSuiteEntrypointFuncOptions{ | ||
RequiredSuiteTools: []string{"docker", "git"}, | ||
RequiredSuiteEnvs: []string{ | ||
"WERF_TEST_K8S_DOCKER_REGISTRY", | ||
"WERF_TEST_K8S_DOCKER_REGISTRY_USERNAME", | ||
"WERF_TEST_K8S_DOCKER_REGISTRY_PASSWORD", | ||
}, | ||
})(t) | ||
} | ||
|
||
var SuiteData suite_init.SuiteData | ||
|
||
var ( | ||
_ = SuiteData.SetupStubs(suite_init.NewStubsData()) | ||
_ = SuiteData.SetupSynchronizedSuiteCallbacks(suite_init.NewSynchronizedSuiteCallbacksData()) | ||
_ = SuiteData.SetupWerfBinary(suite_init.NewWerfBinaryData(SuiteData.SynchronizedSuiteCallbacksData)) | ||
_ = SuiteData.SetupProjectName(suite_init.NewProjectNameData(SuiteData.StubsData)) | ||
_ = SuiteData.SetupTmp(suite_init.NewTmpDirData()) | ||
_ = SuiteData.SetupK8sDockerRegistry(suite_init.NewK8sDockerRegistryData(SuiteData.ProjectNameData, SuiteData.StubsData)) | ||
) |
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