You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2021/04/12 13:56:43 UTC
[camel-k] branch master updated (d50322e -> ca0bcad)
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.
from d50322e chore(cli): Fix error handling in local commands
new 5505bec Fix #2083: add kamel bind command
new 0314d28 Fix #2083: add steps and query-like parameters
new ff587df chore: add some more time to YAKS tests
new 2d0916c chore: fix test panic
new b3c5909 chore: split yaks tests
new ca0bcad fixed bug that caused creation of double knative revision
The 6 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/common/cli/dev_mode_test.go | 2 +
.../common/apache-kamelet-catalog/kamelet.feature | 5 +
.../kamelet-autoload-specific.feature | 4 +-
.../kamelet-autoload.feature | 4 +-
.../common/kamelet-binding-broker/kamelet.feature | 5 +
.../display.groovy | 0
.../common/kamelet-binding-http/kamelet.feature | 11 +
.../timer-source-binding-display.yaml | 0
.../timer-source.kamelet.yaml | 0
.../yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-binding/kamelet.feature | 10 +-
e2e/yaks/common/kamelet-binding/yaks-config.yaml | 4 -
.../kamelet-no-properties/kamelet-no-props.feature | 3 +
.../common/kamelet-steps/steps-binding.feature | 5 +
e2e/yaks/common/kamelet/kamelet.feature | 5 +
.../common/knative-sinkbinding/sinkbinding.feature | 5 +
e2e/yaks/common/knative/sources.feature | 5 +
pkg/cmd/bind.go | 357 +++++++++++++++++++++
pkg/cmd/root.go | 11 +-
pkg/cmd/run.go | 2 +-
pkg/metadata/metadata_http_test.go | 1 +
pkg/trait/knative_service.go | 10 +-
pkg/util/reference/reference.go | 44 ++-
pkg/util/reference/reference_test.go | 36 +++
pkg/util/source/inspector.go | 3 +
pkg/util/uri/uri.go | 7 +
pkg/util/uri/uri_test.go | 37 +++
27 files changed, 553 insertions(+), 29 deletions(-)
rename e2e/yaks/common/{kamelet-binding => kamelet-binding-http}/display.groovy (100%)
create mode 100644 e2e/yaks/common/kamelet-binding-http/kamelet.feature
rename e2e/yaks/common/{kamelet-binding => kamelet-binding-http}/timer-source-binding-display.yaml (100%)
copy e2e/yaks/common/{kamelet => kamelet-binding-http}/timer-source.kamelet.yaml (100%)
copy e2e/yaks/common/{kamelet-steps => kamelet-binding-http}/yaks-config.yaml (79%)
create mode 100644 pkg/cmd/bind.go
[camel-k] 01/06: Fix #2083: add kamel bind command
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 5505bec203dbb40b6bbaadb3b2db226a86cf5074
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Mon Mar 29 10:28:34 2021 +0200
Fix #2083: add kamel bind command
---
pkg/cmd/bind.go | 307 +++++++++++++++++++++++++++++++++++++++++++++++
pkg/cmd/root.go | 3 +-
pkg/cmd/run.go | 2 +-
pkg/util/uri/uri.go | 7 ++
pkg/util/uri/uri_test.go | 37 ++++++
5 files changed, 354 insertions(+), 2 deletions(-)
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
new file mode 100644
index 0000000..320ffb4
--- /dev/null
+++ b/pkg/cmd/bind.go
@@ -0,0 +1,307 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package cmd
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "strings"
+
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/kubernetes"
+ "github.com/apache/camel-k/pkg/util/reference"
+ "github.com/apache/camel-k/pkg/util/uri"
+ "github.com/spf13/cobra"
+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+)
+
+// newCmdBind --
+func newCmdBind(rootCmdOptions *RootCmdOptions) (*cobra.Command, *bindCmdOptions) {
+ options := bindCmdOptions{
+ RootCmdOptions: rootCmdOptions,
+ }
+ cmd := cobra.Command{
+ Use: "bind [source] [sink] ...",
+ Short: "Bind Kubernetes resources, such as Kamelets, in an integration flow. Endpoints are expected in the format \"[[apigroup/]version:]kind:[namespace/]name\" or plain Camel URIs.",
+ PreRunE: decode(&options),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ if err := options.validate(cmd, args); err != nil {
+ return err
+ }
+ if err := options.run(args); err != nil {
+ fmt.Println(err.Error())
+ }
+
+ return nil
+ },
+ }
+
+ cmd.Flags().String("name", "", "Name for the binding")
+ cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
+ cmd.Flags().StringArrayP("property", "p", nil, `Add a binding property in the form of "source.<key>=<value>" or "sink.<key>=<value>"`)
+ cmd.Flags().Bool("skip-checks", false, "Do not verify the binding for compliance with Kamelets and other Kubernetes resources")
+
+ return &cmd, &options
+}
+
+const (
+ sourceKey = "source"
+ sinkKey = "sink"
+)
+
+type bindCmdOptions struct {
+ *RootCmdOptions
+ Name string `mapstructure:"name" yaml:",omitempty"`
+ OutputFormat string `mapstructure:"output" yaml:",omitempty"`
+ Properties []string `mapstructure:"properties" yaml:",omitempty"`
+ SkipChecks bool `mapstructure:"skip-checks" yaml:",omitempty"`
+}
+
+func (o *bindCmdOptions) validate(cmd *cobra.Command, args []string) error {
+ if len(args) > 2 {
+ return errors.New("too many arguments: expected source and sink")
+ } else if len(args) < 2 {
+ return errors.New("source or sink arguments are missing")
+ }
+
+ for _, p := range o.Properties {
+ if _, _, _, err := o.parseProperty(p); err != nil {
+ return err
+ }
+ }
+
+ if !o.SkipChecks {
+ source, err := o.decode(args[0], sourceKey)
+ if err != nil {
+ return err
+ }
+ if err := o.checkCompliance(cmd, source); err != nil {
+ return err
+ }
+
+ sink, err := o.decode(args[1], sinkKey)
+ if err != nil {
+ return err
+ }
+ if err := o.checkCompliance(cmd, sink); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func (o *bindCmdOptions) run(args []string) error {
+ source, err := o.decode(args[0], sourceKey)
+ if err != nil {
+ return err
+ }
+
+ sink, err := o.decode(args[1], sinkKey)
+ if err != nil {
+ return err
+ }
+
+ name := o.nameFor(source, sink)
+
+ binding := v1alpha1.KameletBinding{
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: o.Namespace,
+ Name: name,
+ },
+ Spec: v1alpha1.KameletBindingSpec{
+ Source: source,
+ Sink: sink,
+ },
+ }
+
+ switch o.OutputFormat {
+ case "":
+ // continue..
+ case "yaml":
+ data, err := kubernetes.ToYAML(&binding)
+ if err != nil {
+ return err
+ }
+ fmt.Print(string(data))
+ return nil
+
+ case "json":
+ data, err := kubernetes.ToJSON(&binding)
+ if err != nil {
+ return err
+ }
+ fmt.Print(string(data))
+ return nil
+
+ default:
+ return fmt.Errorf("invalid output format option '%s', should be one of: yaml|json", o.OutputFormat)
+ }
+
+ client, err := o.GetCmdClient()
+ if err != nil {
+ return err
+ }
+
+ existed := false
+ err = client.Create(o.Context, &binding)
+ if err != nil && k8serrors.IsAlreadyExists(err) {
+ existed = true
+ err = kubernetes.ReplaceResource(o.Context, client, &binding)
+ }
+ if err != nil {
+ return err
+ }
+
+ if !existed {
+ fmt.Printf("kamelet binding \"%s\" created\n", name)
+ } else {
+ fmt.Printf("kamelet binding \"%s\" updated\n", name)
+ }
+ return nil
+}
+
+func (o *bindCmdOptions) decode(res string, key string) (v1alpha1.Endpoint, error) {
+ refConverter := reference.NewConverter(reference.KameletPrefix)
+ endpoint := v1alpha1.Endpoint{}
+ props, err := o.asEndpointProperties(o.getProperties(key))
+ if err != nil {
+ return endpoint, err
+ }
+ endpoint.Properties = props
+
+ ref, err := refConverter.FromString(res)
+ if err != nil {
+ if uri.HasCamelURIFormat(res) {
+ endpoint.URI = &res
+ return endpoint, nil
+ }
+ return endpoint, err
+ }
+ endpoint.Ref = &ref
+ if endpoint.Ref.Namespace == "" {
+ endpoint.Ref.Namespace = o.Namespace
+ }
+ return endpoint, nil
+}
+
+func (o *bindCmdOptions) nameFor(source, sink v1alpha1.Endpoint) string {
+ if o.Name != "" {
+ return o.Name
+ }
+ sourcePart := o.nameForEndpoint(source)
+ sinkPart := o.nameForEndpoint(sink)
+ name := fmt.Sprintf("%s-to-%s", sourcePart, sinkPart)
+ return kubernetes.SanitizeName(name)
+}
+
+func (o *bindCmdOptions) nameForEndpoint(endpoint v1alpha1.Endpoint) string {
+ if endpoint.URI != nil {
+ return uri.GetComponent(*endpoint.URI)
+ }
+ if endpoint.Ref != nil {
+ return endpoint.Ref.Name
+ }
+ return ""
+}
+
+func (o *bindCmdOptions) asEndpointProperties(props map[string]string) (*v1alpha1.EndpointProperties, error) {
+ if len(props) == 0 {
+ return nil, nil
+ }
+ data, err := json.Marshal(props)
+ if err != nil {
+ return nil, err
+ }
+ return &v1alpha1.EndpointProperties{
+ RawMessage: v1.RawMessage(data),
+ }, nil
+}
+
+func (o *bindCmdOptions) getProperties(refType string) map[string]string {
+ props := make(map[string]string)
+ for _, p := range o.Properties {
+ tp, k, v, err := o.parseProperty(p)
+ if err != nil {
+ continue
+ }
+ if tp == refType {
+ props[k] = v
+ }
+ }
+ return props
+}
+
+func (o *bindCmdOptions) parseProperty(prop string) (string, string, string, error) {
+ parts := strings.SplitN(prop, "=", 2)
+ if len(parts) != 2 {
+ return "", "", "", fmt.Errorf(`property %q does not follow format "[source|sink].<key>=<value>"`, prop)
+ }
+ keyParts := strings.SplitN(parts[0], ".", 2)
+ if len(keyParts) != 2 {
+ return "", "", "", fmt.Errorf(`property key %q does not follow format "[source|sink].<key>"`, parts[0])
+ }
+ if keyParts[0] != sourceKey && keyParts[0] != sinkKey {
+ return "", "", "", fmt.Errorf(`property key %q does not start with "source." or "sink."`, parts[0])
+ }
+ return keyParts[0], keyParts[1], parts[1], nil
+}
+
+func (o *bindCmdOptions) checkCompliance(cmd *cobra.Command, endpoint v1alpha1.Endpoint) error {
+ if endpoint.Ref != nil && endpoint.Ref.Kind == "Kamelet" {
+ c, err := o.GetCmdClient()
+ if err != nil {
+ return err
+ }
+ key := client.ObjectKey{
+ Namespace: endpoint.Ref.Namespace,
+ Name: endpoint.Ref.Name,
+ }
+ kamelet := v1alpha1.Kamelet{}
+ if err := c.Get(o.Context, key, &kamelet); err != nil {
+ if k8serrors.IsNotFound(err) {
+ // Kamelet may be in the operator namespace, but we currently don't have a way to determine it: we just warn
+ fmt.Fprintf(cmd.OutOrStderr(), "Warning: Kamelet %q not found in namespace %q\n", key.Name, key.Namespace)
+ return nil
+ }
+ return err
+ }
+ if kamelet.Spec.Definition != nil && len(kamelet.Spec.Definition.Required) > 0 {
+ pMap, err := endpoint.Properties.GetPropertyMap()
+ if err != nil {
+ return err
+ }
+ for _, reqProp := range kamelet.Spec.Definition.Required {
+ found := false
+ if endpoint.Properties != nil {
+ if _, contains := pMap[reqProp]; contains {
+ found = true
+ }
+ }
+ if !found {
+ return fmt.Errorf("binding is missing required property %q for Kamelet %q", reqProp, key.Name)
+ }
+ }
+ }
+ }
+ return nil
+}
diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go
index c61a2fa..d3de5c7 100644
--- a/pkg/cmd/root.go
+++ b/pkg/cmd/root.go
@@ -147,6 +147,7 @@ func addKamelSubcommands(cmd *cobra.Command, options *RootCmdOptions) {
cmd.AddCommand(cmdOnly(newCmdDebug(options)))
cmd.AddCommand(cmdOnly(newCmdDump(options)))
cmd.AddCommand(newCmdLocal(options))
+ cmd.AddCommand(cmdOnly(newCmdBind(options)))
}
func addHelpSubCommands(cmd *cobra.Command, options *RootCmdOptions) error {
@@ -206,7 +207,7 @@ func checkAndShowCompatibilityWarning(ctx context.Context, c client.Client, name
if k8serrors.IsNotFound(err) {
fmt.Printf("No IntegrationPlatform resource in %s namespace\n", namespace)
} else {
- fmt.Printf("Unable to retrieve the operator version: %s", err.Error())
+ fmt.Printf("Unable to retrieve the operator version: %s\n", err.Error())
}
} else {
if operatorVersion != "" && !compatibleVersions(operatorVersion, defaults.Version) {
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 7caea00..0b6bf6e 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -414,7 +414,7 @@ func (o *runCmdOptions) syncIntegration(cmd *cobra.Command, c client.Client, sou
}
}()
} else {
- fmt.Printf("WARNING: the following URL will not be watched for changes: %s\n", s)
+ fmt.Printf("Warning: the following URL will not be watched for changes: %s\n", s)
}
}
diff --git a/pkg/util/uri/uri.go b/pkg/util/uri/uri.go
index 1e0cf1e..542eee4 100644
--- a/pkg/util/uri/uri.go
+++ b/pkg/util/uri/uri.go
@@ -27,8 +27,15 @@ import (
"github.com/apache/camel-k/pkg/util/log"
)
+var uriRegexp = regexp.MustCompile(`^[a-z0-9+][a-zA-Z0-9-+]*:.*$`)
+
var queryExtractorRegexp = `^[^?]+\?(?:|.*[&])%s=([^&]+)(?:[&].*|$)`
+// HasCamelURIFormat tells if a given string may belong to a Camel URI, without checking any catalog
+func HasCamelURIFormat(uri string) bool {
+ return uriRegexp.MatchString(uri)
+}
+
// GetComponent returns the Camel component used in the URI
func GetComponent(uri string) string {
parts := strings.Split(uri, ":")
diff --git a/pkg/util/uri/uri_test.go b/pkg/util/uri/uri_test.go
index ae22ff8..19dcdca 100644
--- a/pkg/util/uri/uri_test.go
+++ b/pkg/util/uri/uri_test.go
@@ -142,3 +142,40 @@ func TestAppendParameters(t *testing.T) {
})
}
}
+
+func TestCamelURIFormat(t *testing.T) {
+ tests := []struct {
+ uri string
+ invalid bool
+ }{
+ {
+ uri: "knative:channnel",
+ },
+ {
+ uri: "atomix-value:",
+ },
+ {
+ uri: "aws-ec2:",
+ },
+ {
+ uri: "coap+tcp:",
+ },
+ {
+ uri: "solrCloud:",
+ },
+ {
+ uri: "PostgreSQL:db",
+ invalid: true,
+ },
+ {
+ uri: "postgres.org/v1alpha1:PostgreSQL:db",
+ invalid: true,
+ },
+ }
+
+ for i, tc := range tests {
+ t.Run(fmt.Sprintf("%d-%s", i, tc.uri), func(t *testing.T) {
+ assert.Equal(t, !tc.invalid, HasCamelURIFormat(tc.uri))
+ })
+ }
+}
[camel-k] 05/06: chore: split yaks tests
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b3c59094690fc70048ce39c083630cf1f80903e4
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Apr 9 16:30:57 2021 +0200
chore: split yaks tests
---
.../display.groovy | 0
.../kamelet.feature | 6 +--
.../timer-source-binding-display.yaml | 0
.../timer-source.kamelet.yaml} | 43 +++++++++++++++++-----
.../yaks-config.yaml | 9 -----
e2e/yaks/common/kamelet-binding/kamelet.feature | 5 ---
e2e/yaks/common/kamelet-binding/yaks-config.yaml | 4 --
7 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/e2e/yaks/common/kamelet-binding/display.groovy b/e2e/yaks/common/kamelet-binding-http/display.groovy
similarity index 100%
rename from e2e/yaks/common/kamelet-binding/display.groovy
rename to e2e/yaks/common/kamelet-binding-http/display.groovy
diff --git a/e2e/yaks/common/kamelet-binding/kamelet.feature b/e2e/yaks/common/kamelet-binding-http/kamelet.feature
similarity index 59%
copy from e2e/yaks/common/kamelet-binding/kamelet.feature
copy to e2e/yaks/common/kamelet-binding-http/kamelet.feature
index fa93a2e..4430823 100644
--- a/e2e/yaks/common/kamelet-binding/kamelet.feature
+++ b/e2e/yaks/common/kamelet-binding-http/kamelet.feature
@@ -1,14 +1,10 @@
-Feature: Camel K can bind Kamelets
+Feature: Camel K can bind Kamelets via HTTP
Background:
Given Camel-K resource polling configuration
| maxAttempts | 40 |
| delayBetweenAttempts | 3000 |
- Scenario: Running integration using a simple Kamelet with KameletBinding
- Given Camel-K integration logger-sink-binding is running
- Then Camel-K integration logger-sink-binding should print message: Hello Kamelets
-
Scenario: Binding to a HTTP URI should use CloudEvents
Given Camel-K integration display is running
Then Camel-K integration display should print type: org.apache.camel.event
diff --git a/e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml b/e2e/yaks/common/kamelet-binding-http/timer-source-binding-display.yaml
similarity index 100%
copy from e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml
copy to e2e/yaks/common/kamelet-binding-http/timer-source-binding-display.yaml
diff --git a/e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml b/e2e/yaks/common/kamelet-binding-http/timer-source.kamelet.yaml
similarity index 56%
rename from e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml
rename to e2e/yaks/common/kamelet-binding-http/timer-source.kamelet.yaml
index 91cbf37..a08cecf 100644
--- a/e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml
+++ b/e2e/yaks/common/kamelet-binding-http/timer-source.kamelet.yaml
@@ -16,16 +16,39 @@
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1alpha1
-kind: KameletBinding
+kind: Kamelet
metadata:
- name: timer-source-binding-display
+ name: timer-source
+ labels:
+ camel.apache.org/kamelet.type: "source"
spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1alpha1
- name: timer-source
+ definition:
+ title: "Timer"
+ description: "Produces periodic events with a custom payload"
+ required:
+ - message
properties:
- message: Hello
- sink:
- uri: http://display.{namespace}.svc.cluster.local
+ period:
+ title: Period
+ description: The time interval between two events
+ type: integer
+ default: 1000
+ message:
+ title: Message
+ description: The message to generate
+ type: string
+ types:
+ out:
+ mediaType: application/json
+ schema:
+ id: text.camel.apache.org
+ type: string
+ flow:
+ from:
+ uri: timer:tick
+ parameters:
+ period: "{{period}}"
+ steps:
+ - set-body:
+ constant: "{{message}}"
+ - to: "kamelet:sink"
diff --git a/e2e/yaks/common/kamelet-binding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml
similarity index 74%
copy from e2e/yaks/common/kamelet-binding/yaks-config.yaml
copy to e2e/yaks/common/kamelet-binding-http/yaks-config.yaml
index 1e0370b..de3709b 100644
--- a/e2e/yaks/common/kamelet-binding/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml
@@ -23,16 +23,7 @@ pre:
run: |
kamel install -n $YAKS_NAMESPACE
- kubectl apply -f messages-channel.yaml -n $YAKS_NAMESPACE
-
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
- kubectl apply -f logger-sink.kamelet.yaml -n $YAKS_NAMESPACE
-
- kubectl apply -f timer-source-binding.yaml -n $YAKS_NAMESPACE
- kubectl apply -f logger-sink-binding.yaml -n $YAKS_NAMESPACE
-
- kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
- kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
kamel run display.groovy -w -n $YAKS_NAMESPACE
cat timer-source-binding-display.yaml | sed 's/{namespace}/'"${YAKS_NAMESPACE}"'/' | kubectl apply -n $YAKS_NAMESPACE -f -
diff --git a/e2e/yaks/common/kamelet-binding/kamelet.feature b/e2e/yaks/common/kamelet-binding/kamelet.feature
index fa93a2e..3cf7775 100644
--- a/e2e/yaks/common/kamelet-binding/kamelet.feature
+++ b/e2e/yaks/common/kamelet-binding/kamelet.feature
@@ -8,8 +8,3 @@ Feature: Camel K can bind Kamelets
Scenario: Running integration using a simple Kamelet with KameletBinding
Given Camel-K integration logger-sink-binding is running
Then Camel-K integration logger-sink-binding should print message: Hello Kamelets
-
- Scenario: Binding to a HTTP URI should use CloudEvents
- Given Camel-K integration display is running
- Then Camel-K integration display should print type: org.apache.camel.event
- Then Camel-K integration display should print Hello
diff --git a/e2e/yaks/common/kamelet-binding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
index 1e0370b..a75bafe 100644
--- a/e2e/yaks/common/kamelet-binding/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
@@ -33,7 +33,3 @@ pre:
kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
-
- kamel run display.groovy -w -n $YAKS_NAMESPACE
- cat timer-source-binding-display.yaml | sed 's/{namespace}/'"${YAKS_NAMESPACE}"'/' | kubectl apply -n $YAKS_NAMESPACE -f -
- kubectl wait kameletbinding timer-source-binding-display --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
[camel-k] 06/06: fixed bug that caused creation of double knative
revision
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit ca0bcad23f0b6f76e3646d6e0e62ebec24348baa
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Apr 9 18:48:20 2021 +0200
fixed bug that caused creation of double knative revision
---
pkg/metadata/metadata_http_test.go | 1 +
pkg/trait/knative_service.go | 10 ++++++----
pkg/util/source/inspector.go | 3 +++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/pkg/metadata/metadata_http_test.go b/pkg/metadata/metadata_http_test.go
index a0ec2bb..3f653ac 100644
--- a/pkg/metadata/metadata_http_test.go
+++ b/pkg/metadata/metadata_http_test.go
@@ -57,6 +57,7 @@ func TestHttpOnlyJavaSource(t *testing.T) {
from("direct:bots/cippa").to("log:stash");
from("netty-http:uri").to("log:stash");
from("seda:path").to("log:stash");
+ from("kamelet:source").to("log:sink");
`,
},
Language: v1.LanguageJavaSource,
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index a1e8ac1..9cc77aa 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -102,10 +102,7 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, error) {
return false, nil
}
- if e.IntegrationInPhase(v1.IntegrationPhaseRunning) {
- condition := e.Integration.Status.GetCondition(v1.IntegrationConditionKnativeServiceAvailable)
- return condition != nil && condition.Status == corev1.ConditionTrue, nil
- } else if !e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseDeploying) {
+ if !e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseDeploying) && !e.IntegrationInPhase(v1.IntegrationPhaseRunning) {
return false, nil
}
@@ -164,6 +161,11 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, error) {
}
}
+ if e.IntegrationInPhase(v1.IntegrationPhaseRunning) {
+ condition := e.Integration.Status.GetCondition(v1.IntegrationConditionKnativeServiceAvailable)
+ return condition != nil && condition.Status == corev1.ConditionTrue, nil
+ }
+
return true, nil
}
diff --git a/pkg/util/source/inspector.go b/pkg/util/source/inspector.go
index 746a03a..3933a61 100644
--- a/pkg/util/source/inspector.go
+++ b/pkg/util/source/inspector.go
@@ -324,6 +324,9 @@ func (i *baseInspector) hasOnlyPassiveEndpoints(fromURIs []string) bool {
func (i *baseInspector) containsOnlyURIsIn(fromURI []string, allowed map[string]bool) bool {
for _, uri := range fromURI {
+ if uri == "kamelet:source" {
+ continue
+ }
prefix := i.getURIPrefix(uri)
if enabled, ok := allowed[prefix]; !ok || !enabled {
return false
[camel-k] 02/06: Fix #2083: add steps and query-like parameters
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0314d28c0435f54e9f848bc701792a1cce801db5
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Wed Apr 7 15:20:09 2021 +0200
Fix #2083: add steps and query-like parameters
---
pkg/cmd/bind.go | 68 +++++++++++++++++++++++++++++++-----
pkg/cmd/root.go | 10 +++---
pkg/cmd/run.go | 2 +-
pkg/util/reference/reference.go | 44 +++++++++++++++++++++--
pkg/util/reference/reference_test.go | 36 +++++++++++++++++++
5 files changed, 142 insertions(+), 18 deletions(-)
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 320ffb4..2771899 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -57,15 +57,17 @@ func newCmdBind(rootCmdOptions *RootCmdOptions) (*cobra.Command, *bindCmdOptions
cmd.Flags().String("name", "", "Name for the binding")
cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
- cmd.Flags().StringArrayP("property", "p", nil, `Add a binding property in the form of "source.<key>=<value>" or "sink.<key>=<value>"`)
+ cmd.Flags().StringArrayP("property", "p", nil, `Add a binding property in the form of "source.<key>=<value>", "sink.<key>=<value>" or "step-<n>.<key>=<value>"`)
cmd.Flags().Bool("skip-checks", false, "Do not verify the binding for compliance with Kamelets and other Kubernetes resources")
+ cmd.Flags().StringArray("step", nil, `Add binding steps as Kubernetes resources, such as Kamelets. Endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name" or plain Camel URIs.`)
return &cmd, &options
}
const (
- sourceKey = "source"
- sinkKey = "sink"
+ sourceKey = "source"
+ sinkKey = "sink"
+ stepKeyPrefix = "step-"
)
type bindCmdOptions struct {
@@ -74,6 +76,7 @@ type bindCmdOptions struct {
OutputFormat string `mapstructure:"output" yaml:",omitempty"`
Properties []string `mapstructure:"properties" yaml:",omitempty"`
SkipChecks bool `mapstructure:"skip-checks" yaml:",omitempty"`
+ Steps []string `mapstructure:"steps" yaml:",omitempty"`
}
func (o *bindCmdOptions) validate(cmd *cobra.Command, args []string) error {
@@ -105,6 +108,17 @@ func (o *bindCmdOptions) validate(cmd *cobra.Command, args []string) error {
if err := o.checkCompliance(cmd, sink); err != nil {
return err
}
+
+ for idx, stepDesc := range o.Steps {
+ stepKey := fmt.Sprintf("%s%d", stepKeyPrefix, idx)
+ step, err := o.decode(stepDesc, stepKey)
+ if err != nil {
+ return err
+ }
+ if err := o.checkCompliance(cmd, step); err != nil {
+ return err
+ }
+ }
}
return nil
@@ -134,6 +148,18 @@ func (o *bindCmdOptions) run(args []string) error {
},
}
+ if len(o.Steps) > 0 {
+ binding.Spec.Steps = make([]v1alpha1.Endpoint, 0)
+ for idx, stepDesc := range o.Steps {
+ stepKey := fmt.Sprintf("%s%d", stepKeyPrefix, idx)
+ step, err := o.decode(stepDesc, stepKey)
+ if err != nil {
+ return err
+ }
+ binding.Spec.Steps = append(binding.Spec.Steps, step)
+ }
+ }
+
switch o.OutputFormat {
case "":
// continue..
@@ -183,7 +209,8 @@ func (o *bindCmdOptions) run(args []string) error {
func (o *bindCmdOptions) decode(res string, key string) (v1alpha1.Endpoint, error) {
refConverter := reference.NewConverter(reference.KameletPrefix)
endpoint := v1alpha1.Endpoint{}
- props, err := o.asEndpointProperties(o.getProperties(key))
+ explicitProps := o.getProperties(key)
+ props, err := o.asEndpointProperties(explicitProps)
if err != nil {
return endpoint, err
}
@@ -201,6 +228,26 @@ func (o *bindCmdOptions) decode(res string, key string) (v1alpha1.Endpoint, erro
if endpoint.Ref.Namespace == "" {
endpoint.Ref.Namespace = o.Namespace
}
+ embeddedProps, err := refConverter.PropertiesFromString(res)
+ if err != nil {
+ return endpoint, err
+ }
+ if len(embeddedProps) > 0 {
+ allProps := make(map[string]string)
+ for k, v := range explicitProps {
+ allProps[k] = v
+ }
+ for k, v := range embeddedProps {
+ allProps[k] = v
+ }
+
+ props, err := o.asEndpointProperties(allProps)
+ if err != nil {
+ return endpoint, err
+ }
+ endpoint.Properties = props
+ }
+
return endpoint, nil
}
@@ -254,14 +301,17 @@ func (o *bindCmdOptions) getProperties(refType string) map[string]string {
func (o *bindCmdOptions) parseProperty(prop string) (string, string, string, error) {
parts := strings.SplitN(prop, "=", 2)
if len(parts) != 2 {
- return "", "", "", fmt.Errorf(`property %q does not follow format "[source|sink].<key>=<value>"`, prop)
+ return "", "", "", fmt.Errorf(`property %q does not follow format "[source|sink|step-<n>].<key>=<value>"`, prop)
}
keyParts := strings.SplitN(parts[0], ".", 2)
if len(keyParts) != 2 {
- return "", "", "", fmt.Errorf(`property key %q does not follow format "[source|sink].<key>"`, parts[0])
+ return "", "", "", fmt.Errorf(`property key %q does not follow format "[source|sink|step-<n>].<key>"`, parts[0])
}
- if keyParts[0] != sourceKey && keyParts[0] != sinkKey {
- return "", "", "", fmt.Errorf(`property key %q does not start with "source." or "sink."`, parts[0])
+ isSource := keyParts[0] == sourceKey
+ isSink := keyParts[0] == sinkKey
+ isStep := strings.HasPrefix(keyParts[0], stepKeyPrefix)
+ if !isSource && !isSink && !isStep {
+ return "", "", "", fmt.Errorf(`property key %q does not start with "source.", "sink." or "step-<n>."`, parts[0])
}
return keyParts[0], keyParts[1], parts[1], nil
}
@@ -280,7 +330,7 @@ func (o *bindCmdOptions) checkCompliance(cmd *cobra.Command, endpoint v1alpha1.E
if err := c.Get(o.Context, key, &kamelet); err != nil {
if k8serrors.IsNotFound(err) {
// Kamelet may be in the operator namespace, but we currently don't have a way to determine it: we just warn
- fmt.Fprintf(cmd.OutOrStderr(), "Warning: Kamelet %q not found in namespace %q\n", key.Name, key.Namespace)
+ fmt.Fprintf(cmd.ErrOrStderr(), "Warning: Kamelet %q not found in namespace %q\n", key.Name, key.Namespace)
return nil
}
return err
diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go
index d3de5c7..06a775b 100644
--- a/pkg/cmd/root.go
+++ b/pkg/cmd/root.go
@@ -194,24 +194,24 @@ func (command *RootCmdOptions) preRun(cmd *cobra.Command, _ []string) error {
// Furthermore, there can be any incompatibilities, as the install command deploys
// the operator version it's compatible with.
if cmd.Use != installCommand && cmd.Use != operatorCommand {
- checkAndShowCompatibilityWarning(command.Context, c, command.Namespace)
+ checkAndShowCompatibilityWarning(cmd, command.Context, c, command.Namespace)
}
}
return nil
}
-func checkAndShowCompatibilityWarning(ctx context.Context, c client.Client, namespace string) {
+func checkAndShowCompatibilityWarning(cmd *cobra.Command, ctx context.Context, c client.Client, namespace string) {
operatorVersion, err := operatorVersion(ctx, c, namespace)
if err != nil {
if k8serrors.IsNotFound(err) {
- fmt.Printf("No IntegrationPlatform resource in %s namespace\n", namespace)
+ fmt.Fprintf(cmd.ErrOrStderr(), "No IntegrationPlatform resource in %s namespace\n", namespace)
} else {
- fmt.Printf("Unable to retrieve the operator version: %s\n", err.Error())
+ fmt.Fprintf(cmd.ErrOrStderr(), "Unable to retrieve the operator version: %s\n", err.Error())
}
} else {
if operatorVersion != "" && !compatibleVersions(operatorVersion, defaults.Version) {
- fmt.Printf("You're using Camel K %s client with a %s cluster operator, it's recommended to use the same version to improve compatibility.\n\n", defaults.Version, operatorVersion)
+ fmt.Fprintf(cmd.ErrOrStderr(), "You're using Camel K %s client with a %s cluster operator, it's recommended to use the same version to improve compatibility.\n\n", defaults.Version, operatorVersion)
}
}
}
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 0b6bf6e..255feaf 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -414,7 +414,7 @@ func (o *runCmdOptions) syncIntegration(cmd *cobra.Command, c client.Client, sou
}
}()
} else {
- fmt.Printf("Warning: the following URL will not be watched for changes: %s\n", s)
+ fmt.Fprintf(cmd.ErrOrStderr(), "Warning: the following URL will not be watched for changes: %s\n", s)
}
}
diff --git a/pkg/util/reference/reference.go b/pkg/util/reference/reference.go
index dc79cd5..5af887e 100644
--- a/pkg/util/reference/reference.go
+++ b/pkg/util/reference/reference.go
@@ -18,12 +18,14 @@ limitations under the License.
package reference
import (
- "errors"
"fmt"
+ "net/url"
"regexp"
+ "strings"
"unicode"
camelv1alpha1 "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1"
@@ -35,8 +37,9 @@ const (
)
var (
- simpleNameRegexp = regexp.MustCompile(`^(?:(?P<namespace>[a-z0-9-.]+)/)?(?P<name>[a-z0-9-.]+)$`)
- fullNameRegexp = regexp.MustCompile(`^(?:(?P<apiVersion>(?:[a-z0-9-.]+/)?(?:[a-z0-9-.]+)):)?(?P<kind>[A-Za-z0-9-.]+):(?:(?P<namespace>[a-z0-9-.]+)/)?(?P<name>[a-z0-9-.]+)$`)
+ simpleNameRegexp = regexp.MustCompile(`^(?:(?P<namespace>[a-z0-9-.]+)/)?(?P<name>[a-z0-9-.]+)(?:$|[?].*$)`)
+ fullNameRegexp = regexp.MustCompile(`^(?:(?P<apiVersion>(?:[a-z0-9-.]+/)?(?:[a-z0-9-.]+)):)?(?P<kind>[A-Za-z0-9-.]+):(?:(?P<namespace>[a-z0-9-.]+)/)?(?P<name>[a-z0-9-.]+)(?:$|[?].*$)`)
+ queryRegexp = regexp.MustCompile(`^[^?]*[?](?P<query>.*)$`)
templates = map[string]corev1.ObjectReference{
"kamelet": corev1.ObjectReference{
@@ -81,6 +84,41 @@ func (c *Converter) FromString(str string) (corev1.ObjectReference, error) {
return ref, nil
}
+func (c *Converter) PropertiesFromString(str string) (map[string]string, error) {
+ if queryRegexp.MatchString(str) {
+ groupNames := queryRegexp.SubexpNames()
+ res := make(map[string]string)
+ var query string
+ for _, match := range queryRegexp.FindAllStringSubmatch(str, -1) {
+ for idx, text := range match {
+ groupName := groupNames[idx]
+ switch groupName {
+ case "query":
+ query = text
+ }
+ }
+ }
+ parts := strings.Split(query, "&")
+ for _, part := range parts {
+ kv := strings.SplitN(part, "=", 2)
+ if len(kv) != 2 {
+ return nil, fmt.Errorf("invalid key=value format for string %q", part)
+ }
+ k, errkey := url.QueryUnescape(kv[0])
+ if errkey != nil {
+ return nil, errors.Wrapf(errkey, "cannot unescape key %q", kv[0])
+ }
+ v, errval := url.QueryUnescape(kv[1])
+ if errval != nil {
+ return nil, errors.Wrapf(errval, "cannot unescape value %q", kv[1])
+ }
+ res[k] = v
+ }
+ return res, nil
+ }
+ return nil, nil
+}
+
func (c *Converter) expandReference(ref *corev1.ObjectReference) {
if template, ok := templates[ref.Kind]; ok {
if template.Kind != "" {
diff --git a/pkg/util/reference/reference_test.go b/pkg/util/reference/reference_test.go
index f13c5d8..ca5be0b 100644
--- a/pkg/util/reference/reference_test.go
+++ b/pkg/util/reference/reference_test.go
@@ -33,6 +33,7 @@ func TestExpressions(t *testing.T) {
error bool
ref corev1.ObjectReference
stringRef string
+ properties map[string]string
}{
{
name: "lowercase:source",
@@ -123,6 +124,37 @@ func TestExpressions(t *testing.T) {
},
stringRef: "postgres.org/v1alpha1:PostgreSQL:ns1/db",
},
+ {
+ name: "postgres.org/v1alpha1:PostgreSQL:ns1/db?user=user1&password=pwd2&host=192.168.2.2&special=%201&special2=a=1",
+ ref: corev1.ObjectReference{
+ APIVersion: "postgres.org/v1alpha1",
+ Kind: "PostgreSQL",
+ Namespace: "ns1",
+ Name: "db",
+ },
+ stringRef: "postgres.org/v1alpha1:PostgreSQL:ns1/db",
+ properties: map[string]string{
+ "user": "user1",
+ "password": "pwd2",
+ "host": "192.168.2.2",
+ "special": " 1",
+ "special2": "a=1",
+ },
+ },
+ {
+ name: "source?a=b&b=c&d=e",
+ ref: corev1.ObjectReference{
+ Kind: "Kamelet",
+ APIVersion: "camel.apache.org/v1alpha1",
+ Name: "source",
+ },
+ stringRef: "camel.apache.org/v1alpha1:Kamelet:source",
+ properties: map[string]string{
+ "a": "b",
+ "b": "c",
+ "d": "e",
+ },
+ },
}
for i, tc := range tests {
@@ -143,6 +175,10 @@ func TestExpressions(t *testing.T) {
asString, err2 := converter.ToString(ref)
assert.NoError(t, err2)
+ props, err3 := converter.PropertiesFromString(tc.name)
+ assert.NoError(t, err3)
+ assert.Equal(t, tc.properties, props)
+
assert.NoError(t, err)
assert.Equal(t, tc.ref, ref)
assert.Equal(t, tc.stringRef, asString)
[camel-k] 03/06: chore: add some more time to YAKS tests
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit ff587df1ccce6af52dfa810c993c919b72b6f799
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Apr 9 15:28:29 2021 +0200
chore: add some more time to YAKS tests
---
e2e/yaks/common/apache-kamelet-catalog/kamelet.feature | 5 +++++
.../kamelet-binding-autoload/kamelet-autoload-specific.feature | 4 ++--
e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload.feature | 4 ++--
e2e/yaks/common/kamelet-binding-broker/kamelet.feature | 5 +++++
e2e/yaks/common/kamelet-binding/kamelet.feature | 5 +++++
e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature | 3 +++
e2e/yaks/common/kamelet-steps/steps-binding.feature | 5 +++++
e2e/yaks/common/kamelet/kamelet.feature | 5 +++++
e2e/yaks/common/knative-sinkbinding/sinkbinding.feature | 5 +++++
e2e/yaks/common/knative/sources.feature | 5 +++++
10 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/e2e/yaks/common/apache-kamelet-catalog/kamelet.feature b/e2e/yaks/common/apache-kamelet-catalog/kamelet.feature
index 6482957..46618d7 100644
--- a/e2e/yaks/common/apache-kamelet-catalog/kamelet.feature
+++ b/e2e/yaks/common/apache-kamelet-catalog/kamelet.feature
@@ -1,5 +1,10 @@
Feature: Camel K can run Kamelets from default catalog
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Integrations can use default catalog
Given Camel-K integration logger is running
Then Camel-K integration logger should print Camel K
diff --git a/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload-specific.feature b/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload-specific.feature
index f84e78e..608c7d0 100644
--- a/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload-specific.feature
+++ b/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload-specific.feature
@@ -4,8 +4,8 @@ Feature: Camel K can load specific secrets for Kamelets
Given Disable auto removal of Kamelet resources
Given Disable auto removal of Kubernetes resources
Given Camel-K resource polling configuration
- | maxAttempts | 20 |
- | delayBetweenAttempts | 1000 |
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
Scenario: KameletBinding can load specific settings for Kamelet
Given create Kubernetes service stub-service-2 with target port 8081
diff --git a/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload.feature b/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload.feature
index 297e93a..3662acd 100644
--- a/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload.feature
+++ b/e2e/yaks/common/kamelet-binding-autoload/kamelet-autoload.feature
@@ -4,8 +4,8 @@ Feature: Camel K can load default secrets for Kamelets
Given Disable auto removal of Kamelet resources
Given Disable auto removal of Kubernetes resources
Given Camel-K resource polling configuration
- | maxAttempts | 20 |
- | delayBetweenAttempts | 1000 |
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
Scenario: KameletBinding can load default settings for Kamelet
Given create Kubernetes service stub-service with target port 8080
diff --git a/e2e/yaks/common/kamelet-binding-broker/kamelet.feature b/e2e/yaks/common/kamelet-binding-broker/kamelet.feature
index ea45ada..afd7a0c 100644
--- a/e2e/yaks/common/kamelet-binding-broker/kamelet.feature
+++ b/e2e/yaks/common/kamelet-binding-broker/kamelet.feature
@@ -1,5 +1,10 @@
Feature: Camel K can bind Kamelets to the broker
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Sending event to the broker with KameletBinding
Given Camel-K integration logger-sink-binding is running
Then Camel-K integration logger-sink-binding should print message: Hello Custom Event
diff --git a/e2e/yaks/common/kamelet-binding/kamelet.feature b/e2e/yaks/common/kamelet-binding/kamelet.feature
index 4234a3b..fa93a2e 100644
--- a/e2e/yaks/common/kamelet-binding/kamelet.feature
+++ b/e2e/yaks/common/kamelet-binding/kamelet.feature
@@ -1,5 +1,10 @@
Feature: Camel K can bind Kamelets
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Running integration using a simple Kamelet with KameletBinding
Given Camel-K integration logger-sink-binding is running
Then Camel-K integration logger-sink-binding should print message: Hello Kamelets
diff --git a/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature b/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature
index 04806ef..29ab6d6 100644
--- a/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature
+++ b/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature
@@ -3,6 +3,9 @@ Feature: Kamelet may have no properties
Background:
Given Disable auto removal of Camel-K resources
Given Disable auto removal of Kamelet resources
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
Scenario: Create Kamelet
Given create Kamelet no-props-source with flow
diff --git a/e2e/yaks/common/kamelet-steps/steps-binding.feature b/e2e/yaks/common/kamelet-steps/steps-binding.feature
index f099945..4166cf4 100644
--- a/e2e/yaks/common/kamelet-steps/steps-binding.feature
+++ b/e2e/yaks/common/kamelet-steps/steps-binding.feature
@@ -1,5 +1,10 @@
Feature: KameletBindings can have multiple processing steps
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Data is transformed by the steps
Given Camel-K integration steps-binding is running
Then Camel-K integration steps-binding should print Hello Apache Camel
diff --git a/e2e/yaks/common/kamelet/kamelet.feature b/e2e/yaks/common/kamelet/kamelet.feature
index a3d9217..5e2c896 100644
--- a/e2e/yaks/common/kamelet/kamelet.feature
+++ b/e2e/yaks/common/kamelet/kamelet.feature
@@ -1,5 +1,10 @@
Feature: Camel K can run Kamelets
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Integrations can use multiple kamelets
Given Camel-K integration source-sink is running
Then Camel-K integration source-sink should print nice echo: Camel K
diff --git a/e2e/yaks/common/knative-sinkbinding/sinkbinding.feature b/e2e/yaks/common/knative-sinkbinding/sinkbinding.feature
index 842ee44..6af9673 100644
--- a/e2e/yaks/common/knative-sinkbinding/sinkbinding.feature
+++ b/e2e/yaks/common/knative-sinkbinding/sinkbinding.feature
@@ -1,5 +1,10 @@
Feature: Camel K can run source in sinkbinding mode
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Integration gets the message from the sinkbinding source
Given Camel-K integration receiver is running
Then Camel-K integration receiver should print HELLO SINKBINDING
diff --git a/e2e/yaks/common/knative/sources.feature b/e2e/yaks/common/knative/sources.feature
index db0edbe..0257e8a 100644
--- a/e2e/yaks/common/knative/sources.feature
+++ b/e2e/yaks/common/knative/sources.feature
@@ -1,5 +1,10 @@
Feature: Camel K can run latest released Knative CamelSource
+ Background:
+ Given Camel-K resource polling configuration
+ | maxAttempts | 40 |
+ | delayBetweenAttempts | 3000 |
+
Scenario: Integration gets the message from the source
Given Camel-K integration receiver is running
Then Camel-K integration receiver should print MagicString!
[camel-k] 04/06: chore: fix test panic
Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 2d0916ce1532c521f6eed627fbef78b0c3b00c3e
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Apr 9 16:24:24 2021 +0200
chore: fix test panic
---
e2e/common/cli/dev_mode_test.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/e2e/common/cli/dev_mode_test.go b/e2e/common/cli/dev_mode_test.go
index fef9153..93cb052 100644
--- a/e2e/common/cli/dev_mode_test.go
+++ b/e2e/common/cli/dev_mode_test.go
@@ -38,6 +38,7 @@ func TestRunDevMode(t *testing.T) {
Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
t.Run("run yaml dev mode", func(t *testing.T) {
+ RegisterTestingT(t)
ctx, cancel := context.WithCancel(TestContext)
defer cancel()
piper, pipew := io.Pipe()
@@ -65,6 +66,7 @@ func TestRunDevMode(t *testing.T) {
})
t.Run("run yaml remote dev mode", func(t *testing.T) {
+ RegisterTestingT(t)
ctx, cancel := context.WithCancel(TestContext)
defer cancel()
piper, pipew := io.Pipe()