Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for adding gatling session variables into karate features. #1613

Merged
merged 3 commits into from
May 23, 2021

Conversation

abhi-rao
Copy link

@abhi-rao abhi-rao commented May 23, 2021

Description

Currently, while using karate-gatling, there is no way to pass variables from gatling onto karate.
By adding an action karateAdd, the data from gatling can be passed onto karate features.
Without this, __karate needs to manipulate, but this abstraction would help in keeping avoiding dependence on internals.

Comment on lines 88 to 91
if (arg.containsKey(KarateAction.KARATE_CONTEXT_SESSION_KEY)) {
// unwrapping karate attributes and removing it from attribs.
val karateAttribs = arg.remove("__karate").asInstanceOf[scala.collection.mutable.Map[String, AnyRef]].asJava
val karateAttribs = arg.remove(KarateAction.KARATE_CONTEXT_SESSION_KEY).asInstanceOf[Map[String, AnyRef]].asJava
arg.putAll(karateAttribs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally moved away from mutable map, in favour of immutable map.

object PreDef {
def karateProtocol(uriPatterns: (String, Seq[MethodPause])*) = new KarateProtocol(uriPatterns.toMap)
def karateFeature(name: String, tags: String *) = new KarateActionBuilder(name, tags)
def karateAdd(key: String, valueSupplier: Session => AnyRef ) = new KarateContextAddBuilder(key, valueSupplier)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptrthomas Any suggestions on the name?

@ptrthomas ptrthomas merged commit f1d98d6 into karatelabs:develop May 23, 2021
@ptrthomas
Copy link
Member

thanks for this. it may be easier for me to refactor after merge. I'd like to see if we can merge the 2 simulations we have since it adds to the CI time

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants