k1LoW / runn

runn is a package/tool for running operations following a scenario.
https://runn.run
MIT License
433 stars 32 forks source link

How to use .env value in scenario.yaml #903

Closed amraupward closed 6 months ago

amraupward commented 6 months ago

.env file in UUID=blahblahblah

scenario.yaml

message:
     owner:
           orgUUID: ${env.uuid} 

how to get UUID value from .env in scenario.yaml

k1LoW commented 6 months ago

Hi @amraupward.

runn does not support .env file.

It can be used by setting the environment variable.

$ export UUID=blahblahblah
$ runn run path/to/scenario.yaml
amraupward commented 6 months ago
desc: ロケーション設定取得サービステスト
interval: 2
runners:
  greq: grpc://localhost:9005
vars:
  ORGUUID: ${ORGUUID}
steps:
  - desc: ロケーション設定取得
    greq:
      settingService/getSettings:
        message:
          owner:
            orgUUID: {{ vars.ORGUUID }}
    test: |
      current.res.status == 0
      && len(current.res.message) > 0
      && len(current.res.message['settings']) > 0
      && upper(current.res.message['settings'][0]['orgUUID']) == {{ vars.ORGUUID }}

this scenario.yaml I runnig with below command

USER=hello-k1low-good-runn-tools runn run scenario-local.yaml --grpc-no-tls --grpc-proto "$PROTO_FILE_NAME" --format json --verbose > result

but not working.

it's syntax error when execute. that message.owner.orgUUID can't get {{ vars.ORGUUID }}

how to solve this. i tried too many times. but still error occuring. HELP K1low :)

k1LoW commented 6 months ago

It seems that the way the variables are retrieved is incorrect.

-      && upper(current.res.message['settings'][0]['orgUUID']) == {{ vars.ORGUUID }}
+      && upper(current.res.message['settings'][0]['orgUUID']) == vars.ORGUUID

If you find runn difficult, We recommend https://zenn.dev/katzumi/books/runn-tutorial 📖 👍