This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 0e21d6854 fix(e2e): local test when staging
0e21d6854 is described below

commit 0e21d685417564b5650869f1c42e0e01db65e5da
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Thu Aug 25 12:05:50 2022 +0200

    fix(e2e): local test when staging
    
    Ref #3560
---
 e2e/local/local_build_test.go | 14 +++++++-------
 e2e/local/local_run_test.go   | 10 +++++-----
 e2e/local/util.go             | 12 ++++++++++++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/e2e/local/local_build_test.go b/e2e/local/local_build_test.go
index 2c0f40c6d..7b0ea7f51 100644
--- a/e2e/local/local_build_test.go
+++ b/e2e/local/local_build_test.go
@@ -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 := kamelWithContext(ctx, "local", "build", file, "--image", 
image)
        kamelBuild.SetOut(pipew)
        kamelBuild.SetErr(pipew)
 
@@ -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 := kamelWithContext(ctx, "local", "build", file, "--image", 
image)
        kamelBuild.SetOut(pipew)
        kamelBuild.SetErr(pipew)
 
@@ -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 := kamelWithContext(ctx, "local", "build", file, 
"--integration-directory", dir)
 
        go func() {
                err := kamelBuild.Execute()
@@ -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 := kamelWithContext(ctx, "local", "build", file, 
"--integration-directory", dir)
 
        go func() {
                err := kamelBuild.Execute()
@@ -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 := kamelWithContext(ctx, "local", "build", file, 
"--integration-directory", dir)
 
        go func() {
                err := kamelBuild.Execute()
@@ -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 := kamelWithContext(ctx, "local", "build", file, 
"--integration-directory", dir, "--dependencies-only", "-d", "camel-amqp")
 
        go func() {
                err := kamelBuild.Execute()
@@ -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 := kamelWithContext(ctx, "local", "build", file, 
"--integration-directory", dir, "-d", "camel-amqp")
 
        go func() {
                err := kamelBuild.Execute()
diff --git a/e2e/local/local_run_test.go b/e2e/local/local_run_test.go
index cef5112b1..44a936395 100644
--- a/e2e/local/local_run_test.go
+++ b/e2e/local/local_run_test.go
@@ -45,7 +45,7 @@ func TestLocalRun(t *testing.T) {
 
        file := testutil.MakeTempCopy(t, "files/yaml.yaml")
 
-       kamelRun := KamelWithContext(ctx, "local", "run", file)
+       kamelRun := kamelWithContext(ctx, "local", "run", file)
        kamelRun.SetOut(pipew)
        kamelRun.SetErr(pipew)
 
@@ -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 := kamelWithContext(ctx, "local", "run", file, "-d", 
"camel-amqp")
        kamelRun.SetOut(pipew)
        kamelRun.SetErr(pipew)
 
@@ -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 := kamelWithContext(ctx, "local", "run", file, "--image", 
image, "--containerize")
        kamelRun.SetOut(pipew)
        kamelRun.SetErr(pipew)
 
@@ -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 := kamelWithContext(ctx1, "local", "build", file, 
"--integration-directory", dir)
 
        go func() {
                err := kamelBuild.Execute()
@@ -142,7 +142,7 @@ func TestLocalRunIntegrationDirectory(t *testing.T) {
        defer pipew.Close()
        defer piper.Close()
 
-       kamelRun := KamelWithContext(ctx2, "local", "run", 
"--integration-directory", dir)
+       kamelRun := kamelWithContext(ctx2, "local", "run", 
"--integration-directory", dir)
        kamelRun.SetOut(pipew)
        kamelRun.SetErr(pipew)
 
diff --git a/e2e/local/util.go b/e2e/local/util.go
index 1cbd7d067..aa2ffd2fe 100644
--- a/e2e/local/util.go
+++ b/e2e/local/util.go
@@ -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()
@@ -48,3 +53,10 @@ func StopDockerContainers() {
                Docker(args...)
        }
 }
+
+func kamelWithContext(ctx context.Context, args ...string) *cobra.Command {
+       if runtimeRepo != "" {
+               args = append(args, "--maven-repository", runtimeRepo)
+       }
+       return KamelWithContext(ctx, args...)
+}

Reply via email to