From 0d239f68217d6807782cd02fd34c44791994ce62 Mon Sep 17 00:00:00 2001 From: Seungjin Kim Date: Mon, 3 Sep 2018 04:45:48 -0700 Subject: [PATCH] test for parallel SSHKit.run execution with :parallel option --- test/sshkit_functional_test.exs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/sshkit_functional_test.exs b/test/sshkit_functional_test.exs index 58723d4e..7032ecc2 100644 --- a/test/sshkit_functional_test.exs +++ b/test/sshkit_functional_test.exs @@ -17,6 +17,23 @@ defmodule SSHKitFunctionalTest do assert name == host.options[:user] end + @tag boot: [@bootconf] + test "connects as the login user and runs commands in parallel", %{hosts: [host]} do + begin_time = Time.utc_now() + [{:ok, output1, 0},{:ok, output2, 0},{:ok, output3, 0}] = + [host, host, host] + |> SSHKit.context() + |> SSHKit.run("sleep 2; id -un", :parallel) + end_time = Time.utc_now() + run_time = Time.diff(end_time, begin_time, :second) + + assert run_time < 3 + assert String.trim(stdout(output1)) == host.options[:user] + assert String.trim(stdout(output2)) == host.options[:user] + assert String.trim(stdout(output3)) == host.options[:user] + + end + @tag boot: [@bootconf] test "runs commands and returns their output and exit status", %{hosts: [host]} do context = SSHKit.context(host)