diff --git a/tests/integration/nodes.nim b/tests/integration/nodes.nim new file mode 100644 index 00000000..7ef2da05 --- /dev/null +++ b/tests/integration/nodes.nim @@ -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() diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index acfa0c75..9864e22b 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -1,32 +1,16 @@ import std/osproc -import std/os -import std/streams -import std/strutils import std/httpclient import std/json import pkg/asynctest import pkg/chronos -import pkg/stew/byteutils +import ./integration/nodes suite "Integration tests": - let workingDir = currentSourcePath() / ".." / ".." - var node1, node2: Process var baseurl1, baseurl2: string 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: node1 = startNode ["--api-port=8080", "--udp-port=8090"] node2 = startNode ["--api-port=8081", "--udp-port=8091"]