Skip to content

Commit

Permalink
chore(e2e): kamelet trait test
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Oct 10, 2023
1 parent e14eca2 commit cd65373
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
21 changes: 21 additions & 0 deletions e2e/common/traits/files/webhook.yaml
Original file line number Diff line number Diff line change
@@ -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.
# ---------------------------------------------------------------------------

- from:
uri: "kamelet:capabilities-webhook-source"
steps:
- log: "${body}"
67 changes: 67 additions & 0 deletions e2e/common/traits/kamelet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//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 traits

import (
"testing"

. "github.com/onsi/gomega"

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

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

func TestKameletTrait(t *testing.T) {
RegisterTestingT(t)

t.Run("discover kamelet capabilities", func(t *testing.T) {
template := map[string]interface{}{
"from": map[string]interface{}{
"uri": "platform-http:///webhook",
"steps": []map[string]interface{}{
{
"to": "kamelet:sink",
},
},
},
}
Expect(CreateKamelet(ns, "capabilities-webhook-source", template, nil, nil)()).To(Succeed())

name := "webhook"
Expect(KamelRunWithID(operatorID, ns, "files/webhook.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Started capabilities-webhook-source-1 (platform-http:///webhook)"))
// Verify Integration capabilities
Eventually(IntegrationStatusCapabilities(ns, name), TestTimeoutShort).Should(ContainElements("platform-http"))
// Verify expected resources from Kamelet (Service in this case)
service := Service(ns, name)
Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
})

// Clean-up
Expect(DeleteKamelet(ns, "capabilities-webhook-source")).To(Succeed())
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
10 changes: 10 additions & 0 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,16 @@ func IntegrationSpecProfile(ns string, name string) func() v1.TraitProfile {
}
}

func IntegrationStatusCapabilities(ns string, name string) func() []string {
return func() []string {
it := Integration(ns, name)()
if it == nil || &it.Status == nil {
return nil
}
return it.Status.Capabilities
}
}

func IntegrationSpecSA(ns string, name string) func() string {
return func() string {
it := Integration(ns, name)()
Expand Down

0 comments on commit cd65373

Please sign in to comment.