diff --git a/.github/workflows/hw_mode_test.yml b/.github/workflows/hw_mode_test.yml index 72670cdb..0eeec5b1 100644 --- a/.github/workflows/hw_mode_test.yml +++ b/.github/workflows/hw_mode_test.yml @@ -922,6 +922,52 @@ jobs: if: ${{ always() }} run: docker stop ${{ env.CONTAINER_NAME }} + MySQL_test: + timeout-minutes: 180 + if: github.event_name == 'push' || ${{ contains(github.event.pull_request.labels.*.name, 'SGX-hardware-test-required') }} + runs-on: ${{ matrix.self_runner }} + strategy: + matrix: + self_runner: [[self-hosted, SGX2-HW]] + + steps: + - name: Clean before running + run: | + sudo chown -R ${{ secrets.CI_ADMIN }} "${{ github.workspace }}" + + - name: Checkout code + if: github.event_name == 'push' + uses: actions/checkout@v2 + with: + submodules: true + + - name: Checkout code from fork + if: ${{ contains(github.event.pull_request.labels.*.name, 'SGX-hardware-test-required') }} + uses: actions/checkout@v2 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + submodules: true + + - uses: ./.github/workflows/composite_action/hw + with: + container-name: ${{ github.job }} + build-envs: 'OCCLUM_RELEASE_BUILD=1' + + - name: Download and build mysql + run: docker exec ${{ env.CONTAINER_NAME }} bash -c "cd /root/occlum/demos/mysql && ./dl_and_build_mysql.sh" + + - name: Run mysql server + run: docker exec ${{ env.CONTAINER_NAME }} bash -c "cd /root/occlum/demos/mysql && ./run_mysql_server.sh" & + + - name: Run mysql benchmarks + run: | + sleep 120; + docker exec ${{ env.CONTAINER_NAME }} bash -c "cd /root/occlum/demos/mysql && ./run_benchmarks.sh" + + - name: Clean the environment + if: ${{ always() }} + run: docker stop ${{ env.CONTAINER_NAME }} + Stress_test_with_musl: timeout-minutes: 360 if: github.event_name == 'schedule' diff --git a/demos/README.md b/demos/README.md index 76f240e6..ec7caf1c 100644 --- a/demos/README.md +++ b/demos/README.md @@ -21,6 +21,7 @@ This set of demos shows how real-world apps can be easily run inside SGX enclave * [font](font/font_support_for_java): A demo of supporting font with Java. * [grpc](grpc/): A client and server communicating through [gRPC](https://grpc.io), containing [glibc-supported demo](grpc/grpc_glibc) and [musl-supported demo](grpc/grpc_musl). * [https_server](https_server/): A HTTPS file server based on [Mongoose Embedded Web Server Library](https://github.com/cesanta/mongoose). +* [mysql](mysql/): A demo of [MySQL](https://www.mysql.com/). * [openvino](openvino/) A benchmark of [OpenVINO Inference Engine](https://docs.openvinotoolkit.org/2019_R3/_docs_IE_DG_inference_engine_intro.html). * [pytorch](pytorch/): Demos of standalone and distributed [PyTorch](https://pytorch.org/). * [redis](redis/): A demo of [Redis](https://redis.io). diff --git a/demos/mysql/dl_and_build_mysql.sh b/demos/mysql/dl_and_build_mysql.sh index 542e47dd..e58f8c27 100755 --- a/demos/mysql/dl_and_build_mysql.sh +++ b/demos/mysql/dl_and_build_mysql.sh @@ -39,10 +39,36 @@ patch -s -p0 < apply-mysql-to-occlum.patch pushd mysql_src mkdir bld && cd bld -cmake -j$(nproc) .. -DCMAKE_CXX_FLAGS="-fpic -pie" -DCMAKE_C_FLAGS="-fpic -pie" - -CC="-fpic -pie" CXX="-fpic -pie" make -j$(nproc) +cmake -j$(nproc) .. \ + -DCMAKE_CXX_FLAGS="-fpic -pie" -DCMAKE_C_FLAGS="-fpic -pie" \ + -DWITH_ARCHIVE_STORAGE_ENGINE=0 \ + -DWITH_EXAMPLE_STORAGE_ENGINE=0 \ + -DWITH_FEDERATED_STORAGE_ENGINE=0 \ + -DDISABLE_PSI_COND=1 \ + -DDISABLE_PSI_DATA_LOCK=1 \ + -DDISABLE_PSI_ERROR=1 \ + -DDISABLE_PSI_FILE=1 \ + -DDISABLE_PSI_IDLE=1 \ + -DDISABLE_PSI_MEMORY=1 \ + -DDISABLE_PSI_METADATA=1 \ + -DDISABLE_PSI_MUTEX=1 \ + -DDISABLE_PSI_PS=1 \ + -DDISABLE_PSI_RWLOCK=1 \ + -DDISABLE_PSI_SOCKET=1 \ + -DDISABLE_PSI_SP=1 \ + -DDISABLE_PSI_STAGE=0 \ + -DDISABLE_PSI_STATEMENT=1 \ + -DDISABLE_PSI_STATEMENT_DIGEST=1 \ + -DDISABLE_PSI_TABLE=1 \ + -DDISABLE_PSI_THREAD=0 \ + -DDISABLE_PSI_TRANSACTION=1 \ + -DWITH_MYSQLX=0 \ + -DWITH_NDB_JAVA=0 \ + -DWITH_RAPID=0 \ + -DWITH_ROUTER=0 \ + -DWITH_UNIT_TESTS=0 +make -j4 make install -j$(nproc) cd .. diff --git a/demos/mysql/my.cnf b/demos/mysql/my.cnf index 6b905c62..d7ea8cc8 100644 --- a/demos/mysql/my.cnf +++ b/demos/mysql/my.cnf @@ -11,7 +11,6 @@ port = 3306 bind-address = 127.0.0.1 skip-networking = 0 skip_ssl = 0 -mysqlx = 0 wait_timeout = 60 interactive_timeout = 120 diff --git a/demos/mysql/mysql.yaml b/demos/mysql/mysql.yaml index ce524c6b..50c9cc40 100644 --- a/demos/mysql/mysql.yaml +++ b/demos/mysql/mysql.yaml @@ -27,7 +27,7 @@ targets: - target: /opt/occlum/glibc/lib copy: - files: - - /usr/local/mysql/lib/mysqlrouter/private/libprotobuf-lite.so.3.19.4 + - ../mysql_src/bld/library_output_directory/libprotobuf-lite.so.3.19.4 - target: / copy: - files: diff --git a/demos/mysql/run_benchmarks.sh b/demos/mysql/run_benchmarks.sh new file mode 100755 index 00000000..a48645ce --- /dev/null +++ b/demos/mysql/run_benchmarks.sh @@ -0,0 +1,63 @@ +#!/bin/bash +set -e + +GREEN='\033[1;32m' +NC='\033[0m' + +echo -e "${GREEN}Install sysbench first${NC}" + +# We use sysbench to test mysql, need to install it first +apt-get install -y sysbench + +function run_benchmarks() +{ + WORKLOADS=("oltp_point_select" "oltp_write_only" "oltp_read_write") + for item in ${WORKLOADS[@]} + do + echo "start to prepare for $item" + sleep 3 + sysbench /usr/share/sysbench/$item.lua\ + --mysql-host='127.0.0.1'\ + --mysql-user=root\ + --time=60\ + --mysql-db=mysql\ + --tables=3\ + --table_size=100000\ + --rand-type=pareto\ + prepare + + echo "start to run $item" + sleep 3 + sysbench /usr/share/sysbench/$item.lua\ + --mysql-host='127.0.0.1'\ + --mysql-user=root\ + --time=60\ + --mysql-db=mysql\ + --tables=3\ + --table_size=100000\ + --rand-type=pareto\ + --threads=2\ + --report-interval=10\ + run + + echo "start to cleanup $item" + sleep 3 + sysbench /usr/share/sysbench/$item.lua\ + --mysql-host='127.0.0.1'\ + --mysql-user=root\ + --time=60\ + --mysql-db=mysql\ + --tables=3\ + --table_size=100000\ + --rand-type=pareto\ + --threads=2\ + --report-interval=10\ + cleanup + done + + echo "all done" +} + +echo -e "${GREEN}Run benchmarks using sysbench${NC}" + +run_benchmarks diff --git a/demos/mysql/run_mysql_server.sh b/demos/mysql/run_mysql_server.sh index 2265cd72..a72f3f29 100755 --- a/demos/mysql/run_mysql_server.sh +++ b/demos/mysql/run_mysql_server.sh @@ -14,8 +14,8 @@ MYSQLD=mysqld rm -rf occlum_instance && occlum new occlum_instance pushd occlum_instance -new_json="$(jq '.resource_limits.user_space_size = "3500MB" | - .resource_limits.kernel_space_heap_size ="3000MB" | +new_json="$(jq '.resource_limits.user_space_size = "8000MB" | + .resource_limits.kernel_space_heap_size ="1000MB" | .resource_limits.max_num_of_threads = 96' Occlum.json)" && \ echo "${new_json}" > Occlum.json