Skip to content

Commit 023e658

Browse files
committed
fix(e2e): tests failure in Plain Quarkus runtime
1 parent 7ab181b commit 023e658

File tree

10 files changed

+69
-88
lines changed

10 files changed

+69
-88
lines changed

e2e/common/config/config_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ func TestRunConfigProperties(t *testing.T) {
7171
g.Eventually(IntegrationLogs(t, ctx, ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-configmap-property-value"))
7272
})
7373

74-
t.Run("Property from ConfigMap as property file", func(t *testing.T) {
75-
var cmData = make(map[string]string)
76-
cmData["my.properties"] = "my.message=my-configmap-property-entry"
77-
err := CreatePlainTextConfigmap(t, ctx, ns, "my-cm-test-properties", cmData)
78-
g.Expect(err).To(BeNil())
79-
80-
g.Expect(KamelRun(t, ctx, ns, "./files/property-route.yaml", "-p", "configmap:my-cm-test-properties").Execute()).To(Succeed())
81-
g.Eventually(IntegrationPodPhase(t, ctx, ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
82-
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
83-
g.Eventually(IntegrationLogs(t, ctx, ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-configmap-property-entry"))
84-
})
85-
8674
t.Run("Property from Secret", func(t *testing.T) {
8775
var secData = make(map[string]string)
8876
secData["my.message"] = "my-secret-property-value"
@@ -95,18 +83,6 @@ func TestRunConfigProperties(t *testing.T) {
9583
g.Eventually(IntegrationLogs(t, ctx, ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("my-secret-property-value"))
9684
})
9785

98-
t.Run("Property from Secret as property file", func(t *testing.T) {
99-
var secData = make(map[string]string)
100-
secData["my.properties"] = "my.message=my-secret-property-entry"
101-
err := CreatePlainTextSecret(t, ctx, ns, "my-sec-test-properties", secData)
102-
g.Expect(err).To(BeNil())
103-
104-
g.Expect(KamelRun(t, ctx, ns, "./files/property-route.yaml", "--name", "property-route-secret", "-p", "secret:my-sec-test-properties").Execute()).To(Succeed())
105-
g.Eventually(IntegrationPodPhase(t, ctx, ns, "property-route-secret"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
106-
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "property-route-secret", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
107-
g.Eventually(IntegrationLogs(t, ctx, ns, "property-route-secret"), TestTimeoutShort).Should(ContainSubstring("my-secret-property-entry"))
108-
})
109-
11086
t.Run("Property from Secret inlined", func(t *testing.T) {
11187
var secData = make(map[string]string)
11288
secData["my-message"] = "my-secret-external-value"
@@ -172,19 +148,6 @@ func TestRunConfigConfigmaps(t *testing.T) {
172148
g.Eventually(IntegrationLogs(t, ctx, ns, "resource-configmap-key-location-route"), TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-configmap-key"]))
173149
g.Eventually(IntegrationLogs(t, ctx, ns, "resource-configmap-key-location-route"), TestTimeoutShort).Should(ContainSubstring(cmDataMulti["my-configmap-key-2"]))
174150
})
175-
176-
t.Run("Config configmap as property file", func(t *testing.T) {
177-
// Store a configmap as property file
178-
var cmDataProps = make(map[string]string)
179-
cmDataProps["my.properties"] = "my.key.1=hello\nmy.key.2=world"
180-
err = CreatePlainTextConfigmap(t, ctx, ns, "my-cm-properties", cmDataProps)
181-
g.Expect(err).To(BeNil())
182-
183-
g.Expect(KamelRun(t, ctx, ns, "./files/config-configmap-properties-route.yaml", "--config", "configmap:my-cm-properties").Execute()).To(Succeed())
184-
g.Eventually(IntegrationPodPhase(t, ctx, ns, "config-configmap-properties-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
185-
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "config-configmap-properties-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
186-
g.Eventually(IntegrationLogs(t, ctx, ns, "config-configmap-properties-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
187-
})
188151
})
189152
}
190153

e2e/common/traits/builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func TestBuilderTrait(t *testing.T) {
191191

192192
// Check logs
193193
g.Eventually(Logs(t, ctx, integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom1"})).Should(ContainSubstring(`generated-bytecode.jar`))
194-
g.Eventually(Logs(t, ctx, integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom2"})).Should(ContainSubstring(`<artifactId>camel-k-runtime-bom</artifactId>`))
194+
g.Eventually(Logs(t, ctx, integrationKitNamespace, builderKitName, corev1.PodLogOptions{Container: "custom2"})).Should(ContainSubstring(`<artifactId>camel-k-integration</artifactId>`))
195195
})
196196

197197
t.Run("Run custom pipeline task error", func(t *testing.T) {

pkg/controller/integrationplatform/monitor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx context.Context, catalog
192192
},
193193
},
194194
}
195+
runtimesProps := clonedCatalog.Spec.Runtime.Capabilities["master"].RuntimeProperties
195196
clonedCatalog.Spec.Runtime.Capabilities["master"] = v1.Capability{
196-
Dependencies: []v1.MavenArtifact{},
197+
Dependencies: []v1.MavenArtifact{},
198+
RuntimeProperties: runtimesProps,
197199
}
198200
clonedCatalog.Spec.Runtime.Capabilities["resume-kafka"] = v1.Capability{
199201
Dependencies: []v1.MavenArtifact{},
@@ -206,7 +208,7 @@ func (action *monitorAction) addPlainQuarkusCatalog(ctx context.Context, catalog
206208
},
207209
{
208210
GroupID: "org.apache.camel.quarkus",
209-
ArtifactID: "camel-quarkus-jaxb",
211+
ArtifactID: "camel-quarkus-management",
210212
},
211213
{
212214
GroupID: "org.jolokia",

pkg/trait/mount.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,13 @@ func (t *mountTrait) addSourcesProperties(e *Environment) {
439439
if e.ApplicationProperties == nil {
440440
e.ApplicationProperties = make(map[string]string)
441441
}
442-
if e.CamelCatalog.GetRuntimeProvider() == v1.RuntimeProviderPlainQuarkus {
442+
isQuarkusNative := false
443+
if qt := e.Catalog.GetTrait(quarkusTraitID); qt != nil {
444+
if quarkus, ok := qt.(*quarkusTrait); ok && quarkus.isNativeIntegration(e) {
445+
isQuarkusNative = true
446+
}
447+
}
448+
if e.CamelCatalog.GetRuntimeProvider() == v1.RuntimeProviderPlainQuarkus && !isQuarkusNative {
443449
e.ApplicationProperties["camel.main.source-location-enabled"] = boolean.TrueString
444450
e.ApplicationProperties["camel.main.routes-include-pattern"] = fmt.Sprintf("file:%s/**", camel.SourcesMountPath)
445451
} else {

pkg/util/source/inspector.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var (
5050
camelTypeRegexp = regexp.MustCompile(`.*(org.apache.camel.*Component|DataFormat|Language)`)
5151
jsonLibraryRegexp = regexp.MustCompile(`.*JsonLibrary\.Jackson.*`)
5252
jsonLanguageRegexp = regexp.MustCompile(`.*\.json\(\).*`)
53+
beanRegexp = regexp.MustCompile(`.*\.bean\(.*\).*`)
5354
circuitBreakerRegexp = regexp.MustCompile(`.*\.circuitBreaker\(\).*`)
5455
restConfigurationRegexp = regexp.MustCompile(`.*restConfiguration\(\).*`)
5556
restRegexp = regexp.MustCompile(`.*rest\s*\([^)]*\).*`)
@@ -70,6 +71,13 @@ var (
7071
}
7172

7273
sourceDependencies = map[*regexp.Regexp]catalog2deps{
74+
beanRegexp: func(catalog *camel.RuntimeCatalog) []string {
75+
res := make([]string, 0)
76+
if bean := catalog.GetArtifactByScheme("bean"); bean != nil {
77+
res = append(res, bean.GetDependencyID())
78+
}
79+
return res
80+
},
7381
jsonLibraryRegexp: func(catalog *camel.RuntimeCatalog) []string {
7482
res := make([]string, 0)
7583
if jsonDF := catalog.GetArtifactByDataFormat(defaultJSONDataFormat); jsonDF != nil {

pkg/util/source/inspector_java_source_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,19 @@ public void configure() throws Exception {
190190
require.NoError(t, err)
191191
assert.Contains(t, meta.Dependencies.List(), "camel:rest-openapi")
192192
}
193+
194+
func TestJavaBeanDependencies(t *testing.T) {
195+
inspector := newTestJavaSourceInspector(t)
196+
197+
sourceSpec := &v1.SourceSpec{
198+
DataSpec: v1.DataSpec{
199+
Name: "test.java",
200+
Content: "from(\"timer:foo\").bean(\"myBean\").to(\"log:bar\")",
201+
},
202+
}
203+
assertExtract(t, inspector, sourceSpec.Content, func(meta *Metadata) {
204+
assert.Contains(t, meta.Dependencies.List(), "camel:timer")
205+
assert.Contains(t, meta.Dependencies.List(), "camel:bean")
206+
assert.Contains(t, meta.Dependencies.List(), "camel:log")
207+
})
208+
}

pkg/util/source/inspector_xml_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,13 @@ func TestXMLRestOpenapiFirst(t *testing.T) {
228228
require.NoError(t, err)
229229
assert.Contains(t, meta.Dependencies.List(), "camel:rest-openapi")
230230
}
231+
232+
func TestXMLBeanDependencies(t *testing.T) {
233+
inspector := newTestXMLInspector(t)
234+
235+
assertExtract(t, inspector, "<from uri=\"timer:foo\"/><bean>something</bean><to uri=\"log:bar\"></to>", func(meta *Metadata) {
236+
assert.Contains(t, meta.Dependencies.List(), "camel:timer")
237+
assert.Contains(t, meta.Dependencies.List(), "camel:bean")
238+
assert.Contains(t, meta.Dependencies.List(), "camel:log")
239+
})
240+
}

pkg/util/source/inspector_yaml.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ func (i YAMLInspector) parseDefinition(def map[string]interface{}, meta *Metadat
8888
//nolint:nestif
8989
func (i YAMLInspector) parseStep(key string, content interface{}, meta *Metadata) error {
9090
switch key {
91+
case "bean":
92+
if bean := i.catalog.GetArtifactByScheme("bean"); bean != nil {
93+
meta.AddDependency(bean.GetDependencyID())
94+
}
9195
case "rest":
9296
meta.ExposesHTTPServices = true
9397
meta.RequiredCapabilities.Add(v1.CapabilityRest)

pkg/util/source/inspector_yaml_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,22 @@ func TestYAMLRESTContractFirst(t *testing.T) {
757757
})
758758
})
759759
}
760+
761+
const yamlBean = `
762+
- from:
763+
uri: "timer:foo"
764+
steps:
765+
- bean:
766+
type: "#xyz"
767+
- to: "log:bar"
768+
`
769+
770+
func TestYamlBeanDependencies(t *testing.T) {
771+
inspector := newTestYAMLInspector(t)
772+
773+
assertExtract(t, inspector, yamlBean, func(meta *Metadata) {
774+
assert.Contains(t, meta.Dependencies.List(), "camel:timer")
775+
assert.Contains(t, meta.Dependencies.List(), "camel:bean")
776+
assert.Contains(t, meta.Dependencies.List(), "camel:log")
777+
})
778+
}

pkg/util/util.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -43,53 +43,6 @@ import (
4343
yaml2 "gopkg.in/yaml.v2"
4444
)
4545

46-
// Directories and file names:
47-
48-
// DefaultDependenciesDirectoryName --.
49-
const DefaultDependenciesDirectoryName = "dependencies"
50-
51-
// DefaultPropertiesDirectoryName --.
52-
const DefaultPropertiesDirectoryName = "properties"
53-
54-
// DefaultRoutesDirectoryName --.
55-
const DefaultRoutesDirectoryName = "routes"
56-
57-
// DefaultWorkingDirectoryName --.
58-
const DefaultWorkingDirectoryName = "workspace"
59-
60-
// CustomQuarkusDirectoryName --.
61-
const CustomQuarkusDirectoryName = "quarkus"
62-
63-
// CustomAppDirectoryName --.
64-
const CustomAppDirectoryName = "app"
65-
66-
// CustomLibDirectoryName --.
67-
const CustomLibDirectoryName = "lib/main"
68-
69-
// ContainerDependenciesDirectory --.
70-
var ContainerDependenciesDirectory = "/deployments/dependencies"
71-
72-
// ContainerPropertiesDirectory --.
73-
var ContainerPropertiesDirectory = "/etc/camel/conf.d"
74-
75-
// ContainerRoutesDirectory --.
76-
var ContainerRoutesDirectory = "/etc/camel/sources"
77-
78-
// ContainerResourcesDirectory --.
79-
var ContainerResourcesDirectory = "/etc/camel/resources.d"
80-
81-
// ContainerQuarkusDirectoryName --.
82-
const ContainerQuarkusDirectoryName = "/quarkus"
83-
84-
// ContainerAppDirectoryName --.
85-
const ContainerAppDirectoryName = "/app"
86-
87-
// ContainerLibDirectoryName --.
88-
const ContainerLibDirectoryName = "/lib/main"
89-
90-
// QuarkusDependenciesBaseDirectory --.
91-
var QuarkusDependenciesBaseDirectory = "/quarkus-app"
92-
9346
// ListOfLazyEvaluatedEnvVars -- List of unevaluated environment variables.
9447
// These are sensitive values or values that may have different values depending on
9548
// where the integration is run (locally vs. the cloud). These environment variables

0 commit comments

Comments
 (0)