diff --git a/.github/workflows/demo_test.yml b/.github/workflows/demo_test.yml index d375669a..63e3fa07 100644 --- a/.github/workflows/demo_test.yml +++ b/.github/workflows/demo_test.yml @@ -646,6 +646,24 @@ jobs: sleep ${{ env.nap_time }}; docker exec ${{ github.job }} bash -c "curl -s http://localhost:8080/actuator/readiness | grep -v DOWN" + Netty_UT_test: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + with: + submodules: true + + - uses: ./.github/workflows/composite_action/sim + with: + container-name: ${{ github.job }} + build-envs: 'OCCLUM_RELEASE_BUILD=1' + + - name: Download and compile netty unit test demos + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/netty_ut && ./build.sh" + + - name: Run netty unit test demo + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/netty_ut && SGX_MODE=SIM ./run_netty_ut_jdk11.sh" + Bash_test: runs-on: ubuntu-20.04 steps: diff --git a/demos/netty_ut/README b/demos/netty_ut/README new file mode 100644 index 00000000..72e1d8e1 --- /dev/null +++ b/demos/netty_ut/README @@ -0,0 +1,13 @@ +# A Simple netty unit test usage demo + +This project demonstrates how to verify the completeness of Netty on Occlum. + +1. Download junit and related netty jars +``` +./build.sh +``` + +2. Run `netty unit test ` on Occlum +``` +./run_netty_ut_jdk11.sh +``` diff --git a/demos/netty_ut/build.sh b/demos/netty_ut/build.sh new file mode 100755 index 00000000..b6cc24e6 --- /dev/null +++ b/demos/netty_ut/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash +sudo apt-get update +sudo apt-get install openjdk-11-jdk +rm -rf /usr/lib/jvm/java-11-openjdk-amd64/lib/security/blacklisted.certs + +# Download netty testsuite, junit platform and related dependencies + +if [ ! -d "netty" ]; then + wget -i ./ut-jar.url -P ./netty +fi diff --git a/demos/netty_ut/netty-ut-jdk11.yaml b/demos/netty_ut/netty-ut-jdk11.yaml new file mode 100644 index 00000000..fe092f9e --- /dev/null +++ b/demos/netty_ut/netty-ut-jdk11.yaml @@ -0,0 +1,9 @@ +includes: + - base.yaml + - java-11-openjdk-amd64.yaml +targets: + # copy sofaboot jar + - target: /usr/lib + copy: + - dirs: + - ../netty diff --git a/demos/netty_ut/run_netty_ut_jdk11.sh b/demos/netty_ut/run_netty_ut_jdk11.sh new file mode 100755 index 00000000..35df8f15 --- /dev/null +++ b/demos/netty_ut/run_netty_ut_jdk11.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -e + +BLUE='\033[1;34m' +NC='\033[0m' + +check_dir_exist() { + dir=$1 + if [ ! -d ${dir} ];then + echo "Error: cannot stat file '${dir}'" + echo "Please see README and build it" + exit 1 + fi +} + +init_instance() { + # Init Occlum instance + rm -rf occlum_netty_ut_instance && occlum new occlum_netty_ut_instance + cd occlum_netty_ut_instance + new_json="$(jq '.resource_limits.user_space_size = "4680MB" | + .resource_limits.kernel_space_heap_size="64MB" | + .resource_limits.max_num_of_threads = 128 | + .process.default_heap_size = "512MB" | + .entry_points = [ "/usr/lib/jvm/java-11-openjdk-amd64/bin" ] | + .env.default = [ "LD_LIBRARY_PATH=/usr/lib/jvm/java-11-openjdk-amd64/lib/server:/usr/lib/jvm/java-11-openjdk-amd64/lib:/usr/lib/jvm/java-11-openjdk-amd64/../lib:/lib" ]' Occlum.json)" && \ + echo "${new_json}" > Occlum.json +} + +build_netty_ut() { + # Copy JVM and JAR file into Occlum instance and build + rm -rf image + copy_bom -f ../netty-ut-jdk11.yaml --root image --include-dir /opt/occlum/etc/template + occlum build +} + +run_netty_ut() { + jar_dir_path=./netty + check_dir_exist ${jar_dir_path} + + init_instance + build_netty_ut + echo -e "${BLUE}occlum run netty ut${NC}" + occlum run /usr/lib/jvm/java-11-openjdk-amd64/bin/java \ + -Xmx1048m -XX:-UseCompressedOops -XX:MaxMetaspaceSize=128m \ + -XX:ActiveProcessorCount=2 \ + -Dos.name=Linux \ + -jar /usr/lib/netty/junit-platform-console-standalone-1.8.2.jar \ + -cp /usr/lib/netty/netty-testsuite-4.1.51.Final.jar:/usr/lib/netty/netty-all-4.1.51.Final.jar:/usr/lib/netty/xz-1.5.jar:/usr/lib/netty/hamcrest-library-1.3.jar:/usr/lib/netty/logback-classic-1.1.7.jar \ + --scan-classpath > netty-test-heap512m.log +} + +run_netty_ut diff --git a/demos/netty_ut/ut-jar.url b/demos/netty_ut/ut-jar.url new file mode 100644 index 00000000..df1cf03e --- /dev/null +++ b/demos/netty_ut/ut-jar.url @@ -0,0 +1,6 @@ +https://repo1.maven.org/maven2/io/netty/netty-testsuite/4.1.51.Final/netty-testsuite-4.1.51.Final.jar +https://repo1.maven.org/maven2/io/netty/netty-all/4.1.51.Final/netty-all-4.1.51.Final.jar +https://repo1.maven.org/maven2/org/tukaani/xz/1.5/xz-1.5.jar +https://repo1.maven.org/maven2/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar +https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar +https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.8.2/junit-platform-console-standalone-1.8.2.jar