Add the redis demo
Signed-off-by: yuanwu <yuan.wu@intel.com>
This commit is contained in:
parent
d0331bd397
commit
17464d3bbf
38
.github/workflows/demo_test.yml
vendored
38
.github/workflows/demo_test.yml
vendored
@ -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"
|
||||
|
16
demos/redis/README.md
Normal file
16
demos/redis/README.md
Normal file
@ -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
|
||||
|
4
demos/redis/benchmark.sh
Executable file
4
demos/redis/benchmark.sh
Executable file
@ -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
|
5
demos/redis/benchmark_glibc.sh
Executable file
5
demos/redis/benchmark_glibc.sh
Executable file
@ -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
|
39
demos/redis/download_and_build_redis.sh
Executable file
39
demos/redis/download_and_build_redis.sh
Executable file
@ -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
|
||||
|
38
demos/redis/download_and_build_redis_glibc.sh
Executable file
38
demos/redis/download_and_build_redis_glibc.sh
Executable file
@ -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
|
||||
|
20
demos/redis/run_occlum_redis.sh
Executable file
20
demos/redis/run_occlum_redis.sh
Executable file
@ -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 &
|
25
demos/redis/run_occlum_redis_glibc.sh
Executable file
25
demos/redis/run_occlum_redis_glibc.sh
Executable file
@ -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 &
|
Loading…
Reference in New Issue
Block a user