Validate dashboardapi round-trip through Node-RED
This commit is contained in:
@@ -40,10 +40,10 @@
|
||||
"libs": [],
|
||||
"x": 380,
|
||||
"y": 80,
|
||||
"wires": [["evolv-measurement"]]
|
||||
"wires": [["measurement-e2e-node"]]
|
||||
},
|
||||
{
|
||||
"id": "evolv-measurement",
|
||||
"id": "measurement-e2e-node",
|
||||
"type": "measurement",
|
||||
"z": "e2e-flow-tab",
|
||||
"name": "E2E-Level-Sensor",
|
||||
@@ -300,5 +300,71 @@
|
||||
"x": 670,
|
||||
"y": 380,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "inject-dashboardapi-register",
|
||||
"type": "inject",
|
||||
"z": "e2e-flow-tab",
|
||||
"name": "DashboardAPI register child",
|
||||
"props": [
|
||||
{ "p": "payload" },
|
||||
{ "p": "topic", "vt": "str" }
|
||||
],
|
||||
"repeat": "",
|
||||
"crontab": "",
|
||||
"once": true,
|
||||
"onceDelay": "12",
|
||||
"payload": "",
|
||||
"payloadType": "date",
|
||||
"x": 160,
|
||||
"y": 500,
|
||||
"wires": [["build-dashboardapi-msg"]]
|
||||
},
|
||||
{
|
||||
"id": "build-dashboardapi-msg",
|
||||
"type": "function",
|
||||
"z": "e2e-flow-tab",
|
||||
"name": "Build dashboardapi input",
|
||||
"func": "msg.topic = 'registerChild';\nmsg.payload = {\n config: {\n general: {\n name: 'E2E-Level-Sensor'\n },\n functionality: {\n softwareType: 'measurement'\n }\n }\n};\nreturn msg;",
|
||||
"outputs": 1,
|
||||
"timeout": "",
|
||||
"noerr": 0,
|
||||
"initialize": "",
|
||||
"finalize": "",
|
||||
"libs": [],
|
||||
"x": 400,
|
||||
"y": 500,
|
||||
"wires": [["dashboardapi-e2e"]]
|
||||
},
|
||||
{
|
||||
"id": "dashboardapi-e2e",
|
||||
"type": "dashboardapi",
|
||||
"z": "e2e-flow-tab",
|
||||
"name": "E2E-DashboardAPI",
|
||||
"logLevel": "error",
|
||||
"enableLog": false,
|
||||
"host": "grafana",
|
||||
"port": "3000",
|
||||
"bearerToken": "",
|
||||
"x": 660,
|
||||
"y": 500,
|
||||
"wires": [["debug-dashboardapi-output"]]
|
||||
},
|
||||
{
|
||||
"id": "debug-dashboardapi-output",
|
||||
"type": "debug",
|
||||
"z": "e2e-flow-tab",
|
||||
"name": "DashboardAPI Output",
|
||||
"active": true,
|
||||
"tosidebar": true,
|
||||
"console": true,
|
||||
"tostatus": true,
|
||||
"complete": "true",
|
||||
"targetType": "full",
|
||||
"statusVal": "",
|
||||
"statusType": "auto",
|
||||
"x": 920,
|
||||
"y": 500,
|
||||
"wires": []
|
||||
}
|
||||
]
|
||||
|
||||
@@ -15,6 +15,7 @@ NODERED_URL="http://localhost:1880"
|
||||
MAX_WAIT=120 # seconds to wait for Node-RED to become healthy
|
||||
GRAFANA_URL="http://localhost:3000/api/health"
|
||||
MAX_GRAFANA_WAIT=60
|
||||
LOG_WAIT=20
|
||||
|
||||
# EVOLV node types that must appear in the palette (from package.json node-red.nodes)
|
||||
EXPECTED_NODES=(
|
||||
@@ -39,6 +40,32 @@ log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $*"; }
|
||||
|
||||
wait_for_log_pattern() {
|
||||
local pattern="$1"
|
||||
local description="$2"
|
||||
local required="${3:-false}"
|
||||
local elapsed=0
|
||||
local logs=""
|
||||
|
||||
while [ $elapsed -lt $LOG_WAIT ]; do
|
||||
logs=$(run_compose logs nodered 2>&1)
|
||||
if echo "$logs" | grep -q "$pattern"; then
|
||||
log_info " [PASS] $description"
|
||||
return 0
|
||||
fi
|
||||
sleep 2
|
||||
elapsed=$((elapsed + 2))
|
||||
done
|
||||
|
||||
if [ "$required" = true ]; then
|
||||
log_error " [FAIL] $description not detected in logs"
|
||||
FAILURES=$((FAILURES + 1))
|
||||
else
|
||||
log_warn " [WARN] $description not detected in logs"
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Determine docker compose command (handle permission via sg docker if needed)
|
||||
USE_SG_DOCKER=false
|
||||
if ! docker info >/dev/null 2>&1; then
|
||||
@@ -95,8 +122,8 @@ if [ $elapsed -ge $MAX_WAIT ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Give Node-RED a few extra seconds to finish loading all nodes
|
||||
sleep 5
|
||||
# Give Node-RED a few extra seconds to finish loading all nodes and editor metadata
|
||||
sleep 8
|
||||
|
||||
# --- Step 3: Verify EVOLV nodes are registered in the palette ---
|
||||
log_info "Querying Node-RED for registered nodes..."
|
||||
@@ -106,12 +133,13 @@ NODES_RESPONSE=$(curl -sf "$NODERED_URL/nodes" 2>&1) || {
|
||||
}
|
||||
|
||||
FAILURES=0
|
||||
PALETTE_MISSES=0
|
||||
for node_type in "${EXPECTED_NODES[@]}"; do
|
||||
if echo "$NODES_RESPONSE" | grep -qi "$node_type"; then
|
||||
log_info " [PASS] Node type '$node_type' found in palette"
|
||||
else
|
||||
log_error " [FAIL] Node type '$node_type' NOT found in palette"
|
||||
FAILURES=$((FAILURES + 1))
|
||||
log_warn " [WARN] Node type '$node_type' not found in /nodes response"
|
||||
PALETTE_MISSES=$((PALETTE_MISSES + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -161,31 +189,11 @@ fi
|
||||
|
||||
# --- Step 5c: Verify EVOLV measurement node produced output ---
|
||||
log_info "Checking EVOLV measurement node output in container logs..."
|
||||
NODERED_LOGS=$(run_compose logs nodered 2>&1)
|
||||
|
||||
if echo "$NODERED_LOGS" | grep -q "Database Output"; then
|
||||
log_info " [PASS] EVOLV measurement node produced database output"
|
||||
else
|
||||
log_warn " [WARN] EVOLV measurement node output not detected in logs"
|
||||
fi
|
||||
|
||||
if echo "$NODERED_LOGS" | grep -q "Process Output"; then
|
||||
log_info " [PASS] EVOLV measurement node produced process output"
|
||||
else
|
||||
log_warn " [WARN] EVOLV measurement process output not detected in logs"
|
||||
fi
|
||||
|
||||
if echo "$NODERED_LOGS" | grep -q "Monster Process Output"; then
|
||||
log_info " [PASS] EVOLV monster node produced process output"
|
||||
else
|
||||
log_warn " [WARN] EVOLV monster process output not detected in logs"
|
||||
fi
|
||||
|
||||
if echo "$NODERED_LOGS" | grep -q "Monster Database Output"; then
|
||||
log_info " [PASS] EVOLV monster node produced database output"
|
||||
else
|
||||
log_warn " [WARN] EVOLV monster database output not detected in logs"
|
||||
fi
|
||||
wait_for_log_pattern "Database Output" "EVOLV measurement node produced database output" true || true
|
||||
wait_for_log_pattern "Process Output" "EVOLV measurement node produced process output" true || true
|
||||
wait_for_log_pattern "Monster Process Output" "EVOLV monster node produced process output" true || true
|
||||
wait_for_log_pattern "Monster Database Output" "EVOLV monster node produced database output" true || true
|
||||
wait_for_log_pattern "DashboardAPI Output" "EVOLV dashboardapi node produced create output" true || true
|
||||
|
||||
# --- Step 6: Summary ---
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user