diff --git a/docs/build_from_source.md b/docs/build_from_source.md index 0c459db5ed..3cb013a265 100644 --- a/docs/build_from_source.md +++ b/docs/build_from_source.md @@ -10,18 +10,19 @@ This section provides instructions on building Infinity from source on Ubuntu 22 ### Step1 Download the source code ```shell -$ git clone https://github.com/infiniflow/infinity.git +git clone https://github.com/infiniflow/infinity.git ``` ### Step2 Install necessary dependencies -```bash +```shell sudo apt update && sudo apt install git wget unzip software-properties-common wget https://cmake.org/files/v3.28/cmake-3.28.1-linux-x86_64.tar.gz tar zxvf cmake-3.28.1-linux-x86_64.tar.gz -cp -rf cmake-3.28.1-linux-x86_64/bin/* /usr/local/bin && cp -rf cmake-3.28.1-linux-x86_64/share/* /usr/local/share && rm -rf cmake-3.28.1-linux-x86_64 +sudo cp -rf cmake-3.28.1-linux-x86_64/bin/* /usr/local/bin && sudo cp -rf cmake-3.28.1-linux-x86_64/share/* /usr/local/share && rm -rf cmake-3.28.1-linux-x86_64 wget https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip -unzip ninja-linux.zip && cp ninja /usr/local/bin && rm ninja ninja-linux.zip +unzip ninja-linux.zip && sudo cp ninja /usr/local/bin && rm ninja +sudo echo 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main' > /etc/apt/sources.list.d/llvm17.list wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc sudo add-apt-repository -P ppa:ubuntu-toolchain-r/test sudo add-apt-repository -P ppa:mhier/libboost-latest @@ -43,7 +44,7 @@ ninja -j 12 ### Step4 Start up the Infinity server ```shell -.build/src/infinity_main +.build/src/infinity ``` @@ -60,11 +61,11 @@ git clone https://github.com/infiniflow/infinity.git ### Step2 Install dependencies -```bash +```shell sudo apt update && sudo apt install -y git wget wget https://cmake.org/files/v3.28/cmake-3.28.1-linux-x86_64.tar.gz tar zxvf cmake-3.28.1-linux-x86_64.tar.gz -cp -rf cmake-3.28.1-linux-x86_64/bin/* /usr/local/bin && cp -rf cmake-3.28.1-linux-x86_64/share/* /usr/local/share && rm -rf cmake-3.28.1-linux-x86_64 +sudo cp -rf cmake-3.28.1-linux-x86_64/bin/* /usr/local/bin && sudo cp -rf cmake-3.28.1-linux-x86_64/share/* /usr/local/share && rm -rf cmake-3.28.1-linux-x86_64 sudo apt install -y ninja-build clang-17 clang-tools-17 flex libboost1.81-dev liblz4-dev libevent-dev liburing-dev libthrift-dev ln -s /usr/lib/llvm-17/bin/clang-scan-deps /usr/bin/clang-scan-deps ``` @@ -74,8 +75,8 @@ ln -s /usr/lib/llvm-17/bin/clang-scan-deps /usr/bin/clang-scan-deps ```shell git config --global --add safe.directory infinity cd infinity && mkdir build && cd build -export CC=/usr/bin/clang-18 -export CXX=/usr/bin/clang++-18 +export CC=/usr/bin/clang-17 +export CXX=/usr/bin/clang++-17 cmake -G Ninja .. ninja -j 12 ``` @@ -83,5 +84,5 @@ ninja -j 12 ### Step4 Start up Infinity server ```shell -.build/src/infinity_main +.build/src/infinity ``` \ No newline at end of file diff --git a/scripts/Dockerfile_build_environment_ubuntu_2004 b/scripts/Dockerfile_build_environment_ubuntu_2004 new file mode 100644 index 0000000000..c077b97e10 --- /dev/null +++ b/scripts/Dockerfile_build_environment_ubuntu_2004 @@ -0,0 +1,68 @@ +FROM ubuntu:focal + +RUN apt update && apt install -y ca-certificates \ + && sed -i 's@//.*archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list \ + && apt update + +# Install git wget unzip software-properties-common +RUN DEBIAN_FRONTEND=noninteractive apt install -y git wget unzip software-properties-common + +# Install cmake-3.28.1 +RUN wget https://cmake.org/files/v3.28/cmake-3.28.1-linux-x86_64.tar.gz \ + && tar zxvf cmake-3.28.1-linux-x86_64.tar.gz \ + && cp -rf cmake-3.28.1-linux-x86_64/bin/* /usr/local/bin \ + && cp -rf cmake-3.28.1-linux-x86_64/share/* /usr/local/share \ + && rm -rf cmake-3.28.1-linux-x86_64 + +# Install ninja-1.11.1 +RUN wget https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip \ + && unzip ninja-linux.zip && cp ninja /usr/local/bin && rm ninja + +# Add apt source for llvm-17 +RUN echo 'deb https://mirrors.tuna.tsinghua.edu.cn/llvm-apt/focal/ llvm-toolchain-focal-17 main' > /etc/apt/sources.list.d/llvm17.list \ + && wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc + +# Add apt source for g++-13 gcc-13 libstdc++-13-dev libboost1.81-dev liburing-dev +RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test \ + && add-apt-repository -y ppa:mhier/libboost-latest \ + && add-apt-repository -y ppa:rhansen/qemu + +# Install g++-13 clang-17 clang-tools-17 flex libboost1.81-dev liblz4-dev libevent-dev liburing-dev libthrift-dev +RUN apt update \ + && apt install -y g++-13 clang-17 clang-tools-17 flex libboost1.81-dev liblz4-dev libevent-dev liburing-dev libthrift-dev + +# Create a symbolic link for clang-scan-deps-17 +RUN ln -s /usr/lib/llvm-17/bin/clang-scan-deps /usr/bin/clang-scan-deps + +ENV CC=/usr/bin/clang-17 +ENV CXX=/usr/bin/clang++-17 + +# Install curl clang-tidy-17 clang-format-17 vim emacs-nox bison thrift-compiler postgresql-client python3-pip python3-venv tree rpm libgflags-dev +RUN apt install -y curl clang-tidy-17 clang-format-17 vim emacs-nox bison thrift-compiler postgresql-client python3-pip python3-venv tree rpm libgflags-dev +RUN ln -s /usr/bin/clang-format-17 /usr/bin/clang-format \ + && ln -s /usr/bin/clang-tidy-17 /usr/bin/clang-tidy \ + && ln -s /usr/bin/llvm-symbolizer-17 /usr/bin/llvm-symbolizer + +# rust, refers to https://rsproxy.cn/ +ENV RUSTUP_DIST_SERVER="https://rsproxy.cn" +ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" +ENV PATH=/root/.cargo/bin:$PATH +RUN wget -O rustup-init.sh https://rsproxy.cn/rustup-init.sh && sh rustup-init.sh -y +RUN mkdir -vp $HOME/.cargo && echo "[source.crates-io]" >> $HOME/.cargo/config \ + && echo "replace-with = 'rsproxy-sparse'" >> $HOME/.cargo/config \ + && echo "[source.rsproxy]" >> $HOME/.cargo/config \ + && echo "registry = 'https://rsproxy.cn/index/'" >> $HOME/.cargo/config \ + && echo "[source.rsproxy-sparse]" >> $HOME/.cargo/config \ + && echo "registry = 'sparse+https://rsproxy.cn/index/'" >> $HOME/.cargo/config \ + && echo "[registries.rsproxy]" >> $HOME/.cargo/config \ + && echo "index = 'https://rsproxy.cn/crates.io-index'" >> $HOME/.cargo/config \ + && echo "[net]" >> $HOME/.cargo/config \ + && echo "git-fetch-with-cli = true" >> $HOME/.cargo/config + +# sqllogictest +RUN cargo install sqllogictest-bin + +# Create a python virtual environment. Set PATH so that the shell activate this virtual environment automatically when entering a container from this image. +RUN python3 -m venv /usr/local/venv +ENV PATH="/usr/local/venv/bin:$PATH" + diff --git a/src/unit_test/storage/buffer/buffer_handle.cpp b/src/unit_test/storage/buffer/buffer_handle.cpp index d295e3afc3..3775f69b44 100644 --- a/src/unit_test/storage/buffer/buffer_handle.cpp +++ b/src/unit_test/storage/buffer/buffer_handle.cpp @@ -20,8 +20,26 @@ import buffer_manager; import data_file_worker; import buffer_obj; import infinity_exception; +import global_resource_usage; +import infinity_context; + +class BufferHandleTest : public BaseTest { + void SetUp() override { + BaseTest::SetUp(); + system("rm -rf /tmp/infinity/log /tmp/infinity/data /tmp/infinity/wal"); + infinity::GlobalResourceUsage::Init(); + std::shared_ptr config_path = nullptr; + infinity::InfinityContext::instance().Init(config_path); + } -class BufferHandleTest : public BaseTest {}; + void TearDown() override { + infinity::InfinityContext::instance().UnInit(); + EXPECT_EQ(infinity::GlobalResourceUsage::GetObjectCount(), 0); + EXPECT_EQ(infinity::GlobalResourceUsage::GetRawMemoryCount(), 0); + infinity::GlobalResourceUsage::UnInit(); + BaseTest::TearDown(); + } +}; TEST_F(BufferHandleTest, test1) { using namespace infinity; diff --git a/src/unit_test/storage/buffer/buffer_obj.cpp b/src/unit_test/storage/buffer/buffer_obj.cpp index 8352f23453..1947e349f2 100644 --- a/src/unit_test/storage/buffer/buffer_obj.cpp +++ b/src/unit_test/storage/buffer/buffer_obj.cpp @@ -22,9 +22,25 @@ import buffer_manager; import buffer_handle; import buffer_obj; import data_file_worker; +import global_resource_usage; +import infinity_context; class BufferObjTest : public BaseTest { - void SetUp() override { system("rm -rf /tmp/infinity"); } + void SetUp() override { + BaseTest::SetUp(); + system("rm -rf /tmp/infinity/log /tmp/infinity/data /tmp/infinity/wal"); + infinity::GlobalResourceUsage::Init(); + std::shared_ptr config_path = nullptr; + infinity::InfinityContext::instance().Init(config_path); + } + + void TearDown() override { + infinity::InfinityContext::instance().UnInit(); + EXPECT_EQ(infinity::GlobalResourceUsage::GetObjectCount(), 0); + EXPECT_EQ(infinity::GlobalResourceUsage::GetRawMemoryCount(), 0); + infinity::GlobalResourceUsage::UnInit(); + BaseTest::TearDown(); + } }; // Test status transfer of buffer handle. diff --git a/third_party/thrift/build_cmake/cmake/DefinePlatformSpecifc.cmake b/third_party/thrift/build_cmake/cmake/DefinePlatformSpecifc.cmake index 84409e6ff5..58130ca098 100644 --- a/third_party/thrift/build_cmake/cmake/DefinePlatformSpecifc.cmake +++ b/third_party/thrift/build_cmake/cmake/DefinePlatformSpecifc.cmake @@ -21,7 +21,7 @@ # include (NewPlatformDebug) # For Debug build types, default to "d"-suffix in library names. -set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix") +#set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix") # basic options foreach(lang IN ITEMS C CXX) diff --git a/tools/README.md b/tools/README.md index 0fe22e497b..7a9fdc01ac 100644 --- a/tools/README.md +++ b/tools/README.md @@ -14,6 +14,6 @@ ## start the test 1. run `sudo rm -rf /tmp/infinity/*` to remove all previous data. -2. run `infinity_main`, so the database is ready for test. +2. run `infinity`, so the database is ready for test. 3. run `python3 ./tools/sqllogictest.py` under **the root path of infinity project**. - This python script will first call `generate_big.py`, `generate_fvecs.py` and so on to generate big test file under coresponding directory, then call sqllogictest cli tool to run the test cases. The cli tools will compare the actual result of infinity_main and result in slt file. Difference will be marked **RED**. Only when all slt test is passed, the test is passed. + This python script will first call `generate_big.py`, `generate_fvecs.py` and so on to generate big test file under coresponding directory, then call sqllogictest cli tool to run the test cases. The cli tools will compare the actual result of infinity and result in slt file. Difference will be marked **RED**. Only when all slt test is passed, the test is passed.