diff --git a/src/service/.gitlab-ci.yml b/src/service/.gitlab-ci.yml index 9e8cb736cd2ff3e079656e51d79fa759c6b8c99d..6114a3399aa42ab87728cf1dbe18b353fbd6d905 100644 --- a/src/service/.gitlab-ci.yml +++ b/src/service/.gitlab-ci.yml @@ -156,37 +156,40 @@ unit_test service: - echo "Starting stage: deploy_mock_nodes" - for port in 11111 22222 33333; do if lsof -i:$port >/dev/null 2>&1; then - echo "Freeing up port $port..."; - fuser -k $port/tcp; + echo "Freeing up port $port..." + fuser -k $port/tcp fi done - MOCK_NODES_DIR="$PWD/src/tests/tools/mock_qkd_nodes" - - if [ -d "$MOCK_NODES_DIR" ]; then - cd "$MOCK_NODES_DIR" || exit; - ./start.sh &; - MOCK_NODES_PID=$!; + - | + if [ -d "$MOCK_NODES_DIR" ]; then + cd "$MOCK_NODES_DIR" || exit + ./start.sh & + MOCK_NODES_PID=$! else - echo "Error: Mock QKD nodes directory '$MOCK_NODES_DIR' not found."; - exit 1; + echo "Error: Mock QKD nodes directory '$MOCK_NODES_DIR' not found." + exit 1 fi - echo "Waiting for mock nodes to be up..." - RETRY_COUNT=0 - MAX_RETRIES=15 - - while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + - | + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do if curl -s http://127.0.0.1:11111 > /dev/null && \ curl -s http://127.0.0.1:22222 > /dev/null && \ curl -s http://127.0.0.1:33333 > /dev/null; then - echo "Mock nodes are up!"; - break; + echo "Mock nodes are up!" + break else - echo "Mock nodes not ready, retrying in 5 seconds..."; - RETRY_COUNT=$((RETRY_COUNT + 1)); - sleep 5; + echo "Mock nodes not ready, retrying in 5 seconds..." + RETRY_COUNT=$((RETRY_COUNT + 1)) + sleep 5 fi done - - if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then - echo "Error: Mock nodes failed to start after multiple attempts."; - exit 1; + - | + if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then + echo "Error: Mock nodes failed to start after multiple attempts." + exit 1 fi # Run the tests