csharp-e2e.sh
1 #!/bin/bash 2 # Copyright 2026 Alibaba Group Holding Ltd. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -euxo pipefail 17 18 TAG=${TAG:-latest} 19 20 REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" 21 22 # build execd image locally (context must include internal/) 23 docker build -f components/execd/Dockerfile -t opensandbox/execd:local "${REPO_ROOT}" 24 25 # prepare required images from registry 26 docker pull opensandbox/code-interpreter:${TAG} 27 echo "-------- Eval test images --------" 28 docker images 29 30 # prepare hostpath volume for e2e test 31 mkdir -p /tmp/opensandbox-e2e/host-volume-test 32 mkdir -p /tmp/opensandbox-e2e/logs 33 echo "opensandbox-e2e-marker" > /tmp/opensandbox-e2e/host-volume-test/marker.txt 34 chmod -R 755 /tmp/opensandbox-e2e 35 36 # prepare Docker named volume for pvc e2e test 37 docker volume rm opensandbox-e2e-pvc-test 2>/dev/null || true 38 docker volume create opensandbox-e2e-pvc-test 39 docker run --rm -v opensandbox-e2e-pvc-test:/data alpine sh -c "\ 40 echo 'pvc-marker-data' > /data/marker.txt && \ 41 mkdir -p /data/datasets/train && \ 42 echo 'pvc-subpath-marker' > /data/datasets/train/marker.txt" 43 echo "-------- CSHARP E2E test logs for execd --------" > /tmp/opensandbox-e2e/logs/execd.log 44 45 # setup server 46 cd server 47 : > server.log 48 export OPENSANDBOX_INSECURE_SERVER=YES 49 (uv sync && uv run python -m opensandbox_server.main) > server.log 2>&1 & 50 cd .. 51 52 # wait for server 53 sleep 10 54 55 # test env for C# fixture 56 export OPENSANDBOX_TEST_DOMAIN="localhost:8080" 57 export OPENSANDBOX_TEST_PROTOCOL="http" 58 export OPENSANDBOX_TEST_API_KEY="" 59 export OPENSANDBOX_SANDBOX_DEFAULT_IMAGE="opensandbox/code-interpreter:${TAG}" 60 61 mkdir -p tests/csharp/build/test-results 62 dotnet restore "tests/csharp/OpenSandbox.E2ETests/OpenSandbox.E2ETests.csproj" 63 dotnet test "tests/csharp/OpenSandbox.E2ETests/OpenSandbox.E2ETests.csproj" \ 64 --configuration Release \ 65 --no-restore \ 66 --results-directory "tests/csharp/build/test-results" \ 67 --logger "trx;LogFileName=csharp-e2e.trx"