Closed Tobolov closed 5 months ago
Hi, just wondering if this issue is still open. If so, can I work on this issue?
Hi, just wondering if this issue is still open. If so, can I work on this issue?
@luke-zhou , It's open. You can start working please. Thanks
cool, that is good. just want to confirm my idea here. I am thinking to add something like "#name-tag" to the end of the following 5 type of tokens:
RANDOM.UUID
RANDOM.UUID.FIXED
RANDOM.NUMBER
RANDOM.NUMBER.FIXED
RANDOM.STRING
so when the user need to use the same value as the previous random value, he can just quote the name-tag. For example:
---
scenarioName: Demonstrate bug
parameterized:
csvSource:
# {0}: App ID {1}: User ID
- "${RANDOM.NUMBER#0}, ${RANDOM.NUMBER#first}"
steps:
- name: create_app
url: "kafka-topic:APP"
operation: produce
request:
recordType: JSON
records:
- key: ${RANDOM.NUMBER#0}
value:
appId: ${RANDOM.NUMBER#0}
userId: ${RANDOM.NUMBER#first}
verify:
status: Ok
- name: verify_app
url: "kafka-topic:APP"
operation: consume
retry:
max: 3
delay: 1000 #ms
request:
consumerLocalConfigs:
recordType: JSON
commitSync: true
showRecordsConsumed: true
maxNoOfRetryPollsOrTimeouts: 3
verify:
size: 1
records:
- key: ${RANDOM.NUMBER#0}
value:
appId: ${RANDOM.NUMBER#0}
userId: ${RANDOM.NUMBER#first}
cool, that is good. just want to confirm my idea here. I am thinking to add something like "#name-tag" to the end of the following 5 type of tokens:
Hello @luke-zhou , really appreciate you have been trying to solutionize it. Good to see your ideas, prefix "#first" etc might create confusion imo.
Can you have a look at the Issue description section "Solution to Implement:", which could be simpler ? https://github.com/authorjapps/zerocode/issues/659#issue-2234390371
Basically the 1st line has got words (without spaces) wrapped by "|", will be treated as a headers.
- "|firstRandom|, |secondRandom|, |myName|"
Everytime a scenario runs it should pick the value under each header (e.g "${PARAM.firstRandom}" <------- instead of ${0} which is the current behavior).
Also it will keep the scenario clean and readable.
Can you give it a try to implement it?
appId: "${PARAM.firstRandom}", <------- instead of ${0}
Also, keep ${0}
working as usual for not to break existing tests (keep backward compatible I mean)
ok, no problem, will give a shot
PR is ready to be merged.
Test result is here:
PR is ready to be merged.
Test result is here:
@Tobolov , can you have a look at the test result and check you got everything you needed for this issue?
TODO - Add documentation for this feature. Take help from here.
Solution to Implement:
YAML View of Scenario:
Usage:
When it runs, it should replace the random values like below:
JSON View of Scenario:
Usage:
When it runs, it should replace with the random values like below:
---------------- End of Solution -----------------
**** ISSUE DESCRIPTION **** Goal: I want to generate a random ID and use it throughout a test scenario, without bloating the scenario file (lookups such as
$.create_app.request.records[0].key
too bloaty).How I want to achieve this: Generate random id's in a csvSource and reference them throughout the scenario. Bonus points if the values in the csvSource can be named and referenced in a manner like
${PARAM:APP_ID}
or even#.APP_ID
.Issue: Tokens such as
${RANDOM.NUMBER}
are only computed at usage in parameter sources, as opposed to when the scenario starts.Scenario to replicate:
Exception: