Skip to content

Commit

Permalink
chore: Add Slack sink Kamelet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed May 14, 2024
1 parent be5383e commit 64fa372
Show file tree
Hide file tree
Showing 19 changed files with 255 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
yaks run test/protobuf $YAKS_RUN_OPTIONS
yaks run test/ftp/sink $YAKS_RUN_OPTIONS
yaks run test/ftp/source $YAKS_RUN_OPTIONS
yaks run test/slack $YAKS_RUN_OPTIONS
yaks run test/kafka $YAKS_RUN_OPTIONS
yaks run test/postgresql $YAKS_RUN_OPTIONS
- name: YAKS Report
Expand Down
10 changes: 5 additions & 5 deletions test/aws/kinesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ You can review the installation steps for the operators in the documentation:
To run the Kinesis source tests:

```shell script
$ yaks test aws-kinesis-source.feature
$ yaks run aws-kinesis-source.feature
```

To run the Kinesis sink tests:

```shell script
$ yaks test aws-kinesis-sink.feature
$ yaks run aws-kinesis-sink.feature
```

To run tests with URI based configuration:

```shell script
$ yaks test aws-kinesis-source-uri-conf.feature
$ yaks run aws-kinesis-source-uri-conf.feature
```

To run tests with property based configuration:

```shell script
$ yaks test aws-kinesis-source-property-conf.feature
$ yaks run aws-kinesis-source-property-conf.feature
```

To run tests with URI binding:

```shell script
$ yaks test aws-kinesis-uri-pipe.feature
$ yaks run aws-kinesis-uri-pipe.feature
```

You will be provided with the test log output and the test results.
10 changes: 5 additions & 5 deletions test/aws/sqs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ You can review the installation steps for the operators in the documentation:
To run tests with URI based configuration:

```shell script
$ yaks test aws-sqs-source-uri-conf.feature
$ yaks run aws-sqs-source-uri-conf.feature
```

To run tests with secret based configuration:

```shell script
$ yaks test aws-sqs-source-secret-conf.feature
$ yaks run aws-sqs-source-secret-conf.feature
```

To run tests with property based configuration:

```shell script
$ yaks test aws-sqs-source-property-conf.feature
$ yaks run aws-sqs-source-property-conf.feature
```

To run tests with URI binding:

```shell script
$ yaks test aws-sqs-uri-pipe.feature
$ yaks run aws-sqs-uri-pipe.feature
```

To run tests with binding to Knative channel:

```shell script
$ yaks test aws-sqs-knative-channel.feature
$ yaks run aws-sqs-knative-channel.feature
```

You will be provided with the test log output and the test results.
8 changes: 4 additions & 4 deletions test/jira/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ Yaks operator. In this case you should change [yaks-config.yaml](yaks-config.yam
## Run the test

```shell script
$ yaks test jira-source-uri-based.feature
$ yaks test jira-source-secret-based.feature
$ yaks test jira-source-prop-based.feature
$ yaks test jira-source.feature
$ yaks run jira-source-uri-based.feature
$ yaks run jira-source-secret-based.feature
$ yaks run jira-source-prop-based.feature
$ yaks run jira-source.feature
```

You can increase number of attempts to run the test by adding: "-e YAKS_CAMELK_MAX_ATTEMPTS=1000"
Expand Down
4 changes: 2 additions & 2 deletions test/salesforce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Now you should be ready to run the test!
## Run the test

```shell script
$ yaks test salesforce-source.feature
$ yaks test salesforce-binding.feature
$ yaks run salesforce-source.feature
$ yaks run salesforce-binding.feature
```

You will be provided with the test log output and the test results.
9 changes: 5 additions & 4 deletions test/slack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This test verifies the Slack Kamelets defined in [slack-source.kamelet.yaml](sla
The test verifies the Slack Kamelets by creating a Camel K integration that uses the Kamelet to listen for messages on a
Slack channel using the Slack bot API.

### Test Kamelet source
### Test Kamelets

The test performs the following high level steps:

*Preparation*
- Create a Slack API server that will simulate the Slack API
- Create a Slack API server that will simulate the Slack API (e.g. providing a webhook URL or verifying the Slack API channel history calls)

*Scenario*
*Scenario*
- Create the Camel K integration that uses the Slack Kamelets
- Wait for the Camel K integration to start and listen for Slack messages
- Create a new message on the Slack channel
Expand All @@ -36,7 +36,8 @@ You can review the installation steps for the operators in the documentation:
## Run the test

```shell script
$ yaks test slack-uri-pipe.feature
$ yaks run slack-source.feature
$ yaks run slack-sink.feature
```

You will be provided with the test log output and the test results.
4 changes: 2 additions & 2 deletions test/slack/slack-auth-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"url": "yaks:resolveURL('slack-service')",
"team": "Camel Workspace",
"user": "camel",
"team_id": "T12345678",
"user_id": "W12345678"
"team_id": "${slack.team.id}",
"user_id": "${slack.user.id}"
}
2 changes: 1 addition & 1 deletion test/slack/slack-conversations-history.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"messages": [
{
"type": "message",
"user": "W12345678",
"user": "${slack.user.id}",
"text": "${slack.message}",
"ts": "1512085950.000000"
}
Expand Down
4 changes: 2 additions & 2 deletions test/slack/slack-conversations-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"ok": true,
"channels": [
{
"id": "C012AB3CD",
"id": "yaks:randomString(9, UPPERCASE)",
"name": "${slack.channel}",
"is_channel": true,
"is_group": false,
"is_im": false,
"created": 1449252889,
"creator": "W12345678",
"creator": "${slack.user.id}",
"is_archived": false,
"is_general": true,
"unlinked": 0,
Expand Down
29 changes: 29 additions & 0 deletions test/slack/slack-sink-pipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: slack-sink-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
period: ${timer.source.period}
message: '${slack.message}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-action
properties:
showHeaders: true
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: slack-sink
properties:
webhookUrl: yaks:resolveURL('slack-service')
channel: ${slack.channel}
token: ${slack.token}
40 changes: 40 additions & 0 deletions test/slack/slack-sink.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Feature: Slack Kamelet - Sink

Background:
Given variables
| timer.source.period | 10000 |
| slack.channel | announcements |
| slack.message | Camel rocks! |
| slack.user.id | W12345678 |
| slack.team.id | T12345678 |
Given HTTP server timeout is 120000 ms
Given HTTP server "slack-service"

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

Scenario: Verify Slack events
Given variables
| slack.token | xoxb-yaks:randomNumber(10)-yaks:randomNumber(13)-yaks:randomString(34) |
# Create binding
Given load Pipe slack-sink-pipe.yaml
And Pipe slack-sink-pipe is available
# Verify authentication test
Given expect HTTP request header: Content-Type="application/json; charset=UTF-8"
Then expect HTTP request body
"""
{
"channel": "${slack.channel}",
"text": "${slack.message}",
}
"""
When receive POST /
Then send HTTP 200 OK
# Verify event
And Camel K integration slack-sink-pipe should print ${slack.message}

Scenario: Remove resources
# Remove Camel K binding
Given delete Pipe slack-sink-pipe
Given delete Kubernetes service slack-service
And stop server component slack-service
21 changes: 21 additions & 0 deletions test/slack/slack-source-pipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: slack-source-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: slack-source
properties:
serverUrl: yaks:resolveURL('slack-service')
channel: ${slack.channel}
token: ${slack.token}
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-sink
properties:
showHeaders: true
7 changes: 5 additions & 2 deletions test/slack/slack-source-prop-based.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ Feature: Slack Kamelet - property based configuration
Background:
Given variables
| slack.channel | announcements |
| slack.token | xoxb-yaks:randomNumber(10)-yaks:randomNumber(13)-yaks:randomString(34) |
| slack.message | Camel rocks! |
Given HTTP server timeout is 15000 ms
| slack.user.id | W12345678 |
| slack.team.id | T12345678 |
Given HTTP server timeout is 120000 ms
Given HTTP server "slack-service"

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

Scenario: Verify Slack events
Given variables
| slack.token | xoxb-yaks:randomNumber(10)-yaks:randomNumber(13)-yaks:randomString(34) |
# Create binding
Given Camel K integration property file slack-credentials.properties
Given create Camel K integration slack-to-log-prop-based.groovy
Expand Down
7 changes: 5 additions & 2 deletions test/slack/slack-source-uri-based.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ Feature: Slack Kamelet - URI based configuration
Background:
Given variables
| slack.channel | announcements |
| slack.token | xoxb-yaks:randomNumber(10)-yaks:randomNumber(13)-yaks:randomString(34) |
| slack.message | Camel rocks! |
Given HTTP server timeout is 15000 ms
| slack.user.id | W12345678 |
| slack.team.id | T12345678 |
Given HTTP server timeout is 120000 ms
Given HTTP server "slack-service"

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

Scenario: Verify Slack events
Given variables
| slack.token | xoxb-yaks:randomNumber(10)-yaks:randomNumber(13)-yaks:randomString(34) |
# Create binding
Given load Camel K integration slack-to-log-uri-based.groovy
# Verify authentication test
Expand Down
Loading

0 comments on commit 64fa372

Please sign in to comment.