Skip to content

Is there any way to execute concurrent step or action ? #1212

@BragdonD

Description

@BragdonD

Hey, I have an usecase where I need to perform an HTTP request to a REST API, which will perform another request to another REST API. To check that this request is performed I use tcpdump in my terminal. It works well but I would like to make fully autonomous using runn.

I tried to use the concurrency field on include notebook in step. However, it did not work.

main runbook:

steps:
  init:
    include: ./init_log.yaml
  list_logs:
    http:
      /mypath
        get:
          headers:
            Authorization: "Bearer xxxx"
          body:
            application/json: null
    test: |
      current.res.status == 200
  export_log:
    include: 
      path: ./export_log_http.yaml
  network_test:
    include: ./export_log_network.yaml
  servers:
    include: ./export_log_server.yaml
  cleanup:
    include: ./cleanup.yaml
    force: true

network runbook:

debug: true
if: included
vars:
  netInt: ${NETWORK_INTERFACE:-ens33}
  host: ${PACKAGE_HOSTNAME:-localhost}
  port: ${PACKAGE_PORT:-9000}
concurrency: export-log-request
steps:
  export_log:
    exec:
      command: |
        tcpdump -i {{ vars.netInt }} -c 1 'host {{ vars.host }} and port {{ vars.port }}'
    test:
      current.stdout contains "1 packet captured"

http runbook:

debug: true
runners:
  http:
    endpoint: ${TEST_HTTP_ENDPOINT:-http://localhost:9004}
    trace: true 
if: included
concurrency: export-log-request
steps:
  export_log:
    http:
      /mypath
        post:
          headers:
            Authorization: "Bearer xxxx"
          body: null

netcat server to simulate the other service:

debug: true
if: included
vars:
  host: ${PACKAGE_HOSTNAME:-localhost} # There is probably a way to use this with netcat
  port: ${PACKAGE_PORT:-9000}
concurrency: export-log-request
steps:
  export_log:
    exec:
      command: |
        nc -l -p {{ vars.port }} -w 1

Is there any way to perform this operation like I want in the main ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions