Skip to content

Commit

Permalink
Fix tests related to recent camel-k-runtime changes
Browse files Browse the repository at this point in the history
This PR brought knative from camel-quarkus
apache/camel-k-runtime#927

There is a breaking change related to Yaml dsl, the template keywork was
renamed to routeTemplate
https://camel.apache.org/manual/camel-3x-upgrade-guide-3_19.html#_camel_yaml_dsl
  • Loading branch information
claudio4j authored and oscerd committed Nov 28, 2022
1 parent cd61d30 commit e28dc43
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 194 deletions.
69 changes: 0 additions & 69 deletions docs/modules/traits/pages/container.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,75 +81,6 @@ The following configuration options are available:
| PullPolicy
| The pull policy: Always\|Never\|IfNotPresent

| container.probes-enabled
| bool
| DeprecatedProbesEnabled enable/disable probes on the container (default `false`).
Deprecated: replaced by the health trait.

| container.liveness-scheme
| string
| Scheme to use when connecting. Defaults to HTTP. Applies to the liveness probe.
Deprecated: replaced by the health trait.

| container.liveness-initial-delay
| int32
| Number of seconds after the container has started before liveness probes are initiated.
Deprecated: replaced by the health trait.

| container.liveness-timeout
| int32
| Number of seconds after which the probe times out. Applies to the liveness probe.
Deprecated: replaced by the health trait.

| container.liveness-period
| int32
| How often to perform the probe. Applies to the liveness probe.
Deprecated: replaced by the health trait.

| container.liveness-success-threshold
| int32
| Minimum consecutive successes for the probe to be considered successful after having failed.
Applies to the liveness probe.
Deprecated: replaced by the health trait.

| container.liveness-failure-threshold
| int32
| Minimum consecutive failures for the probe to be considered failed after having succeeded.
Applies to the liveness probe.
Deprecated: replaced by the health trait.

| container.readiness-scheme
| string
| Scheme to use when connecting. Defaults to HTTP. Applies to the readiness probe.
Deprecated: replaced by the health trait.

| container.readiness-initial-delay
| int32
| Number of seconds after the container has started before readiness probes are initiated.
Deprecated: replaced by the health trait.

| container.readiness-timeout
| int32
| Number of seconds after which the probe times out. Applies to the readiness probe.
Deprecated: replaced by the health trait.

| container.readiness-period
| int32
| How often to perform the probe. Applies to the readiness probe.
Deprecated: replaced by the health trait.

| container.readiness-success-threshold
| int32
| Minimum consecutive successes for the probe to be considered successful after having failed.
Applies to the readiness probe.
Deprecated: replaced by the health trait.

| container.readiness-failure-threshold
| int32
| Minimum consecutive failures for the probe to be considered failed after having succeeded.
Applies to the readiness probe.
Deprecated: replaced by the health trait.

|===

// End of autogenerated code - DO NOT EDIT! (configuration)
2 changes: 1 addition & 1 deletion e2e/global/builder/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestKitTimerToLogFullBuild(t *testing.T) {
func TestKitKnativeFullBuild(t *testing.T) {
doKitFullBuild(t, "knative", "500Mi", "8m0s", TestTimeoutLong, kitOptions{
dependencies: []string{
"camel-k-knative",
"camel-quarkus-knative",
},
})
}
Expand Down
27 changes: 14 additions & 13 deletions e2e/global/knative/kamelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ import (
func TestKameletChange(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-kamelet-change"
timerSource := "my-timer-source"
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Expect(CreateTimerKamelet(ns, "my-timer-source")()).To(Succeed())
Expect(CreateTimerKamelet(ns, timerSource)()).To(Succeed())
Expect(CreateKnativeChannel(ns, "messages")()).To(Succeed())

Expect(KamelRunWithID(operatorID, ns, "files/display.groovy", "-w").Execute()).To(Succeed())

from := corev1.ObjectReference{
Kind: "Kamelet",
APIVersion: v1alpha1.SchemeGroupVersion.String(),
Name: "my-timer-source",
Name: timerSource,
}

to := corev1.ObjectReference{
Expand All @@ -59,37 +60,37 @@ func TestKameletChange(t *testing.T) {
APIVersion: messaging.SchemeGroupVersion.String(),
}

name := "timer-binding"
timerBinding := "timer-binding"
annotations := map[string]string{
"trait.camel.apache.org/health.enabled": "true",
"trait.camel.apache.org/health.readiness-initial-delay": "10",
}

Expect(BindKameletTo(ns, name, annotations, from, to, map[string]string{"message": "message is Hello"}, map[string]string{})()).To(Succeed())
Expect(BindKameletTo(ns, timerBinding, annotations, from, to, map[string]string{"message": "message is Hello"}, map[string]string{})()).To(Succeed())

Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
Eventually(KameletBindingCondition(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).Should(And(
Eventually(KameletBindingConditionStatus(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
Eventually(KameletBindingCondition(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).Should(And(
WithTransform(KameletBindingConditionReason, Equal(v1.IntegrationConditionDeploymentProgressingReason)),
WithTransform(KameletBindingConditionMessage, Or(
Equal("0/1 updated replicas"),
Equal("0/1 ready replicas"),
))))

Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPodPhase(ns, timerBinding), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "timer-binding", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "display"), TestTimeoutShort).Should(ContainSubstring("message is Hello"))

Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(KameletBindingCondition(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).Should(And(
Eventually(KameletBindingConditionStatus(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(KameletBindingCondition(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).Should(And(
WithTransform(KameletBindingConditionReason, Equal(v1.IntegrationConditionDeploymentReadyReason)),
WithTransform(KameletBindingConditionMessage, Equal(fmt.Sprintf("1/1 ready replicas"))),
))

// Update the KameletBinding
Expect(BindKameletTo(ns, "timer-binding", annotations, from, to, map[string]string{"message": "message is Hi"}, map[string]string{})()).To(Succeed())

Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
Eventually(KameletBindingCondition(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).Should(And(
Eventually(KameletBindingConditionStatus(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
Eventually(KameletBindingCondition(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).Should(And(
WithTransform(KameletBindingConditionReason, Equal(v1.IntegrationConditionDeploymentProgressingReason)),
WithTransform(KameletBindingConditionMessage, Or(
Equal("0/1 updated replicas"),
Expand All @@ -100,8 +101,8 @@ func TestKameletChange(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, "timer-binding", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "display"), TestTimeoutShort).Should(ContainSubstring("message is Hi"))

Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(KameletBindingCondition(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).
Eventually(KameletBindingConditionStatus(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(KameletBindingCondition(ns, timerBinding, v1alpha1.KameletBindingConditionReady), TestTimeoutMedium).
Should(And(
WithTransform(KameletBindingConditionReason, Equal(v1.IntegrationConditionDeploymentReadyReason)),
WithTransform(KameletBindingConditionMessage, Equal("1/1 ready replicas")),
Expand Down
6 changes: 3 additions & 3 deletions pkg/metadata/metadata_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func TestLanguageDependencies(t *testing.T) {
"camel:jsonpath",
"camel:groovy",
"camel:saxon",
"camel:xml-jaxp",
"camel:stax",
},
meta.Dependencies.List())
}
Expand Down Expand Up @@ -662,7 +662,7 @@ func TestXMLLanguageDependencies(t *testing.T) {
"camel:mvel",
"camel:ognl",
"camel:xpath",
"camel:xml-jaxp",
"camel:stax",
"camel:jsonpath",
"camel:saxon",
"camel:groovy",
Expand Down Expand Up @@ -787,7 +787,7 @@ func TestYAMLLanguageDependencies(t *testing.T) {
"camel:jsonpath",
"camel:groovy",
"camel:saxon",
"camel:xml-jaxp",
"camel:stax",
},
meta.Dependencies.List())
}
8 changes: 4 additions & 4 deletions pkg/resources/resources.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pkg/trait/knative.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func (t *knativeTrait) Configure(e *Environment) (bool, error) {

func (t *knativeTrait) Apply(e *Environment) error {
if pointer.BoolDeref(t.SinkBinding, false) {
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.k:camel-k-knative")
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "camel:knative")
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.k:camel-k-knative-impl")
}

if len(t.ChannelSources) > 0 || len(t.EndpointSources) > 0 || len(t.EventSources) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/dsl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TemplateToYamlDSL(template v1.Template, id string) ([]byte, error) {
jsondata["id"] = id
}
templateWrapper := make(map[string]interface{}, 2)
templateWrapper["template"] = jsondata
templateWrapper["routeTemplate"] = jsondata
listWrapper := make([]interface{}, 0, 1)
listWrapper = append(listWrapper, templateWrapper)
yamldata, err := yaml2.Marshal(listWrapper)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/dsl/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestTemplateReadWrite(t *testing.T) {
yamlBytes, err := TemplateToYamlDSL(templateJSON, "myid")
assert.NoError(t, err)
yaml := string(yamlBytes)
expected := `- template:
expected := `- routeTemplate:
beans:
- name: myBean
type: com.acme.MyBean
Expand Down
27 changes: 11 additions & 16 deletions pkg/util/source/inspector_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,53 +111,48 @@ func TestYAMLDependencies(t *testing.T) {
missingDependencies []string
}{
{
name: "consumer",
source: YAMLRouteConsumer,
dependencies: []string{`mvn:org.apache.camel.k:camel-k-knative-consumer`},
missingDependencies: []string{`mvn:org.apache.camel.k:camel-k-knative-producer`},
name: "consumer",
source: YAMLRouteConsumer,
dependencies: []string{`camel:knative`},
},
{
name: "producer",
source: YAMLRouteProducer,
dependencies: []string{`mvn:org.apache.camel.k:camel-k-knative-producer`},
missingDependencies: []string{`mvn:org.apache.camel.k:camel-k-knative-consumer`},
name: "producer",
source: YAMLRouteProducer,
dependencies: []string{`camel:knative`},
},
{
name: "transformer",
source: YAMLRouteTransformer,
dependencies: []string{
`mvn:org.apache.camel.k:camel-k-knative-producer`,
`mvn:org.apache.camel.k:camel-k-knative-consumer`,
`camel:knative`,
},
},
{
name: "invalid",
source: YAMLInvalid,
dependencies: []string{
`mvn:org.apache.camel.k:camel-k-knative-consumer`,
`camel:knative`,
},
},
{
name: "in-depth",
source: YAMLInDepthChannel,
dependencies: []string{
`mvn:org.apache.camel.k:camel-k-knative-producer`,
`mvn:org.apache.camel.k:camel-k-knative-consumer`,
`camel:knative`,
},
},
{
name: "wire-tap-knative",
source: YAMLWireTapKnativeEIP,
dependencies: []string{
`mvn:org.apache.camel.k:camel-k-knative-producer`,
`mvn:org.apache.camel.k:camel-k-knative-consumer`,
`camel:knative`,
},
},
{
name: "wire-tap-jms",
source: YAMLWireTapJmsEIP,
dependencies: []string{
`mvn:org.apache.camel.k:camel-k-knative-consumer`,
`camel:knative`,
`camel:jms`,
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/test/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func TestRuntimeContainsEmbeddedArtifacts(t *testing.T) {

artifact := catalog.GetArtifactByScheme("knative")
assert.Equal(t, 1, len(artifact.Schemes))
assert.Equal(t, "org.apache.camel.k", artifact.GroupID)
assert.Equal(t, "camel-k-knative", artifact.ArtifactID)
assert.Equal(t, "org.apache.camel.quarkus", artifact.GroupID)
assert.Equal(t, "camel-quarkus-knative", artifact.ArtifactID)

scheme, found := catalog.GetScheme("knative")
assert.True(t, found)
Expand Down
44 changes: 17 additions & 27 deletions resources/camel-catalog-1.16.0-SNAPSHOT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ metadata:
name: camel-catalog-1.16.0-snapshot
labels:
app: camel-k
camel.apache.org/catalog.loader.version: 3.18.3
camel.apache.org/catalog.version: 3.18.3
camel.apache.org/catalog.loader.version: 3.19.0
camel.apache.org/catalog.version: 3.19.0
camel.apache.org/runtime.version: 1.16.0-SNAPSHOT
spec:
runtime:
version: 1.16.0-SNAPSHOT
provider: quarkus
applicationClass: io.quarkus.bootstrap.runner.QuarkusEntryPoint
metadata:
camel-quarkus.version: 2.13.1
camel.version: 3.18.3
quarkus.version: 2.13.4.Final
camel-quarkus.version: 2.14.0
camel.version: 3.19.0
quarkus.version: 2.14.0.Final
dependencies:
- groupId: org.apache.camel.k
artifactId: camel-k-runtime
Expand Down Expand Up @@ -75,21 +75,6 @@ spec:
camel-k-cron:
groupId: org.apache.camel.k
artifactId: camel-k-cron
camel-k-knative:
groupId: org.apache.camel.k
artifactId: camel-k-knative
schemes:
- id: knative
http: true
passive: false
producer:
dependencies:
- groupId: org.apache.camel.k
artifactId: camel-k-knative-producer
consumer:
dependencies:
- groupId: org.apache.camel.k
artifactId: camel-k-knative-consumer
camel-k-master:
groupId: org.apache.camel.k
artifactId: camel-k-master
Expand Down Expand Up @@ -1630,6 +1615,15 @@ spec:
passive: false
javaTypes:
- org.apache.camel.component.kamelet.KameletComponent
camel-quarkus-knative:
groupId: org.apache.camel.quarkus
artifactId: camel-quarkus-knative
schemes:
- id: knative
http: true
passive: false
javaTypes:
- org.apache.camel.component.knative.KnativeComponent
camel-quarkus-kubernetes:
groupId: org.apache.camel.quarkus
artifactId: camel-quarkus-kubernetes
Expand Down Expand Up @@ -2428,8 +2422,11 @@ spec:
- id: stax
http: false
passive: false
languages:
- xtokenize
javaTypes:
- org.apache.camel.component.stax.StAXComponent
- org.apache.camel.language.xtokenizer.XMLTokenizeLanguage
camel-quarkus-stitch:
groupId: org.apache.camel.quarkus
artifactId: camel-quarkus-stitch
Expand Down Expand Up @@ -2673,13 +2670,6 @@ spec:
passive: false
javaTypes:
- org.apache.camel.component.xj.XJComponent
camel-quarkus-xml-jaxp:
groupId: org.apache.camel.quarkus
artifactId: camel-quarkus-xml-jaxp
languages:
- xtokenize
javaTypes:
- org.apache.camel.language.xtokenizer.XMLTokenizeLanguage
camel-quarkus-xmlsecurity:
groupId: org.apache.camel.quarkus
artifactId: camel-quarkus-xmlsecurity
Expand Down
Loading

0 comments on commit e28dc43

Please sign in to comment.