[tests] move node management into separate module
And add a debug option that writes the output of the node during integration tests to stdout.
This commit is contained in:
parent
7f9fa0a183
commit
43c0a48245
|
@ -0,0 +1,22 @@
|
||||||
|
import std/osproc
|
||||||
|
import std/os
|
||||||
|
import std/streams
|
||||||
|
import std/strutils
|
||||||
|
|
||||||
|
const workingDir = currentSourcePath() / ".." / ".." / ".."
|
||||||
|
const executable = "build" / "dagger"
|
||||||
|
|
||||||
|
proc startNode*(args: openArray[string], debug = false): Process =
|
||||||
|
if debug:
|
||||||
|
result = startProcess(executable, workingDir, args, options={poParentStreams})
|
||||||
|
sleep(1000)
|
||||||
|
else:
|
||||||
|
result = startProcess(executable, workingDir, args)
|
||||||
|
for line in result.outputStream.lines:
|
||||||
|
if line.contains("Started dagger node"):
|
||||||
|
break
|
||||||
|
|
||||||
|
proc stop*(node: Process) =
|
||||||
|
node.terminate()
|
||||||
|
discard node.waitForExit()
|
||||||
|
node.close()
|
|
@ -1,32 +1,16 @@
|
||||||
import std/osproc
|
import std/osproc
|
||||||
import std/os
|
|
||||||
import std/streams
|
|
||||||
import std/strutils
|
|
||||||
import std/httpclient
|
import std/httpclient
|
||||||
import std/json
|
import std/json
|
||||||
import pkg/asynctest
|
import pkg/asynctest
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/stew/byteutils
|
import ./integration/nodes
|
||||||
|
|
||||||
suite "Integration tests":
|
suite "Integration tests":
|
||||||
|
|
||||||
let workingDir = currentSourcePath() / ".." / ".."
|
|
||||||
|
|
||||||
var node1, node2: Process
|
var node1, node2: Process
|
||||||
var baseurl1, baseurl2: string
|
var baseurl1, baseurl2: string
|
||||||
var client: HttpClient
|
var client: HttpClient
|
||||||
|
|
||||||
proc startNode(args: openArray[string]): Process =
|
|
||||||
result = startProcess("build" / "dagger", workingDir, args)
|
|
||||||
for line in result.outputStream.lines:
|
|
||||||
if line.contains("Started dagger node"):
|
|
||||||
break
|
|
||||||
|
|
||||||
proc stop(node: Process) =
|
|
||||||
node.terminate()
|
|
||||||
discard node.waitForExit()
|
|
||||||
node.close()
|
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
node1 = startNode ["--api-port=8080", "--udp-port=8090"]
|
node1 = startNode ["--api-port=8080", "--udp-port=8090"]
|
||||||
node2 = startNode ["--api-port=8081", "--udp-port=8091"]
|
node2 = startNode ["--api-port=8081", "--udp-port=8091"]
|
||||||
|
|
Loading…
Reference in New Issue