/ scripts / python-k8s-e2e.sh
python-k8s-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  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
19  # shellcheck source=common/kubernetes-e2e.sh
20  source "${SCRIPT_DIR}/common/kubernetes-e2e.sh"
21  
22  REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
23  
24  KIND_CLUSTER="${KIND_CLUSTER:-opensandbox-e2e}"
25  KIND_K8S_VERSION="${KIND_K8S_VERSION:-v1.30.4}"
26  KUBECONFIG_PATH="${KUBECONFIG_PATH:-/tmp/opensandbox-kind-kubeconfig}"
27  E2E_NAMESPACE="${E2E_NAMESPACE:-opensandbox-e2e}"
28  SERVER_NAMESPACE="${SERVER_NAMESPACE:-opensandbox-system}"
29  PVC_NAME="${PVC_NAME:-opensandbox-e2e-pvc-test}"
30  PV_NAME="${PV_NAME:-opensandbox-e2e-pv-test}"
31  CONTROLLER_IMG="${CONTROLLER_IMG:-opensandbox/controller:e2e-local}"
32  SERVER_IMG="${SERVER_IMG:-opensandbox/server:e2e-local}"
33  EXECD_IMG="${EXECD_IMG:-opensandbox/execd:e2e-local}"
34  EGRESS_IMG="${EGRESS_IMG:-opensandbox/egress:e2e-local}"
35  SERVER_RELEASE="${SERVER_RELEASE:-opensandbox-server}"
36  SERVER_VALUES_FILE="${SERVER_VALUES_FILE:-/tmp/opensandbox-server-values.yaml}"
37  PORT_FORWARD_LOG="${PORT_FORWARD_LOG:-/tmp/opensandbox-server-port-forward.log}"
38  SANDBOX_TEST_IMAGE="${SANDBOX_TEST_IMAGE:-ubuntu:latest}"
39  LIFECYCLE_LOCAL_PORT="${LIFECYCLE_LOCAL_PORT:-8080}"
40  
41  SERVER_IMG_REPOSITORY="${SERVER_IMG%:*}"
42  SERVER_IMG_TAG="${SERVER_IMG##*:}"
43  
44  k8s_e2e_export_kubeconfig
45  k8s_e2e_setup_kind_and_controller
46  k8s_e2e_build_runtime_images
47  k8s_e2e_kind_load_runtime_images
48  k8s_e2e_apply_pvc_and_seed
49  k8s_e2e_write_server_helm_values
50  k8s_e2e_helm_install_server
51  
52  kubectl port-forward -n "${SERVER_NAMESPACE}" svc/opensandbox-server "${LIFECYCLE_LOCAL_PORT}:80" >"${PORT_FORWARD_LOG}" 2>&1 &
53  PORT_FORWARD_PID=$!
54  trap 'kill "${PORT_FORWARD_PID}" >/dev/null 2>&1 || true' EXIT
55  
56  k8s_e2e_wait_http_ok "http://127.0.0.1:${LIFECYCLE_LOCAL_PORT}/health"
57  
58  export OPENSANDBOX_TEST_DOMAIN="localhost:${LIFECYCLE_LOCAL_PORT}"
59  export OPENSANDBOX_TEST_PROTOCOL="http"
60  export OPENSANDBOX_TEST_API_KEY="kubernetes-e2e"
61  export OPENSANDBOX_SANDBOX_DEFAULT_IMAGE="${SANDBOX_TEST_IMAGE}"
62  export OPENSANDBOX_E2E_RUNTIME="kubernetes"
63  export OPENSANDBOX_TEST_USE_SERVER_PROXY="true"
64  export OPENSANDBOX_TEST_PVC_NAME="${PVC_NAME}"
65  
66  k8s_e2e_export_sandbox_resource_env
67  
68  k8s_e2e_generate_sdk_and_run_kubernetes_mini