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 6d0fc8060fcafb6a2b6007ced332029053f65106 Author: nicolaferraro <ni.ferr...@gmail.com> AuthorDate: Wed Aug 5 16:52:36 2020 +0200 Fix #1548: add e2e test for sinkbinding --- deploy/resources.go | 24 ++++++++--------- e2e/yaks/knative-sinkbinding/messages-channel.yaml | 21 +++++++++++++++ e2e/yaks/knative-sinkbinding/receiver.groovy | 19 +++++++++++++ e2e/yaks/knative-sinkbinding/sinkbinding.feature | 5 ++++ e2e/yaks/knative-sinkbinding/source.yaml | 28 +++++++++++++++++++ e2e/yaks/knative-sinkbinding/yaks-config.yaml | 31 ++++++++++++++++++++++ pkg/trait/knative.go | 2 +- pkg/util/kubernetes/collection.go | 7 +++++ 8 files changed, 124 insertions(+), 13 deletions(-) diff --git a/deploy/resources.go b/deploy/resources.go index e1e547b..cdd0e08 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -312,44 +312,44 @@ var assets = func() http.FileSystem { "/templates/groovy.tmpl": &vfsgen۰CompressedFileInfo{ name: "groovy.tmpl", modTime: time.Time{}, - uncompressedSize: 1010, + uncompressedSize: 207, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x53\x5d\x6f\xea\x46\x10\x7d\xf7\xaf\x38\x42\x95\x80\x2b\x2e\xa6\x7d\xa4\xba\xaa\x08\x01\xc5\x4a\x04\x52\x4c\x1a\xe5\x71\xb1\x07\x7b\x14\x7b\xc7\x9d\x5d\xc7\x41\x55\xff\x7b\xb5\x36\xa4\x54\xd7\x6f\xbb\x9e\x39\x1f\x7b\x66\xe2\x18\x99\xa9\xa9\xfa\xfe\xbe\x44\x65\x6c\xd1\x9a\x82\x7e\x14\x2a\xf2\x71\x8e\xe2\x6f\x11\xbe\xe1\x89\x33\xb2\x8e\x72\x78\x81\x2f\x09\xab\xc6\x64\x25\x21\x95\x93\xef\x8c\x12\xb6\xd2\xda\xdc\x78\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8e\xc1\x6a\xc3\x30\x0c\x86\xef\x7e\x8a\xff\x30\xb0\x03\xdb\x9c\x5d\x0d\x61\xb0\x5d\x36\xf6\x00\x3b\x9b\x46\x71\x4d\xed\x28\x28\x4e\x69\x28\x7d\xf7\xe2\xa6\x39\xea\x43\xdf\x27\x59\x8b\x83\xcf\x94\xde\x4e\x0e\xc9\x8f\x61\xf1\x81\xba\x20\xcc\xe7\x55\x29\x6b\xf1\x2f\xb1\x10\x56\x5e\x04\xc2\x4b\xa1\x19\x47\x12\x7a\xc5\xc0\x02\xba\xf8\x3c\x25\x72\x6a\x10\xce\x46\x97\x98\x49\xdc\xe6\x7e\x4e\x24\x91\xfb\xee\xa3\x6d\x5b\x [...] }, "/templates/java.tmpl": &vfsgen۰CompressedFileInfo{ name: "java.tmpl", modTime: time.Time{}, - uncompressedSize: 1193, + uncompressedSize: 390, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x94\x41\x6f\xdb\x46\x10\x85\xef\xfc\x15\x0f\x44\x0f\x72\xe0\x90\x6e\x8f\x32\x82\x56\x76\x64\x84\x48\x20\x01\xa6\x52\x23\xc7\x15\x39\x22\xa7\x59\xee\xb0\xb3\x4b\xd3\x82\xa0\xff\x5e\x2c\x25\x25\x2a\xa2\x1b\xc9\xd9\x6f\xe6\xcd\x7b\xab\x3c\x47\x65\x3a\xb2\xef\xbf\xcf\x61\x8d\x6b\x06\xd3\xd0\x87\x7f\xcc\xab\x49\xf2\x77\x09\xde\xe1\x0b\x57\xe4\x3c\xd5\x08\x82\xd0\x12\x16\xbd\xa9\x5a\x42\x29\xbb\x30\x1a\x25\x3c\xc9\xe0\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x90\x41\x4b\xf3\x40\x10\x86\xef\xfb\x2b\x5e\xc2\x77\x48\xe1\x33\xa9\xd7\x94\xa2\x54\x04\x45\x50\xf0\xe2\x79\x9b\x9d\xa4\xa3\x9b\x4c\x98\x6c\x6a\x4b\xc8\x7f\x97\x8d\x01\xb3\xb7\x9d\x7d\xf6\x79\x79\x27\xcf\x51\xda\x86\xfc\xcd\x57\x01\x6f\xdb\x7a\xb0\x35\xed\x3f\xed\xd9\x1a\xc3\x4d\x27\x1a\x20\x5a\x67\xb6\xb3\xe5\x89\xb2\x99\xcc\x8e\x03\x7b\x47\x9a\xbd\xcb\x10\xe8\xf0\x7b\xd9\x19\xd3\x0d\x47\xcf\x25\x4a\x6f\xfb\x1e\x [...] }, "/templates/js.tmpl": &vfsgen۰CompressedFileInfo{ name: "js.tmpl", modTime: time.Time{}, - uncompressedSize: 991, + uncompressedSize: 195, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x93\x51\x6f\xea\x38\x10\x85\xdf\xf9\x15\x47\x68\x25\x40\xa2\x09\xbb\x8f\xac\xaa\x15\xa5\xa0\x46\xad\x40\x6a\xe8\x56\x7d\x34\xc9\x90\x4c\x9b\x78\xb2\x63\x67\x53\x74\x75\xff\xfb\x95\x03\xf4\x72\x75\xf3\x66\xc7\xf3\xcd\x39\x3e\xe3\x38\x46\x66\x6a\xaa\x6e\x3e\xe6\xa8\x8c\x2d\x5a\x53\xd0\xed\xbb\x1b\xc4\x31\x9e\x38\x23\xeb\x28\x87\x17\xf8\x92\xb0\x68\x4c\x56\x12\x52\x39\xf8\xce\x28\x61\x2d\xad\xcd\x8d\x67\xb1\x18\x2f\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8e\xb1\x6a\xc3\x30\x14\x45\x77\x7d\xc5\x1d\x0a\x92\xa1\xad\xdc\x55\x60\x0a\xed\xd2\xd2\x0f\xe8\x2c\xe2\x67\x47\x8e\xe4\x67\x9e\x64\x88\x09\xf9\xf7\xa0\x24\x1e\xef\x81\x73\xb8\xd6\xe2\xe0\x13\xc5\xb7\x93\x43\xf4\xf3\xb8\xfa\x91\xba\x29\x2b\x65\x2d\xfe\x25\x14\xc2\xc6\xab\x40\x78\x2d\x94\x71\x24\xa1\x57\x0c\x2c\xa0\xb3\x4f\x4b\x24\xa7\x06\xe1\x64\x74\x09\x89\xc4\x4d\xf9\x73\x21\x09\xdc\x77\x1f\x6d\xdb\xea\x46\x01\x [...] }, "/templates/kts.tmpl": &vfsgen۰CompressedFileInfo{ name: "kts.tmpl", modTime: time.Time{}, - uncompressedSize: 1003, + uncompressedSize: 200, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x93\x41\x6f\xda\x4e\x10\xc5\xef\xfe\x14\x4f\xd6\xff\x00\x11\xc1\xfc\x7b\xa4\x8a\x2a\x42\x40\xb1\x12\x81\x14\x93\x46\x91\x7a\x59\xec\xc1\x1e\x65\xbd\xe3\xee\xae\xeb\xa0\xaa\xdf\xbd\x5a\x1b\x52\xaa\x72\x5b\x3c\xf3\x9b\xf7\xf6\xcd\x26\x09\x72\x55\x93\xbe\x7e\x9b\x43\x2b\x53\xb6\xaa\xa4\x9b\x37\xf1\x9a\x4d\x94\x5c\x45\xb8\xc2\x23\xe7\x64\x1c\x15\xf0\x02\x5f\x11\x16\x8d\xca\x2b\x42\x26\x07\xdf\x29\x4b\x58\x4b\x6b\x0a\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2c\x8e\x41\xca\xc2\x30\x10\x46\xf7\x39\xc5\x10\xfe\x45\x0a\xbf\xa6\x6e\x03\x45\xd0\x8d\xe2\x01\xdc\xb8\x09\x76\x5a\x43\x27\x9d\x32\x4d\xc1\x22\xde\x5d\x62\x5c\xbe\x61\xde\xe3\xb3\x16\xee\x3e\x22\x6d\x06\x07\xe4\xc7\x7e\xf1\x3d\x36\x03\x27\x0a\xa3\x52\xd6\xc2\x55\x42\x42\x58\x79\x11\x10\x5e\x12\xce\xf0\x40\xc1\x7f\xe8\x58\x00\x9f\x3e\x4e\x84\x4e\x75\xc2\xd1\xe8\x14\x22\x8a\x2b\xee\x7e\x42\x09\xdc\x36\xbb\xba\xae\x75\x [...] }, "/templates/xml.tmpl": &vfsgen۰CompressedFileInfo{ name: "xml.tmpl", modTime: time.Time{}, - uncompressedSize: 1408, + uncompressedSize: 597, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x54\xc1\x8e\xdb\x36\x10\x3d\xd7\x5f\xf1\x2a\xf4\x90\x00\xb6\xe4\x4d\x2f\x85\x6b\x7b\xe1\x6c\xd6\x88\x90\xad\x0d\xac\xbc\xdd\xe6\xc8\x95\xc6\xd2\x20\x14\xa9\x92\x54\x24\xa3\xe8\xbf\x17\xa4\x6c\xaf\x82\x00\x05\xa2\x93\x88\x99\x79\xf3\xde\xbc\x21\x97\xb7\x7d\x2d\xf1\x95\x8c\x65\xad\x56\xd1\x4d\x3c\x8f\x40\x2a\xd7\x05\xab\x72\x15\x3d\x1d\xb6\xb3\xdf\xa2\xdb\xf5\x64\xf9\xf3\x6c\x86\x5c\xd4\x24\x67\x5f\x16\x90\x42\x95\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x92\x4f\x4b\xf4\x30\x10\xc6\xcf\x6f\x3f\xc5\xbc\xe1\x3d\xbe\x69\xba\x7a\x91\x92\x76\x41\x41\x14\xd7\x93\x8a\x5e\x43\x3b\xdb\x06\xf3\xa7\x24\xa9\xcd\x22\x7e\x77\x69\xba\xae\x2b\x5e\x74\x4e\x2d\x33\xbf\xe7\x99\x79\x08\x5f\x47\xad\xe0\x05\x9d\x97\xd6\x54\x64\x95\x17\x04\xd0\x34\xb6\x95\xa6\xab\xc8\xc3\xfd\x25\x3d\x23\xeb\x3a\xe3\x7f\x29\x85\x46\x68\x54\xf4\xb9\x04\x25\x4c\x37\x8a\x0e\xab\x99\xa5\xb4\xce\x32\xee\xec\x [...] }, "/templates/yaml.tmpl": &vfsgen۰CompressedFileInfo{ name: "yaml.tmpl", modTime: time.Time{}, - uncompressedSize: 1168, + uncompressedSize: 230, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x54\x4d\x8f\xe3\x36\x0c\xbd\xfb\x57\x3c\xd8\x97\x5d\x20\x5f\xed\xd1\x45\x0f\x69\x36\xc1\x1a\xbb\x48\x80\x71\xb6\x83\x39\x2a\x36\x63\x13\x23\x8b\x2e\x25\xd7\x93\x7f\x5f\xc8\x49\xe6\x03\xbd\x0e\x6f\x96\x28\xf2\x3d\xbe\x47\x67\xa8\x4c\x47\x76\xfe\x9c\xc3\x1a\xd7\x0c\xa6\xa1\x3f\x2f\xa6\xb3\x49\x86\xf9\xe7\x45\x92\xe1\x27\x57\xe4\x3c\xd5\x08\x82\xd0\x12\xd6\xbd\xa9\x5a\x42\x29\xe7\x30\x1a\x25\xec\x64\x70\xb5\x09\x2c\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x44\x8e\x31\x4e\x04\x31\x0c\x45\xfb\x9c\xe2\x2b\xdb\x32\xd2\xd0\x5a\xa2\xa2\x41\xe2\x00\xd4\x66\xd7\x33\x44\x24\x71\xe4\x38\x12\x73\x7b\x94\x1d\xc1\xba\xfc\x7e\xf6\x7f\x17\x5c\xb9\x48\x5e\xbe\x09\x99\xeb\x3e\x78\x97\x97\x83\x4b\x0e\xe1\x82\x0f\x4b\x2e\x38\x74\x18\x4c\x87\x4b\xc7\x97\x98\x3c\x61\x53\x83\xfc\x70\x69\x59\x28\x2c\xd8\x4c\x0b\x05\x00\x18\x96\x08\xd1\x53\x11\xa3\xf9\x24\xde\xd3\xc6\xc6\x45\x5c\xac\x9f\x14\x [...] }, "/traits.yaml": &vfsgen۰CompressedFileInfo{ name: "traits.yaml", diff --git a/e2e/yaks/knative-sinkbinding/messages-channel.yaml b/e2e/yaks/knative-sinkbinding/messages-channel.yaml new file mode 100644 index 0000000..abd3483 --- /dev/null +++ b/e2e/yaks/knative-sinkbinding/messages-channel.yaml @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +apiVersion: messaging.knative.dev/v1beta1 +kind: InMemoryChannel +metadata: + name: messages diff --git a/e2e/yaks/knative-sinkbinding/receiver.groovy b/e2e/yaks/knative-sinkbinding/receiver.groovy new file mode 100644 index 0000000..65eeb2e --- /dev/null +++ b/e2e/yaks/knative-sinkbinding/receiver.groovy @@ -0,0 +1,19 @@ +/* + * 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. + */ + +from('knative:channel/messages') + .log('Received: ${body}') diff --git a/e2e/yaks/knative-sinkbinding/sinkbinding.feature b/e2e/yaks/knative-sinkbinding/sinkbinding.feature new file mode 100644 index 0000000..736e928 --- /dev/null +++ b/e2e/yaks/knative-sinkbinding/sinkbinding.feature @@ -0,0 +1,5 @@ +Feature: Camel K can run source in sinkbinding mode + + Scenario: Integration gets the message from the sinkbinding source + Given integration receiver is running + Then integration receiver should print HELLO SINKBINDING diff --git a/e2e/yaks/knative-sinkbinding/source.yaml b/e2e/yaks/knative-sinkbinding/source.yaml new file mode 100644 index 0000000..e54dd96 --- /dev/null +++ b/e2e/yaks/knative-sinkbinding/source.yaml @@ -0,0 +1,28 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- from: + uri: "timer:tick" + parameters: + period: "1000" + steps: + - set-body: + constant: "Hello SinkBinding !!!" + - transform: + simple: "${body.toUpperCase()}" + - to: "log:info" + - to: "knative:channel/messages" diff --git a/e2e/yaks/knative-sinkbinding/yaks-config.yaml b/e2e/yaks/knative-sinkbinding/yaks-config.yaml new file mode 100644 index 0000000..aed4c94 --- /dev/null +++ b/e2e/yaks/knative-sinkbinding/yaks-config.yaml @@ -0,0 +1,31 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +config: + namespace: + temporary: true +pre: +- name: installation + run: | + kamel install -n $YAKS_NAMESPACE + + kubectl apply -n $YAKS_NAMESPACE -f messages-channel.yaml + + kamel run receiver.groovy -w -n $YAKS_NAMESPACE + kamel run source.yaml -w -n $YAKS_NAMESPACE -t knative.sink-binding=true + + kubectl wait integration --all --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go index e21266f..d735146 100644 --- a/pkg/trait/knative.go +++ b/pkg/trait/knative.go @@ -460,7 +460,7 @@ func (t *knativeTrait) configureSinkBinding(e *Environment, env *knativeapi.Came Name: ref.Name, APIVersion: ref.APIVersion, } - e.Resources.Add(knativeutil.CreateSinkBinding(source, target)) + e.Resources.AddFirst(knativeutil.CreateSinkBinding(source, target)) } return nil }) diff --git a/pkg/util/kubernetes/collection.go b/pkg/util/kubernetes/collection.go index e04ddbf..8ad7bf2 100644 --- a/pkg/util/kubernetes/collection.go +++ b/pkg/util/kubernetes/collection.go @@ -81,6 +81,13 @@ func (c *Collection) Add(resource runtime.Object) { } } +// AddFirst adds a resource to the head of the collection +func (c *Collection) AddFirst(resource runtime.Object) { + if resource != nil { + c.items = append([]runtime.Object{resource}, c.items...) + } +} + // AddAll adds all resources to the collection func (c *Collection) AddAll(resource []runtime.Object) { c.items = append(c.items, resource...)