fetch_ml/scripts/testing/test-native-with-redis.sh
Jeremie Fraeys 6d200b5ac2
fix(docker): Use named volume for Redis to fix permission errors
Replace bind mount with Docker named volume for Redis data

This fixes 'operation not permitted' errors on macOS Docker Desktop

where bind mounts fail due to file sharing restrictions
2026-02-23 14:20:23 -05:00

53 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# Test script for native libraries with Redis via docker-compose
# Usage: ./scripts/test-native-with-redis.sh
set -e
echo "=== FetchML Native Library Test with Redis ==="
echo ""
# Check if native libraries are built
if [ ! -f "native/build/libqueue_index.so" ] && [ ! -f "native/build/libqueue_index.dylib" ]; then
echo "Building native libraries..."
make native-build
fi
# Start Redis via docker-compose
echo "Starting Redis..."
cd deployments
docker-compose -f docker-compose.dev.yml up -d redis
cd ..
# Wait for Redis to be ready
echo "Waiting for Redis to be ready..."
sleep 2
until docker exec ml-experiments-redis redis-cli ping | grep -q PONG; do
echo " Redis not ready yet, waiting..."
sleep 1
done
echo " Redis is ready!"
echo ""
# Run tests with native_libs build tag
echo "Running tests with -tags native_libs..."
CGO_ENABLED=1 go test -tags native_libs -v ./tests/benchmarks/... 2>&1 | head -100
TEST_EXIT=${PIPESTATUS[0]}
echo ""
echo "=== Test Summary ==="
if [ $TEST_EXIT -eq 0 ]; then
echo "✅ All tests passed with native libraries enabled"
else
echo "❌ Tests failed with exit code: $TEST_EXIT"
fi
# Cleanup
echo ""
echo "Stopping Redis..."
cd deployments
docker-compose -f docker-compose.dev.yml stop redis
cd ..
exit $TEST_EXIT