mirror of https://github.com/logos-co/wadoku.git
added pub/sub to run-waku
This commit is contained in:
parent
73bca2786e
commit
43ada8fd4f
47
main.star
47
main.star
|
@ -1,13 +1,21 @@
|
||||||
DEFAULT_CONFIG_FILE = "github.com/logos-co/wadoku/waku/config.json"
|
DEFAULT_CONFIG_FILE = "github.com/logos-co/wadoku/waku/config.json"
|
||||||
|
DEFAULT_RUN_PAIR = "lf"
|
||||||
|
|
||||||
|
|
||||||
def get_config_file(args):
|
def get_config_file(args):
|
||||||
return DEFAULT_CONFIG_FILE if not hasattr(args, "config") else args.config
|
return DEFAULT_CONFIG_FILE if not hasattr(args, "config") else args.config
|
||||||
|
|
||||||
|
|
||||||
|
def get_run_pair(args):
|
||||||
|
return DEFAULT_RUN_PAIR if not hasattr(args, "run_pair") else args.run_pair
|
||||||
|
|
||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
print(args)
|
print(args)
|
||||||
config_file = get_config_file(args)
|
config_file = get_config_file(args)
|
||||||
|
run_pair = get_run_pair(args)
|
||||||
print("Reading the config from: %s" %config_file)
|
print("Reading the config from: %s" %config_file)
|
||||||
|
print("The runpair is %s" %run_pair)
|
||||||
config_json = read_file(src=config_file)
|
config_json = read_file(src=config_file)
|
||||||
config = json.decode(config_json)
|
config = json.decode(config_json)
|
||||||
|
|
||||||
|
@ -19,7 +27,10 @@ def run(args):
|
||||||
ctopic = config['content_topic']
|
ctopic = config['content_topic']
|
||||||
print(config)
|
print(config)
|
||||||
|
|
||||||
waku_filtr = add_service(
|
|
||||||
|
if run_pair == "lf": # run lightpush and filter
|
||||||
|
|
||||||
|
waku_filtr = add_service(
|
||||||
service_id = "waku-filter",
|
service_id = "waku-filter",
|
||||||
config = struct(
|
config = struct(
|
||||||
image = "waku-filter:alpha",
|
image = "waku-filter:alpha",
|
||||||
|
@ -30,8 +41,8 @@ def run(args):
|
||||||
"-l=" + loglvl,
|
"-l=" + loglvl,
|
||||||
"-i=" + iat ],
|
"-i=" + iat ],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
waku_lpush = add_service(
|
waku_lpush = add_service(
|
||||||
service_id = "waku-lightpush",
|
service_id = "waku-lightpush",
|
||||||
config = struct(
|
config = struct(
|
||||||
image = "waku-lightpush:alpha",
|
image = "waku-lightpush:alpha",
|
||||||
|
@ -42,7 +53,33 @@ def run(args):
|
||||||
"-l=" + loglvl,
|
"-l=" + loglvl,
|
||||||
"-i=" + iat ],
|
"-i=" + iat ],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
print(waku_filtr, waku_lpush)
|
||||||
|
|
||||||
print(waku_filtr, waku_lpush)
|
else: # run waku publish and subscribe
|
||||||
|
|
||||||
|
waku_sub = add_service(
|
||||||
|
service_id = "waku-subscribe",
|
||||||
|
config = struct(
|
||||||
|
image = "waku-subscribe:alpha",
|
||||||
|
entrypoint= ["/go/bin/waku-subscribe"],
|
||||||
|
cmd = [ "-o=" + "/go/bin/out/subscribe.out",
|
||||||
|
"-d=" + duration,
|
||||||
|
"-c=" + ctopic,
|
||||||
|
"-l=" + loglvl,
|
||||||
|
"-i=" + iat ],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
waku_pub = add_service(
|
||||||
|
service_id = "waku-publish",
|
||||||
|
config = struct(
|
||||||
|
image = "waku-publish:alpha",
|
||||||
|
entrypoint= ["/go/bin/waku-publish"],
|
||||||
|
cmd = [ "-o=" + "/go/bin/out/publish.out",
|
||||||
|
"-d=" + duration,
|
||||||
|
"-c=" + ctopic,
|
||||||
|
"-l=" + loglvl,
|
||||||
|
"-i=" + iat ],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
print(waku_sub, waku_pub)
|
||||||
|
|
43
run-waku.sh
43
run-waku.sh
|
@ -1,13 +1,24 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
echo "Usage: ./run.sh < clean | metal | docker | kurtosis>"
|
echo "Usage: ./run.sh <clean | metal | docker | kurtosis> <duration> <time> <ps|lf>"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_pair="lf"
|
||||||
# two tests per run
|
# two tests per run
|
||||||
filtr="filter"
|
if [ lf = $4 ]; then
|
||||||
lpush="lightpush"
|
lpush="lightpush"
|
||||||
|
filtr="filter"
|
||||||
|
elif [ ps = $4 ]; then
|
||||||
|
lpush="publish"
|
||||||
|
filtr="subscribe"
|
||||||
|
run_pair="ps"
|
||||||
|
# two tests per run
|
||||||
|
else
|
||||||
|
echo "Unknown run pair: $4"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
# file/dir locations
|
# file/dir locations
|
||||||
prefix="waku"
|
prefix="waku"
|
||||||
|
@ -18,14 +29,14 @@ host_output_dir="/home1/mimosa/runs"
|
||||||
# params for the run
|
# params for the run
|
||||||
ctopic="8fc1f6b30b63bdd0a65df833f1da3fa" # default ctopic, a md5
|
ctopic="8fc1f6b30b63bdd0a65df833f1da3fa" # default ctopic, a md5
|
||||||
duration="100s" # duration of the run
|
duration="100s" # duration of the run
|
||||||
iat="100ms" # pub msg inter-arrival-time
|
iat="100ms" # pub msg inter-arrival-time
|
||||||
loglvl="info" # log level
|
loglvl="info" # log level
|
||||||
|
|
||||||
duration=$2
|
duration=$2
|
||||||
#iat=$3
|
#iat=$3
|
||||||
|
|
||||||
sleep_time=20
|
sleep_time=20
|
||||||
time=""
|
time=$3
|
||||||
|
|
||||||
unique="XYZ"
|
unique="XYZ"
|
||||||
|
|
||||||
|
@ -65,7 +76,7 @@ build_docker() {
|
||||||
|
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
|
#time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
|
||||||
ctopic="$duration-$iat-$time-$unique"
|
ctopic="$duration-$iat-$time-$unique"
|
||||||
echo "\t\t.............................................."
|
echo "\t\t.............................................."
|
||||||
echo "\t\tBEGINNING THE $1 RUN @ $time"
|
echo "\t\tBEGINNING THE $1 RUN @ $time"
|
||||||
|
@ -86,7 +97,7 @@ metal_run() {
|
||||||
FTDIR="$host_output_dir/data/metal/$ctopic"
|
FTDIR="$host_output_dir/data/metal/$ctopic"
|
||||||
LPDIR="$host_output_dir/data/metal/$ctopic"
|
LPDIR="$host_output_dir/data/metal/$ctopic"
|
||||||
|
|
||||||
killall -9 $prefix-$filtr $prefix-$lpush
|
killall -SIGTERM $prefix-$filtr $prefix-$lpush # TODO: send SIGTERM/SIGINT
|
||||||
cd waku/$filtr
|
cd waku/$filtr
|
||||||
[ -d $FTDIR ] || mkdir -p $FTDIR
|
[ -d $FTDIR ] || mkdir -p $FTDIR
|
||||||
ofname="$FTDIR/$filtr.out"
|
ofname="$FTDIR/$filtr.out"
|
||||||
|
@ -94,7 +105,7 @@ metal_run() {
|
||||||
./$prefix-$filtr -o $ofname -d $duration -i $iat -l $loglvl -c $ctopic > $FTDIR/$filtr.log &
|
./$prefix-$filtr -o $ofname -d $duration -i $iat -l $loglvl -c $ctopic > $FTDIR/$filtr.log &
|
||||||
echo " done"
|
echo " done"
|
||||||
cd ..
|
cd ..
|
||||||
cd lightpush
|
cd $lpush
|
||||||
|
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
|
||||||
|
@ -122,7 +133,7 @@ docker_run() {
|
||||||
[ -d $FTDIR ] || mkdir -p $FTDIR
|
[ -d $FTDIR ] || mkdir -p $FTDIR
|
||||||
ofname="$FTDIR/$filtr.out"
|
ofname="$FTDIR/$filtr.out"
|
||||||
echo "docker: stopping and removing $prefix-$filtr"
|
echo "docker: stopping and removing $prefix-$filtr"
|
||||||
docker stop $prefix-$filtr
|
docker stop $prefix-$filtr # NOTE: docker stop sends SIGTERM; stick to it
|
||||||
docker rm $prefix-$filtr
|
docker rm $prefix-$filtr
|
||||||
echo "docker: starting $prefix-$filtr"
|
echo "docker: starting $prefix-$filtr"
|
||||||
echo "docker run --name "$prefix-$filtr" -d=true "$prefix-$filtr:alpha" -o "$docker_op_dir/$filtr.out" -d $duration -l $loglvl -i $iat -c $ctopic "
|
echo "docker run --name "$prefix-$filtr" -d=true "$prefix-$filtr:alpha" -o "$docker_op_dir/$filtr.out" -d $duration -l $loglvl -i $iat -c $ctopic "
|
||||||
|
@ -134,7 +145,7 @@ docker_run() {
|
||||||
[ -d $LPDIR ] || mkdir -p $LPDIR
|
[ -d $LPDIR ] || mkdir -p $LPDIR
|
||||||
ofname="$LPDIR/$lpush.out"
|
ofname="$LPDIR/$lpush.out"
|
||||||
echo "docker: stopping and removing $prefix-$lpush"
|
echo "docker: stopping and removing $prefix-$lpush"
|
||||||
docker stop $prefix-$lpush
|
docker stop $prefix-$lpush # NOTE: docker stop sends SIGTERM; stick to it
|
||||||
docker rm $prefix-$lpush
|
docker rm $prefix-$lpush
|
||||||
echo "docker: starting $prefix-$lpush"
|
echo "docker: starting $prefix-$lpush"
|
||||||
echo " docker run --name "$prefix-$lpush" -d=true "$prefix-$lpush:alpha" -o "$docker_op_dir/$lpush.out" -d $duration -i $iat -l $loglvl -c $ctopic"
|
echo " docker run --name "$prefix-$lpush" -d=true "$prefix-$lpush:alpha" -o "$docker_op_dir/$lpush.out" -d $duration -i $iat -l $loglvl -c $ctopic"
|
||||||
|
@ -167,7 +178,7 @@ kurtosis_run() {
|
||||||
[ -d $FTDIR ] || mkdir -p $FTDIR
|
[ -d $FTDIR ] || mkdir -p $FTDIR
|
||||||
[ -d $LPDIR ] || mkdir -p $LPDIR
|
[ -d $LPDIR ] || mkdir -p $LPDIR
|
||||||
#cd waku
|
#cd waku
|
||||||
kurtosis clean -a
|
kurtosis clean -a # TODO: find out what signal kurtosis sends
|
||||||
docker rm $prefix-$filtr
|
docker rm $prefix-$filtr
|
||||||
docker rm $prefix-$lpush
|
docker rm $prefix-$lpush
|
||||||
|
|
||||||
|
@ -179,9 +190,10 @@ kurtosis_run() {
|
||||||
\"content_topic\": \"$ctopic\",
|
\"content_topic\": \"$ctopic\",
|
||||||
\"log_level\": \"$loglvl\",
|
\"log_level\": \"$loglvl\",
|
||||||
\"log_file\": \"output.log\"
|
\"log_file\": \"output.log\"
|
||||||
}" > waku/config.json
|
}" > waku/config.json
|
||||||
|
|
||||||
kurtosis run --enclave-id $enclave . '{"config":"github.com/logos-co/wadoku/waku/config.json"}' > $FTDIR/kurtosis_output.log
|
echo "kurtosis run --enclave-id $enclave . '{\"config\":\"github.com/logos-co/wadoku/waku/config.json\", \"run_pair\":\"$run_pair\"}' > $FTDIR/kurtosis_output.log"
|
||||||
|
kurtosis run --enclave-id $enclave . '{"config":"github.com/logos-co/wadoku/waku/config.json", "run_pair":"'$run_pair'"}' > $FTDIR/kurtosis.output
|
||||||
|
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
|
||||||
|
@ -206,11 +218,10 @@ kurtosis_run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "$# $1 $2"
|
echo "$# $1 $2 $3 $4"
|
||||||
[ 2 -eq "$#" ] || usage
|
[ 4 -eq "$#" ] || usage
|
||||||
[ metal != $1 -a docker != $1 -a kurtosis != $1 -a clean != $1 ] && usage
|
[ metal != $1 -a docker != $1 -a kurtosis != $1 -a clean != $1 ] && usage
|
||||||
|
|
||||||
|
|
||||||
if [ clean = $1 ]; then
|
if [ clean = $1 ]; then
|
||||||
start $1
|
start $1
|
||||||
clean
|
clean
|
||||||
|
|
|
@ -3,11 +3,11 @@ FROM golang:1.18
|
||||||
|
|
||||||
# Create the app directory to hold app’s source code
|
# Create the app directory to hold app’s source code
|
||||||
|
|
||||||
ADD waku-subscribe /go/bin/waku-subscribe
|
ADD ./waku-subscribe /go/bin/waku-subscribe
|
||||||
RUN umask -S 202
|
RUN umask -S 202
|
||||||
RUN mkdir -p /go/bin/out
|
RUN mkdir -p /go/bin/out
|
||||||
|
|
||||||
ADD subscribe.go /go/src/subscribe.go
|
ADD ./subscribe.go /go/src/subscribe.go
|
||||||
ADD go.mod go.sum /go/src/
|
ADD go.mod go.sum /go/src/
|
||||||
|
|
||||||
# Tells Docker which network port your container listens on
|
# Tells Docker which network port your container listens on
|
||||||
|
|
|
@ -120,6 +120,10 @@ func main() {
|
||||||
log.Info("Waiting to receive the message")
|
log.Info("Waiting to receive the message")
|
||||||
for env := range theSub.C {
|
for env := range theSub.C {
|
||||||
msg := env.Message()
|
msg := env.Message()
|
||||||
|
// ignore other relay messages
|
||||||
|
if msg.ContentTopic != conf.ContentTopic {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
rbuf := bytes.NewBuffer(msg.Payload)
|
rbuf := bytes.NewBuffer(msg.Payload)
|
||||||
var r32 int32 //:= make([]int64, (len(msg.Payload)+7)/8)
|
var r32 int32 //:= make([]int64, (len(msg.Payload)+7)/8)
|
||||||
|
|
Loading…
Reference in New Issue