Update SSH access patterns documentation and expand workflow integration test suite
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Coverage Phase 1 (70% Target) / test-coverage-70 (push) Has been cancelled
Coverage Phase 2 (85% Target) / test-coverage-85 (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Coverage Phase 1 (70% Target) / test-coverage-70 (push) Has been cancelled
Coverage Phase 2 (85% Target) / test-coverage-85 (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
- ssh-access-patterns.md: Clarify ns3/aitbc container setup with correct paths and service names - Add container hostname verification command - Update paths: /etc/aitbc/blockchain.env, /opt/aitbc/apps/blockchain-node/ - Fix service name: aitbc-blockchain-node (not aitbc-blockchain-node-3) - Add service restart and log viewing examples - test_workflow.sh: Rewrite as comprehensive integration test suite - Add
This commit is contained in:
167
scripts/testing/test_config_profiles.sh
Executable file
167
scripts/testing/test_config_profiles.sh
Executable file
@@ -0,0 +1,167 @@
|
||||
#!/bin/bash
|
||||
# Integration test script for config profiles CLI commands
|
||||
# Tests profile save, list, load, and delete operations with file system validation
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
PROFILES_DIR="$HOME/.config/aitbc/profiles"
|
||||
TEST_PROFILE="test_profile_$$"
|
||||
CONFIG_FILE=".aitbc.yaml"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
|
||||
# Helper functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
log_info "Running: $test_name"
|
||||
|
||||
if eval "$test_command"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: $test_name"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: $test_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
log_info "Cleaning up test artifacts..."
|
||||
|
||||
# Remove test profile if it exists
|
||||
if [ -f "$PROFILES_DIR/$TEST_PROFILE.yaml" ]; then
|
||||
rm -f "$PROFILES_DIR/$TEST_PROFILE.yaml"
|
||||
log_info "Removed test profile: $TEST_PROFILE"
|
||||
fi
|
||||
|
||||
# Remove test config file if it exists
|
||||
if [ -f "$REPO_ROOT/$CONFIG_FILE" ]; then
|
||||
rm -f "$REPO_ROOT/$CONFIG_FILE"
|
||||
log_info "Removed test config file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "$REPO_ROOT"
|
||||
mkdir -p "$PROFILES_DIR"
|
||||
|
||||
log_info "Starting config profiles integration tests"
|
||||
log_info "Test profile name: $TEST_PROFILE"
|
||||
log_info "Profiles directory: $PROFILES_DIR"
|
||||
|
||||
# Test 1: Save profile
|
||||
run_test "Save profile" "aitbc config profiles save $TEST_PROFILE"
|
||||
|
||||
# Verify profile file was created
|
||||
if [ -f "$PROFILES_DIR/$TEST_PROFILE.yaml" ]; then
|
||||
log_info "Profile file created successfully"
|
||||
else
|
||||
log_error "Profile file was not created"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
|
||||
# Test 2: List profiles (should include our test profile)
|
||||
run_test "List profiles" "aitbc config profiles list | grep -q $TEST_PROFILE"
|
||||
|
||||
# Test 3: Load profile
|
||||
run_test "Load profile" "aitbc config profiles load $TEST_PROFILE"
|
||||
|
||||
# Verify config file was created
|
||||
if [ -f "$REPO_ROOT/$CONFIG_FILE" ]; then
|
||||
log_info "Config file created by profile load"
|
||||
else
|
||||
log_error "Config file was not created by profile load"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
|
||||
# Test 4: Delete profile (with confirmation)
|
||||
run_test "Delete profile" "echo 'y' | aitbc config profiles delete $TEST_PROFILE"
|
||||
|
||||
# Verify profile file was deleted
|
||||
if [ ! -f "$PROFILES_DIR/$TEST_PROFILE.yaml" ]; then
|
||||
log_info "Profile file deleted successfully"
|
||||
else
|
||||
log_error "Profile file was not deleted"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
|
||||
# Test 5: Save again for cancellation test
|
||||
run_test "Save profile again" "aitbc config profiles save $TEST_PROFILE"
|
||||
|
||||
# Test 6: Delete with cancellation
|
||||
run_test "Delete profile (cancelled)" "echo 'n' | aitbc config profiles delete $TEST_PROFILE"
|
||||
|
||||
# Verify profile still exists after cancellation
|
||||
if [ -f "$PROFILES_DIR/$TEST_PROFILE.yaml" ]; then
|
||||
log_info "Profile file preserved after cancellation"
|
||||
else
|
||||
log_error "Profile file was deleted despite cancellation"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
|
||||
# Test 7: Load non-existent profile (should fail)
|
||||
if aitbc config profiles load nonexistent_profile_$$ 2>&1 | grep -q "not found"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: Load non-existent profile fails correctly"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: Load non-existent profile should fail"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
# Test 8: Delete non-existent profile (should fail)
|
||||
if aitbc config profiles delete nonexistent_profile_$$ 2>&1 | grep -q "not found"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: Delete non-existent profile fails correctly"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: Delete non-existent profile should fail"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
# Cleanup
|
||||
cleanup
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Test Summary"
|
||||
echo "========================================"
|
||||
echo "Tests Run: $TESTS_RUN"
|
||||
echo "Tests Passed: $TESTS_PASSED"
|
||||
echo "Tests Failed: $TESTS_FAILED"
|
||||
echo "========================================"
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
log_info "All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed!"
|
||||
exit 1
|
||||
fi
|
||||
149
scripts/testing/test_edge_advanced.sh
Executable file
149
scripts/testing/test_edge_advanced.sh
Executable file
@@ -0,0 +1,149 @@
|
||||
#!/bin/bash
|
||||
# Integration test script for edge advanced CLI commands
|
||||
# Tests island leave/bridge, GPU operations, database operations, serve operations, and metrics
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
EDGE_URL="http://127.0.0.1:8200"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
TESTS_SKIPPED=0
|
||||
|
||||
# Helper functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
check_edge() {
|
||||
if curl -s -f "$EDGE_URL/health" > /dev/null 2>&1; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
local require_edge="${3:-true}"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if [ "$require_edge" = "true" ] && ! check_edge; then
|
||||
log_warn "SKIPPED: $test_name (edge-api not available)"
|
||||
TESTS_SKIPPED=$((TESTS_SKIPPED + 1))
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_info "Running: $test_name"
|
||||
|
||||
if eval "$test_command"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: $test_name"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: $test_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
log_info "Starting edge advanced CLI integration tests"
|
||||
log_info "Edge API URL: $EDGE_URL"
|
||||
|
||||
# Island advanced operations
|
||||
run_test "Island leave" "aitbc edge island leave --island-id test_island_123" "true"
|
||||
|
||||
run_test "Island bridge" "aitbc edge island bridge --source island_a --target island_b" "true"
|
||||
|
||||
# GPU operations
|
||||
run_test "GPU list" "aitbc edge gpu list_gpus" "true"
|
||||
|
||||
run_test "GPU get" "aitbc edge gpu get_gpu --gpu-id gpu_123" "true"
|
||||
|
||||
run_test "GPU remove" "aitbc edge gpu remove_gpu --gpu-id gpu_123" "true"
|
||||
|
||||
run_test "GPU scan" "aitbc edge gpu scan_gpus" "true"
|
||||
|
||||
run_test "GPU metrics" "aitbc edge gpu gpu_metrics --gpu-id gpu_123" "true"
|
||||
|
||||
# Database operations
|
||||
run_test "Database init" "aitbc edge database init_db --db-name test_db" "true"
|
||||
|
||||
run_test "Database list" "aitbc edge database list_dbs" "true"
|
||||
|
||||
run_test "Database get" "aitbc edge database get_db --db-id db_123" "true"
|
||||
|
||||
run_test "Database delete" "aitbc edge database delete_db --db-id db_123" "true"
|
||||
|
||||
run_test "Database sync" "aitbc edge database sync_db --db-id db_123" "true"
|
||||
|
||||
# Serve operations
|
||||
run_test "Serve submit request" "aitbc edge serve submit_request --request-type compute --parameters '{\"gpu_count\": 2}'" "true"
|
||||
|
||||
run_test "Serve list requests" "aitbc edge serve list_requests" "true"
|
||||
|
||||
run_test "Serve get request" "aitbc edge serve get_request --request-id req_123" "true"
|
||||
|
||||
run_test "Serve cancel request" "aitbc edge serve cancel_request --request-id req_123" "true"
|
||||
|
||||
run_test "Serve get result" "aitbc edge serve get_result --request-id req_123" "true"
|
||||
|
||||
# Metrics operations
|
||||
run_test "Metrics record" "aitbc edge metrics record --metric-name test_metric --value 100" "true"
|
||||
|
||||
run_test "Metrics list" "aitbc edge metrics list_metrics" "true"
|
||||
|
||||
run_test "Metrics get" "aitbc edge metrics get_metric --metric-id metric_123" "true"
|
||||
|
||||
run_test "Metrics delete" "aitbc edge metrics delete_metric --metric-id metric_123" "true"
|
||||
|
||||
# Error handling tests (should handle gracefully)
|
||||
run_test "Island leave nonexistent" "aitbc edge island leave --island-id nonexistent_island" "false"
|
||||
|
||||
run_test "GPU get nonexistent" "aitbc edge gpu get_gpu --gpu-id nonexistent_gpu" "false"
|
||||
|
||||
# Output format tests
|
||||
run_test "GPU list table format" "aitbc edge gpu list_gpus --format table" "true"
|
||||
|
||||
run_test "Database list table format" "aitbc edge database list_dbs --format table" "true"
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Test Summary"
|
||||
echo "========================================"
|
||||
echo "Tests Run: $TESTS_RUN"
|
||||
echo "Tests Passed: $TESTS_PASSED"
|
||||
echo "Tests Failed: $TESTS_FAILED"
|
||||
echo "Tests Skipped: $TESTS_SKIPPED"
|
||||
echo "========================================"
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
log_info "All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed!"
|
||||
exit 1
|
||||
fi
|
||||
149
scripts/testing/test_resource.sh
Executable file
149
scripts/testing/test_resource.sh
Executable file
@@ -0,0 +1,149 @@
|
||||
#!/bin/bash
|
||||
# Integration test script for resource CLI commands
|
||||
# Tests resource status, deallocation, and coordinator-api integration
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
|
||||
# Helper functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
log_info "Running: $test_name"
|
||||
|
||||
if eval "$test_command"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: $test_name"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: $test_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
log_info "Starting resource CLI integration tests"
|
||||
log_info "Note: Some tests require coordinator-api running"
|
||||
|
||||
# Test 1: Resource status (all resources)
|
||||
run_test "Resource status (all)" "aitbc resource status"
|
||||
|
||||
# Test 2: Resource status (specific resource)
|
||||
run_test "Resource status (specific)" "aitbc resource status --resource-id test_res_123"
|
||||
|
||||
# Test 3: Resource deallocation (with confirmation)
|
||||
run_test "Resource deallocation (confirmed)" "echo 'y' | aitbc resource deallocate test_res_123"
|
||||
|
||||
# Test 4: Resource deallocation (force)
|
||||
run_test "Resource deallocation (force)" "aitbc resource deallocate test_res_123 --force"
|
||||
|
||||
# Test 5: Resource deallocation (cancelled)
|
||||
run_test "Resource deallocation (cancelled)" "echo 'n' | aitbc resource deallocate test_res_123"
|
||||
|
||||
# Test 6: Experimental commands require --mock flag
|
||||
log_warn "Testing experimental commands (should fail without --mock)"
|
||||
|
||||
if aitbc resource allocate --resource-type gpu --quantity 4 2>&1 | grep -q "EXPERIMENTAL"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: Allocate shows experimental warning"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: Allocate should show experimental warning"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if aitbc resource list 2>&1 | grep -q "EXPERIMENTAL"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: List shows experimental warning"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: List should show experimental warning"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if aitbc resource release test_res 2>&1 | grep -q "EXPERIMENTAL"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: Release shows experimental warning"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: Release should show experimental warning"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if aitbc resource utilization 2>&1 | grep -q "EXPERIMENTAL"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: Utilization shows experimental warning"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: Utilization should show experimental warning"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if aitbc resource optimize 2>&1 | grep -q "EXPERIMENTAL"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: Optimize shows experimental warning"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: Optimize should show experimental warning"
|
||||
fi
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
# Test 7: Mock mode for experimental commands
|
||||
log_info "Testing experimental commands with --mock flag"
|
||||
|
||||
run_test "Allocate with --mock" "aitbc resource allocate --resource-type gpu --quantity 4 --mock"
|
||||
|
||||
run_test "List with --mock" "aitbc resource list --mock"
|
||||
|
||||
run_test "Release with --mock" "aitbc resource release test_res --mock"
|
||||
|
||||
run_test "Utilization with --mock" "aitbc resource utilization --mock"
|
||||
|
||||
run_test "Optimize with --mock" "aitbc resource optimize --mock"
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Test Summary"
|
||||
echo "========================================"
|
||||
echo "Tests Run: $TESTS_RUN"
|
||||
echo "Tests Passed: $TESTS_PASSED"
|
||||
echo "Tests Failed: $TESTS_FAILED"
|
||||
echo "========================================"
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
log_info "All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed!"
|
||||
exit 1
|
||||
fi
|
||||
140
scripts/testing/test_simulate.sh
Executable file
140
scripts/testing/test_simulate.sh
Executable file
@@ -0,0 +1,140 @@
|
||||
#!/bin/bash
|
||||
# Integration test script for simulate CLI commands
|
||||
# Tests simulation operations including blockchain, wallets, price, network, and ai-jobs
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
COORDINATOR_URL="http://127.0.0.1:18000"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
TESTS_SKIPPED=0
|
||||
|
||||
# Helper functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
check_coordinator() {
|
||||
if curl -s -f "$COORDINATOR_URL/health" > /dev/null 2>&1; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
local require_coordinator="${3:-true}"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if [ "$require_coordinator" = "true" ] && ! check_coordinator; then
|
||||
log_warn "SKIPPED: $test_name (coordinator-api not available)"
|
||||
TESTS_SKIPPED=$((TESTS_SKIPPED + 1))
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_info "Running: $test_name"
|
||||
|
||||
if eval "$test_command"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: $test_name"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: $test_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
log_info "Starting simulate CLI integration tests"
|
||||
log_info "Coordinator URL: $COORDINATOR_URL"
|
||||
|
||||
# Test 1: Blockchain simulation
|
||||
run_test "Blockchain simulation" "aitbc simulate blockchain --blocks 10 --transactions 50" "true"
|
||||
|
||||
# Test 2: Wallets simulation
|
||||
run_test "Wallets simulation" "aitbc simulate wallets --count 5 --balance 1000" "true"
|
||||
|
||||
# Test 3: Price simulation
|
||||
run_test "Price simulation" "aitbc simulate price --days 30 --volatility 0.1" "true"
|
||||
|
||||
# Test 4: Network simulation
|
||||
run_test "Network simulation" "aitbc simulate network --nodes 10 --latency 50" "true"
|
||||
|
||||
# Test 5: AI jobs simulation
|
||||
run_test "AI jobs simulation" "aitbc simulate ai-jobs --jobs 20 --duration 300" "true"
|
||||
|
||||
# Test 6: Run simulation
|
||||
run_test "Run simulation" "aitbc simulate run --type blockchain --duration 60" "true"
|
||||
|
||||
# Test 7: Blockchain with custom parameters
|
||||
run_test "Blockchain with params" "aitbc simulate blockchain --blocks 100 --transactions 500 --difficulty 5" "true"
|
||||
|
||||
# Test 8: Wallets with distribution
|
||||
run_test "Wallets with distribution" "aitbc simulate wallets --count 10 --distribution exponential" "true"
|
||||
|
||||
# Test 9: Price with trend
|
||||
run_test "Price with trend" "aitbc simulate price --days 90 --trend bullish --volatility 0.15" "true"
|
||||
|
||||
# Test 10: Network with topology
|
||||
run_test "Network with topology" "aitbc simulate network --nodes 20 --topology mesh --latency 100" "true"
|
||||
|
||||
# Test 11: AI jobs with GPU
|
||||
run_test "AI jobs with GPU" "aitbc simulate ai-jobs --jobs 30 --gpu-required --duration 600" "true"
|
||||
|
||||
# Test 12: Run async simulation
|
||||
run_test "Run async simulation" "aitbc simulate run --type network --async --duration 120" "true"
|
||||
|
||||
# Test 13: Status of non-existent simulation (should handle gracefully)
|
||||
run_test "Status non-existent simulation" "aitbc simulate status sim_nonexistent_12345" "false"
|
||||
|
||||
# Test 14: Result of non-existent simulation (should handle gracefully)
|
||||
run_test "Result non-existent simulation" "aitbc simulate result sim_nonexistent_12345" "false"
|
||||
|
||||
# Test 15: Output format JSON
|
||||
run_test "Output format JSON" "aitbc simulate blockchain --blocks 5 --format json" "true"
|
||||
|
||||
# Test 16: Output format table
|
||||
run_test "Output format table" "aitbc simulate blockchain --blocks 5 --format table" "true"
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Test Summary"
|
||||
echo "========================================"
|
||||
echo "Tests Run: $TESTS_RUN"
|
||||
echo "Tests Passed: $TESTS_PASSED"
|
||||
echo "Tests Failed: $TESTS_FAILED"
|
||||
echo "Tests Skipped: $TESTS_SKIPPED"
|
||||
echo "========================================"
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
log_info "All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed!"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,23 +1,144 @@
|
||||
#!/bin/bash
|
||||
# Test Updated Workflow Scripts
|
||||
echo "=== Testing Updated Workflow Scripts ==="
|
||||
# Integration test script for workflow CLI commands
|
||||
# Tests workflow run, list, status, and stop operations with coordinator-api
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
||||
WORKFLOW_DIR="${REPO_ROOT}/scripts/workflow"
|
||||
CLI_PATH="${REPO_ROOT}/aitbc-cli"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
COORDINATOR_URL="http://127.0.0.1:18000"
|
||||
TEST_WORKFLOW="test_workflow_$$"
|
||||
|
||||
echo "1. Testing wallet creation script..."
|
||||
"${WORKFLOW_DIR}/04_create_wallet.sh"
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
TESTS_SKIPPED=0
|
||||
|
||||
# Helper functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
check_coordinator() {
|
||||
log_info "Checking coordinator-api availability..."
|
||||
if curl -s -f "$COORDINATOR_URL/health" > /dev/null 2>&1; then
|
||||
log_info "coordinator-api is running"
|
||||
return 0
|
||||
else
|
||||
log_warn "coordinator-api is not running at $COORDINATOR_URL"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
local require_coordinator="${3:-true}"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
if [ "$require_coordinator" = "true" ] && ! check_coordinator; then
|
||||
log_warn "SKIPPED: $test_name (coordinator-api not available)"
|
||||
TESTS_SKIPPED=$((TESTS_SKIPPED + 1))
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_info "Running: $test_name"
|
||||
|
||||
if eval "$test_command"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: $test_name"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: $test_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
log_info "Cleaning up test workflows..."
|
||||
# Attempt to stop test workflow if it exists
|
||||
if [ -n "$TEST_WORKFLOW" ]; then
|
||||
aitbc workflow stop "$TEST_WORKFLOW" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
log_info "Starting workflow CLI integration tests"
|
||||
log_info "Test workflow name: $TEST_WORKFLOW"
|
||||
log_info "Coordinator URL: $COORDINATOR_URL"
|
||||
|
||||
# Test 1: List workflows
|
||||
run_test "List workflows" "aitbc workflow list" "true"
|
||||
|
||||
# Test 2: Run a simple workflow
|
||||
run_test "Run workflow" "aitbc workflow run $TEST_WORKFLOW" "true"
|
||||
|
||||
# Test 3: Get workflow status
|
||||
run_test "Get workflow status" "aitbc workflow status $TEST_WORKFLOW" "true"
|
||||
|
||||
# Test 4: Run workflow with dry-run flag
|
||||
run_test "Run workflow dry-run" "aitbc workflow run $TEST_WORKFLOW --dry-run" "false"
|
||||
|
||||
# Test 5: Run workflow with async flag
|
||||
run_test "Run workflow async" "aitbc workflow run ${TEST_WORKFLOW}_async --async" "true"
|
||||
|
||||
# Test 6: Stop workflow
|
||||
run_test "Stop workflow" "aitbc workflow stop $TEST_WORKFLOW" "true"
|
||||
|
||||
# Test 7: List workflows in table format
|
||||
run_test "List workflows table format" "aitbc workflow list --format table" "true"
|
||||
|
||||
# Test 8: Get workflow status in JSON format
|
||||
run_test "Get workflow status JSON" "aitbc workflow status $TEST_WORKFLOW --format json" "true"
|
||||
|
||||
# Test 9: Run workflow with parameters
|
||||
run_test "Run workflow with parameters" "aitbc workflow run ${TEST_WORKFLOW}_params --param gpu_count=2 --param timeout=60" "true"
|
||||
|
||||
# Test 10: Status of non-existent workflow (should handle gracefully)
|
||||
run_test "Status of non-existent workflow" "aitbc workflow status nonexistent_workflow_$$" "false"
|
||||
|
||||
# Test 11: Stop non-existent workflow (should handle gracefully)
|
||||
run_test "Stop non-existent workflow" "aitbc workflow stop nonexistent_workflow_$$" "false"
|
||||
|
||||
# Test 12: Workflow with special characters in name
|
||||
run_test "Workflow with special characters" "aitbc workflow run test-workflow-with-dashes" "false"
|
||||
|
||||
# Cleanup
|
||||
cleanup
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "2. Testing final verification script..."
|
||||
export WALLET_ADDR=$("$CLI_PATH" wallet balance aitbc-user 2>/dev/null | grep "Address:" | awk '{print $2}' || echo "")
|
||||
"${WORKFLOW_DIR}/06_final_verification.sh"
|
||||
echo "========================================"
|
||||
echo "Test Summary"
|
||||
echo "========================================"
|
||||
echo "Tests Run: $TESTS_RUN"
|
||||
echo "Tests Passed: $TESTS_PASSED"
|
||||
echo "Tests Failed: $TESTS_FAILED"
|
||||
echo "Tests Skipped: $TESTS_SKIPPED"
|
||||
echo "========================================"
|
||||
|
||||
echo ""
|
||||
echo "3. Testing transaction manager script..."
|
||||
"${WORKFLOW_DIR}/09_transaction_manager.sh"
|
||||
|
||||
echo ""
|
||||
echo "✅ All script tests completed!"
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
log_info "All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
108
scripts/testing/test_workflow_cli.sh
Executable file
108
scripts/testing/test_workflow_cli.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
# Integration test script for workflow CLI commands
|
||||
# Tests workflow run, list, status, and stop operations
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
|
||||
# Helper functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
log_info "Running: $test_name"
|
||||
|
||||
if eval "$test_command"; then
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
log_info "PASSED: $test_name"
|
||||
else
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
log_error "FAILED: $test_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
log_info "Starting workflow CLI integration tests"
|
||||
|
||||
# Test 1: List workflows
|
||||
run_test "List workflows" "aitbc workflow list"
|
||||
|
||||
# Test 2: List workflows in JSON format
|
||||
run_test "List workflows (JSON)" "aitbc workflow list --format json | jq -e '.'"
|
||||
|
||||
# Test 3: Run workflow (dry run)
|
||||
run_test "Run workflow (dry run)" "aitbc workflow run test_workflow --dry-run"
|
||||
|
||||
# Test 4: Run workflow basic
|
||||
run_test "Run workflow basic" "aitbc workflow run test_workflow"
|
||||
|
||||
# Test 5: Get workflow status
|
||||
run_test "Get workflow status" "aitbc workflow status test_workflow"
|
||||
|
||||
# Test 6: Stop workflow
|
||||
run_test "Stop workflow" "aitbc workflow stop test_workflow"
|
||||
|
||||
# Test 7: Run workflow with special characters
|
||||
run_test "Run workflow with dashes" "aitbc workflow run workflow-with-dashes --dry-run"
|
||||
|
||||
# Test 8: Run workflow with underscores
|
||||
run_test "Run workflow with underscores" "aitbc workflow run workflow_with_underscores --dry-run"
|
||||
|
||||
# Test 9: Get status of non-existent workflow
|
||||
run_test "Status of non-existent workflow" "aitbc workflow status nonexistent_workflow_xyz"
|
||||
|
||||
# Test 10: Stop non-existent workflow
|
||||
run_test "Stop non-existent workflow" "aitbc workflow stop nonexistent_workflow_xyz"
|
||||
|
||||
# Test 11: Run workflow with config file (create temp config)
|
||||
TEMP_CONFIG=$(mktemp)
|
||||
echo "param1: value1" > "$TEMP_CONFIG"
|
||||
run_test "Run workflow with config" "aitbc workflow run test_workflow --config $TEMP_CONFIG --dry-run"
|
||||
rm -f "$TEMP_CONFIG"
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Test Summary"
|
||||
echo "========================================"
|
||||
echo "Tests Run: $TESTS_RUN"
|
||||
echo "Tests Passed: $TESTS_PASSED"
|
||||
echo "Tests Failed: $TESTS_FAILED"
|
||||
echo "========================================"
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
log_info "All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
log_error "Some tests failed!"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user