Skip to content

Commit

Permalink
chore: Refactor YAKS tests
Browse files Browse the repository at this point in the history
- Use proper yaks-config conventions
- Use YAKS dump functionality in case of failure
- Move Camel K installation steps to workflow
- Apply all current Kamelets at once in workflow prior to running the tests
- Keep pre/post test scripts as simple as possible
- Use Camel K 1.8.2 (fixes earthquake-source CI test)
  • Loading branch information
christophd committed Mar 15, 2022
1 parent fbbd34b commit f0ddaa5
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 155 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/yaks-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ concurrency:
cancel-in-progress: true

env:
CAMEL_K_VERSION: 1.7.0
CAMEL_K_VERSION: 1.8.2
YAKS_VERSION: 0.9.0-202203140033
YAKS_IMAGE_NAME: "docker.io/yaks/yaks"
YAKS_RUN_OPTIONS: "--timeout=15m"

jobs:
test:
Expand Down Expand Up @@ -73,25 +74,40 @@ jobs:
uses: container-tools/kind-action@v1
- name: Info
run: |
kubectl version
kubectl cluster-info
kubectl describe nodes
- name: Run Tests
- name: Install Camel K
run: |
echo "Configuring Camel K"
kamel install --cluster-setup
# Configure install options
export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum
export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
export KAMEL_INSTALL_REGISTRY_INSECURE=true
echo "Configuring Yaks"
yaks install --operator-image $YAKS_IMAGE_NAME:$YAKS_VERSION
kamel install -w
# TODO replaces the below statement with --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
# when we use camel k 1.8.0
kubectl delete kamelets --all
# Install the local kamelets
find kamelets -maxdepth 1 -name '*.kamelet.yaml' -exec kubectl apply -f {} \;
- name: Install YAKS
run: |
yaks install --operator-image $YAKS_IMAGE_NAME:$YAKS_VERSION
- name: YAKS Tests
run: |
echo "Running tests"
yaks run ./test
yaks run test/aws-ddb-sink $YAKS_RUN_OPTIONS
yaks run test/insert-field-action $YAKS_RUN_OPTIONS
yaks run test/mail-sink $YAKS_RUN_OPTIONS
yaks run test/timer-source $YAKS_RUN_OPTIONS
yaks run test/earthquake-source $YAKS_RUN_OPTIONS
- name: YAKS Report
if: failure()
run: |
yaks report
- uses: actions/upload-artifact@v2
if: failure()
with:
name: dumps
path: /tmp/dumps/*.log
path: _output/*-dump.log
23 changes: 5 additions & 18 deletions test/aws-ddb-sink/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,8 @@ config:
- groupId: org.apache.camel
artifactId: camel-jackson
version: "@camel.version@"
pre:
- name: installation
if: env:CI=true
run: |
# Install required Kamelets (these steps may be done globally in future versions)
kamel install -n $YAKS_NAMESPACE -w
kubectl delete kamelet -n $YAKS_NAMESPACE --all
kubectl apply -f ../../kamelets/timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f ../../kamelets/log-sink.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f ../../kamelets/aws-ddb-sink.kamelet.yaml -n $YAKS_NAMESPACE
post:
- name: dump
if: env:CI=true
run: |
kamel dump -n $YAKS_NAMESPACE $(basename `pwd`)-dump.log
mkdir -p /tmp/dumps
cp *-dump.log /tmp/dumps
dump:
enabled: true
failedOnly: true
includes:
- app=camel-k
34 changes: 20 additions & 14 deletions test/earthquake-source/earthquake-source.feature
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
Feature: Kamelet earthquake-source works
Feature: Kamelet earthquake-source

Background:
Given Disable auto removal of Kamelet resources
Given Disable auto removal of Kubernetes resources
Given Camel K resource polling configuration
| maxAttempts | 60 |
| delayBetweenAttempts | 3000 |
Given HTTP server timeout is 15000 ms
Given HTTP server "test-service"

Scenario: Bind Kamelet to service
Scenario: Create Http server
Given create Kubernetes service test-service with target port 8080
And bind Kamelet earthquake-source to uri http://test-service.${YAKS_NAMESPACE}.svc.cluster.local/test
When create KameletBinding earthquake-source-uri

Scenario: Create Kamelet binding
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
When bind Kamelet earthquake-source to uri http://test-service.${YAKS_NAMESPACE}/test
And create KameletBinding earthquake-source-uri
Then KameletBinding earthquake-source-uri should be available
Then Camel K integration earthquake-source-uri should be running
And Camel K integration earthquake-source-uri should print Routes startup

Scenario: Verify binding
Given HTTP server "test-service"
And HTTP server timeout is 120000 ms
Then expect HTTP request header: Content-Type="application/json;charset=UTF-8"
And receive POST /test
And delete KameletBinding earthquake-source-uri
Given expect HTTP request header: Content-Type="application/json;charset=UTF-8"
When receive POST /test
Then send HTTP 200 OK

Scenario: Remove Camel K resources
Given delete KameletBinding earthquake-source-uri
And delete Kubernetes service test-service
29 changes: 12 additions & 17 deletions test/earthquake-source/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@

config:
namespace:
temporary: true
pre:
- name: installation
if: env:CI=true
run: |
# Install required Kamelets (these steps may be done globally in future versions)
kamel install -n $YAKS_NAMESPACE -w
kubectl delete kamelet -n $YAKS_NAMESPACE --all
kubectl apply -f ../../kamelets/earthquake-source.kamelet.yaml -n $YAKS_NAMESPACE
post:
- name: dump
if: env:CI=true
run: |
kamel dump -n $YAKS_NAMESPACE $(basename `pwd`)-dump.log
mkdir -p /tmp/dumps
cp *-dump.log /tmp/dumps
temporary: false
runtime:
env:
- name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
value: false
- name: YAKS_KUBERNETES_AUTO_REMOVE_RESOURCES
value: false
dump:
enabled: true
failedOnly: true
includes:
- app=camel-k
26 changes: 14 additions & 12 deletions test/insert-field-action/insert-field-action-binding.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
kind: KameletBinding
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: insert-field-action-binding
spec:
source:
ref:
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: '{"content": "thecontent"}'
contentType: "application/json"
period: 5000
contentType: application/json
message: >
${input}
steps:
- ref:
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
name: insert-field-action
properties:
field: "thefield"
value: "thevalue"
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: insert-field-action
properties:
field: ${field}
value: ${value}
sink:
uri: http://probe-service/events
uri: http://test-insert-service.${YAKS_NAMESPACE}/result
48 changes: 29 additions & 19 deletions test/insert-field-action/insert-field-action.feature
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
Feature: Timer Source Kamelet
Feature: Insert field Kamelet action

Background:
Given Disable auto removal of Kamelet resources
Given Disable auto removal of Kubernetes resources
Given Camel K resource polling configuration
| maxAttempts | 60 |
| delayBetweenAttempts | 3000 |
Given HTTP server timeout is 15000 ms
Given HTTP server "test-insert-service"
Given variables
| field | subject |
| value | Camel K rocks! |

Scenario: Create Http server
Given create Kubernetes service test-insert-service with target port 8080

Scenario: Wait for binding to start
Given create Kubernetes service probe-service with target port 8080
Scenario: Create Kamelet binding
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
Given variable input is
"""
{ "id": "citrus:randomUUID()" }
"""
When load KameletBinding insert-field-action-binding.yaml
Then Camel K integration insert-field-action-binding should be running
And Camel K integration insert-field-action-binding should print Routes startup

Scenario: Verify binding
Given HTTP server "probe-service"
And HTTP server timeout is 300000 ms
Then expect HTTP request body
Scenario: Verify output message sent
Given expect HTTP request body
"""
{
"content": "thecontent",
"thefield": "thevalue"
}
{ "id": "@ignore@", "${field}": "${value}" }
"""
And expect HTTP request header: Content-Type="application/json;charset=UTF-8"
And receive POST /events
And delete KameletBinding insert-field-action-binding
And HTTP request header Content-Type="application/json"
When receive POST /result
Then send HTTP 200 OK

Scenario: Remove resources
Given delete KameletBinding insert-field-action-binding
And delete Kubernetes service test-insert-service
33 changes: 14 additions & 19 deletions test/insert-field-action/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,17 @@

config:
namespace:
temporary: true
pre:
- name: installation
if: env:CI=true
run: |
# Install required Kamelets (these steps may be done globally in future versions)
kamel install -n $YAKS_NAMESPACE -w
kubectl delete kamelet -n $YAKS_NAMESPACE --all
kubectl apply -f ../../kamelets/timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f ../../kamelets/insert-field-action.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f insert-field-action-binding.yaml -n $YAKS_NAMESPACE
post:
- name: dump
if: env:CI=true
run: |
kamel dump -n $YAKS_NAMESPACE $(basename `pwd`)-dump.log
mkdir -p /tmp/dumps
cp *-dump.log /tmp/dumps
temporary: false
runtime:
env:
- name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
value: false
- name: YAKS_KUBERNETES_AUTO_REMOVE_RESOURCES
value: false
resources:
- insert-field-action-binding.yaml
dump:
enabled: true
failedOnly: true
includes:
- app=camel-k
7 changes: 4 additions & 3 deletions test/mail-sink/mail-sink.feature
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
Feature: Mail Sink

Background:
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
Given variables
| host | mail-server |
| username | test |
Expand All @@ -18,10 +15,14 @@ Feature: Mail Sink
Given create Kubernetes service mail-server with port mapping 25:22222

Scenario: Create Camel K resources
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
Given Kamelet mail-sink is available
Given Kamelet timer-source is available
Given load KameletBinding timer-to-mail.yaml
And Camel K integration timer-to-mail should be running
And Camel K integration timer-to-mail should print Routes startup

Scenario: Verify mail message sent
Then endpoint mail-server should receive body
Expand Down
24 changes: 6 additions & 18 deletions test/mail-sink/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

config:
namespace:
temporary: true
temporary: false
runtime:
env:
- name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
Expand All @@ -32,20 +32,8 @@ config:
resources:
- mail-server.groovy
- timer-to-mail.yaml
pre:
- name: installation
if: env:CI=true
run: |
# Install required Kamelets (these steps may be done globally in future versions)
kamel install -n $YAKS_NAMESPACE -w
kubectl delete kamelet -n $YAKS_NAMESPACE --all
kubectl apply -f ../../kamelets/mail-sink.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f ../../kamelets/timer-source.kamelet.yaml -n $YAKS_NAMESPACE
post:
- name: dump
if: env:CI=true
run: |
kamel dump -n $YAKS_NAMESPACE $(basename `pwd`)-dump.log
mkdir -p /tmp/dumps
cp *-dump.log /tmp/dumps
dump:
enabled: true
failedOnly: true
includes:
- app=camel-k
28 changes: 17 additions & 11 deletions test/timer-source/timer-source.feature
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
Feature: Timer Source Kamelet

Background:
Given Disable auto removal of Kamelet resources
Given Disable auto removal of Kubernetes resources
Given Camel K resource polling configuration
| maxAttempts | 20 |
| delayBetweenAttempts | 1000 |
Given HTTP server timeout is 15000 ms
Given HTTP server "probe-service"

Scenario: Bind Kamelet to service
Scenario: Create Http server
Given create Kubernetes service probe-service with target port 8080

Scenario: Create Kamelet binding
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
And KameletBinding source properties
| message | Hello World |
And bind Kamelet timer-source to uri http://probe-service.${YAKS_NAMESPACE}/events
When create KameletBinding timer-source-binding
Then KameletBinding timer-source-binding should be available
Then Camel K integration timer-source-binding should be running
And Camel K integration timer-source-binding should print Routes startup

Scenario: Verify binding
Given HTTP server "probe-service"
And HTTP server timeout is 300000 ms
Then expect HTTP request body: Hello World
And receive POST /events
And delete KameletBinding timer-source-binding
Given expect HTTP request body: Hello World
When receive POST /events
Then send HTTP 200 OK

Scenario: Remove Camel K resources
Given delete KameletBinding timer-source-binding
And delete Kubernetes service probe-service
Loading

0 comments on commit f0ddaa5

Please sign in to comment.