#!/usr/bin/env bash # logwisp chain aggregation test: edge-tcp and edge-http feed one relay # pipeline that fans both chain sources in and out to a tcp and an http sink. # Requires: bash 5+, coreutils (timeout), curl. Linux dev host only. set -u . "$(dirname -- "${BASH_SOURCE[0]}")/lib.sh" RUN=$E2E_DIR/run PORT_TCP_CHAIN=15801 PORT_HTTP_CHAIN=15802 PORT_TCP_SINK=15803 PORT_HTTP_SINK=15804 PORTS="$PORT_TCP_CHAIN $PORT_HTTP_CHAIN $PORT_TCP_SINK $PORT_HTTP_SINK" e2e_init "$@" section "Setup" need curl ports_free $PORTS mkdir -p "$CONF" "$LOG" edge_conf() { # name sink_type port [sink options] cat >"$CONF/$1.toml" <"$CONF/relay.toml" < nc 127.0.0.1 $PORT_TCP_SINK > curl -N http://127.0.0.1:$PORT_HTTP_SINK/stream > curl http://127.0.0.1:$PORT_HTTP_SINK/status Logs: $(short "$LOG")/ EOF manual_hold section "Checks" info "settling 3 s (connect, first http_chain flush)" sleep 3 # 1. tcp sink: both edges, aggregated tcp_out="$(tcp_read "$PORT_TCP_SINK" 4)" nt=$(grep -c 'edge-tcp/' <<<"$tcp_out") nh=$(grep -c 'edge-http/' <<<"$tcp_out") check "tcp sink: aggregated edge-tcp ($nt) + edge-http ($nh)" $((nt >= 1 && nh >= 1)) # 2. http sink: both edges, aggregated sse_out="$(curl -sN --noproxy '*' --max-time 4 "http://127.0.0.1:$PORT_HTTP_SINK/stream" || true)" nt=$(grep -c '^data:.*edge-tcp/' <<<"$sse_out") nh=$(grep -c '^data:.*edge-http/' <<<"$sse_out") check "http sink: aggregated edge-tcp ($nt) + edge-http ($nh)" $((nt >= 1 && nh >= 1)) # 3. HTTP sink status endpoint status="$(curl -s --noproxy '*' --max-time 3 "http://127.0.0.1:$PORT_HTTP_SINK/status" || true)" proc=$(grep -o '"total_processed"[ :] *[0-9]*' <<<"$status" | grep -o '[0-9]*' || echo 0) check "status endpoint: total_processed=$proc > 0" $((proc > 0)) summary