You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/02/07 11:51:46 UTC

[camel-kamelets] branch main updated: chore: Fix flaky AWS DDB sink YAKS tests

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 85698ba0 chore: Fix flaky AWS DDB sink YAKS tests
85698ba0 is described below

commit 85698ba0238bea8cf15dd710a6ec66e15b367239
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Tue Feb 7 11:42:34 2023 +0100

    chore: Fix flaky AWS DDB sink YAKS tests
    
    - Use repeatOnError with maxRetryAttempts instead of static sleep 10sec
    - Should give GitHub CI job more time to verify AWS DDB items without increasing the total test execution time
---
 test/aws-ddb-sink/aws-ddb-sink-deleteItem.feature       |  7 ++++---
 test/aws-ddb-sink/aws-ddb-sink-putItem.feature          |  7 ++++---
 test/aws-ddb-sink/aws-ddb-sink-updateItem.feature       |  7 ++++---
 test/aws-ddb-sink/verifyItems.groovy                    | 17 ++++++++++++++++-
 .../aws-ddb-sink-exp/aws-ddb-sink-deleteItem.feature    |  7 ++++---
 .../aws-ddb-sink-exp/aws-ddb-sink-putItem.feature       |  7 ++++---
 .../aws-ddb-sink-exp/aws-ddb-sink-updateItem.feature    |  7 ++++---
 test/experimental/aws-ddb-sink-exp/verifyItems.groovy   | 17 ++++++++++++++++-
 8 files changed, 56 insertions(+), 20 deletions(-)

diff --git a/test/aws-ddb-sink/aws-ddb-sink-deleteItem.feature b/test/aws-ddb-sink/aws-ddb-sink-deleteItem.feature
index 2237c07d..a6d2ee85 100644
--- a/test/aws-ddb-sink/aws-ddb-sink-deleteItem.feature
+++ b/test/aws-ddb-sink/aws-ddb-sink-deleteItem.feature
@@ -43,20 +43,21 @@ Feature: AWS DDB Sink - DeleteItem
   Scenario: Create item on AWS-DDB
     Given run script putItem.groovy
     Given variables
+      | maxRetryAttempts  | 20 |
       | aws.ddb.items     | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Create AWS-DDB Kamelet sink binding
     When load KameletBinding aws-ddb-sink-binding.yaml
     And KameletBinding aws-ddb-sink-binding is available
     And Camel K integration aws-ddb-sink-binding is running
     And Camel K integration aws-ddb-sink-binding should print Routes startup
-    Then sleep 10sec
 
   Scenario: Verify Kamelet sink
     Given variables
+      | maxRetryAttempts  | 20 |
       | aws.ddb.items     | [] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Remove Camel K resources
     Given delete KameletBinding aws-ddb-sink-binding
diff --git a/test/aws-ddb-sink/aws-ddb-sink-putItem.feature b/test/aws-ddb-sink/aws-ddb-sink-putItem.feature
index 04eb4deb..15847511 100644
--- a/test/aws-ddb-sink/aws-ddb-sink-putItem.feature
+++ b/test/aws-ddb-sink/aws-ddb-sink-putItem.feature
@@ -30,7 +30,6 @@ Feature: AWS DDB Sink - PutItem
       | aws.ddb.item.year    | 1977 |
       | aws.ddb.item.title   | Star Wars IV |
       | aws.ddb.json.data    | { "id":${aws.ddb.item.id}, "year":${aws.ddb.item.year}, "title":"${aws.ddb.item.title}" } |
-      | aws.ddb.items        | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
 
   Scenario: Start LocalStack container
     Given Enable service DYNAMODB
@@ -46,10 +45,12 @@ Feature: AWS DDB Sink - PutItem
     And KameletBinding aws-ddb-sink-binding is available
     And Camel K integration aws-ddb-sink-binding is running
     And Camel K integration aws-ddb-sink-binding should print Routes startup
-    Then sleep 10sec
 
   Scenario: Verify Kamelet sink
-    Then run script verifyItems.groovy
+    Given variables
+      | maxRetryAttempts  | 20 |
+      | aws.ddb.items     | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
+    Then apply actions verifyItems.groovy
 
   Scenario: Remove Camel K resources
     Given delete KameletBinding aws-ddb-sink-binding
diff --git a/test/aws-ddb-sink/aws-ddb-sink-updateItem.feature b/test/aws-ddb-sink/aws-ddb-sink-updateItem.feature
index 2fe9d482..feba0e23 100644
--- a/test/aws-ddb-sink/aws-ddb-sink-updateItem.feature
+++ b/test/aws-ddb-sink/aws-ddb-sink-updateItem.feature
@@ -45,21 +45,22 @@ Feature: AWS DDB Sink - UpdateItem
   Scenario: Create item on AWS-DDB
     Given run script putItem.groovy
     Given variables
+      | maxRetryAttempts  | 20 |
       | aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Create AWS-DDB Kamelet sink binding
     When load KameletBinding aws-ddb-sink-binding.yaml
     And KameletBinding aws-ddb-sink-binding is available
     And Camel K integration aws-ddb-sink-binding is running
     And Camel K integration aws-ddb-sink-binding should print Routes startup
-    Then sleep 10sec
 
   Scenario: Verify Kamelet sink
     Given variables
+      | maxRetryAttempts  | 200 |
       | aws.ddb.item.directors | [Ernest B. Schoedsack, Merian C. Cooper] |
       | aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), directors=AttributeValue(SS=${aws.ddb.item.directors}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title.new})}] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Remove Camel K resources
     Given delete KameletBinding aws-ddb-sink-binding
diff --git a/test/aws-ddb-sink/verifyItems.groovy b/test/aws-ddb-sink/verifyItems.groovy
index b6e9d27c..b65ca27f 100644
--- a/test/aws-ddb-sink/verifyItems.groovy
+++ b/test/aws-ddb-sink/verifyItems.groovy
@@ -15,4 +15,19 @@
  * limitations under the License.
  */
 
-assert "${aws.ddb.items}".equals(amazonDDBClient.scan(b -> b.tableName("${aws.ddb.tableName}"))?.items()?.toString())
+$actions {
+    $(repeatOnError()
+        .until('i > ${maxRetryAttempts}')
+        .actions(new com.consol.citrus.TestAction() {
+            @Override
+            void execute(com.consol.citrus.context.TestContext context) {
+                try {
+                    assert context.getVariable('aws.ddb.items')
+                            .equals(amazonDDBClient.scan(b -> b.tableName(context.getVariable('aws.ddb.tableName')))?.items()?.toString())
+                } catch (AssertionError e) {
+                    throw new com.consol.citrus.exceptions.CitrusRuntimeException("AWS DDB item verification failed", e)
+                }
+            }
+        })
+    )
+}
diff --git a/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-deleteItem.feature b/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-deleteItem.feature
index d535b82f..6edb0ae2 100644
--- a/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-deleteItem.feature
+++ b/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-deleteItem.feature
@@ -43,20 +43,21 @@ Feature: AWS DDB Sink - DeleteItem
   Scenario: Create item on AWS-DDB
     Given run script putItem.groovy
     Given variables
+      | maxRetryAttempts  | 20 |
       | aws.ddb.items     | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Create AWS-DDB Kamelet sink binding
     When load KameletBinding aws-ddb-sink-binding.yaml
     And KameletBinding aws-ddb-experimental-sink-binding is available
     And Camel K integration aws-ddb-experimental-sink-binding is running
     And Camel K integration aws-ddb-experimental-sink-binding should print Routes startup
-    Then sleep 10sec
 
   Scenario: Verify Kamelet sink
     Given variables
+      | maxRetryAttempts  | 20 |
       | aws.ddb.items     | [] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Remove Camel K resources
     Given delete KameletBinding aws-ddb-experimental-sink-binding
diff --git a/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-putItem.feature b/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-putItem.feature
index 637b1dab..0d8d759a 100644
--- a/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-putItem.feature
+++ b/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-putItem.feature
@@ -30,7 +30,6 @@ Feature: AWS DDB Sink - PutItem
       | aws.ddb.item.year    | 1977 |
       | aws.ddb.item.title   | Star Wars IV |
       | aws.ddb.json.data    | { "id":${aws.ddb.item.id}, "year":${aws.ddb.item.year}, "title":"${aws.ddb.item.title}" } |
-      | aws.ddb.items        | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
 
   Scenario: Start LocalStack container
     Given Enable service DYNAMODB
@@ -46,10 +45,12 @@ Feature: AWS DDB Sink - PutItem
     And KameletBinding aws-ddb-experimental-sink-binding is available
     And Camel K integration aws-ddb-experimental-sink-binding is running
     And Camel K integration aws-ddb-experimental-sink-binding should print Routes startup
-    Then sleep 10sec
 
   Scenario: Verify Kamelet sink
-    Then run script verifyItems.groovy
+    Given variables
+      | maxRetryAttempts  | 20 |
+      | aws.ddb.items     | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
+    Then apply actions verifyItems.groovy
 
   Scenario: Remove Camel K resources
     Given delete KameletBinding aws-ddb-experimental-sink-binding
diff --git a/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-updateItem.feature b/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-updateItem.feature
index 5a0a29c1..14745c26 100644
--- a/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-updateItem.feature
+++ b/test/experimental/aws-ddb-sink-exp/aws-ddb-sink-updateItem.feature
@@ -45,21 +45,22 @@ Feature: AWS DDB Sink - UpdateItem
   Scenario: Create item on AWS-DDB
     Given run script putItem.groovy
     Given variables
+      | maxRetryAttempts  | 20 |
       | aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Create AWS-DDB Kamelet sink binding
     When load KameletBinding aws-ddb-sink-binding.yaml
     And KameletBinding aws-ddb-experimental-sink-binding is available
     And Camel K integration aws-ddb-experimental-sink-binding is running
     And Camel K integration aws-ddb-experimental-sink-binding should print Routes startup
-    Then sleep 10sec
 
   Scenario: Verify Kamelet sink
     Given variables
+      | maxRetryAttempts  | 200 |
       | aws.ddb.item.directors | [Ernest B. Schoedsack, Merian C. Cooper] |
       | aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), directors=AttributeValue(SS=${aws.ddb.item.directors}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title.new})}] |
-    Then run script verifyItems.groovy
+    Then apply actions verifyItems.groovy
 
   Scenario: Remove Camel K resources
     Given delete KameletBinding aws-ddb-experimental-sink-binding
diff --git a/test/experimental/aws-ddb-sink-exp/verifyItems.groovy b/test/experimental/aws-ddb-sink-exp/verifyItems.groovy
index b6e9d27c..b65ca27f 100644
--- a/test/experimental/aws-ddb-sink-exp/verifyItems.groovy
+++ b/test/experimental/aws-ddb-sink-exp/verifyItems.groovy
@@ -15,4 +15,19 @@
  * limitations under the License.
  */
 
-assert "${aws.ddb.items}".equals(amazonDDBClient.scan(b -> b.tableName("${aws.ddb.tableName}"))?.items()?.toString())
+$actions {
+    $(repeatOnError()
+        .until('i > ${maxRetryAttempts}')
+        .actions(new com.consol.citrus.TestAction() {
+            @Override
+            void execute(com.consol.citrus.context.TestContext context) {
+                try {
+                    assert context.getVariable('aws.ddb.items')
+                            .equals(amazonDDBClient.scan(b -> b.tableName(context.getVariable('aws.ddb.tableName')))?.items()?.toString())
+                } catch (AssertionError e) {
+                    throw new com.consol.citrus.exceptions.CitrusRuntimeException("AWS DDB item verification failed", e)
+                }
+            }
+        })
+    )
+}