ovh / venom

🐍 Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Apache License 2.0
1.06k stars 144 forks source link

(suggestion) Allow delay in non-retryable tasks #755

Closed bcecchinato closed 3 months ago

bcecchinato commented 11 months ago

Hello !

Lots of our tests are time based, which forces us to add a lot of "sleep tests". For example, here is on of our test case :

  - name: "SPDU 20-4008 - TC03 - State"
    steps:
      - name: "Assert Output ON_CHARGE"
        type: http
        method: GET
        url: "{{ .env.gateway }}/v2/pdu/{{ .params.address }}/status"
        headers:
          Content-Type: "application/json"
          Accept: "application/json"
        ignore_verify_ssl: true
        timeout: '{{ .env.timeout }}'
        assertions:
          - result.statuscode MustEqual 200
          - result.bodyjson.board MustEqual "OK"
          - result.bodyjson.outputs.{{ .params.output }} MustEqual "ON_CHARGE"
      - name: "Assert Output Disable"
        type: http
        method: PUT
        url: "{{ .env.gateway }}/v2/pdu/{{ .params.address }}/status?output={{ .params.output }}"
        body: |
          {"enabled": false}
        headers:
          Content-Type: "application/json"
          Accept: "application/json"
        ignore_verify_ssl: true
        timeout: '{{ .env.timeout }}'
        assertions:
          - result.statuscode MustEqual 202
      - name: "Assert Wait 5s"
        type: exec
        script: sleep 5
        assertions:
          - result.code MustEqual 0
      - name: "Assert Output OFF"
        type: http
        method: GET
        url: "{{ .env.gateway }}/v2/pdu/{{ .params.address }}/status"
        headers:
          Content-Type: "application/json"
          Accept: "application/json"
        ignore_verify_ssl: true
        timeout: '{{ .env.timeout }}'
        assertions:
          - result.statuscode MustEqual 200
          - result.bodyjson.board MustEqual "OK"
          - result.bodyjson.outputs.{{ .params.output }} MustEqual "OFF"
      - name: "Assert Output Enable"
        type: http
        method: PUT
        url: "{{ .env.gateway }}/v2/pdu/{{ .params.address }}/status?output={{ .params.output }}"
        body: |
          {"enabled": true}
        headers:
          Content-Type: "application/json"
          Accept: "application/json"
        ignore_verify_ssl: true
        timeout: '{{ .env.timeout }}'
        assertions:
          - result.statuscode MustEqual 202
      - name: "Assert Wait 5s"
        type: exec
        script: sleep 5
        assertions:
          - result.code MustEqual 0
      - name: "Assert Output ON_CHARGE"
        type: http
        method: GET
        url: "{{ .env.gateway }}/v2/pdu/{{ .params.address }}/status"
        headers:
          Content-Type: "application/json"
          Accept: "application/json"
        ignore_verify_ssl: true
        timeout: '{{ .env.timeout }}'
        assertions:
          - result.statuscode MustEqual 200
          - result.bodyjson.board MustEqual "OK"
          - result.bodyjson.outputs.{{ .params.output }} MustEqual "ON_CHARGE"

The delay is only used in case of a retryable test. Would it be possible to use the delay in case of non-retryable test. It would then be possible to remove a lot of unecessary tests like our "Assert Wait Xs".

bcecchinato commented 3 months ago

Why closing this issue as it's not treated or fixed ?

yesnault commented 3 months ago

Not planned, but you can use a user executor to factorize the http requestion with wait after. It will be much more readeable.