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

commit 33316ec39319368c457fb5d5c5d654e3f5ccb6db
Author: Christoph Deppisch <cdeppi...@redhat.com>
AuthorDate: Tue Mar 15 16:30:51 2022 +0100

    chore: Refactor YAKS tests
    
    - 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)
---
 .github/workflows/yaks-tests.yaml                  | 34 +++++++++++----
 test/aws-ddb-sink/yaks-config.yaml                 | 23 +++--------
 test/earthquake-source/earthquake-source.feature   | 34 ++++++++-------
 test/earthquake-source/yaks-config.yaml            | 29 ++++++-------
 .../insert-field-action-binding.yaml               | 26 ++++++------
 .../insert-field-action.feature                    | 48 +++++++++++++---------
 test/insert-field-action/yaks-config.yaml          | 33 +++++++--------
 test/mail-sink/mail-sink.feature                   |  7 ++--
 test/mail-sink/yaks-config.yaml                    | 24 +++--------
 test/timer-source/timer-source.feature             | 28 ++++++++-----
 test/timer-source/yaks-config.yaml                 | 27 ++++++------
 11 files changed, 158 insertions(+), 155 deletions(-)

diff --git a/.github/workflows/yaks-tests.yaml 
b/.github/workflows/yaks-tests.yaml
index 11cf6ab..754f566 100644
--- a/.github/workflows/yaks-tests.yaml
+++ b/.github/workflows/yaks-tests.yaml
@@ -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:
@@ -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
diff --git a/test/aws-ddb-sink/yaks-config.yaml 
b/test/aws-ddb-sink/yaks-config.yaml
index 6118b7b..15156f0 100644
--- a/test/aws-ddb-sink/yaks-config.yaml
+++ b/test/aws-ddb-sink/yaks-config.yaml
@@ -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
diff --git a/test/earthquake-source/earthquake-source.feature 
b/test/earthquake-source/earthquake-source.feature
index 3a7c180..20e481f 100644
--- a/test/earthquake-source/earthquake-source.feature
+++ b/test/earthquake-source/earthquake-source.feature
@@ -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
diff --git a/test/earthquake-source/yaks-config.yaml 
b/test/earthquake-source/yaks-config.yaml
index 95b5a80..5167ea2 100644
--- a/test/earthquake-source/yaks-config.yaml
+++ b/test/earthquake-source/yaks-config.yaml
@@ -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
diff --git a/test/insert-field-action/insert-field-action-binding.yaml 
b/test/insert-field-action/insert-field-action-binding.yaml
index de2fd2b..68712cc 100644
--- a/test/insert-field-action/insert-field-action-binding.yaml
+++ b/test/insert-field-action/insert-field-action-binding.yaml
@@ -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
diff --git a/test/insert-field-action/insert-field-action.feature 
b/test/insert-field-action/insert-field-action.feature
index 850903e..33f050d 100644
--- a/test/insert-field-action/insert-field-action.feature
+++ b/test/insert-field-action/insert-field-action.feature
@@ -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
diff --git a/test/insert-field-action/yaks-config.yaml 
b/test/insert-field-action/yaks-config.yaml
index efd9423..ae300e5 100644
--- a/test/insert-field-action/yaks-config.yaml
+++ b/test/insert-field-action/yaks-config.yaml
@@ -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
diff --git a/test/mail-sink/mail-sink.feature b/test/mail-sink/mail-sink.feature
index bb889d6..13a3f6d 100644
--- a/test/mail-sink/mail-sink.feature
+++ b/test/mail-sink/mail-sink.feature
@@ -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 |
@@ -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
diff --git a/test/mail-sink/yaks-config.yaml b/test/mail-sink/yaks-config.yaml
index 910c83a..06b6d82 100644
--- a/test/mail-sink/yaks-config.yaml
+++ b/test/mail-sink/yaks-config.yaml
@@ -17,7 +17,7 @@
 
 config:
   namespace:
-    temporary: true
+    temporary: false
   runtime:
     env:
       - name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
@@ -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
diff --git a/test/timer-source/timer-source.feature 
b/test/timer-source/timer-source.feature
index 6917806..c976ff7 100644
--- a/test/timer-source/timer-source.feature
+++ b/test/timer-source/timer-source.feature
@@ -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
diff --git a/test/timer-source/yaks-config.yaml 
b/test/timer-source/yaks-config.yaml
index dad4a09..5167ea2 100644
--- a/test/timer-source/yaks-config.yaml
+++ b/test/timer-source/yaks-config.yaml
@@ -17,18 +17,15 @@
 
 config:
   namespace:
-    temporary: true
-pre:
-- name: installation
-  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
-post:
-- name: dump
-  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

Reply via email to