-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-wasm.sh
More file actions
executable file
·83 lines (66 loc) · 2.67 KB
/
Copy pathtest-wasm.sh
File metadata and controls
executable file
·83 lines (66 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# WASM Plugin Test Script
# This script demonstrates all WASM plugin functionality
set -e
echo "=========================================="
echo "Nord WASM Plugin Test Suite"
echo "=========================================="
echo ""
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if TinyGo is installed
if ! command -v tinygo &> /dev/null; then
echo -e "${YELLOW}Warning: TinyGo not found. Install from https://tinygo.org${NC}"
echo "Skipping build step..."
else
echo -e "${BLUE}Step 1: Building WASM plugins...${NC}"
make build-wasm
echo -e "${GREEN}✓ Build complete${NC}"
echo ""
fi
echo -e "${BLUE}Step 2: Listing loaded plugins...${NC}"
go run . -p wasm -a list 2>&1 | grep -A 10 "Loaded WASM Plugins"
echo -e "${GREEN}✓ Plugins loaded${NC}"
echo ""
echo -e "${BLUE}Step 3: Testing Demo Plugin${NC}"
echo ""
echo " → Getting plugin info..."
go run . -p wasm -a execute "plugin=demo req_action=info" 2>&1 | grep -A 10 "Plugin Response"
echo ""
echo " → Testing ping action..."
go run . -p wasm -a execute "plugin=demo req_action=ping target=test-server" 2>&1 | grep -A 10 "Plugin Response"
echo ""
echo " → Testing collect action..."
go run . -p wasm -a execute "plugin=demo req_action=collect hostname=server1" 2>&1 | grep -A 15 "Plugin Response"
echo ""
echo " → Testing status action..."
go run . -p wasm -a execute "plugin=demo req_action=status" 2>&1 | grep -A 10 "Plugin Response"
echo -e "${GREEN}✓ Demo plugin tests passed${NC}"
echo ""
echo -e "${BLUE}Step 4: Testing Network Monitor Plugin${NC}"
echo ""
echo " → Getting plugin info..."
go run . -p wasm -a execute "plugin=network-monitor req_action=info" 2>&1 | grep -A 10 "Plugin Response"
echo ""
echo " → Collecting network metrics..."
go run . -p wasm -a execute "plugin=network-monitor req_action=collect host=router" 2>&1 | grep -A 15 "Plugin Response"
echo ""
echo " → Checking latency..."
go run . -p wasm -a execute "plugin=network-monitor req_action=check_latency target=8.8.8.8" 2>&1 | grep -A 10 "Plugin Response"
echo ""
echo " → Checking bandwidth..."
go run . -p wasm -a execute "plugin=network-monitor req_action=check_bandwidth interface=eth0" 2>&1 | grep -A 10 "Plugin Response"
echo -e "${GREEN}✓ Network monitor plugin tests passed${NC}"
echo ""
echo "=========================================="
echo -e "${GREEN}All tests passed! ✓${NC}"
echo "=========================================="
echo ""
echo "Next steps:"
echo " 1. See WASM_QUICKSTART.md for integration guide"
echo " 2. Check examples/ directory for plugin templates"
echo " 3. Read plugins/wasm/README.md for detailed docs"
echo ""