Expression evaluation for the transform script file location - spring-xd

Basically looking to parameterize the selected groovy transformation file based on message characteristics...
Something like this:
stream create --name DynamicTestStream --definition "http | transform --script='file:/tmp/groovy/#jsonPath(payload,'$.SELECTOR')/transform.groovy' | log"
This errors out as the script is not running through an evaluation step.
Any suggestions?
Thanks,
Mark

Right - this won't work. You could possibly have your groovy script be a master that routes to the selector script, e.g. Including a groovy script in another groovy or delegate to internal classes or functions.

It's not currently possible to re-evaluate the script location at runtime, it's only evaluated at deployment time. You would need to write a custom transform processor.

Related

How do I set a secret value with build script interaction on team city?

I know I can define a secret value like this in kotlin DSL on teamcity:
params {
password(
"env.MY_SECRET_VALUE",
"credentialsJSON:faf2d7c8-3565-452a-8cfe-a7a55a4f0f4c",
display = ParameterDisplay.HIDDEN
)
}
How do I achieve the same with build script interaction? I mean a command of the kind
##teamcity[setParameter name='env.MY_SECRET_VALUE' value='1234']
Is it possible at all? I was unable to find this use-case in this documentation, which is the most complete I've found until now on the topic.
The way I understand it, making this happen with build script interaction makes no sense, because I'd need to write a command like
echo "##teamcity[setParameter password='env.MY_SECRET_VALUE' value='1234']"
assuming such a command existed. That means TeamCity will display that line in the logs with the value not hidden, making it therefore pointless.

How can I embed a test data set in my JMeter test plan?

At the moment, my JMeter test uses a CSV Data Set Config to iterate through a limited set of input data for each HTTP request that I do.
But I don't want to deal with the hassle of an external file (uploading it to my test runner, etc.) - I'd like to just embed the data into the jmx file itself.
I was hoping for something like a "test data" node, that would work similarly to a CSV data set (with Recycle on EOF especially) and I'd just copy/paste the data into the test plan instead of working with an external file.
I'm thinking I might be able to work around it with a JSR223 preprocessor - but is there a better built-in way?
Edit: As per comment: the data cannot be generated.
If you want to do this via JSR223 Test Elements and Groovy language correct syntax would be
vars.put("messageId", "wibble");
vars is a shorthand for JMeterVariables class instance, see the JavaDoc for available functions and properties.
Easier way would be going for User Defined Variables or User Parameters or even better Set Variables Action
You can create a text contains keys and values separated with tab, copy all text
Notice if you have property file you can replace = with tab
Add to JMeter GUI User Defined Variables and click Add from Clipboard
It'll load all your variables to JMeter without "do that by hand using JMeter's GUI"
.
This is my first go at a script based approach using a JSR223 preprocessor node:
// This is where the data is embedded. Up to a couple of hundred entries
// is probably fine, more than that will likely be a bad idea.
def messageIdList = ["graffle", "wibble", "wobble", "flobble", "gibble", ...]
def messageIndex = (vars.getIteration() -1) % (messageIdList.size() -1)
println "iteration ${vars.iteration}, size ${messageIdList.size()}, index: ${messageIndex}"
vars.put("messageId", messageIdList[messageIndex]);
messageIndex++
This appears to do what I want, even when run in a Thread Group with multiple threads.
I'm not sure exactly what the vars.getIteration() represents, and I'm not clear about the precise lifetime / scope of the variables. But it'll do for now.
Any better answers will cheerfully accepted, marked and upvoted.

How to break beanshell script into functions & call them?

Here below are my scenario:
I am using JMeter to generate loads
I have to read multiple .csv files and extracting values, then add some logic to it and then pass this data to Java functions (we have a jars files for that)
I am using a BeanShell script. But I don't want to write all the code into one file. As its become a very big file and hard to maintain.
Query: Is there any way to write these functions in multiple beanshell script?
Query: Is that possible to call these function written in different beanshell scripts?
Can you provide a sample code for this.
You can use different JSR223 Elements to hold one file of beanshell scripts/functions by defining same script file
Script File
Name of a file to be used as a JSR223 script
If you have different functions you can use similarly Test Fragment
Test Fragment is used in conjunction with the Include Controller and Module Controller.

How to debug a transform script in ServiceNow?

I have written a transform script in SN.Its not performing as it should be.So
i just want to debug the script.So please suggest the ways to debug transform
script in SN.
The same way you debug other scripts. Add gs.info/warning/error or add it directly to the Transform Script's log through the variable 'log'.
Additionally, you could use the legacy function gs.print, but you need to turn on debugging first.
Read more on the Fuji wiki or Geneva documentation

How to write any variable created in a test to the jasmine-reporters output file using Protractor?

In parts of my test, I have some variables I dynamically create that simply capture some strings. I have jasmine-reporters set up and working, and writing to an output.xml file. How do I get any variables I create in my tests to write to that output file?
For example, if I do a search in my test, the results display number of lines in a string as part of what's returned. I do a getText() on that and store in a variable. I have figured out how to write to console, but it would be great to get it to write to the output file instead.
Yes like #bloveridge mentioned, jasmine does not allow you to add data from the tests into the report, and you should not try to do it as it's not the concern of the test reporter. If you want to use protractor to collect some kind of information while testing, you should write into your own (i.e. separate) file (http://nodejs.org/api/fs.html) in your test.

Resources