[wip] stub in the "upload_download" Codex Testground plan
This commit is contained in:
parent
9678605be7
commit
610aa52727
|
@ -0,0 +1,11 @@
|
||||||
|
FROM nimbase
|
||||||
|
|
||||||
|
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=upload_download 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,57 @@
|
||||||
|
import std/strutils
|
||||||
|
|
||||||
|
import pkg/chronos
|
||||||
|
import pkg/stew/byteutils
|
||||||
|
import pkg/testground_sdk
|
||||||
|
|
||||||
|
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,25 @@
|
||||||
|
name = "upload_download"
|
||||||
|
|
||||||
|
[defaults]
|
||||||
|
builder = "docker:generic"
|
||||||
|
runner = "local:docker"
|
||||||
|
|
||||||
|
[builders."docker:generic"]
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
[runners."local:docker"]
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
[[testcases]]
|
||||||
|
name= "default"
|
||||||
|
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