Skip to content

Commit

Permalink
Fix slow test (#2274)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Fix slow test bug.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
small-turtle-1 authored Nov 21, 2024
1 parent 403cc13 commit 91bc965
Show file tree
Hide file tree
Showing 19 changed files with 451 additions and 298 deletions.
41 changes: 24 additions & 17 deletions .github/workflows/slow_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
runs-on: ["self-hosted", "slow-test" ]
steps:

- name: Choose test type
id: choose_test_type
run: |
echo "RUN_TSAN_TEST=true" >> $GITHUB_OUTPUT
echo "RUN_RESTART_TEST=true" >> $GITHUB_OUTPUT
echo "RUN_PYTEST_PARALLEL=true" >> $GITHUB_OUTPUT
- name: Show PR labels
if: ${{ !cancelled() && !failure() }}
run: |
Expand Down Expand Up @@ -56,7 +63,7 @@ jobs:
sudo docker rm -f -v ${BUILDER_CONTAINER} && sudo docker run --cap-add=NET_ADMIN -d --name ${BUILDER_CONTAINER} -e TZ=$TZ -e CMAKE_BUILD_PARALLEL_LEVEL=${CPUS} -v $PWD:/infinity -v /boot:/boot --cpus ${CPUS} infiniflow/infinity_builder:centos7_clang18
- name: Create Test image & Start tester container
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
run: |
TESTER_IMAGE_NAME=infiniflow/infinity_tester:centos7_clang18
sudo python3 scripts/build_tester_image.py --image_name=${TESTER_IMAGE_NAME} --bin_path=${RUNNER_WORKSPACE_PREFIX}/build_tester_image
Expand All @@ -81,18 +88,18 @@ jobs:
sudo docker exec ${BUILDER_CONTAINER} bash -c "rm -rf /root/.config/pip/pip.conf && cd /infinity/ && pip3 uninstall -y infinity-embedded-sdk && pip3 install . -v --config-settings=cmake.build-type='RelWithDebInfo' --config-settings=build-dir='cmake-build-release' -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host tuna.tsinghua.edu.cn"
- name: Build debug version with thread sanitizer
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
run: sudo docker exec ${BUILDER_CONTAINER} bash -c "git config --global safe.directory \"*\" && cd /infinity && rm -fr cmake-build-debug && mkdir -p cmake-build-debug && cmake -G Ninja -DENABLE_SANITIZER_THREAD=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_JOB_POOLS:STRING=link=8 -S /infinity -B /infinity/cmake-build-debug && cmake --build /infinity/cmake-build-debug --target infinity"

- name: Prepare restart test data
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_RESTART_TEST == 'true' }}
run: |
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
echo "RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX}" >> $GITHUB_ENV
sudo python3 scripts/prepare_restart_test_data.py --from_dir=${RUNNER_WORKSPACE_PREFIX} --op=add
- name: Run restart test with thread sanitizer
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
id: run_restart_test_sanitizer
run : |
sudo docker exec ${BUILDER_CONTAINER} bash -c "cd /infinity/ && pip3 install -r python/restart_test/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host tuna.tsinghua.edu.cn"
Expand All @@ -103,7 +110,7 @@ jobs:
sudo sysctl -w vm.mmap_rnd_bits=$old_value
- name: Collect restart test output with thread sanitizer
if: ${{ !cancelled() }} # always run this step even if previous steps failed
if: ${{ !cancelled() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }} # always run this step even if previous steps failed
# remove symbolic link
# find all log file like [debug.log.*] in directory, and cat to stdout
run: |
Expand All @@ -112,7 +119,7 @@ jobs:
sudo rm restart_tsan.log*
- name: Run cluster test
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
id: run_cluster_test
run: |
sudo docker exec ${TESTER_CONTAINER} bash -c "rm -rf /root/.config/pip/pip.conf && cd /infinity/ && pip3 uninstall -y infinity-sdk infinity-embedded-sdk && pip3 install . -v --config-settings=cmake.build-type='RelWithDebInfo' --config-settings=build-dir='cmake-build-release' -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host tuna.tsinghua.edu.cn && cd python/infinity_sdk/ && pip3 install . -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host tuna.tsinghua.edu.cn && cd ../.."
Expand All @@ -123,14 +130,14 @@ jobs:
sudo sysctl -w vm.mmap_rnd_bits=$old_value
- name: Collect thread sanitizer output in cluster test
if: ${{ !cancelled() }}
if: ${{ !cancelled() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
run: |
failure="${{ steps.run_cluster_test.outcome == 'failure'}}"
sudo python3 scripts/collect_cluster_log.py --executable_path=cmake-build-debug/src/infinity --log_dir=/var/infinity/ --output_dir=${RUNNER_WORKSPACE_PREFIX}/log --failure=${failure} --tsan_log=cluster_tsan.log
sudo rm -f cluster_tsan.log*
- name: Start infinity debug version with thread sanitizer
if: ${{ !cancelled() && !failure()}}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
id: start_tests_debug
run: |
# Fix sanitizer: https://github.com/ClickHouse/ClickHouse/issues/64086
Expand All @@ -145,13 +152,13 @@ jobs:
fi
- name: Run pytest parallel with thread sanitizer
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
id: run_tests_debug
run: |
sudo docker exec ${BUILDER_CONTAINER} bash -c "cd /infinity/ && LD_PRELOAD=/usr/local/lib/clang/18/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.so ASAN_OPTIONS=detect_leaks=0 python3 tools/run_pytest_parallel.py" && sleep 1s
- name: Stop infinity pysdk & http_api & sqllogictest debug
if: ${{ !cancelled() }}
if: ${{ !cancelled() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
id: stop_tests_debug
env:
old_value: ${{ steps.start_tests_debug.outputs.old_mmmap_rnd_bits }}
Expand All @@ -166,15 +173,15 @@ jobs:
sudo sysctl -w vm.mmap_rnd_bits=$old_value
- name: Collect thread sanitizer output in pytest parallel
if: ${{ !cancelled() }}
if: ${{ !cancelled() && steps.choose_test_type.outputs.RUN_TSAN_TEST == 'true' }}
# GitHub Actions interprets output lines starting with "Error" as error messages, and it automatically sets the step status to failed when such lines are detected.
run: |
failure="${{ steps.run_tests_debug.outcome == 'failure' || steps.stop_tests_debug.outcome == 'failure' }}"
sudo python3 scripts/collect_log.py --log_path=/var/infinity/log/infinity.log --stdout_path=debug.log --stderror_path=debug_error.log --executable_path=cmake-build-debug/src/infinity --output_dir=${RUNNER_WORKSPACE_PREFIX}/log --failure=${failure} --tsan_log=tsan.log
sudo rm -f tsan.log*
- name: Run restart test
if: ${{ !cancelled() && !failure() }}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_RESTART_TEST == 'true' }}
id: run_restart_test
run : |
sudo docker exec ${BUILDER_CONTAINER} bash -c "cd /infinity/ && pip3 install -r python/restart_test/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host tuna.tsinghua.edu.cn"
Expand All @@ -183,7 +190,7 @@ jobs:
# sudo docker exec ${BUILDER_CONTAINER} bash -c "cd /infinity/ && pytest python/restart_test/test_insert.py -k "test_index[infinity_runner0-columns2-indexes2-gen-1000000-test/data/config/restart_test/test_insert/1.toml]" -s --infinity_path=cmake-build-release/src/infinity"

- name: Collect restart test output
if: ${{ !cancelled() }} # always run this step even if previous steps failed
if: ${{ !cancelled() && steps.choose_test_type.outputs.RUN_RESTART_TEST == 'true' }} # always run this step even if previous steps failed
# remove symbolic link
# find all log file like [debug.log.*] in directory, and cat to stdout
run: |
Expand All @@ -192,20 +199,20 @@ jobs:
sudo python3 scripts/collect_restart_log.py --executable_path=cmake-build-release/src/infinity --output_dir=${RUNNER_WORKSPACE_PREFIX}/log --failure=${failure}
- name: Start infinity release version
if: ${{ !cancelled() && !failure()}}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_PYTEST_PARALLEL == 'true' }}
# && !contains(github.event.pull_request.labels.*.name, 'invalid')
run: |
# Run a command in the background
sudo docker exec ${BUILDER_CONTAINER} bash -c "cd /infinity/ && rm -fr /var/infinity && cmake-build-release/src/infinity --config=conf/pytest_parallel_continuous_conf.toml > release.log 2> release_error.log" &
- name: Run pysdk remote infinity & parallel & http_api & sqllogic test release version continously
if: ${{ !cancelled() && !failure()}}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_PYTEST_PARALLEL == 'true' }}
# && !contains(github.event.pull_request.labels.*.name, 'invalid')
id: run_py_tests
run: sudo docker exec ${BUILDER_CONTAINER} bash -c "cd /infinity/ && python3 tools/run_pytest_parallel_continuous.py" && sleep 1s

- name: Stop infinity release
if: ${{ !cancelled() && !failure()}}
if: ${{ !cancelled() && !failure() && steps.choose_test_type.outputs.RUN_PYTEST_PARALLEL == 'true' }}
# && !contains(github.event.pull_request.labels.*.name, 'invalid')
id: stop_py_tests
run: |
Expand All @@ -218,7 +225,7 @@ jobs:
fi
- name: Collect infinity release output
if: ${{ !cancelled() }} # always run this step even if previous steps failed
if: ${{ !cancelled() && steps.choose_test_type.outputs.RUN_PYTEST_PARALLEL == 'true' }} # always run this step even if previous steps failed
run: |
failure="${{ steps.run_py_tests.outcome == 'failure' || steps.stop_py_tests.outcome == 'failure' }}"
sudo python3 scripts/collect_log.py --log_path=/var/infinity/log/infinity.log --stdout_path=release.log --stderror_path=release_error.log --executable_path=cmake-build-release/src/infinity --output_dir=${RUNNER_WORKSPACE_PREFIX}/log --failure=${failure}
Expand Down
5 changes: 3 additions & 2 deletions python/infinity_sdk/infinity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# __version__ = importlib.metadata.version("infinity_sdk")

import logging
import os
# import pkg_resources
# __version__ = pkg_resources.get_distribution("infinity_sdk").version
Expand All @@ -25,8 +26,8 @@
from infinity.remote_thrift.infinity import RemoteThriftInfinityConnection
from infinity.errors import ErrorCode

def connect(uri = LOCAL_HOST) -> InfinityConnection:
def connect(uri = LOCAL_HOST, logger: logging.Logger = None) -> InfinityConnection:
if isinstance(uri, NetworkAddress):
return RemoteThriftInfinityConnection(uri)
return RemoteThriftInfinityConnection(uri, logger)
else:
raise InfinityException(ErrorCode.INVALID_SERVER_ADDRESS, f"Unknown uri: {uri}")
Loading

0 comments on commit 91bc965

Please sign in to comment.