Skip to content

Commit

Permalink
fix(e2e): local test when staging
Browse files Browse the repository at this point in the history
Ref #3560
  • Loading branch information
squakez committed Aug 25, 2022
1 parent 04c76ec commit a1d07fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
14 changes: 7 additions & 7 deletions e2e/local/local_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestLocalBuild(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
image := "test/test-" + strings.ToLower(util.RandomString(10))

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--image", image)
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--image", image)
kamelBuild.SetOut(pipew)
kamelBuild.SetErr(pipew)

Expand Down Expand Up @@ -93,7 +93,7 @@ func TestLocalBuildWithTrait(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/trait.groovy")
image := "test/test-" + strings.ToLower(util.RandomString(10))

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--image", image)
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--image", image)
kamelBuild.SetOut(pipew)
kamelBuild.SetErr(pipew)

Expand Down Expand Up @@ -122,7 +122,7 @@ func TestLocalBuildIntegrationDirectory(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
dir := testutil.MakeTempDir(t)

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--integration-directory", dir)
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--integration-directory", dir)

go func() {
err := kamelBuild.Execute()
Expand All @@ -149,7 +149,7 @@ func TestLocalBuildIntegrationDirectoryWithSpaces(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
dir := testutil.MakeTempDir(t) + " - Camel rocks!"

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--integration-directory", dir)
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--integration-directory", dir)

go func() {
err := kamelBuild.Execute()
Expand All @@ -173,7 +173,7 @@ func TestLocalBuildIntegrationDirectoryWithMultiBytes(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
dir := testutil.MakeTempDir(t) + "_らくだ" // Camel

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--integration-directory", dir)
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--integration-directory", dir)

go func() {
err := kamelBuild.Execute()
Expand All @@ -197,7 +197,7 @@ func TestLocalBuildDependenciesOnly(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
dir := testutil.MakeTempDir(t)

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--integration-directory", dir, "--dependencies-only", "-d", "camel-amqp")
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--integration-directory", dir, "--dependencies-only", "-d", "camel-amqp")

go func() {
err := kamelBuild.Execute()
Expand All @@ -222,7 +222,7 @@ func TestLocalBuildModelineDependencies(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/dependency.groovy")
dir := testutil.MakeTempDir(t)

kamelBuild := KamelWithContext(ctx, "local", "build", file, "--integration-directory", dir, "-d", "camel-amqp")
kamelBuild := kamelWithContextAndMaybeStaging(ctx, "local", "build", file, "--integration-directory", dir, "-d", "camel-amqp")

go func() {
err := kamelBuild.Execute()
Expand Down
10 changes: 5 additions & 5 deletions e2e/local/local_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestLocalRun(t *testing.T) {

file := testutil.MakeTempCopy(t, "files/yaml.yaml")

kamelRun := KamelWithContext(ctx, "local", "run", file)
kamelRun := kamelWithContextAndMaybeStaging(ctx, "local", "run", file)
kamelRun.SetOut(pipew)
kamelRun.SetErr(pipew)

Expand All @@ -71,7 +71,7 @@ func TestLocalRunWithDependencies(t *testing.T) {

file := testutil.MakeTempCopy(t, "files/dependency.groovy")

kamelRun := KamelWithContext(ctx, "local", "run", file, "-d", "camel-amqp")
kamelRun := kamelWithContextAndMaybeStaging(ctx, "local", "run", file, "-d", "camel-amqp")
kamelRun.SetOut(pipew)
kamelRun.SetErr(pipew)

Expand All @@ -98,7 +98,7 @@ func TestLocalRunContainerize(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
image := "test/test-" + strings.ToLower(util.RandomString(10))

kamelRun := KamelWithContext(ctx, "local", "run", file, "--image", image, "--containerize")
kamelRun := kamelWithContextAndMaybeStaging(ctx, "local", "run", file, "--image", image, "--containerize")
kamelRun.SetOut(pipew)
kamelRun.SetErr(pipew)

Expand All @@ -124,7 +124,7 @@ func TestLocalRunIntegrationDirectory(t *testing.T) {
file := testutil.MakeTempCopy(t, "files/yaml.yaml")
dir := testutil.MakeTempDir(t)

kamelBuild := KamelWithContext(ctx1, "local", "build", file, "--integration-directory", dir)
kamelBuild := kamelWithContextAndMaybeStaging(ctx1, "local", "build", file, "--integration-directory", dir)

go func() {
err := kamelBuild.Execute()
Expand All @@ -142,7 +142,7 @@ func TestLocalRunIntegrationDirectory(t *testing.T) {
defer pipew.Close()
defer piper.Close()

kamelRun := KamelWithContext(ctx2, "local", "run", "--integration-directory", dir)
kamelRun := kamelWithContextAndMaybeStaging(ctx2, "local", "run", "--integration-directory", dir)
kamelRun.SetOut(pipew)
kamelRun.SetErr(pipew)

Expand Down
12 changes: 12 additions & 0 deletions e2e/local/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ limitations under the License.
package local

import (
"context"
"os"
"os/exec"
"strings"

. "github.com/apache/camel-k/e2e/support"
"github.com/spf13/cobra"
)

var runtimeRepo = os.Getenv("STAGING_RUNTIME_REPO")

func Docker(args ...string) string {
cmd := exec.CommandContext(TestContext, "docker", args...)
out, err := cmd.Output()
Expand All @@ -48,3 +53,10 @@ func StopDockerContainers() {
Docker(args...)
}
}

func kamelWithContextAndMaybeStaging(ctx context.Context, args ...string) *cobra.Command {
if runtimeRepo != "" {
args = append(args, "--maven-repository", runtimeRepo)
}
return KamelWithContext(ctx, args...)
}

0 comments on commit a1d07fd

Please sign in to comment.