This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new e1a7e27e chore(e2e): Add Jira Kamelets tests (#2049)
e1a7e27e is described below

commit e1a7e27e6eee34546e7478562d16a5eaa4433786
Author: Christoph Deppisch <cdeppi...@redhat.com>
AuthorDate: Fri May 17 06:20:47 2024 +0200

    chore(e2e): Add Jira Kamelets tests (#2049)
---
 .../src/test/resources/jira/README.md              |  45 +++++++
 .../resources/jira/jira-add-issue-sink-pipe.yaml   |  74 ++++++++++++
 .../resources/jira/jira-add-issue-sink.feature     | 109 +++++++++++++++++
 .../src/test/resources/jira/jira-source-pipe.yaml  |  34 ++++++
 .../src/test/resources/jira/jira-source.feature    | 130 +++++++++++++++++++++
 .../src/test/resources/jira/yaks-config.yaml       |  55 +++++++++
 6 files changed, 447 insertions(+)

diff --git a/tests/camel-kamelets-itest/src/test/resources/jira/README.md 
b/tests/camel-kamelets-itest/src/test/resources/jira/README.md
new file mode 100644
index 00000000..9d1801d4
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/jira/README.md
@@ -0,0 +1,45 @@
+# Jira Kamelet test
+
+This test verifies Jira Kamelets.
+
+## Objectives
+
+The test verifies the Jira Kamelet by creating a Camel K integration that uses 
the Kamelet interacting with the Jira REST API. 
+The Jira API is simulated during the test with an Http server endpoint.
+
+### Test Kamelet
+
+The test performs the following high level steps:
+
+*Preparation*
+- Create a Jira API server that will simulate the Jira API (e.g. providing a 
new issue as a response)
+
+*Scenario* 
+- Create the Camel K integration that uses the Jira Kamelets
+- Wait for the Camel K integration to start and listen for new issue events
+- Simulate a new issue returned by the Jira API server
+- Verify the issue was logged by Camel K integrations using the log-sink
+
+*Cleanup*
+- Delete the Camel K integration
+
+## Installation
+
+The test assumes that you have access to a Kubernetes cluster and that the 
Camel K operator as well as the YAKS operator is installed
+and running.
+
+You can review the installation steps for the operators in the documentation:
+
+- [Install Camel K 
operator](https://camel.apache.org/camel-k/latest/installation/installation.html)
+- [Install YAKS operator](https://github.com/citrusframework/yaks#installation)
+
+## Run the test
+
+```shell script
+$ yaks run --local src/test/resources/jira/jira-source.feature
+$ yaks run --local src/test/resources/jira/jira-add-issue-sink.feature
+```
+
+You can increase number of attempts to run the test by adding: "-e 
YAKS_CAMELK_MAX_ATTEMPTS=1000"
+
+You will be provided with the test log output and the test results.
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.yaml
new file mode 100644
index 00000000..bb798620
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.yaml
@@ -0,0 +1,74 @@
+# ---------------------------------------------------------------------------
+# 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: camel.apache.org/v1
+kind: Pipe
+metadata:
+  name: jira-add-issue-sink-pipe
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1
+      name: timer-source
+    properties:
+      period: ${timer.source.period}
+      message: '${jira.issue.description}'
+  steps:
+    - ref:
+        kind: Kamelet
+        apiVersion: camel.apache.org/v1
+        name: insert-header-action
+      properties:
+        name: projectKey
+        value: ${jira.project.key}
+    - ref:
+        kind: Kamelet
+        apiVersion: camel.apache.org/v1
+        name: insert-header-action
+      properties:
+        name: issueTypeName
+        value: ${jira.issue.type}
+    - ref:
+        kind: Kamelet
+        apiVersion: camel.apache.org/v1
+        name: insert-header-action
+      properties:
+        name: issueSummary
+        value: ${jira.issue.summary}
+    - ref:
+        kind: Kamelet
+        apiVersion: camel.apache.org/v1
+        name: insert-header-action
+      properties:
+        name: issueAssignee
+        value: ${jira.issue.assignee}
+    - ref:
+        kind: Kamelet
+        apiVersion: camel.apache.org/v1
+        name: log-action
+      properties:
+        showHeaders: true
+  sink:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1
+      name: jira-add-issue-sink
+    properties:
+      jiraUrl: yaks:resolveURL('jira-service')
+      username: ${jira.username}
+      password: ${jira.password}
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink.feature
 
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink.feature
new file mode 100644
index 00000000..313ba8c2
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink.feature
@@ -0,0 +1,109 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+Feature: Jira Kamelet - Sink
+
+  Background:
+    Given variables
+      | timer.source.period | 10000 |
+      | jira.project.key    | CAMEL |
+      | jira.project.id     | 10001 |
+      | jira.issue.id       | 10001 |
+      | jira.issue.key      | CAMEL-10001 |
+      | jira.issue.summary  | New bug, citrus:randomString(10) |
+      | jira.issue.assignee | Superman |
+      | jira.issue.type     | Bug |
+      | jira.issue.description | Sample bug |
+      | jira.username       | yaks   |
+      | jira.password       | secr3t |
+    Given HTTP server timeout is 15000 ms
+    Given HTTP server "jira-service"
+
+  Scenario: Create Http server
+    Given create Kubernetes service jira-service
+    Given purge endpoint jira-service
+
+  Scenario: Verify Jira events
+    # Create binding
+    Given load Pipe jira-add-issue-sink-pipe.yaml
+    # Verify issue type request
+    Given expect HTTP request header: Authorization="Basic 
citrus:encodeBase64(${jira.username}:${jira.password})"
+    When receive GET /rest/api/latest/issuetype
+    Then HTTP response header: Content-Type="application/json"
+    And HTTP response body
+    """
+    [
+        {
+            "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/issueType/1",
+            "id": "1",
+            "description": "A problem with the software.",
+            "iconUrl": 
"yaks:resolveURL('jira-service')/images/icons/issuetypes/bug.png",
+            "name": "Bug",
+            "subtask": false,
+            "avatarId": 2
+        },
+        {
+            "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/issueType/3",
+            "id": "3",
+            "description": "A task that needs to be done.",
+            "iconUrl": 
"yaks:resolveURL('jira-service')/images/icons/issuetypes/task.png",
+            "name": "Task",
+            "subtask": false,
+            "avatarId": 1
+        }
+    ]
+    """
+    Then send HTTP 200 OK
+    # Verify add issue request
+    Given expect HTTP request header: Authorization="Basic 
citrus:encodeBase64(${jira.username}:${jira.password})"
+    Then expect HTTP request body
+    """
+    {
+        "fields": {
+            "project": {
+                "key": "${jira.project.key}"
+            },
+            "summary": "${jira.issue.summary}",
+            "description": "${jira.issue.description}",
+            "issuetype": {
+                "id": "1"
+            },
+            "assignee": {
+                "name": "${jira.issue.assignee}"
+            }
+        },
+        "properties": []
+    }
+    """
+    When receive POST /rest/api/latest/issue
+    Then HTTP response body
+    """
+    {
+        "id": "${jira.issue.id}",
+        "key": "${jira.issue.key}",
+        "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.id}"
+    }
+    """
+    Then send HTTP 200 OK
+    # Verify event
+    And Camel K integration jira-add-issue-sink-pipe should print 
${jira.issue.summary}
+
+  Scenario: Remove resources
+    # Remove Camel K binding
+    Given delete Pipe jira-add-issue-sink-pipe
+    Given delete Kubernetes service jira-service
+    And stop server component jira-service
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.yaml 
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.yaml
new file mode 100644
index 00000000..f3b4c6a4
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.yaml
@@ -0,0 +1,34 @@
+# ---------------------------------------------------------------------------
+# 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: camel.apache.org/v1
+kind: Pipe
+metadata:
+  name: jira-source-pipe
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1
+      name: jira-source
+    properties:
+      jiraUrl: yaks:resolveURL('jira-service')
+      username: ${jira.username}
+      password: ${jira.password}
+      jql: ${jira.jql}
+  sink:
+    uri: log:info
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-source.feature 
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-source.feature
new file mode 100644
index 00000000..34507036
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/jira/jira-source.feature
@@ -0,0 +1,130 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+Feature: Jira Kamelet - Source
+
+  Background:
+    Given variables
+      | jira.project.id    | 10001 |
+      | jira.issue.id      | 10001 |
+      | jira.issue.key     | CAMEL-1 |
+      | jira.issue.summary | New bug, citrus:randomString(10) |
+      | jira.username      | yaks   |
+      | jira.password      | secr3t |
+      | jira.jql           | assignee=yaks |
+    Given HTTP server timeout is 120000 ms
+    Given HTTP server "jira-service"
+
+  Scenario: Create Http server
+    Given create Kubernetes service jira-service
+    Given purge endpoint jira-service
+
+  Scenario: Verify Jira events
+    # Create binding
+    Given load Pipe jira-source-pipe.yaml
+    # Verify latest issue request
+    Given expect HTTP request header: Authorization="Basic 
citrus:encodeBase64(${jira.username}:${jira.password})"
+    And expect HTTP request query parameter 
jql="yaks:urlEncode(${jira.jql})+ORDER+BY+key+desc"
+    And expect HTTP request query parameter maxResults="1"
+    When receive GET /rest/api/latest/search
+    Then HTTP response header: Content-Type="application/json"
+    And HTTP response body
+    """
+    {
+        "expand": "",
+        "startAt": 0,
+        "maxResults": 1,
+        "total": 1,
+        "issues": [
+            {
+                "expand": "",
+                "id": "${jira.issue.id}",
+                "key": "${jira.issue.key}",
+                "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.id}",
+                "transitions": 
"yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.key}/transitions"
+            }
+        ]
+    }
+    """
+    Then send HTTP 200 OK
+    # Verify search request
+    Given expect HTTP request header: Authorization="Basic 
citrus:encodeBase64(${jira.username}:${jira.password})"
+    And expect HTTP request query parameter 
jql="yaks:urlEncode(${jira.jql})+ORDER+BY+key+desc"
+    And expect HTTP request query parameter maxResults="50"
+    And expect HTTP request query parameter expand="schema%2Cnames"
+    When receive GET /rest/api/latest/search
+    Then HTTP response header: Content-Type="application/json"
+    And HTTP response body
+    """
+    {
+        "expand": "schema,names",
+        "startAt": 0,
+        "maxResults": 50,
+        "total": 1,
+        "names": {
+            "custom": "${jira.issue.key}"
+        },
+        "schema": {
+            "custom": {
+                "type": "string"
+            }
+        },
+        "issues": [
+            {
+                "expand": "",
+                "id": "${jira.issue.id}",
+                "key": "${jira.issue.key}",
+                "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.id}",
+                "transitions": 
"yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.key}/transitions",
+                "fields": {
+                    "project": {
+                        "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/project/${jira.project.id}",
+                        "id": "${jira.project.id}",
+                        "key": "CAMEL"
+                    },
+                    "summary": "${jira.issue.summary}",
+                    "custom": "${jira.issue.key}",
+                    "issuetype": {
+                        "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/issuetype/3",
+                        "id": "3",
+                        "description": "A task that needs to be done.",
+                        "iconUrl": 
"yaks:resolveURL('jira-service')/images/icons/task.gif",
+                        "name": "Task",
+                        "subtask": false
+                    },
+                    "created": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
+                    "updated": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
+                    "status": {
+                        "self": 
"yaks:resolveURL('jira-service')/rest/api/latest/status/1",
+                        "id": 1,
+                        "description": "Open task.",
+                        "iconUrl": 
"yaks:resolveURL('jira-service')/images/icons/status_1.gif",
+                        "name": "Open"
+                    }
+                }
+            }
+        ]
+    }
+    """
+    Then send HTTP 200 OK
+    And Camel K integration jira-source-pipe should print ${jira.issue.summary}
+
+  Scenario: Remove resources
+    # Remove Camel K binding
+    Given delete Pipe jira-source-pipe
+    Given delete Kubernetes service jira-service
+    And stop server component jira-service
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/jira/yaks-config.yaml 
b/tests/camel-kamelets-itest/src/test/resources/jira/yaks-config.yaml
new file mode 100644
index 00000000..52cf9ba2
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/jira/yaks-config.yaml
@@ -0,0 +1,55 @@
+# ---------------------------------------------------------------------------
+# 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: false
+  runtime:
+    env:
+      - name: YAKS_CAMEL_AUTO_REMOVE_RESOURCES
+        value: false
+      - name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
+        value: false
+      - name: YAKS_KAMELETS_AUTO_REMOVE_RESOURCES
+        value: false
+      - name: YAKS_KUBERNETES_AUTO_REMOVE_RESOURCES
+        value: false
+      - name: YAKS_KNATIVE_AUTO_REMOVE_RESOURCES
+        value: false
+      - name: YAKS_JBANG_CAMEL_DUMP_INTEGRATION_OUTPUT
+        value: true
+      - name: YAKS_TESTCONTAINERS_AUTO_REMOVE_RESOURCES
+        value: false
+      - name: CITRUS_TYPE_CONVERTER
+        value: camel
+    resources:
+      - jira-source-pipe.yaml
+      - jira-add-issue-sink-pipe.yaml
+    cucumber:
+      tags:
+        - "not @ignored"
+    settings:
+      loggers:
+        - name: INTEGRATION_STATUS
+          level: INFO
+        - name: INTEGRATION_LOGS
+          level: INFO
+  dump:
+    enabled: true
+    failedOnly: true
+    includes:
+      - app=camel-k

Reply via email to