From 495c6695a9601d7da625733b462e6cfb4ba2b3ab Mon Sep 17 00:00:00 2001 From: "Zheng, Qi" Date: Wed, 18 May 2022 18:29:41 +0800 Subject: [PATCH] Add iperf2 demo --- .github/workflows/demo_test.yml | 25 ++++++++++++++++++++++ demos/iperf2/README.md | 28 ++++++++++++++++++++++++ demos/iperf2/build.sh | 38 +++++++++++++++++++++++++++++++++ demos/iperf2/iperf2.yaml | 9 ++++++++ 4 files changed, 100 insertions(+) create mode 100644 demos/iperf2/README.md create mode 100755 demos/iperf2/build.sh create mode 100644 demos/iperf2/iperf2.yaml diff --git a/.github/workflows/demo_test.yml b/.github/workflows/demo_test.yml index 2eca023a..65254c0c 100644 --- a/.github/workflows/demo_test.yml +++ b/.github/workflows/demo_test.yml @@ -707,6 +707,31 @@ jobs: run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/python/flask; curl --cacert flask.crt -X GET https://localhost:4996/customer/1" + iperf2_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: Build iperf2 + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/iperf2; SGX_MODE=SIM ./build.sh" + + - name: Start iperf2 server + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/iperf2/occlum_server; + occlum run /bin/iperf -s -p 6888 &" + + - name: Start iperf2 client + run: | + sleep ${{ 5 }}; + docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/iperf2/occlum_client; + occlum run /bin/iperf -c 127.0.0.1 -p 6888 -P 16" + Linux_LTP_test: runs-on: ubuntu-20.04 steps: diff --git a/demos/iperf2/README.md b/demos/iperf2/README.md new file mode 100644 index 00000000..05c5fb85 --- /dev/null +++ b/demos/iperf2/README.md @@ -0,0 +1,28 @@ +# Run iperf2 on Occlum + +[`Iperf2`](https://sourceforge.net/projects/iperf2/) is a popular tool for measuring Internet bandwidth performance. + +### Build +``` +./build.sh +``` + +If everything goes well, it generates two occlum instances. +``` +occlum_server +occlum_client +``` + +### Run the test + +* Start the iperf2 server +``` +cd occlum_server +occlum run /bin/iperf -s -p 6888 +``` + +* Start the iperf2 client with 16 threads +``` +cd occlum_client +occlum run /bin/iperf -c 127.0.0.1 -p 6888 -P 16 +``` diff --git a/demos/iperf2/build.sh b/demos/iperf2/build.sh new file mode 100755 index 00000000..44809748 --- /dev/null +++ b/demos/iperf2/build.sh @@ -0,0 +1,38 @@ +#! /bin/bash +set -e + +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +export IPERF_INSTALL_DIR=${script_dir}/iperf2-install + +function dl_and_build_iperf() +{ + rm -rf iperf2-* + rm -rf ${IPERF_INSTALL_DIR} + mkdir -p ${IPERF_INSTALL_DIR} + git clone https://git.code.sf.net/p/iperf2/code iperf2-code + pushd iperf2-code + ./configure + make install exec_prefix=${IPERF_INSTALL_DIR} + popd +} + +function build_occlum_instance() +{ + name=$1 + rm -rf ${name} + occlum new ${name} + pushd ${name} + copy_bom -f ../iperf2.yaml --root image --include-dir /opt/occlum/etc/template + + new_json="$(jq '.resource_limits.user_space_size = "1000MB" | + .resource_limits.max_num_of_threads = 64 ' Occlum.json)" && \ + echo "${new_json}" > Occlum.json + + occlum build + popd +} + +dl_and_build_iperf +build_occlum_instance occlum_server +build_occlum_instance occlum_client \ No newline at end of file diff --git a/demos/iperf2/iperf2.yaml b/demos/iperf2/iperf2.yaml new file mode 100644 index 00000000..23f9ef7c --- /dev/null +++ b/demos/iperf2/iperf2.yaml @@ -0,0 +1,9 @@ +includes: + - base.yaml +# bash +targets: + # copy iperf + - target: /bin + copy: + - files: + - ${IPERF_INSTALL_DIR}/bin/iperf \ No newline at end of file