You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/03/02 09:06:11 UTC

[camel-k] branch main updated (f3ec6f3 -> 214acdc)

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

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


    from f3ec6f3  fix: The error handler trait should update status dependencies
     new c3f1f60  test(e2e): add test for 'kamel local run --integration-directory'
     new 333533b  chore(e2e): kamel local e2e tests should run much faster than 60m
     new 214acdc  fix(cli): kamel local run with integration dir outside of current dir

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 e2e/local/local_run_test.go  | 48 +++++++++++++++++++++++++++++++++--
 pkg/cmd/local_run.go         | 25 ++++++-------------
 pkg/cmd/util_commands.go     |  2 +-
 pkg/cmd/util_dependencies.go | 59 ++++++++++++++------------------------------
 script/Makefile              |  2 +-
 5 files changed, 75 insertions(+), 61 deletions(-)

[camel-k] 02/03: chore(e2e): kamel local e2e tests should run much faster than 60m

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 333533b887f68c65767a4923f730e44087b82e32
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Tue Mar 1 14:26:26 2022 +0900

    chore(e2e): kamel local e2e tests should run much faster than 60m
---
 script/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script/Makefile b/script/Makefile
index 6b5b7b5..3beed37 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -211,7 +211,7 @@ test-builder: build
 
 test-local: build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \
-	go test -timeout 60m -v ./e2e/local -tags=integration $(TEST_LOCAL_RUN)
+	go test -timeout 10m -v ./e2e/local -tags=integration $(TEST_LOCAL_RUN)
 
 test-kamel-cli: build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \

[camel-k] 01/03: test(e2e): add test for 'kamel local run --integration-directory'

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c3f1f60ba2bf6c2dbba3f57c45374711e7d91ac1
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Tue Mar 1 14:25:14 2022 +0900

    test(e2e): add test for 'kamel local run --integration-directory'
    
    Fix #2075
---
 e2e/local/local_run_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/e2e/local/local_run_test.go b/e2e/local/local_run_test.go
index 349f478..6eeb00d 100644
--- a/e2e/local/local_run_test.go
+++ b/e2e/local/local_run_test.go
@@ -25,8 +25,8 @@ import (
 	"io"
 	"testing"
 
-	"github.com/golangplus/testing/assert"
 	. "github.com/onsi/gomega"
+	"github.com/stretchr/testify/assert"
 
 	. "github.com/apache/camel-k/e2e/support"
 	"github.com/apache/camel-k/e2e/support/util"
@@ -57,7 +57,7 @@ func TestLocalRun(t *testing.T) {
 	Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
 }
 
-func TestLocalContainerRun(t *testing.T) {
+func TestLocalRunContainerize(t *testing.T) {
 	RegisterTestingT(t)
 
 	ctx, cancel := context.WithCancel(TestContext)
@@ -81,3 +81,44 @@ func TestLocalContainerRun(t *testing.T) {
 
 	Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
 }
+
+func TestLocalRunIntegrationDirectory(t *testing.T) {
+	RegisterTestingT(t)
+
+	ctx1, cancel1 := context.WithCancel(TestContext)
+	defer cancel1()
+
+	file := util.MakeTempCopy(t, "files/yaml.yaml")
+	dir := util.MakeTempDir(t)
+
+	kamelBuild := KamelWithContext(ctx1, "local", "build", file, "--integration-directory", dir)
+
+	go func() {
+		err := kamelBuild.Execute()
+		assert.NoError(t, err)
+		cancel1()
+	}()
+
+	Eventually(dir+"/dependencies", TestTimeoutShort).Should(BeADirectory())
+	Eventually(dir+"/properties", TestTimeoutShort).Should(BeADirectory())
+	Eventually(dir+"/routes/yaml.yaml", TestTimeoutShort).Should(BeAnExistingFile())
+
+	ctx2, cancel2 := context.WithCancel(TestContext)
+	defer cancel2()
+	piper, pipew := io.Pipe()
+	defer pipew.Close()
+	defer piper.Close()
+
+	kamelRun := KamelWithContext(ctx2, "local", "run", "--integration-directory", dir)
+	kamelRun.SetOut(pipew)
+
+	logScanner := util.NewLogScanner(ctx2, piper, "Magicstring!")
+
+	go func() {
+		err := kamelRun.Execute()
+		assert.NoError(t, err)
+		cancel2()
+	}()
+
+	Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
+}

[camel-k] 03/03: fix(cli): kamel local run with integration dir outside of current dir

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 214acdc1feb8b80ee8873b1c8d12f04ab855e291
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Tue Mar 1 20:59:59 2022 +0900

    fix(cli): kamel local run with integration dir outside of current dir
---
 e2e/local/local_run_test.go  |  3 +++
 pkg/cmd/local_run.go         | 25 ++++++-------------
 pkg/cmd/util_commands.go     |  2 +-
 pkg/cmd/util_dependencies.go | 59 ++++++++++++++------------------------------
 4 files changed, 31 insertions(+), 58 deletions(-)

diff --git a/e2e/local/local_run_test.go b/e2e/local/local_run_test.go
index 6eeb00d..4a8b1a0 100644
--- a/e2e/local/local_run_test.go
+++ b/e2e/local/local_run_test.go
@@ -120,5 +120,8 @@ func TestLocalRunIntegrationDirectory(t *testing.T) {
 		cancel2()
 	}()
 
+	Eventually(dir+"/../quarkus", TestTimeoutShort).Should(BeADirectory())
+	Eventually(dir+"/../app", TestTimeoutShort).Should(BeADirectory())
+	Eventually(dir+"/../lib", TestTimeoutShort).Should(BeADirectory())
 	Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
 }
diff --git a/pkg/cmd/local_run.go b/pkg/cmd/local_run.go
index 696704a..a1cf21a 100644
--- a/pkg/cmd/local_run.go
+++ b/pkg/cmd/local_run.go
@@ -169,34 +169,25 @@ func (command *localRunCmdOptions) run(cmd *cobra.Command, args []string) error
 		localDependenciesDirectory := getCustomDependenciesDir(command.IntegrationDirectory)
 
 		// The quarkus application files need to be at a specific location i.e.:
-		// <current_working_folder>/quarkus/quarkus-application.dat
-		// <current_working_folder>/quarkus/generated-bytecode.jar
-		localQuarkusDir, err := getCustomQuarkusDir()
-		if err != nil {
-			return err
-		}
+		// <integration_directory>/../quarkus/quarkus-application.dat
+		// <integration_directory>/../quarkus/generated-bytecode.jar
+		localQuarkusDir := getCustomQuarkusDir(command.IntegrationDirectory)
 		err = util.CopyQuarkusAppFiles(localDependenciesDirectory, localQuarkusDir)
 		if err != nil {
 			return err
 		}
 
 		// The dependency jar files need to be at a specific location i.e.:
-		// <current_working_folder>/lib/main/*.jar
-		localLibDirectory, err := getCustomLibDir()
-		if err != nil {
-			return err
-		}
+		// <integration_directory>/../lib/main/*.jar
+		localLibDirectory := getCustomLibDir(command.IntegrationDirectory)
 		err = util.CopyLibFiles(localDependenciesDirectory, localLibDirectory)
 		if err != nil {
 			return err
 		}
 
 		// The Camel K jar file needs to be at a specific location i.e.:
-		// <current_working_folder>/app/camel-k-integration-X.X.X{-SNAPSHOT}.jar
-		localAppDirectory, err := getCustomAppDir()
-		if err != nil {
-			return err
-		}
+		// <integration_directory>/../app/camel-k-integration-X.X.X{-SNAPSHOT}.jar
+		localAppDirectory := getCustomAppDir(command.IntegrationDirectory)
 		err = util.CopyAppFile(localDependenciesDirectory, localAppDirectory)
 		if err != nil {
 			return err
@@ -277,7 +268,7 @@ func (command *localRunCmdOptions) deinit() error {
 	}
 
 	if command.IntegrationDirectory != "" {
-		err := deleteLocalIntegrationDirs()
+		err := deleteLocalIntegrationDirs(command.IntegrationDirectory)
 		if err != nil {
 			return err
 		}
diff --git a/pkg/cmd/util_commands.go b/pkg/cmd/util_commands.go
index c7c3605..15a14c8 100644
--- a/pkg/cmd/util_commands.go
+++ b/pkg/cmd/util_commands.go
@@ -108,7 +108,7 @@ func RunLocalIntegrationRunCommand(ctx context.Context, properties []string, dep
 	}
 
 	// Output command we are about to run.
-	fmt.Printf("Executing: %s", strings.Join(cmd.Args, " "))
+	fmt.Printf("Executing: %s\n", strings.Join(cmd.Args, " "))
 
 	// Run integration locally.
 	err = cmd.Run()
diff --git a/pkg/cmd/util_dependencies.go b/pkg/cmd/util_dependencies.go
index 1409d7d..dfabb92 100644
--- a/pkg/cmd/util_dependencies.go
+++ b/pkg/cmd/util_dependencies.go
@@ -497,54 +497,33 @@ func getCustomRoutesDir(integrationDirectory string) string {
 	return path.Join(integrationDirectory, "routes")
 }
 
-func getCustomQuarkusDir() (string, error) {
-	currentDir, err := os.Getwd()
-	if err != nil {
-		return "", err
-	}
-	return path.Join(currentDir, "quarkus"), nil
+func getCustomQuarkusDir(integrationDirectory string) string {
+	parentDir := path.Dir(strings.TrimSuffix(integrationDirectory, "/"))
+	return path.Join(parentDir, "quarkus")
 }
 
-func getCustomLibDir() (string, error) {
-	currentDir, err := os.Getwd()
-	if err != nil {
-		return "", err
-	}
-	return path.Join(currentDir, "lib/main"), nil
+func getCustomLibDir(integrationDirectory string) string {
+	parentDir := path.Dir(strings.TrimSuffix(integrationDirectory, "/"))
+	return path.Join(parentDir, "lib/main")
 }
 
-func getCustomAppDir() (string, error) {
-	currentDir, err := os.Getwd()
-	if err != nil {
-		return "", err
-	}
-	return path.Join(currentDir, "app"), nil
+func getCustomAppDir(integrationDirectory string) string {
+	parentDir := path.Dir(strings.TrimSuffix(integrationDirectory, "/"))
+	return path.Join(parentDir, "app")
 }
 
-func deleteLocalIntegrationDirs() error {
-	directory, err := getCustomQuarkusDir()
-	if err != nil {
-		return err
-	}
-
-	err = os.RemoveAll(directory)
-	if err != nil {
-		return err
+func deleteLocalIntegrationDirs(integrationDirectory string) error {
+	dirs := []string{
+		getCustomQuarkusDir(integrationDirectory),
+		getCustomLibDir(integrationDirectory),
+		getCustomAppDir(integrationDirectory),
 	}
 
-	err = os.RemoveAll("lib")
-	if err != nil {
-		return err
-	}
-
-	directory, err = getCustomAppDir()
-	if err != nil {
-		return err
-	}
-
-	err = os.RemoveAll(directory)
-	if err != nil {
-		return err
+	for _, dir := range dirs {
+		err := os.RemoveAll(dir)
+		if err != nil {
+			return err
+		}
 	}
 
 	return nil