diff --git a/.github/workflows/demo_test.yml b/.github/workflows/demo_test.yml index 0574e660..a5c28fde 100644 --- a/.github/workflows/demo_test.yml +++ b/.github/workflows/demo_test.yml @@ -63,7 +63,6 @@ jobs: run: docker exec language_support_test bash -c "cd /root/occlum/demos/golang/web_server && occlum-go get -u -v github.com/gin-gonic/gin; occlum-go build -o web_server ./web_server.go; SGX_MODE=SIM ./run_golang_on_occlum.sh" & - - name: Curl test run: | sleep ${{ env.nap_time }}; @@ -408,3 +407,40 @@ jobs: - name: Check result run: docker exec python_support_test bash -c "cd /root/occlum/demos/python/occlum_instance; cat smvlight.dat" + + # Redis test + Redis_support_test: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v1 + with: + submodules: true + + - name: Get occlum version + run: echo "OCCLUM_VERSION=$(grep "Version =" src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV + + - name: Create container + run: docker run -itd --name=redis_support_test -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:${{ env.OCCLUM_VERSION }}-ubuntu18.04 + + - name: Build dependencies + run: docker exec redis_support_test bash -c "cd /root/occlum; make submodule" + + - name: Make install + run: docker exec redis_support_test bash -c "cd /root/occlum; OCCLUM_RELEASE_BUILD=1 make install" + + - name: download and build redis + run: docker exec redis_support_test bash -c "cd /root/occlum/demos/redis; ./download_and_build_redis.sh" + + - name: Run redis benchmark + run: docker exec redis_support_test bash -c "cd /root/occlum/demos/redis; SGX_MODE=SIM ./benchmark.sh" + + - name: Restart the container + run: | + sleep ${{ env.nap_time }}; + docker restart redis_support_test + + - name: download and build redis with glibc + run: docker exec redis_support_test bash -c "cd /root/occlum/demos/redis; ./download_and_build_redis_glibc.sh" + + - name: Run redis benchmark + run: docker exec redis_support_test bash -c "cd /root/occlum/demos/redis; SGX_MODE=SIM ./benchmark_glibc.sh" diff --git a/demos/redis/README.md b/demos/redis/README.md new file mode 100644 index 00000000..ae77fe46 --- /dev/null +++ b/demos/redis/README.md @@ -0,0 +1,16 @@ +1.Download and build + occlum-gcc: + ./download_and_build_redis.sh + glibc: + ./download_and_build_redis_glibc.sh +2. Run redis + occlum-gcc: + ./run_occlum_redis.sh + glibc: + ./run_occlum_redis_glibc.sh +3. Benchmark + occlum-gcc: + ./benchmark.sh + glibc: + ./benchmark_glibc.sh + diff --git a/demos/redis/benchmark.sh b/demos/redis/benchmark.sh new file mode 100755 index 00000000..e28cb17a --- /dev/null +++ b/demos/redis/benchmark.sh @@ -0,0 +1,4 @@ +./run_occlum_redis.sh & +sleep 20 +echo 'start client' +/usr/local/occlum/x86_64-linux-musl/bin/redis-benchmark -n 1000 diff --git a/demos/redis/benchmark_glibc.sh b/demos/redis/benchmark_glibc.sh new file mode 100755 index 00000000..88dfb697 --- /dev/null +++ b/demos/redis/benchmark_glibc.sh @@ -0,0 +1,5 @@ +#run the occlum benchmark +./run_occlum_redis_glibc.sh & +sleep 20 +echo 'start client' +/usr/local/redis/bin/redis-benchmark -n 1000 diff --git a/demos/redis/download_and_build_redis.sh b/demos/redis/download_and_build_redis.sh new file mode 100755 index 00000000..31309588 --- /dev/null +++ b/demos/redis/download_and_build_redis.sh @@ -0,0 +1,39 @@ +#!/bin/bash +PREFIX=/usr/local/occlum/x86_64-linux-musl +set -e + + +build_openssl() { + # 1. Download and install OpenSSL 1.1.1 + rm -rf deps && mkdir -p deps/openssl + pushd deps/openssl + git clone https://github.com/openssl/openssl . + git checkout tags/OpenSSL_1_1_1 -b OpenSSL_1_1_1 + CC=occlum-gcc ./config \ + --prefix=$PREFIX \ + --openssldir=/usr/local/occlum/ssl \ + --with-rand-seed=rdcpu \ + no-zlib no-async no-tests + make -j `getconf _NPROCESSORS_ONLN` + sudo make install + popd +} + +# Build redis +build_redis() { + rm -rf redis_src && mkdir redis_src + pushd redis_src + git clone https://github.com/redis/redis.git . + git checkout -b 6.0.9 6.0.9 + export CC=/opt/occlum/toolchains/gcc/bin/occlum-gcc + export CXX=/opt/occlum/toolchains/gcc/bin/occlum-g++ + make -j `getconf _NPROCESSORS_ONLN` BUILD_TLS=yes + make PREFIX=$PREFIX install + popd +} + +# Tell CMake to search for packages in Occlum toolchain's directory only +export PKG_CONFIG_LIBDIR=$PREFIX/lib +build_openssl +build_redis + diff --git a/demos/redis/download_and_build_redis_glibc.sh b/demos/redis/download_and_build_redis_glibc.sh new file mode 100755 index 00000000..6c3fe323 --- /dev/null +++ b/demos/redis/download_and_build_redis_glibc.sh @@ -0,0 +1,38 @@ +#!/bin/bash +PREFIX=/usr/local/redis/ +OCCLUM_LINKER=/opt/occlum/glibc/lib/ld-linux-x86-64.so.2 +set -e +rm -rf $PREFIX + + +build_openssl() { + # 1. Download and install OpenSSL 1.1.1 + rm -rf deps && mkdir -p deps/openssl + pushd deps/openssl + git clone https://github.com/openssl/openssl . + git checkout tags/OpenSSL_1_1_1 -b OpenSSL_1_1_1 + ./config \ + --openssldir=/usr/local/occlum/ssl \ + --with-rand-seed=rdcpu \ + no-zlib no-async no-tests + make -j `getconf _NPROCESSORS_ONLN` + sudo make install + popd +} + +# Build redis +build_redis() { + rm -rf redis_src && mkdir redis_src + pushd redis_src + git clone https://github.com/redis/redis.git . + git checkout -b 6.0.9 6.0.9 + make -j `getconf _NPROCESSORS_ONLN` BUILD_TLS=yes + make PREFIX=$PREFIX install + popd +} + +# Tell CMake to search for packages in Occlum toolchain's directory only +export PKG_CONFIG_LIBDIR=$PREFIX/lib +build_openssl +build_redis + diff --git a/demos/redis/run_occlum_redis.sh b/demos/redis/run_occlum_redis.sh new file mode 100755 index 00000000..474e381f --- /dev/null +++ b/demos/redis/run_occlum_redis.sh @@ -0,0 +1,20 @@ +#!/bin/bash +occlum_dir=/usr/local/occlum/x86_64-linux-musl +set -e + +# 1. Init Occlum Workspace +rm -rf occlum_instance +occlum new occlum_instance +cd occlum_instance +new_json="$(jq '.resource_limits.user_space_size = "320MB" | + .process.default_mmap_size = "256MB"' Occlum.json)" && \ +echo "${new_json}" > Occlum.json + +# 2. Copy files into Occlum Workspace and Build +cp $occlum_dir/bin/redis* image/bin +cp $occlum_dir/lib/libssl* image/lib +cp $occlum_dir/lib/libcrypto* image/lib +#occlum build +occlum build +# 3. Run redis server +occlum run /bin/redis-server --save "" --appendonly no & diff --git a/demos/redis/run_occlum_redis_glibc.sh b/demos/redis/run_occlum_redis_glibc.sh new file mode 100755 index 00000000..331884a3 --- /dev/null +++ b/demos/redis/run_occlum_redis_glibc.sh @@ -0,0 +1,25 @@ +#!/bin/bash +redis_dir=/usr/local/redis/ +occlum_glibc=/opt/occlum/glibc/lib/ +set -e + +# 1. Init Occlum Workspace +rm -rf occlum_instance +occlum new occlum_instance +cd occlum_instance +new_json="$(jq '.resource_limits.user_space_size = "320MB" | + .process.default_mmap_size = "256MB"' Occlum.json)" && \ +echo "${new_json}" > Occlum.json + +# 2. Copy files into Occlum Workspace and Build +cp $redis_dir/bin/redis* image/bin +cp /usr/local/bin/openssl* image/bin +cp /usr/local/lib/libssl* image/$occlum_glibc +cp /usr/local/lib/libcrypto* image/$occlum_glibc +cp $occlum_glibc/libdl.so.2 image/$occlum_glibc +cp $occlum_glibc/librt.so.1 image/$occlum_glibc +cp $occlum_glibc/libm.so.6 image/$occlum_glibc +#occlum build +occlum build +# 3. Run redis server +occlum run /bin/redis-server --save "" --appendonly no &