Skip to content
Snippets Groups Projects
Commit 2e36ec21 authored by DISSOUBRAY Nathan's avatar DISSOUBRAY Nathan Committed by DETCHART Jonathan
Browse files

setup the CI

parent fa07831a
Branches
Tags
1 merge request!4Trying to setup the CI
File moved
......@@ -6,14 +6,13 @@ use std assert
let SWARM = swarm create 2
let record_name = "tata"
let message = "it works at least"
let sleep_duration = 1sec
mut node_is_setup = false
# create the nodes
swarm run --no-shell $SWARM
print "Sleeping for 1s to setup ports"
sleep 1sec
print "Resuming execution"
try {
print "Env var inside the script"
try {
print $'http_proxy: ($env.http_proxy)'
......@@ -27,11 +26,29 @@ try {
print "HTTP_PROXY not set"
}
let original_time = date now
# make the node start to listen on their own ports
print "Node 0 listening"
print "Trying to listen with node 0"
while not $node_is_setup {
# try to listen on node 0, this is to allow time for the ports to setup properly
try {
sleep 1sec
app listen --node $SWARM.0.ip_port $SWARM.0.multiaddr
print "Node 1 listening"
print "Exiting the try-listen"
$node_is_setup = true
} catch {
let current_time = (date now)
let elapsed_time = $current_time - $original_time
print -n $"Failed to listen, elapsed_time: ($elapsed_time | format duration sec)\r"
}
}
print $"Successfully listening on node 0, took: ((date now) - $original_time | format duration sec)"
# Node 1 doesn't need the same kind of setup as node 0, since it's only needed for the first node to do this
print "Trying to listen with node 1"
app listen --node $SWARM.1.ip_port $SWARM.1.multiaddr
print "Node 1 listening"
# connect the nodes
print "Node 0 dialing node 1"
......@@ -40,8 +57,9 @@ app dial --node $SWARM.0.ip_port $SWARM.1.multiaddr
# announce that you provide a key and add a message with the given key
print "Node 0 announces it has a given record"
app start-provide --node $SWARM.0.ip_port $record_name
print "Sleeping for 1s"
sleep 1sec
# a short sleep to ensure everything is setup properly
print $"Sleeping for ($sleep_duration)"
sleep $sleep_duration
print "Node 0 gives a value associated with the record key"
app put-record --node $SWARM.0.ip_port $record_name $message
......@@ -55,3 +73,8 @@ print "Killing the swarm"
swarm kill --no-shell
assert equal $res $message
} catch {
print "Test failed"
print "Killing the swarm"
swarm kill --no-shell
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment