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

When using loop, how to change description #546

Open
t-kitamura-axel opened this issue Jun 12, 2023 · 5 comments
Open

When using loop, how to change description #546

t-kitamura-axel opened this issue Jun 12, 2023 · 5 comments
Labels
question Further information is requested

Comments

@t-kitamura-axel
Copy link

I try changing description in loop.
But, I cannot change description.

  • curent log
Run 'test' on 'impoted yaml'.steps.normal
Run '{{ vars.register_session_desc }}' on 'impoted yaml'.steps.normal
.
.
.
Run 'test' on 'impoted yaml'.steps.normal
Run '{{ vars.register_session_desc }}' on 'impoted yaml'.steps.normal
.
.
.
  • root yaml

desc: desc change test
runners:
  sc:
    host:  xxxx
    keepSession: true
    localForward: '10443:xxxxx.execute-api.xxxxx.vpce.amazonaws.com:443'
    useAgent: false
  req:
    endpoint: https://127.0.0.1:10443/xxxx
    skipVerify: true
debug: true
vars:
  header: "json://header/header.json"
  vars_section:
    desc:
      - "xxxxx xxxxx (normal) 1"
      - "xxxxx xxxxx (normal) 2"
    req:
      - "json://../../json/req/200/normal1.json"
      - "json://../../json/req/200/normal2.json"
    res:
      - "json://../../json/res/200/normal1.json"
      - "json://../../json/res/200/normal2.json"
steps:
  step_name:
    desc: xxx xxxx
    loop:
      count: len(vars.vars_section.req)
    include:
      path: books/xxx_xxxx/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 }}"
        vars_section_desc: "{{ vars.vars_section.desc[i] }}"
        vars_section_req: "{{ vars.vars_section.req[i] }}"
        vars_section_res: "{{ vars.vars_section.res[i] }}"

  • imported yaml
desc: impoted yaml
steps:
  normal:
    desc:  "{{ vars.vars_section_desc }}"
    req:
      /xxxx/xxxx/xxx:
        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.vars_section_req }}"
    test: steps.normal.res.status == 200
      && steps.normal.res.body contains vars.vars_section_res.res

I think description is important in data driven test, because we know what data are we using.
Threfore, though I specify vars_section_desc: "{{ vars.vars_section.desc[i] }}" in root yaml, I didn't have expected result.

  • expected log
Run 'test' on 'impoted yaml'.steps.normal
Run  'xxxxx xxxxx (normal) 1' on 'impoted yaml'.steps.normal
.
.
.
Run 'test' on 'impoted yaml'.steps.normal
Run 'xxxxx xxxxx (normal) 2' on 'impoted yaml'.steps.normal
.
.
.
@k1LoW
Copy link
Owner

k1LoW commented Jun 12, 2023

Currently, variables do not expand in the desc: section.

desc: test
vars:
  foo: var
steps:
  -
    desc: '{{ vars.foo }}'
    test: vars.foo == 'var'
$ runn run tmp.yml --verbose
=== test (tmp.yml) ... ok
    --- {{ vars.foo }} (0) ... ok


1 scenario, 0 skipped, 0 failures

@k1LoW k1LoW added the question Further information is requested label Jun 12, 2023
@t-kitamura-axel
Copy link
Author

Thank you for answer.
So, is there a way to set the description for each loop instead?

@k2tzumi
Copy link
Collaborator

k2tzumi commented Jul 17, 2023

So, is there a way to set the description for each loop instead?

I don't think we have that feature at this time.

@k1LoW
How about adding a description for include and outputting it when including?

@k1LoW
Copy link
Owner

k1LoW commented Jul 17, 2023

How about adding a description for include and outputting it when including?

The Include runner already has a desc: section.

steps:
  -
    desc: Login
    include:
      path: path/to/login.yml
      vars:
        username: bob
        password: bobpass

I believe you are saying that we will add the feature to overwrite the desc: in the included runbook, which I believe is the same as variable expansion in the desc: section.

I am still cautious about whether we should add a variable expansion feature in the desc: section.

Because there is still a small chance that the desc: section will be one of the sources of the runbook ID.

@k1LoW
Copy link
Owner

k1LoW commented Dec 3, 2023

ref: #672

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants