Comments (13)
In order to be recognized json in loop, do I declare json list vars in importing yaml?
You can manage the path of the json file in the runbook from which you are importing
- root.yaml
desc: xxxx xxxxx xxxx
vars:
xxxxx_req:
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
xxxxx_res:
- "do some magic"
- "do some magic"
headers:
accept: 'application/json'
Content-Type: 'application/json'
Host: 'xxxx'
X-API-KEY: 'xxxxxx'
steps:
normal:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.xxxxx_req)
include:
path: xx/xx/xxx/yamls/200/normal.yaml
vars:
headers: '{{ vars.headers }}'
request: 'json://{{ vars.xxxxx_req[i]}}'
response: '{{ vars. xxxxx_res[i] }}'
- xx/xx/xxx/yamls/200/normal.yaml
vars:
request: null
response: null
headers: null
steps:
normal:
desc: xxxx xxxx xxxx xxxx
req:
/xxx/xxx/xx/xxxxx:
post:
headers: "{{ vars.headers }}"
body:
application/json: "{{ vars.request }}"
test: steps.normal.res.status == 200
&& steps.normal.res.body contains vars.response
from runn.
What is include.vars ?
vars:
section of include runner.
from runn.
The json://
and yaml://
schemes are only allowed in the root of the vars:
section.
from runn.
I think it will be recognized as JSON if set as follows
runn/testdata/book/httpbin.yml
Lines 22 to 25 in f103866
runn/testdata/book/httpbin.yml
Line 107 in f103866
from runn.
Thank you for advice.
But., still recognized json as string.
- runn book yaml
desc: xxxx xxxxx xxxx
vars:
xxxxx_req:
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
xxxxx_res:
- "do some magic"
- "do some magic"
steps:
normal:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.xxxxx_req)
req:
/xxx/xxx/xx/xxxxx:
post:
headers:
accept: "{{ vars.header.accept }}"
Content-Type: "{{ vars.header.content_type }}"
Host: "{{ vars.header.host }}"
X-API-KEY: "{{ vars.header.x_api_key }}"
body:
application/json: "json://{{ vars.xxxxx_req[i] }}"
test: steps.normal.res.status == 200
&& steps.normal.res.body contains vars.xxxxx_res[i]
Avobe yaml is imported one.
Bellow yaml is importing yaml.
In order to be recognized json in loop, do I declare json list vars in importing yaml?
If so, it might be hard a little in my usecase.
Because test case is many, vars will be fat. Also it is hard to find certain test case vars in importing one.
Than that, I want to summarize vars to imported yaml.
I think that way is view better for seeing the details individually.
importing runn book yaml (root)
xxx xxx xx:
desc: xxx xxxx xxxx
include:I
path: xx/xx/xxx/yamls/200/normal.yaml
vars:
header:
accept: "{{ vars.header.accept }}"
content_type: "{{ vars.header.content_type }}"
host: "{{ vars.header.host }}"
x_api_key: "{{ vars.header.x_api_key }}"
from runn.
fmm...
I do not know what you want to achieve.
If possible I would be glad to get the smallest example I can try.
You shouldn't need to have a test server by using the API on httpbin.org or github.com.
from runn.
I want to recognize json as json in impoted yaml.
In runn
, Is it impossible to make bellow yaml ?
desc: xxxx xxxxx xxxx
vars:
xxxxx_req: <- json list
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
xxxxx_res:
- "do some magic"
- "do some magic"
steps:
normal:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.xxxxx_req)
req:
/xxx/xxx/xx/xxxxx:
post:
headers:
accept: "{{ vars.header.accept }}"
Content-Type: "{{ vars.header.content_type }}"
Host: "{{ vars.header.host }}"
X-API-KEY: "{{ vars.header.x_api_key }}"
body:
application/json: "json://{{ vars.xxxxx_req[i] }}" <- json as json
test: steps.normal.res.status == 200
&& steps.normal.res.body contains vars.xxxxx_res[i]
from runn.
In runn, Is it impossible to make bellow yaml ?
No, it cannot.
The json://
scheme only works for root in the vars:
section ( or include.vars:
).
from runn.
I want to recognize json as json in impoted yaml.
Do you want the list of json file paths in the root runbook to be specified in the vars of the include and expanded as a json request?
I would be able to give you better advice if I could get a more concrete image of the test you want to achieve.
from runn.
What is include.vars
?
The json:// scheme only works for root in the vars: section ( or include.vars: ).
With this, the root yaml vars will be fat, right?
If many test is written in root yaml. I think root yaml vars is fat.
bellow root yaml fat example
desc: xxxx xxxxx xxxx
vars:
xxxxx_req:
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
xxxxx_res:
- "do some magic"
- "do some magic"
yyyyy_req:
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
yyyy_res:
- "do some magic"
- "do some magic"
zzzz_req:
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
zzzz_res:
- "do some magic"
- "do some magic"
wwww_req:
- "../../json/req/200/normal1.json"
- "../../json/req/200/normal2.json"
wwww_res:
- "do some magic"
- "do some magic"
.
.
.
.
headers:
accept: 'application/json'
Content-Type: 'application/json'
Host: 'xxxx'
X-API-KEY: 'xxxxxx'
steps:
normal-x:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.xxxxx_req)
include:
path: xx/xx/xxx/yamls/200/normal.yaml
vars:
headers: '{{ vars.headers }}'
request: 'json://{{ vars.xxxx_req[i]}}'
response: '{{ vars. xxxx_res[i] }}'
normal-y:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.yyyyy_req)
include:
path: xx/xx/xxx/yamls/200/normal.yaml
vars:
headers: '{{ vars.headers }}'
request: 'json://{{ vars.yyyy_req[i]}}'
response: '{{ vars. yyyy_res[i] }}'
normal-z:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.zzzz_req)
include:
path: xx/xx/xxx/yamls/200/normal.yaml
vars:
headers: '{{ vars.headers }}'
request: 'json://{{ vars.zzzz_req[i]}}'
response: '{{ vars. zzzz_res[i] }}'
normal-w:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.wwwww_req)
include:
path: xx/xx/xxx/yamls/200/normal.yaml
vars:
headers: '{{ vars.headers }}'
request: 'json://{{ vars.wwww_req[i]}}'
response: '{{ vars. wwww_res[i] }}'
.
.
.
.
from runn.
How about xxxxx_req
and yyyyy_req
and zzzz_req
and wwww_req
and all responses in one JSON?
desc: xxxx xxxxx xxxx
vars:
reqres: "json://../../json/reqres.json"
.
.
.
headers:
accept: 'application/json'
Content-Type: 'application/json'
Host: 'xxxx'
X-API-KEY: 'xxxxxx'
steps:
normal-x:
desc: xxxx xxxx xxxx xxxx
loop:
count: len(vars.reqres.xxxxx)
req:
/xxx/xxx/xx/xxxxx:
post:
headers:
accept: "{{ vars.header.accept }}"
Content-Type: "{{ vars.header.content_type }}"
Host: "{{ vars.header.host }}"
X-API-KEY: "{{ vars.header.x_api_key }}"
body:
application/json: "{{ vars.reqres.xxxxx[i].req}}"
test: steps.normal.res.status == 200
&& steps.normal.res.body contains vars.reqres.xxxxx[i].res
.
.
.
With this, the root yaml vars will be fat, right?
I don't know if this is what you want, but at least all requests and responses can be externalized to reqres.json.
from runn.
With this, the root yaml vars will be fat, right?
How to divide the scenario to solve the problem of large root yaml? It would be better to consider how to divide the scenario.
- Define the steps of a repeating scenario as a single scenario itself.
- Define several steps as a single scenario.
For example, split the yaml as one scenario withnormal-x
andnormal-y
steps (Have normal-z and normal-w processed in a separate file)
from runn.
Hi @t-kitamura-axel
runn now support wildcards in json://
and yaml://
.
I think this will be one way to solve your problem.
from runn.
Related Issues (20)
- How can I loop over multiple steps? HOT 2
- Failed to multipart/form-data request with very long value HOT 5
- Specify the header name for the trace header HOT 5
- Bind the response for each loop in a variable HOT 3
- Issues Encountered While Testing a Multi-Service gRPC Server with Runn HOT 5
- spanner: code = "InvalidArgument", desc = "invalid session pool"
- [Proposal] Load YAML anchors declared in external YAML files HOT 5
- How to count tests that were not completed in time for load testing HOT 2
- Add coverage rate to json format when getting OpenAPI Spec coverage HOT 5
- Support for the shard option of the coverage command HOT 1
- Using a variable passed from parent runner for the loop count specifier HOT 1
- Regression: flattenYamlAliases() breaks CRLF encoded runbooks in a certain situation HOT 1
- Additional coverage can be checked after the runn run HOT 2
- [Feature Request] Make concurrency field accepts multiple values HOT 1
- Is there way runn test of grpc with using "buf/validate/validate.proto" in proto ? HOT 5
- concurrency: option seems not working HOT 2
- 🐛 bug: Error messages are not displayed correctly HOT 1
- [Feature request] Add diff output when compare() returns false HOT 3
- How to specify an absolute path to load JSON file HOT 5
- Including string literal `{{ ... }}` in HTTP request body HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runn.