From: Ashish Jain Date: Fri, 7 Nov 2025 10:39:12 +0000 (+0000) Subject: Add scripts for building and destroying testing env X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=c036c34a4b8c38541916782f78526ae629a0e097;p=aiml-fw%2Fawmf%2Fmodelmgmtservice.git Add scripts for building and destroying testing env Adding the following scripts: 1. setup_local_testing_env.sh: Which Deploys kind cluster, mocks, postgresql, leofs-secret, mme componenet for local-testing. 2. teardown_local_testing_env.sh: It uninstalls the mme component and deletes the kind-cluster. Issue-Id: AIMLFW-310 Change-Id: Ibd66b0a9bd357ec693c66261ff0a7e62c18092a2 Signed-off-by: ashishj1729 --- diff --git a/component-testing/local-testing/kind.yaml b/component-testing/local-testing/kind.yaml new file mode 100644 index 0000000..e7fc0f9 --- /dev/null +++ b/component-testing/local-testing/kind.yaml @@ -0,0 +1,22 @@ +# ================================================================================== +# +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + image: kindest/node:v1.32.0 \ No newline at end of file diff --git a/component-testing/local-testing/setup_local_testing_env.sh b/component-testing/local-testing/setup_local_testing_env.sh new file mode 100644 index 0000000..64daa9c --- /dev/null +++ b/component-testing/local-testing/setup_local_testing_env.sh @@ -0,0 +1,76 @@ +# ================================================================================== +# +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== + +echo -e "The following script will setup the local testing environment which includes: \nCreating kind Cluster, deploying modelmgmtservice component & mocks" +# Prerequisties +# 1. Docker + +CLUSTER_NAME="testing" + +echo "Step-1: Installing & Creating Kind Cluster" +# For AMD64 / x86_64 +[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.30.0/kind-linux-amd64 +# For ARM64 +[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.30.0/kind-linux-arm64 +chmod +x ./kind +sudo mv ./kind /usr/local/bin/kind + +kind create cluster --config kind.yaml --name ${CLUSTER_NAME} +kubectl wait --for=condition=Ready nodes --all --timeout=120s --context kind-${CLUSTER_NAME} + +echo "Step-2: Building Components-Image" +docker build -t modelmgmtservice:latest ../../. +kind load docker-image modelmgmtservice:latest --name ${CLUSTER_NAME} + +echo "Step-3: Deploying Patches, Hacks and mocks" +kubectl create namespace traininghost +echo "Installing PostgreSQL (tm-db) in namespace traininghost..." +helm repo add bitnami https://charts.bitnami.com/bitnami +helm repo update + +helm install tm-db bitnami/postgresql \ +--set image.repository="bitnamilegacy/postgresql" \ +--set image.tag="17.6.0" \ +--set global.security.allowInsecureImages=true \ +--set auth.postgresPassword=postgres \ +--set primary.persistence.enabled=false \ +--namespace traininghost + +echo "Waiting for PostgreSQL pod to be ready..." +kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=postgresql -n traininghost --timeout=300s + +echo "PostgreSQL installation complete." +kubectl get pods -n traininghost -l app.kubernetes.io/name=postgresql + +echo "Creating mock secret: leofs-secret" + kubectl create secret generic leofs-secret \ + --from-literal=password="dummy-s3-secret-key" \ + -n traininghost --dry-run=client -o yaml | kubectl apply -f - + + +echo "Step-4: Setup Helm & Deploy dataextraction component" +PREV_WORK_DIR=$(pwd) +cd /tmp/ +git clone https://github.com/o-ran-sc/aiml-fw-aimlfw-dep.git +cd aiml-fw-aimlfw-dep +./bin/install_common_templates_to_helm.sh + +helm dep up helm/modelmgmtservice +helm install mme helm/modelmgmtservice -f RECIPE_EXAMPLE/example_recipe_local_images_oran_latest.yaml --kube-context kind-${CLUSTER_NAME} + +cd $PREV_WORK_DIR \ No newline at end of file diff --git a/component-testing/local-testing/teardown_local_testing_env.sh b/component-testing/local-testing/teardown_local_testing_env.sh new file mode 100644 index 0000000..3a1c3fc --- /dev/null +++ b/component-testing/local-testing/teardown_local_testing_env.sh @@ -0,0 +1,27 @@ +# ================================================================================== +# +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== + +echo -e "The following script will destroy the local testing environment which includes: \nDeleting kind Cluster, undeploying modelmgmtservice component & mocks" + +CLUSTER_NAME="testing" + +echo "Step-1: Uninstall modelmgmtservice component" +helm uninstall mme --kube-context kind-${CLUSTER_NAME} + +echo "Step-2: Delete kind cluster" +kind delete cluster --name ${CLUSTER_NAME} \ No newline at end of file