citrusframework / yaks

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

YAML Camel K files cause com.consol.citrus.exceptions.CitrusRuntimeException #410

Closed mwmahlberg closed 2 years ago

mwmahlberg commented 2 years ago
$ yaks version
YAKS 0.11.0-202205230038

I have a feature file loading a Camel K integration:

Feature: tls-rest
  Background: Deployment
    Given load Camel K integration basic-test.yaml
...

with basic-test.yaml looking like this:

- route:
    from:
      uri: direct:test
      steps:
        - to:
            uri: microprofile-metrics:counter:incoming
            description: Count the incoming messages
        - log:
            message:  Received incoming ${body}

This causes (abridged):

com.consol.citrus.exceptions.TestCaseFailedException: Unknown variable 'body'
      at com.consol.citrus.DefaultTestCase.executeAction(DefaultTestCase.java:144)
      at com.consol.citrus.DefaultTestCaseRunner.run(DefaultTestCaseRunner.java:125)
      at org.citrusframework.yaks.camelk.CamelKSteps.createIntegration(CamelKSteps.java:157)
      at org.citrusframework.yaks.camelk.CamelKSteps.loadIntegrationFromFile(CamelKSteps.java:139)
      at ✽.load Camel K integration tls-rest.yaml(classpath:org/citrusframework/yaks/tls-rest.feature:4)
Caused by: com.consol.citrus.exceptions.CitrusRuntimeException: Unknown variable 'body'

My working theory here is that the source files are processed by the same template engine as the feature file. Is that wanted behavior?

For completeness, my jaks-config.yaml:

config:
  runtime:
    resources:
      - tls-rest.yaml
christophd commented 2 years ago

This is because both Citrus/YAKS and Apache Camel do use the ${} placeholder syntax. So YAKS tries to replace that placeholder ${body} and can not find a test variable named body.

To solve this you can disable the YAKS placeholder replacement for Apache Camel resources with the env setting: YAKS_CAMELK_SUPPORT_VARIABLES_IN_SOURCES=false

You can globally add this env setting to the yaks-config.yaml configuration. Or you can disable this in your feature file explicitly with:

Given Disable variable support in Camel-K sources

As an alternative you may want to use variable expression escaping like this ${//body//}. This syntax prevents YAKS from replacing this as a test variable, too.

mwmahlberg commented 2 years ago

@christophd Will verify that this was my actual problem and get back to you.

christophd commented 2 years ago

@mwmahlberg any news on this?