citrusframework / yaks

YAKS is a platform to enable Cloud Native BDD testing on Kubernetes
Apache License 2.0
82 stars 27 forks source link

Kamelet: Camel-Simple and Yaks do not interact well when using "Load Kamelet" in a Yaks test #488

Closed andy-d2019 closed 6 months ago

andy-d2019 commented 7 months ago

Given the following Syntax in a Kamelet running with Camel-K 2.1.0

 - set-property:
            name: data
            simple: "${body}"

If i use Kamelet load on the given Kamelet in a yaks test.feature file and run it with yaks run i get an exception of the form

org.citrusframework.exceptions.TestCaseFailedException: Unknown variable 'body'

Without Yaks the Kamelet runs perfectly fine by itself, but it seems like Yaks/Citrus try to interpret the variable in the simple-language block as their own variable.

I could find a workaround by escaping the dollar sign with '\u0024'. Other common yaml escape sequences do not seem to work.

christophd commented 7 months ago

Yes, this is because Citrus test variables and Camel simple language both use the same syntax '${}' for expressions.

You have two options here:

  1. Set the option YAKS_CAMELK_SUPPORT_VARIABLES_IN_SOURCES to false - this will prevent Citrus from parsing the expressions in Camel K resources
  2. Use the alternative simple language syntax $simple{ } in your Camel logic (e.g. $simple{body})

This should go into the YAKS documentation 😄

mwmahlberg commented 7 months ago

2. Use the alternative simple language syntax $simple{ } in your Camel logic (e.g. $simple{body})

Just to make sure, so this would be

set-property:
    name: data
    simple: "$simple{body}"

?

If yes, a PR for the docs would be my pleasure.

andy-d2019 commented 7 months ago

Thanks for the quick responses, this will make the Kamelet a lot more readable again 😄

christophd commented 6 months ago

Closing this one as it seems to have clarified. Thx!