diff --git a/scripts/health_check.sh b/scripts/health_check.sh new file mode 100755 index 00000000..9792a40b --- /dev/null +++ b/scripts/health_check.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Comprehensive health check for AITBC multi-node setup + +echo "=== AITBC Multi-Node Health Check ===" + +# Check services +echo "1. Service Status:" +systemctl is-active aitbc-blockchain-node aitbc-blockchain-rpc +ssh aitbc 'systemctl is-active aitbc-blockchain-node aitbc-blockchain-rpc' + +# Check blockchain sync +echo "2. Blockchain Sync:" +HEIGHT1=$(curl -s http://localhost:8006/rpc/head | jq .height) +HEIGHT2=$(ssh aitbc 'curl -s http://localhost:8006/rpc/head | jq .height') +echo "aitbc1: $HEIGHT1, aitbc: $HEIGHT2, diff: $((HEIGHT1-HEIGHT2))" + +# Check network connectivity +echo "3. Network Connectivity:" +ping -c 1 10.1.223.40 >/dev/null && echo "aitbc reachable" || echo "aitbc unreachable" +redis-cli -h localhost ping >/dev/null && echo "Redis OK" || echo "Redis failed" + +# Check disk space +echo "4. Disk Usage:" +df -h /var/lib/aitbc/ | tail -1 + +# Check memory usage +echo "5. Memory Usage:" +free -h | grep Mem + +echo "=== Health Check Complete ===" diff --git a/scripts/log_monitor.sh b/scripts/log_monitor.sh new file mode 100755 index 00000000..74651023 --- /dev/null +++ b/scripts/log_monitor.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Monitor AITBC logs for critical errors + +tail -f /var/log/aitbc/blockchain-node.log | grep --line-buffered -E "(ERROR|CRITICAL|FATAL)" | while read line; do + echo "$(date): $line" >> /var/log/aitbc/critical_errors.log + # Send alert (configure your alert system here) +done diff --git a/scripts/performance_tune.sh b/scripts/performance_tune.sh new file mode 100755 index 00000000..9db53c19 --- /dev/null +++ b/scripts/performance_tune.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Performance optimization + +echo "=== Performance Tuning ===" + +# Optimize Redis +redis-cli CONFIG SET maxmemory 2gb +redis-cli CONFIG SET maxmemory-policy allkeys-lru + +# Optimize Python processes +echo 'ulimit -n 65536' >> /etc/security/limits.conf + +# Optimize system parameters +echo 'vm.swappiness=10' >> /etc/sysctl.conf +echo 'net.core.somaxconn=65535' >> /etc/sysctl.conf +sysctl -p + +echo "=== Performance Tuning Complete ===" diff --git a/scripts/provision_node.sh b/scripts/provision_node.sh new file mode 100755 index 00000000..5c5521e9 --- /dev/null +++ b/scripts/provision_node.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Provision new AITBC node + +NODE_NAME=$1 +if [ -z "$NODE_NAME" ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "Provisioning node: $NODE_NAME" + +# Install dependencies +apt update && apt install -y python3 python3-venv redis-server + +# Setup directories +mkdir -p /var/lib/aitbc/{data,keystore} +mkdir -p /etc/aitbc +mkdir -p /var/log/aitbc + +# Copy configuration +scp aitbc1:/etc/aitbc/blockchain.env /etc/aitbc/ +scp aitbc1:/opt/aitbc/aitbc-cli-final /opt/aitbc/ + +# Pull code +cd /opt/aitbc +git pull origin main + +# Setup as follower +sed -i 's|enable_block_production=true|enable_block_production=false|g' /etc/aitbc/blockchain.env +sed -i 's|proposer_id=.*|proposer_id=follower-node-'$NODE_NAME'|g' /etc/aitbc/blockchain.env + +echo "Node $NODE_NAME provisioned successfully" diff --git a/scripts/weekly_maintenance.sh b/scripts/weekly_maintenance.sh new file mode 100755 index 00000000..f2470939 --- /dev/null +++ b/scripts/weekly_maintenance.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Weekly maintenance tasks + +echo "=== Weekly Maintenance ===" + +# Clean old logs +find /var/log/aitbc -name "*.log" -mtime +7 -delete + +# Update software +cd /opt/aitbc && git pull origin main +/opt/aitbc/venv/bin/pip install -r requirements.txt + +# Restart services if needed +systemctl restart aitbc-blockchain-node aitbc-blockchain-rpc + +# Run health check +/opt/aitbc/scripts/health_check.sh + +echo "=== Weekly Maintenance Complete ===" diff --git a/tests/integration_test.sh b/tests/integration_test.sh new file mode 100755 index 00000000..4aca257f --- /dev/null +++ b/tests/integration_test.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Integration test suite for AITBC multi-node setup + +echo "=== AITBC Integration Tests ===" + +# Test 1: Basic connectivity +echo "1. Testing connectivity..." +curl -s http://localhost:8006/rpc/head >/dev/null && echo "✅ RPC accessible" || echo "❌ RPC failed" +ssh aitbc 'curl -s http://localhost:8006/rpc/head' >/dev/null && echo "✅ Remote RPC accessible" || echo "❌ Remote RPC failed" + +# Test 2: Wallet operations +echo "2. Testing wallet operations..." +python /opt/aitbc/cli/simple_wallet.py list >/dev/null && echo "✅ Wallet list works" || echo "❌ Wallet list failed" + +# Test 3: Transaction operations +echo "3. Testing transactions..." +# Create test wallet +python /opt/aitbc/cli/simple_wallet.py create --name test-integration --password-file /var/lib/aitbc/keystore/.password >/dev/null && echo "✅ Wallet creation works" || echo "❌ Wallet creation failed" + +# Test 4: Blockchain operations +echo "4. Testing blockchain operations..." +python /opt/aitbc/cli/simple_wallet.py chain >/dev/null && echo "✅ Chain info works" || echo "❌ Chain info failed" + +echo "=== Integration Tests Complete ===" diff --git a/tests/load_test.py b/tests/load_test.py new file mode 100644 index 00000000..29371a37 --- /dev/null +++ b/tests/load_test.py @@ -0,0 +1,28 @@ +from locust import HttpUser, task, between +import json + +class AITBCUser(HttpUser): + wait_time = between(1, 3) + + def on_start(self): + # Setup test wallet + response = self.client.post("/rpc/wallet/create", json={"name": "test-wallet"}) + self.wallet_data = response.json() + + @task(3) + def check_balance(self): + self.client.get(f"/rpc/getBalance/{self.wallet_data['address']}") + + @task(2) + def get_network_status(self): + self.client.get("/rpc/network") + + @task(1) + def send_transaction(self): + tx_data = { + "from": self.wallet_data['address'], + "to": "ait1testaddress123...", + "amount": 1, + "fee": 1 + } + self.client.post("/rpc/sendTx", json=tx_data)