/ scripts / python-e2e.sh
python-e2e.sh
 1  #!/bin/bash
 2  # Copyright 2025 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  # This script verifies that required files contain the Apache 2.0 license header.
17  # It scans tracked source files and fails with a list of violations if any header
18  # is missing.
19  
20  set -euxo pipefail
21  
22  TAG=${TAG:-latest}
23  
24  REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
25  
26  # build execd image locally (context must include internal/)
27  docker build -f components/execd/Dockerfile -t opensandbox/execd:local "${REPO_ROOT}"
28  
29  # prepare required images from registry
30  docker pull opensandbox/code-interpreter:${TAG}
31  echo "-------- Eval test images --------"
32  docker images
33  
34  # prepare hostpath volume for e2e test
35  mkdir -p /tmp/opensandbox-e2e/host-volume-test
36  mkdir -p /tmp/opensandbox-e2e/logs
37  echo "opensandbox-e2e-marker" > /tmp/opensandbox-e2e/host-volume-test/marker.txt
38  chmod -R 755 /tmp/opensandbox-e2e
39  
40  # prepare Docker named volume for pvc e2e test
41  docker volume rm opensandbox-e2e-pvc-test 2>/dev/null || true
42  docker volume create opensandbox-e2e-pvc-test
43  # seed the named volume with a marker file and subpath test data via a temporary container
44  docker run --rm -v opensandbox-e2e-pvc-test:/data alpine sh -c "\
45    echo 'pvc-marker-data' > /data/marker.txt && \
46    mkdir -p /data/datasets/train && \
47    echo 'pvc-subpath-marker' > /data/datasets/train/marker.txt"
48  echo "-------- PYTHON E2E test logs for execd --------" > /tmp/opensandbox-e2e/logs/execd.log
49  
50  # setup server
51  cd server
52  export OPENSANDBOX_INSECURE_SERVER=YES
53  uv sync && uv run python -m opensandbox_server.main > server.log 2>&1 &
54  cd ..
55  
56  # wait for server
57  sleep 10
58  
59  # build local api
60  cd sdks/sandbox/python && make generate-api
61  cd ../../..
62  
63  # run real python e2e
64  cd tests/python
65  uv sync --all-extras --refresh && make test