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

chore: Add E2E tests for Jira add comment sink Kamelet #337

Merged
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
23 changes: 23 additions & 0 deletions test/jira/jira-add-comment-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"self": "yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.id}/comment/${jira.issue.comment.id}",
"id": "${jira.issue.comment.id}",
"author": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/user?username=yaks",
"name": "yaks",
"displayName": "YAKS User",
"active": false
},
"body": "${jira.issue.comment}",
"updateAuthor": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/user?username=yaks",
"name": "yaks",
"displayName": "YAKS User",
"active": false
},
"created": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"updated": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"visibility": {
"type": "role",
"value": "Users"
}
}
36 changes: 36 additions & 0 deletions test/jira/jira-add-comment-sink-pipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: jira-add-comment-sink-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
period: ${timer.source.period}
message: '${jira.issue.comment}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: insert-header-action
properties:
name: issueKey
value: ${jira.issue.key}
- 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-comment-sink
properties:
jiraUrl: yaks:resolveURL('jira-service')
username: ${jira.username}
password: ${jira.password}
56 changes: 56 additions & 0 deletions test/jira/jira-add-comment-sink.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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.issue.comment | New comment, citrus:randomString(10) |
| jira.issue.comment.id | 10001 |
| jira.username | yaks |
| jira.password | secr3t |
Given HTTP server timeout is 120000 ms
Given HTTP server "jira-service"

Scenario: Create Http server
Given create Kubernetes service jira-service

Scenario: Verify Jira events
# Create binding
Given load Pipe jira-add-comment-sink-pipe.yaml
# Verify get issue request
Given expect HTTP request header: Authorization="Basic citrus:encodeBase64(${jira.username}:${jira.password})"
When receive GET /rest/api/latest/issue/${jira.issue.key}
Then HTTP response header: Content-Type="application/json"
And HTTP response body: yaks:readFile('jira-get-issue-response.json')
Then send HTTP 200 OK
# Verify add comment request
Given expect HTTP request header: Authorization="Basic citrus:encodeBase64(${jira.username}:${jira.password})"
When receive GET /rest/api/latest/serverInfo
Then HTTP response body: yaks:readFile('jira-server-info.json')
Then send HTTP 200 OK
# Verify add comment request
Given expect HTTP request header: Authorization="Basic citrus:encodeBase64(${jira.username}:${jira.password})"
Then expect HTTP request body
"""
{
"body": "${jira.issue.comment}"
}
"""
When receive POST /rest/api/latest/issue/${jira.issue.key}/comment
Then HTTP response body: yaks:readFile('jira-add-comment-response.json')
Then send HTTP 200 OK
# Verify event
And Camel K integration jira-add-comment-sink-pipe should print ${jira.issue.comment}

Scenario: Remove resources
# Remove Camel K binding
Given delete Pipe jira-add-comment-sink-pipe
Given delete Kubernetes service jira-service
And stop server component jira-service
35 changes: 35 additions & 0 deletions test/jira/jira-get-issue-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"expand": "schema,names",
"id": "${jira.issue.id}",
"key": "${jira.issue.key}",
"self": "yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.key}",
"transitions": "yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.key}/transitions",
"names": {},
"schema": {},
"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"
}
}
}
15 changes: 15 additions & 0 deletions test/jira/jira-server-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"baseUrl": "yaks:resolveURL('jira-service')",
"version": "5.0.0",
"versionNumbers": [
5,
0,
0
],
"buildNumber": 581,
"buildDate": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"serverTime": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"scmInfo": "yaks:randomString(40, LOWERCASE)",
"buildPartnerName": "YAKS Co.",
"serverTitle": "Test Jira Server"
}
4 changes: 4 additions & 0 deletions test/jira/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ config:
- jira-credentials.properties
- jira-source-pipe.yaml
- jira-add-issue-sink-pipe.yaml
- jira-add-comment-sink-pipe.yaml
- jira-server-info.json
- jira-add-comment-response.json
- jira-get-issue-response.json
- jira-create-issue-request.json
- jira-create-issue-response.json
- jira-issue-types.json
Expand Down
Loading