1+ #! /bin/bash
2+
3+ set -e
4+ mkdir -p /tmp/protoplaster/pickle_node/{tests,reports,artifacts}
5+ mkdir -p /tmp/protoplaster/pickle_main/{tests,reports,artifacts}
6+ OUTPUT_DIR=" test_pickle_output"
7+ TEST_DIR=" $( dirname " ${BASH_SOURCE[0]} " ) "
8+ mkdir -p " $OUTPUT_DIR "
9+
10+ cat << EOF > /tmp/protoplaster/pickle_devices.yaml
11+ node1: localhost:2140
12+ EOF
13+
14+ cat << EOF > /tmp/protoplaster/rpc-pickle-test.yml
15+ tests:
16+ pickle_test:
17+ - rpc_pickle:
18+ dev: "node1"
19+
20+ test-suites:
21+ local:
22+ tests:
23+ - pickle_test
24+ EOF
25+
26+ echo " Starting Protoplaster nodes for Pickle RPC test..."
27+
28+ # Start Worker Node on port 2140
29+ protoplaster --test-dir /tmp/protoplaster/pickle_node/tests \
30+ --reports-dir /tmp/protoplaster/pickle_node/reports \
31+ --artifacts-dir /tmp/protoplaster/pickle_node/artifacts \
32+ --custom-tests $TEST_DIR /custom_modules \
33+ --port 2140 --dut &
34+ PID_WORKER=$!
35+
36+ # Start Main Node on port 5001
37+ protoplaster --test-dir /tmp/protoplaster/pickle_main/tests \
38+ --reports-dir /tmp/protoplaster/pickle_main/reports \
39+ --artifacts-dir /tmp/protoplaster/pickle_main/artifacts \
40+ --external-devices /tmp/protoplaster/pickle_devices.yaml \
41+ --custom-tests $TEST_DIR /custom_modules \
42+ --port 5001 --server &
43+ PID_MAIN=$!
44+
45+ # Cleanup function
46+ function finish {
47+ echo " Stopping servers..."
48+ kill $PID_WORKER $PID_MAIN 2> /dev/null || true
49+ }
50+ trap finish EXIT
51+
52+ # Wait for servers
53+ echo " Waiting for servers to start..."
54+ for port in 2140 5001; do
55+ while ! curl -s http://localhost:$port /api/v1/configs > /dev/null; do
56+ sleep 1
57+ done
58+ done
59+
60+ # Upload config
61+ CONFIG_FILE=" rpc-pickle-test.yml"
62+ for port in 2140 5001; do
63+ echo " Uploading config to port $port ..."
64+ NAME=$( curl -s -X POST http://localhost:$port /api/v1/configs -F " file=@/tmp/protoplaster/$CONFIG_FILE " | jq -r ' .name' )
65+ if [ " $NAME " != " $CONFIG_FILE " ] ; then
66+ echo " Config upload failed on port $port !"
67+ exit 1
68+ fi
69+ done
70+
71+ # Trigger test run
72+ echo " Triggering Pickle RPC run..."
73+ curl -s -X POST http://localhost:5001/api/v1/test-runs \
74+ -H " Content-Type: application/json" \
75+ -d " {\" config_name\" : \" $CONFIG_FILE \" }" > /dev/null
76+
77+ sleep 2
78+
79+ REPORT_FILE=" $OUTPUT_DIR /pickle_test_report.csv"
80+ RUN_ID=$( curl -s http://localhost:5001/api/v1/test-runs | jq -r ' .[-1].id' )
81+
82+ # Wait for finish
83+ STATUS=" "
84+ while [ " $STATUS " != " finished" ] && [ " $STATUS " != " failed" ]; do
85+ STATUS=$( curl -s http://localhost:5001/api/v1/test-runs/$RUN_ID | jq -r ' .status' )
86+ sleep 1
87+ done
88+
89+ # Get report
90+ curl -s http://localhost:5001/api/v1/test-runs/$RUN_ID /report > " $REPORT_FILE "
91+
92+ if ! grep " test_custom_objects_rpc" " $REPORT_FILE " | grep -q " passed" ; then
93+ echo " FAILURE: Pickle RPC test did not pass!"
94+ cat " $REPORT_FILE "
95+ exit 1
96+ fi
97+
98+ echo " SUCCESS: Pickle RPC test passed."
99+ echo " ---------------------------------------------------"
100+ echo " Results saved in: $OUTPUT_DIR "
101+ echo " ---------------------------------------------------"
0 commit comments