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 023e658c1 fix(e2e): tests failure in Plain Quarkus runtime
023e658c1 is described below
commit 023e658c1715e155c56c821b5d2213d3966513f9
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Tue Dec 17 18:45:22 2024 +0100
fix(e2e): tests failure in Plain Quarkus runtime
---
e2e/common/config/config_test.go | 37 ---------------------
e2e/common/traits/builder_test.go | 2 +-
pkg/controller/integrationplatform/monitor.go | 6 ++--
pkg/trait/mount.go | 8 ++++-
pkg/util/source/inspector.go | 8 +++++
pkg/util/source/inspector_java_source_test.go | 16 +++++++++
pkg/util/source/inspector_xml_test.go | 10 ++++++
pkg/util/source/inspector_yaml.go | 4 +++
pkg/util/source/inspector_yaml_test.go | 19 +++++++++++
pkg/util/util.go | 47 ---------------------------
10 files changed, 69 insertions(+), 88 deletions(-)
diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index fe3904fa7..dc6f14640 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -71,18 +71,6 @@ func TestRunConfigProperties(t *testing.T) {
g.Eventually(IntegrationLogs(t, ctx, ns,
"property-route"),
TestTimeoutShort).Should(ContainSubstring("my-configmap-property-value"))
})
- t.Run("Property from ConfigMap as property file", func(t
*testing.T) {
- var cmData = make(map[string]string)
- cmData["my.properties"] =
"my.message=my-configmap-property-entry"
- err := CreatePlainTextConfigmap(t, ctx, ns,
"my-cm-test-properties", cmData)
- g.Expect(err).To(BeNil())
-
- g.Expect(KamelRun(t, ctx, ns,
"./files/property-route.yaml", "-p",
"configmap:my-cm-test-properties").Execute()).To(Succeed())
- g.Eventually(IntegrationPodPhase(t, ctx, ns,
"property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- g.Eventually(IntegrationConditionStatus(t, ctx, ns,
"property-route", v1.IntegrationConditionReady),
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationLogs(t, ctx, ns,
"property-route"),
TestTimeoutShort).Should(ContainSubstring("my-configmap-property-entry"))
- })
-
t.Run("Property from Secret", func(t *testing.T) {
var secData = make(map[string]string)
secData["my.message"] = "my-secret-property-value"
@@ -95,18 +83,6 @@ func TestRunConfigProperties(t *testing.T) {
g.Eventually(IntegrationLogs(t, ctx, ns,
"property-route"),
TestTimeoutShort).Should(ContainSubstring("my-secret-property-value"))
})
- t.Run("Property from Secret as property file", func(t
*testing.T) {
- var secData = make(map[string]string)
- secData["my.properties"] =
"my.message=my-secret-property-entry"
- err := CreatePlainTextSecret(t, ctx, ns,
"my-sec-test-properties", secData)
- g.Expect(err).To(BeNil())
-
- g.Expect(KamelRun(t, ctx, ns,
"./files/property-route.yaml", "--name", "property-route-secret", "-p",
"secret:my-sec-test-properties").Execute()).To(Succeed())
- g.Eventually(IntegrationPodPhase(t, ctx, ns,
"property-route-secret"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- g.Eventually(IntegrationConditionStatus(t, ctx, ns,
"property-route-secret", v1.IntegrationConditionReady),
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationLogs(t, ctx, ns,
"property-route-secret"),
TestTimeoutShort).Should(ContainSubstring("my-secret-property-entry"))
- })
-
t.Run("Property from Secret inlined", func(t *testing.T) {
var secData = make(map[string]string)
secData["my-message"] = "my-secret-external-value"
@@ -172,19 +148,6 @@ func TestRunConfigConfigmaps(t *testing.T) {
g.Eventually(IntegrationLogs(t, ctx, ns,
"resource-configmap-key-location-route"),
TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-configmap-key"]))
g.Eventually(IntegrationLogs(t, ctx, ns,
"resource-configmap-key-location-route"),
TestTimeoutShort).Should(ContainSubstring(cmDataMulti["my-configmap-key-2"]))
})
-
- t.Run("Config configmap as property file", func(t *testing.T) {
- // Store a configmap as property file
- var cmDataProps = make(map[string]string)
- cmDataProps["my.properties"] =
"my.key.1=hello\nmy.key.2=world"
- err = CreatePlainTextConfigmap(t, ctx, ns,
"my-cm-properties", cmDataProps)
- g.Expect(err).To(BeNil())
-
- g.Expect(KamelRun(t, ctx, ns,
"./files/config-configmap-properties-route.yaml", "--config",
"configmap:my-cm-properties").Execute()).To(Succeed())
- g.Eventually(IntegrationPodPhase(t, ctx, ns,
"config-configmap-properties-route"),
TestTimeoutLong).Should(Equal(corev1.PodRunning))
- g.Eventually(IntegrationConditionStatus(t, ctx, ns,
"config-configmap-properties-route", v1.IntegrationConditionReady),
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationLogs(t, ctx, ns,
"config-configmap-properties-route"),
TestTimeoutShort).Should(ContainSubstring("hello world"))
- })
})
}
diff --git a/e2e/common/traits/builder_test.go
b/e2e/common/traits/builder_test.go
index d2aab8859..12b40aa34 100644
--- a/e2e/common/traits/builder_test.go
+++ b/e2e/common/traits/builder_test.go
@@ -191,7 +191,7 @@ func TestBuilderTrait(t *testing.T) {
// Check logs
g.Eventually(Logs(t, ctx, integrationKitNamespace,
builderKitName, corev1.PodLogOptions{Container:
"custom1"})).Should(ContainSubstring(`generated-bytecode.jar`))
- g.Eventually(Logs(t, ctx, integrationKitNamespace,
builderKitName, corev1.PodLogOptions{Container:
"custom2"})).Should(ContainSubstring(`<artifactId>camel-k-runtime-bom</artifactId>`))
+ g.Eventually(Logs(t, ctx, integrationKitNamespace,
builderKitName, corev1.PodLogOptions{Container:
"custom2"})).Should(ContainSubstring(`<artifactId>camel-k-integration</artifactId>`))
})
t.Run("Run custom pipeline task error", func(t *testing.T) {
diff --git a/pkg/controller/integrationplatform/monitor.go
b/pkg/controller/integrationplatform/monitor.go
index 32df55387..816c9f454 100644
--- a/pkg/controller/integrationplatform/monitor.go
+++ b/pkg/controller/integrationplatform/monitor.go
@@ -192,8 +192,10 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx
context.Context, catalog
},
},
}
+ runtimesProps :=
clonedCatalog.Spec.Runtime.Capabilities["master"].RuntimeProperties
clonedCatalog.Spec.Runtime.Capabilities["master"] =
v1.Capability{
- Dependencies: []v1.MavenArtifact{},
+ Dependencies: []v1.MavenArtifact{},
+ RuntimeProperties: runtimesProps,
}
clonedCatalog.Spec.Runtime.Capabilities["resume-kafka"]
= v1.Capability{
Dependencies: []v1.MavenArtifact{},
@@ -206,7 +208,7 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx
context.Context, catalog
},
{
GroupID:
"org.apache.camel.quarkus",
- ArtifactID:
"camel-quarkus-jaxb",
+ ArtifactID:
"camel-quarkus-management",
},
{
GroupID: "org.jolokia",
diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go
index dfa350530..b1a3d3034 100644
--- a/pkg/trait/mount.go
+++ b/pkg/trait/mount.go
@@ -439,7 +439,13 @@ func (t *mountTrait) addSourcesProperties(e *Environment) {
if e.ApplicationProperties == nil {
e.ApplicationProperties = make(map[string]string)
}
- if e.CamelCatalog.GetRuntimeProvider() ==
v1.RuntimeProviderPlainQuarkus {
+ isQuarkusNative := false
+ if qt := e.Catalog.GetTrait(quarkusTraitID); qt != nil {
+ if quarkus, ok := qt.(*quarkusTrait); ok &&
quarkus.isNativeIntegration(e) {
+ isQuarkusNative = true
+ }
+ }
+ if e.CamelCatalog.GetRuntimeProvider() ==
v1.RuntimeProviderPlainQuarkus && !isQuarkusNative {
e.ApplicationProperties["camel.main.source-location-enabled"] =
boolean.TrueString
e.ApplicationProperties["camel.main.routes-include-pattern"] =
fmt.Sprintf("file:%s/**", camel.SourcesMountPath)
} else {
diff --git a/pkg/util/source/inspector.go b/pkg/util/source/inspector.go
index 1c697b9a4..8d58602a2 100644
--- a/pkg/util/source/inspector.go
+++ b/pkg/util/source/inspector.go
@@ -50,6 +50,7 @@ var (
camelTypeRegexp =
regexp.MustCompile(`.*(org.apache.camel.*Component|DataFormat|Language)`)
jsonLibraryRegexp = regexp.MustCompile(`.*JsonLibrary\.Jackson.*`)
jsonLanguageRegexp = regexp.MustCompile(`.*\.json\(\).*`)
+ beanRegexp = regexp.MustCompile(`.*\.bean\(.*\).*`)
circuitBreakerRegexp = regexp.MustCompile(`.*\.circuitBreaker\(\).*`)
restConfigurationRegexp =
regexp.MustCompile(`.*restConfiguration\(\).*`)
restRegexp = regexp.MustCompile(`.*rest\s*\([^)]*\).*`)
@@ -70,6 +71,13 @@ var (
}
sourceDependencies = map[*regexp.Regexp]catalog2deps{
+ beanRegexp: func(catalog *camel.RuntimeCatalog) []string {
+ res := make([]string, 0)
+ if bean := catalog.GetArtifactByScheme("bean"); bean !=
nil {
+ res = append(res, bean.GetDependencyID())
+ }
+ return res
+ },
jsonLibraryRegexp: func(catalog *camel.RuntimeCatalog) []string
{
res := make([]string, 0)
if jsonDF :=
catalog.GetArtifactByDataFormat(defaultJSONDataFormat); jsonDF != nil {
diff --git a/pkg/util/source/inspector_java_source_test.go
b/pkg/util/source/inspector_java_source_test.go
index 33e4722ba..4d52c9864 100644
--- a/pkg/util/source/inspector_java_source_test.go
+++ b/pkg/util/source/inspector_java_source_test.go
@@ -190,3 +190,19 @@ public void configure() throws Exception {
require.NoError(t, err)
assert.Contains(t, meta.Dependencies.List(), "camel:rest-openapi")
}
+
+func TestJavaBeanDependencies(t *testing.T) {
+ inspector := newTestJavaSourceInspector(t)
+
+ sourceSpec := &v1.SourceSpec{
+ DataSpec: v1.DataSpec{
+ Name: "test.java",
+ Content:
"from(\"timer:foo\").bean(\"myBean\").to(\"log:bar\")",
+ },
+ }
+ assertExtract(t, inspector, sourceSpec.Content, func(meta *Metadata) {
+ assert.Contains(t, meta.Dependencies.List(), "camel:timer")
+ assert.Contains(t, meta.Dependencies.List(), "camel:bean")
+ assert.Contains(t, meta.Dependencies.List(), "camel:log")
+ })
+}
diff --git a/pkg/util/source/inspector_xml_test.go
b/pkg/util/source/inspector_xml_test.go
index 98f326ced..a8de69477 100644
--- a/pkg/util/source/inspector_xml_test.go
+++ b/pkg/util/source/inspector_xml_test.go
@@ -228,3 +228,13 @@ func TestXMLRestOpenapiFirst(t *testing.T) {
require.NoError(t, err)
assert.Contains(t, meta.Dependencies.List(), "camel:rest-openapi")
}
+
+func TestXMLBeanDependencies(t *testing.T) {
+ inspector := newTestXMLInspector(t)
+
+ assertExtract(t, inspector, "<from
uri=\"timer:foo\"/><bean>something</bean><to uri=\"log:bar\"></to>", func(meta
*Metadata) {
+ assert.Contains(t, meta.Dependencies.List(), "camel:timer")
+ assert.Contains(t, meta.Dependencies.List(), "camel:bean")
+ assert.Contains(t, meta.Dependencies.List(), "camel:log")
+ })
+}
diff --git a/pkg/util/source/inspector_yaml.go
b/pkg/util/source/inspector_yaml.go
index dac9165c0..3b280fc7f 100644
--- a/pkg/util/source/inspector_yaml.go
+++ b/pkg/util/source/inspector_yaml.go
@@ -88,6 +88,10 @@ func (i YAMLInspector) parseDefinition(def
map[string]interface{}, meta *Metadat
//nolint:nestif
func (i YAMLInspector) parseStep(key string, content interface{}, meta
*Metadata) error {
switch key {
+ case "bean":
+ if bean := i.catalog.GetArtifactByScheme("bean"); bean != nil {
+ meta.AddDependency(bean.GetDependencyID())
+ }
case "rest":
meta.ExposesHTTPServices = true
meta.RequiredCapabilities.Add(v1.CapabilityRest)
diff --git a/pkg/util/source/inspector_yaml_test.go
b/pkg/util/source/inspector_yaml_test.go
index 03cd99178..fbe8c286e 100644
--- a/pkg/util/source/inspector_yaml_test.go
+++ b/pkg/util/source/inspector_yaml_test.go
@@ -757,3 +757,22 @@ func TestYAMLRESTContractFirst(t *testing.T) {
})
})
}
+
+const yamlBean = `
+- from:
+ uri: "timer:foo"
+ steps:
+ - bean:
+ type: "#xyz"
+ - to: "log:bar"
+`
+
+func TestYamlBeanDependencies(t *testing.T) {
+ inspector := newTestYAMLInspector(t)
+
+ assertExtract(t, inspector, yamlBean, func(meta *Metadata) {
+ assert.Contains(t, meta.Dependencies.List(), "camel:timer")
+ assert.Contains(t, meta.Dependencies.List(), "camel:bean")
+ assert.Contains(t, meta.Dependencies.List(), "camel:log")
+ })
+}
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 3a53b21ca..d043591f1 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -43,53 +43,6 @@ import (
yaml2 "gopkg.in/yaml.v2"
)
-// Directories and file names:
-
-// DefaultDependenciesDirectoryName --.
-const DefaultDependenciesDirectoryName = "dependencies"
-
-// DefaultPropertiesDirectoryName --.
-const DefaultPropertiesDirectoryName = "properties"
-
-// DefaultRoutesDirectoryName --.
-const DefaultRoutesDirectoryName = "routes"
-
-// DefaultWorkingDirectoryName --.
-const DefaultWorkingDirectoryName = "workspace"
-
-// CustomQuarkusDirectoryName --.
-const CustomQuarkusDirectoryName = "quarkus"
-
-// CustomAppDirectoryName --.
-const CustomAppDirectoryName = "app"
-
-// CustomLibDirectoryName --.
-const CustomLibDirectoryName = "lib/main"
-
-// ContainerDependenciesDirectory --.
-var ContainerDependenciesDirectory = "/deployments/dependencies"
-
-// ContainerPropertiesDirectory --.
-var ContainerPropertiesDirectory = "/etc/camel/conf.d"
-
-// ContainerRoutesDirectory --.
-var ContainerRoutesDirectory = "/etc/camel/sources"
-
-// ContainerResourcesDirectory --.
-var ContainerResourcesDirectory = "/etc/camel/resources.d"
-
-// ContainerQuarkusDirectoryName --.
-const ContainerQuarkusDirectoryName = "/quarkus"
-
-// ContainerAppDirectoryName --.
-const ContainerAppDirectoryName = "/app"
-
-// ContainerLibDirectoryName --.
-const ContainerLibDirectoryName = "/lib/main"
-
-// QuarkusDependenciesBaseDirectory --.
-var QuarkusDependenciesBaseDirectory = "/quarkus-app"
-
// ListOfLazyEvaluatedEnvVars -- List of unevaluated environment variables.
// These are sensitive values or values that may have different values
depending on
// where the integration is run (locally vs. the cloud). These environment
variables