Add integration tests
This commit is contained in:
parent
e2959d4fe5
commit
cc9a4e2af6
|
@ -45,18 +45,23 @@ proc test(name: string, srcDir = "tests/", lang = "c") =
|
|||
buildBinary name, srcDir
|
||||
exec "build/" & name
|
||||
|
||||
task dagger, "build dagger binary":
|
||||
buildBinary "dagger"
|
||||
|
||||
task testDagger, "Build & run Dagger tests":
|
||||
test "testDagger"
|
||||
|
||||
task testContracts, "Build & run Dagger Contract tests":
|
||||
test "testContracts"
|
||||
|
||||
task testIntegration, "Run integration tests":
|
||||
daggerTask()
|
||||
test "testIntegration"
|
||||
|
||||
task test, "Run tests":
|
||||
testDaggerTask()
|
||||
|
||||
task testAll, "Run all tests":
|
||||
testDaggerTask()
|
||||
testContractsTask()
|
||||
|
||||
task dagger, "build dagger binary":
|
||||
buildBinary "dagger"
|
||||
testIntegrationTask()
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
import std/osproc
|
||||
import std/os
|
||||
import std/streams
|
||||
import std/strutils
|
||||
import std/httpclient
|
||||
import pkg/asynctest
|
||||
import pkg/chronos
|
||||
|
||||
suite "Integration tests":
|
||||
|
||||
let workingDir = currentSourcePath() / ".." / ".."
|
||||
|
||||
var node1, node2: Process
|
||||
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"]
|
||||
client = newHttpClient()
|
||||
|
||||
teardown:
|
||||
client.close()
|
||||
node1.stop()
|
||||
node2.stop()
|
||||
|
||||
test "nodes can print their peer information":
|
||||
let info1 = client.get("http://localhost:8080/api/dagger/v1/info").body
|
||||
let info2 = client.get("http://localhost:8081/api/dagger/v1/info").body
|
||||
check info1 != info2
|
Loading…
Reference in New Issue