From 59a67bde707893c120e254d0c0789cf596f11632 Mon Sep 17 00:00:00 2001 From: Mohan E Date: Thu, 19 Sep 2024 12:48:36 +0530 Subject: [PATCH 1/3] [MOSIP-35421] Added values.yaml file for admin uitestrig Signed-off-by: Mohanraj209 --- deploy/admin-uitestrig/README.md | 10 ++++++++++ deploy/admin-uitestrig/values.yaml | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 deploy/admin-uitestrig/README.md create mode 100644 deploy/admin-uitestrig/values.yaml diff --git a/deploy/admin-uitestrig/README.md b/deploy/admin-uitestrig/README.md new file mode 100644 index 00000000..4bd7d962 --- /dev/null +++ b/deploy/admin-uitestrig/README.md @@ -0,0 +1,10 @@ +# ADMIN UITESTRIG + +This directory contains `values.yaml` file which contains the latest admin uitestrig release changes with latest released Docker image and tag. + +## TL;DR + +```console +$ helm repo add mosip https://mosip.github.io +$ helm install my-release mosip/uitestrig -f values.yaml +``` diff --git a/deploy/admin-uitestrig/values.yaml b/deploy/admin-uitestrig/values.yaml new file mode 100644 index 00000000..4e71f12e --- /dev/null +++ b/deploy/admin-uitestrig/values.yaml @@ -0,0 +1,7 @@ +modules: + - name: adminui + enabled: true + image: + registry: docker.io + repository: mosipqa/admintest + tag: develop From ff506b7aeedced9340dda983b4a4b79e0794dd4c Mon Sep 17 00:00:00 2001 From: Mohan E Date: Wed, 23 Oct 2024 17:15:54 +0530 Subject: [PATCH 2/3] [MOSIP-35421] Moved installation scripts of admin uitestrig. Signed-off-by: Mohanraj209 --- deploy/{ => admin-ui}/README.md | 11 ++++ deploy/{ => admin-ui}/copy_cm.sh | 0 deploy/{ => admin-ui}/delete.sh | 0 deploy/{ => admin-ui}/install.sh | 6 +- deploy/{ => admin-ui}/restart.sh | 0 deploy/admin-uitestrig/README.md | 34 +++++++++-- deploy/admin-uitestrig/delete.sh | 30 ++++++++++ deploy/admin-uitestrig/install.sh | 97 +++++++++++++++++++++++++++++++ deploy/copy_cm_func.sh | 33 +++++++++++ 9 files changed, 203 insertions(+), 8 deletions(-) rename deploy/{ => admin-ui}/README.md (96%) rename deploy/{ => admin-ui}/copy_cm.sh (100%) rename deploy/{ => admin-ui}/delete.sh (100%) rename deploy/{ => admin-ui}/install.sh (87%) rename deploy/{ => admin-ui}/restart.sh (100%) create mode 100644 deploy/admin-uitestrig/delete.sh create mode 100644 deploy/admin-uitestrig/install.sh create mode 100755 deploy/copy_cm_func.sh diff --git a/deploy/README.md b/deploy/admin-ui/README.md similarity index 96% rename from deploy/README.md rename to deploy/admin-ui/README.md index 23d6e4aa..7e15a60e 100644 --- a/deploy/README.md +++ b/deploy/admin-ui/README.md @@ -4,6 +4,17 @@ ``` ./install.sh ``` + +## Restart +``` +./restart.sh +``` + +## Delete +``` +./delete.sh +``` + ## Admin proxy Admin service accesses other services like Materdata and Keymanager and currently there is only one URL that is used to connect to both these services. This will get fixed in future versions, but as a an interim solution, Admin Proxy docker has been created, which is basically an Nginx proxy connecting to the above services with these URLs: ``` diff --git a/deploy/copy_cm.sh b/deploy/admin-ui/copy_cm.sh similarity index 100% rename from deploy/copy_cm.sh rename to deploy/admin-ui/copy_cm.sh diff --git a/deploy/delete.sh b/deploy/admin-ui/delete.sh similarity index 100% rename from deploy/delete.sh rename to deploy/admin-ui/delete.sh diff --git a/deploy/install.sh b/deploy/admin-ui/install.sh similarity index 87% rename from deploy/install.sh rename to deploy/admin-ui/install.sh index ea585a6a..2041c0cc 100755 --- a/deploy/install.sh +++ b/deploy/admin-ui/install.sh @@ -9,6 +9,7 @@ fi NS=admin CHART_VERSION=0.0.1-develop +COPY_UTIL=../copy_cm_func.sh echo Create $NS namespace kubectl create ns $NS @@ -19,8 +20,9 @@ function installing_admin_ui() { helm repo update echo Copy configmaps - sed -i 's/\r$//' copy_cm.sh - ./copy_cm.sh + $COPY_UTIL configmap global default $NS + $COPY_UTIL configmap artifactory-share artifactory $NS + $COPY_UTIL configmap config-server-share config-server $NS API_HOST=$(kubectl get cm global -o jsonpath={.data.mosip-api-internal-host}) ADMIN_HOST=$(kubectl get cm global -o jsonpath={.data.mosip-admin-host}) diff --git a/deploy/restart.sh b/deploy/admin-ui/restart.sh similarity index 100% rename from deploy/restart.sh rename to deploy/admin-ui/restart.sh diff --git a/deploy/admin-uitestrig/README.md b/deploy/admin-uitestrig/README.md index 4bd7d962..00b2177f 100644 --- a/deploy/admin-uitestrig/README.md +++ b/deploy/admin-uitestrig/README.md @@ -1,10 +1,32 @@ -# ADMIN UITESTRIG +# UITESTRIG -This directory contains `values.yaml` file which contains the latest admin uitestrig release changes with latest released Docker image and tag. +## Introduction +UITESTRIG will test end-to-end functional flows involving multiple UI modules. -## TL;DR +## Install +* Install +```sh +./install.sh +``` -```console -$ helm repo add mosip https://mosip.github.io -$ helm install my-release mosip/uitestrig -f values.yaml +## Uninstall +* To uninstall UITESTRIG, run `delete.sh` script. +```sh +./delete.sh ``` + +## Run UITESTRIG manually + +#### CLI +* Download Kubernetes cluster `kubeconfig` file from `rancher dashboard` to your local. +* Install `kubectl` package to your local machine. +* Run UITESTRIG manually via CLI by creating a new job from an existing k8s cronjob. + ``` + kubectl --kubeconfig= -n UITESTRIG create job --from=cronjob/ + ``` + example: + ``` + kubectl --kubeconfig=/home/xxx/Downloads/qa4.config -n UITESTRIG create job --from=cronjob/cronjob-uitestrig cronjob-uitestrig + ``` + + diff --git a/deploy/admin-uitestrig/delete.sh b/deploy/admin-uitestrig/delete.sh new file mode 100644 index 00000000..a72024ee --- /dev/null +++ b/deploy/admin-uitestrig/delete.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Uninstalls uitestrig +## Usage: ./delete.sh [kubeconfig] + +if [ $# -ge 1 ] ; then + export KUBECONFIG=$1 +fi + +function deleting_uitestrig() { + NS=admin + while true; do + read -p "Are you sure you want to delete uitestrig helm charts?(Y/n) " yn + if [ $yn = "Y" ] + then + helm -n $NS delete admin-uitestrig + break + else + break + fi + done + return 0 +} + +# set commands for error handling. +set -e +set -o errexit ## set -e : exit the script if any statement returns a non-true return value +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errtrace # trace ERR through 'time command' and other functions +set -o pipefail # trace ERR through pipes +deleting_uitestrig # calling function \ No newline at end of file diff --git a/deploy/admin-uitestrig/install.sh b/deploy/admin-uitestrig/install.sh new file mode 100644 index 00000000..a4a916a3 --- /dev/null +++ b/deploy/admin-uitestrig/install.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# Installs uitestrig automation +## Usage: ./install.sh [kubeconfig] + +if [ $# -ge 1 ] ; then + export KUBECONFIG=$1 +fi + +NS=admin +CHART_VERSION=0.0.1-develop +COPY_UTIL=../copy_cm_func.sh + +echo Create $NS namespace +kubectl create ns $NS + +function installing_uitestrig() { + ENV_NAME=$( kubectl -n default get cm global -o json |jq -r '.data."installation-domain"') + + read -p "Please enter the time(hr) to run the cronjob every day (time: 0-23) : " time + if [ -z "$time" ]; then + echo "ERROR: Time cannot be empty; EXITING;"; + exit 1; + fi + if ! [ $time -eq $time ] 2>/dev/null; then + echo "ERROR: Time $time is not a number; EXITING;"; + exit 1; + fi + if [ $time -gt 23 ] || [ $time -lt 0 ] ; then + echo "ERROR: Time should be in range ( 0-23 ); EXITING;"; + exit 1; + fi + + echo "Do you have public domain & valid SSL? (Y/n) " + echo "Y: if you have public domain & valid ssl certificate" + echo "n: if you don't have public domain & valid ssl certificate" + read -p "" flag + + if [ -z "$flag" ]; then + echo "'flag' was provided; EXITING;" + exit 1; + fi + ENABLE_INSECURE='' + if [ "$flag" = "n" ]; then + ENABLE_INSECURE='--set uitestrig.configmaps.uitestrig.ENABLE_INSECURE=true'; + fi + + echo Istio label + kubectl label ns $NS istio-injection=disabled --overwrite + helm repo update + + echo Copy configmaps + $COPY_UTIL configmap global default $NS + $COPY_UTIL configmap keycloak-host keycloak $NS + $COPY_UTIL configmap artifactory-share artifactory $NS + $COPY_UTIL configmap config-server-share config-server $NS + + echo Copy secrets + $COPY_UTIL secret keycloak-client-secrets keycloak $NS + $COPY_UTIL secret s3 s3 $NS + $COPY_UTIL secret postgres-postgresql postgres $NS + + DB_HOST=$( kubectl -n default get cm global -o json |jq -r '.data."mosip-api-internal-host"' ) + PMP_HOST=$(kubectl -n default get cm global -o json |jq -r '.data."mosip-pmp-host"') + ADMIN_HOST=$(kubectl -n default get cm global -o json |jq -r '.data."mosip-admin-host"') + RESIDENT_HOST=$(kubectl -n default get cm global -o json |jq -r '.data."mosip-resident-host"') + API_INTERNAL_HOST=$( kubectl -n default get cm global -o json |jq -r '.data."mosip-api-internal-host"' ) + + echo Installing admin uitestrig + helm -n $NS install admin-uitestrig mosip/uitestrig \ + --set crontime="0 $time * * *" \ + -f values.yaml \ + --version $CHART_VERSION \ + --set uitestrig.configmaps.s3.s3-host='http://minio.minio:9000' \ + --set uitestrig.configmaps.s3.s3-user-key='admin' \ + --set uitestrig.configmaps.s3.s3-region='' \ + --set uitestrig.configmaps.db.db-server="$DB_HOST" \ + --set uitestrig.configmaps.db.db-su-user="postgres" \ + --set uitestrig.configmaps.db.db-port="5432" \ + --set uitestrig.configmaps.uitestrig.apiInternalEndPoint="https://$API_INTERNAL_HOST" \ + --set uitestrig.configmaps.uitestrig.apiEnvUser="$API_INTERNAL_HOST" \ + --set uitestrig.configmaps.uitestrig.PmpPortalPath="https://$PMP_HOST" \ + --set uitestrig.configmaps.uitestrig.adminPortalPath="https://$ADMIN_HOST" \ + --set uitestrig.configmaps.uitestrig.residentPortalPath="https://$RESIDENT_HOST" \ + --set uitestrig.configmaps.uitestrig.NS="$NS" \ + $ENABLE_INSECURE + + echo Installed admin uitestrig + return 0 +} + +# set commands for error handling. +set -e +set -o errexit ## set -e : exit the script if any statement returns a non-true return value +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errtrace # trace ERR through 'time command' and other functions +set -o pipefail # trace ERR through pipes +installing_uitestrig # calling function \ No newline at end of file diff --git a/deploy/copy_cm_func.sh b/deploy/copy_cm_func.sh new file mode 100755 index 00000000..185ae3e5 --- /dev/null +++ b/deploy/copy_cm_func.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copy configmap and secret from one namespace to another. +# ./copy_cm_func.sh [name] +# Parameters: +# resource: configmap|secret +# name: Optional new name of the configmap or secret in destination namespace. This may be needed if there is +# clash of names + +if [ $1 = "configmap" ] +then + RESOURCE=configmap +elif [ $1 = "secret" ] +then + RESOURCE=secret +else + echo "Incorrect resource $1. Exiting.." + exit 1 +fi + + +if [ $# -ge 5 ] +then + kubectl -n $4 delete --ignore-not-found=true $RESOURCE $5 + kubectl -n $3 get $RESOURCE $2 -o yaml | sed "s/namespace: $3/namespace: $4/g" | sed "s/name: $2/name: $5/g" | kubectl -n $4 create -f - +else + kubectl -n $4 delete --ignore-not-found=true $RESOURCE $2 + kubectl -n $3 get $RESOURCE $2 -o yaml | sed "s/namespace: $3/namespace: $4/g" | kubectl -n $4 create -f - +fi + + + + + From 684204f8ed1c939838ef31d79e840a003ca5b781 Mon Sep 17 00:00:00 2001 From: Mohanraj209 Date: Wed, 23 Oct 2024 17:36:00 +0530 Subject: [PATCH 3/3] [MOSIP-35421] Moved installation scripts of admin uitestrig. Signed-off-by: Mohanraj209 --- deploy/admin-ui/copy_cm.sh | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100755 deploy/admin-ui/copy_cm.sh diff --git a/deploy/admin-ui/copy_cm.sh b/deploy/admin-ui/copy_cm.sh deleted file mode 100755 index fb2d70a6..00000000 --- a/deploy/admin-ui/copy_cm.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Copy configmaps from other namespaces -# DST_NS: Destination namespace - -function copying_cm() { - UTIL_URL=https://raw.githubusercontent.com/mosip/mosip-infra/master/deployment/v3/utils/copy_cm_func.sh - COPY_UTIL=./copy_cm_func.sh - DST_NS=admin - - wget -q $UTIL_URL -O copy_cm_func.sh && chmod +x copy_cm_func.sh - - $COPY_UTIL configmap global default $DST_NS - $COPY_UTIL configmap artifactory-share artifactory $DST_NS - $COPY_UTIL configmap config-server-share config-server $DST_NS - return 0 -} - -# set commands for error handling. -set -e -set -o errexit ## set -e : exit the script if any statement returns a non-true return value -set -o nounset ## set -u : exit the script if you try to use an uninitialised variable -set -o errtrace # trace ERR through 'time command' and other functions -set -o pipefail # trace ERR through pipes -copying_cm # calling function -