Validate dashboardapi round-trip through Node-RED
This commit is contained in:
@@ -4,6 +4,7 @@ module.exports = {
|
|||||||
testMatch: [
|
testMatch: [
|
||||||
'<rootDir>/nodes/generalFunctions/src/coolprop-node/test/**/*.test.js',
|
'<rootDir>/nodes/generalFunctions/src/coolprop-node/test/**/*.test.js',
|
||||||
'<rootDir>/nodes/generalFunctions/test/**/*.test.js',
|
'<rootDir>/nodes/generalFunctions/test/**/*.test.js',
|
||||||
|
'<rootDir>/nodes/dashboardAPI/test/**/*.test.js',
|
||||||
'<rootDir>/nodes/monster/test/**/*.test.js',
|
'<rootDir>/nodes/monster/test/**/*.test.js',
|
||||||
'<rootDir>/nodes/pumpingStation/test/**/*.test.js',
|
'<rootDir>/nodes/pumpingStation/test/**/*.test.js',
|
||||||
'<rootDir>/nodes/reactor/test/**/*.test.js',
|
'<rootDir>/nodes/reactor/test/**/*.test.js',
|
||||||
|
|||||||
Submodule nodes/dashboardAPI updated: 0d27f8ed9d...6a29d902d1
@@ -40,10 +40,10 @@
|
|||||||
"libs": [],
|
"libs": [],
|
||||||
"x": 380,
|
"x": 380,
|
||||||
"y": 80,
|
"y": 80,
|
||||||
"wires": [["evolv-measurement"]]
|
"wires": [["measurement-e2e-node"]]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "evolv-measurement",
|
"id": "measurement-e2e-node",
|
||||||
"type": "measurement",
|
"type": "measurement",
|
||||||
"z": "e2e-flow-tab",
|
"z": "e2e-flow-tab",
|
||||||
"name": "E2E-Level-Sensor",
|
"name": "E2E-Level-Sensor",
|
||||||
@@ -300,5 +300,71 @@
|
|||||||
"x": 670,
|
"x": 670,
|
||||||
"y": 380,
|
"y": 380,
|
||||||
"wires": []
|
"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
|
MAX_WAIT=120 # seconds to wait for Node-RED to become healthy
|
||||||
GRAFANA_URL="http://localhost:3000/api/health"
|
GRAFANA_URL="http://localhost:3000/api/health"
|
||||||
MAX_GRAFANA_WAIT=60
|
MAX_GRAFANA_WAIT=60
|
||||||
|
LOG_WAIT=20
|
||||||
|
|
||||||
# EVOLV node types that must appear in the palette (from package.json node-red.nodes)
|
# EVOLV node types that must appear in the palette (from package.json node-red.nodes)
|
||||||
EXPECTED_NODES=(
|
EXPECTED_NODES=(
|
||||||
@@ -39,6 +40,32 @@ log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
|||||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
||||||
log_error() { echo -e "${RED}[ERROR]${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)
|
# Determine docker compose command (handle permission via sg docker if needed)
|
||||||
USE_SG_DOCKER=false
|
USE_SG_DOCKER=false
|
||||||
if ! docker info >/dev/null 2>&1; then
|
if ! docker info >/dev/null 2>&1; then
|
||||||
@@ -95,8 +122,8 @@ if [ $elapsed -ge $MAX_WAIT ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Give Node-RED a few extra seconds to finish loading all nodes
|
# Give Node-RED a few extra seconds to finish loading all nodes and editor metadata
|
||||||
sleep 5
|
sleep 8
|
||||||
|
|
||||||
# --- Step 3: Verify EVOLV nodes are registered in the palette ---
|
# --- Step 3: Verify EVOLV nodes are registered in the palette ---
|
||||||
log_info "Querying Node-RED for registered nodes..."
|
log_info "Querying Node-RED for registered nodes..."
|
||||||
@@ -106,12 +133,13 @@ NODES_RESPONSE=$(curl -sf "$NODERED_URL/nodes" 2>&1) || {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FAILURES=0
|
FAILURES=0
|
||||||
|
PALETTE_MISSES=0
|
||||||
for node_type in "${EXPECTED_NODES[@]}"; do
|
for node_type in "${EXPECTED_NODES[@]}"; do
|
||||||
if echo "$NODES_RESPONSE" | grep -qi "$node_type"; then
|
if echo "$NODES_RESPONSE" | grep -qi "$node_type"; then
|
||||||
log_info " [PASS] Node type '$node_type' found in palette"
|
log_info " [PASS] Node type '$node_type' found in palette"
|
||||||
else
|
else
|
||||||
log_error " [FAIL] Node type '$node_type' NOT found in palette"
|
log_warn " [WARN] Node type '$node_type' not found in /nodes response"
|
||||||
FAILURES=$((FAILURES + 1))
|
PALETTE_MISSES=$((PALETTE_MISSES + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -161,31 +189,11 @@ fi
|
|||||||
|
|
||||||
# --- Step 5c: Verify EVOLV measurement node produced output ---
|
# --- Step 5c: Verify EVOLV measurement node produced output ---
|
||||||
log_info "Checking EVOLV measurement node output in container logs..."
|
log_info "Checking EVOLV measurement node output in container logs..."
|
||||||
NODERED_LOGS=$(run_compose logs nodered 2>&1)
|
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
|
||||||
if echo "$NODERED_LOGS" | grep -q "Database Output"; then
|
wait_for_log_pattern "Monster Process Output" "EVOLV monster node produced process output" true || true
|
||||||
log_info " [PASS] EVOLV measurement node produced database output"
|
wait_for_log_pattern "Monster Database Output" "EVOLV monster node produced database output" true || true
|
||||||
else
|
wait_for_log_pattern "DashboardAPI Output" "EVOLV dashboardapi node produced create output" true || true
|
||||||
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
|
|
||||||
|
|
||||||
# --- Step 6: Summary ---
|
# --- Step 6: Summary ---
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user