Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native binding 1.9 #3719

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions e2e/native/native_binding_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//go:build integration
// +build integration

// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"

/*
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 native

import (
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"testing"

. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"

. "github.com/apache/camel-k/e2e/support"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)

func TestNativeBinding(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(Kamel("install", "-n", ns,
"--build-timeout", "15m0s",
"--operator-resources", "limits.memory=4Gi",
).Execute()).To(Succeed())
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

t.Run("kamelet binding with native build", func(t *testing.T) {
from := corev1.ObjectReference{
Kind: "Kamelet",
Name: "timer-source",
APIVersion: v1alpha1.SchemeGroupVersion.String(),
}

to := corev1.ObjectReference{
Kind: "Kamelet",
Name: "log-sink",
APIVersion: v1alpha1.SchemeGroupVersion.String(),
}

bindingName := "native-binding"
message := "Magicstring!"
Expect(BindKameletTo(ns, bindingName, map[string]string{"trait.camel.apache.org/quarkus.package-type": "native"}, from, to, map[string]string{"message": message}, map[string]string{})()).To(Succeed())

Eventually(Kits(ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady)),
TestTimeoutLong).Should(HaveLen(1))
nativeKit := Kits(ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady))()[0]
Eventually(IntegrationKit(ns, bindingName), TestTimeoutShort).Should(Equal(nativeKit.Name))

Eventually(IntegrationPodPhase(ns, bindingName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, bindingName), TestTimeoutShort).Should(ContainSubstring(message))

Eventually(IntegrationPod(ns, bindingName), TestTimeoutShort).
Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*")))

// Clean up
Expect(Kamel("delete", bindingName, "-n", ns).Execute()).To(Succeed())
})

// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}
14 changes: 0 additions & 14 deletions e2e/native/native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ limitations under the License.
package native

import (
"strings"
"testing"

. "github.com/onsi/gomega"
Expand All @@ -34,11 +33,6 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)

var (
withFastJarLayout = KitWithLabels(map[string]string{v1.IntegrationKitLayoutLabel: v1.IntegrationKitLayoutFastJar})
withNativeLayout = KitWithLabels(map[string]string{v1.IntegrationKitLayoutLabel: v1.IntegrationKitLayoutNative})
)

func TestNativeIntegrations(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(Kamel("install", "-n", ns,
Expand Down Expand Up @@ -107,11 +101,3 @@ func TestNativeIntegrations(t *testing.T) {
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}

func getContainerCommand() func(pod *corev1.Pod) string {
return func(pod *corev1.Pod) string {
cmd := strings.Join(pod.Spec.Containers[0].Command, " ")
cmd = cmd + strings.Join(pod.Spec.Containers[0].Args, " ")
return cmd
}
}
44 changes: 44 additions & 0 deletions e2e/native/native_test_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//go:build integration
// +build integration

// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"

/*
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 native

import (
corev1 "k8s.io/api/core/v1"
"strings"

. "github.com/apache/camel-k/e2e/support"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)

var (
withFastJarLayout = KitWithLabels(map[string]string{v1.IntegrationKitLayoutLabel: v1.IntegrationKitLayoutFastJar})
withNativeLayout = KitWithLabels(map[string]string{v1.IntegrationKitLayoutLabel: v1.IntegrationKitLayoutNative})
)

func getContainerCommand() func(pod *corev1.Pod) string {
return func(pod *corev1.Pod) string {
cmd := strings.Join(pod.Spec.Containers[0].Command, " ")
cmd = cmd + strings.Join(pod.Spec.Containers[0].Args, " ")
return cmd
}
}