[wip] make simple_tcp_ping the default testground plan (for now)
This commit is contained in:
parent
5c440d7c35
commit
270b4fd8d8
4
Makefile
4
Makefile
|
@ -128,9 +128,9 @@ coverage:
|
|||
SCRATCH_IGNORE ?= "\.update\.timestamp\|Would skip\|build/\|codex\.nims\|nimcache/\|scratch/\|vendor/\.nimble"
|
||||
TESTGROUND_BUILDER ?= docker:generic
|
||||
TESTGROUND_OPTIONS ?= --instances=2
|
||||
TESTGROUND_PLAN ?= hello_codex
|
||||
TESTGROUND_PLAN ?= simple_tcp_ping
|
||||
TESTGROUND_RUNNER ?= local:docker
|
||||
TESTGROUND_TESTCASE ?= hello
|
||||
TESTGROUND_TESTCASE ?= simple_tcp_ping
|
||||
|
||||
testground:
|
||||
mkdir -p scratch && rm -rf scratch/* && git clone --depth=1 "file://$${PWD}" "scratch/$$(basename $${PWD})"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
FROM nimlang/nim as builder
|
||||
|
||||
RUN apt update -qq && \
|
||||
DEBIAN_FRONTEND="noninteractive" apt install -yq cmake curl make
|
||||
|
||||
FROM builder
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN cd /extra/scratch/nim-codex && \
|
||||
make USE_SYSTEM_NIM=1 update
|
||||
|
||||
RUN cd /extra/scratch/nim-codex && \
|
||||
make USE_SYSTEM_NIM=1 TESTGROUND_PLAN=simple_tcp_ping testground_exec
|
||||
|
||||
ENTRYPOINT ["/extra/scratch/nim-codex/build/codex_testground"]
|
|
@ -0,0 +1,2 @@
|
|||
switch("define", "chronicles_sinks=textlines")
|
||||
switch("define", "chronicles_log_level=NOTICE")
|
|
@ -0,0 +1,44 @@
|
|||
import std/strutils, testground_sdk, chronos, stew/byteutils
|
||||
|
||||
testground(client):
|
||||
let
|
||||
myId = await client.signalAndWait("setup", client.testInstanceCount)
|
||||
myIp = client.testSubnet.split('.')[0..1].join(".") & ".1." & $myId
|
||||
serverIp = client.testSubnet.split('.')[0..1].join(".") & ".1.1"
|
||||
await client.updateNetworkParameter(
|
||||
NetworkConf(
|
||||
network: "default",
|
||||
ipv4: some myIp & "/24",
|
||||
enable: true,
|
||||
callback_state: "network_setup",
|
||||
callback_target: some client.testInstanceCount,
|
||||
routing_policy: "accept_all",
|
||||
)
|
||||
)
|
||||
|
||||
await client.waitForBarrier("network_setup", client.testInstanceCount)
|
||||
|
||||
let
|
||||
payload = client.param(string, "payload")
|
||||
count = client.param(int, "count")
|
||||
printResult = client.param(bool, "printResult")
|
||||
if myId == 1: # server
|
||||
let
|
||||
server = createStreamServer(initTAddress(myIp & ":5050"), flags = {ReuseAddr})
|
||||
connection = await server.accept()
|
||||
|
||||
for _ in 0 ..< count:
|
||||
doAssert (await connection.write(payload.toBytes())) == payload.len
|
||||
connection.close()
|
||||
|
||||
else: # client
|
||||
let connection = await connect(initTAddress(serverIp & ":5050"))
|
||||
var buffer = newSeq[byte](payload.len)
|
||||
|
||||
for _ in 0 ..< count:
|
||||
await connection.readExactly(addr buffer[0], payload.len)
|
||||
doAssert string.fromBytes(buffer) == payload
|
||||
connection.close()
|
||||
|
||||
if printResult:
|
||||
client.recordMessage("Hourray " & $myId & "!")
|
|
@ -0,0 +1,24 @@
|
|||
name = "simple_tcp_ping"
|
||||
[defaults]
|
||||
builder = "docker:generic"
|
||||
runner = "local:docker"
|
||||
|
||||
[builders."docker:generic"]
|
||||
enabled = true
|
||||
|
||||
[runners."local:docker"]
|
||||
enabled = true
|
||||
|
||||
[[testcases]]
|
||||
name= "simple_tcp_ping"
|
||||
instances = { min = 2, default = 2, max = 2 }
|
||||
|
||||
[testcases.params]
|
||||
payload = { type = "string", default = "Hello!" }
|
||||
count = { type = "int", default = 2 }
|
||||
printResult = { type = "bool", default = true }
|
||||
|
||||
[extra_sources]
|
||||
docker_generic = [
|
||||
"../../scratch"
|
||||
]
|
Loading…
Reference in New Issue