function _M:get_start_load_cmd()

in kong/spec/helpers/perf/drivers/docker.lua [434:488]


function _M:get_start_load_cmd(stub, script, uri, kong_name)
  if not self.worker_ct_id then
    return false, "worker container is not started, 'start_worker' must be called first"
  end

  local kong_id
  if not uri then
    if not kong_name then
      
      for name, ct_id in pairs(self.kong_ct_ids) do
        local admin_port, err = get_container_port(ct_id, "8000/tcp")
        if err then
          
          self.log.debug("failed to get kong proxy port for " .. ct_id .. ": " .. (err or "nil"))
        elseif admin_port then
          kong_id = ct_id
          self.log.info("automatically picked kong container \"", name, "\" with ID " .. ct_id .. " for proxy port")
          break
        end
      end
      if not kong_id then
        return false, "failed to find kong proxy port"
      end
    else
      kong_id = self.kong_ct_ids[kong_name]
      if not kong_id then
        return false, "kong container \"" .. kong_name .. "\" is not found"
      end
    end

    local kong_vip, err = get_container_vip(kong_id)
    if err then
      return false, "unable to read kong container's private IP: " .. err
    end
    uri = string.format("http://%s:8000", kong_vip)
  end

  local script_path
  if script then
    script_path = string.format("/tmp/wrk-%s.lua", tools.random_string())
    local out, err = perf.execute(string.format(
    "docker exec -i %s tee %s", self.worker_ct_id, script_path),
    {
      stdin = script,
    })
    if err then
      return false, "failed to write script in " .. self.worker_ct_id .. " container: " .. (out or err)
    end
  end

  script_path = script_path and ("-s " .. script_path) or ""

  return "docker exec " .. self.worker_ct_id .. " " ..
          stub:format(script_path, uri)
end