Skip to content

Commit

Permalink
Merge pull request #763 from Mohanraj209/develop
Browse files Browse the repository at this point in the history
[MOSIP-35421] Added values.yaml file for resident uitestrig
  • Loading branch information
ckm007 authored Oct 28, 2024
2 parents af551d3 + d79f6cb commit b87fdf3
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 50 deletions.
24 changes: 0 additions & 24 deletions deploy/copy_cm.sh

This file was deleted.

33 changes: 33 additions & 0 deletions deploy/copy_cm_func.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Copy configmap and secret from one namespace to another.
# ./copy_cm_func.sh <resource> <configmap_name> <source_namespace> <destination_namespace> [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





22 changes: 0 additions & 22 deletions deploy/copy_secrets.sh

This file was deleted.

11 changes: 11 additions & 0 deletions deploy/README.md → deploy/resident-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
```sh
./install.sh
```

## Restart
```sh
./restart.sh
```

## Delete
```sh
./delete.sh
```

* During the execution of the `install.sh` script, a prompt appears requesting information regarding the presence of a public domain and a valid SSL certificate on the server.
* If the server lacks a public domain and a valid SSL certificate, it is advisable to select the `n` option. Opting it will enable the `init-container` with an `emptyDir` volume and include it in the deployment process.
* The init-container will proceed to download the server's self-signed SSL certificate and mount it to the specified location within the container's Java keystore (i.e., `cacerts`) file.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions deploy/install.sh → deploy/resident-ui/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fi

NS=resident
RESIDENT_UI_CHART_VERSION=0.0.1-develop
COPY_UTIL=../copy_cm_func.sh

echo Create $NS namespace
kubectl create ns $NS
Expand All @@ -18,12 +19,13 @@ function installing_resident_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

echo Copy secrets
sed -i 's/\r$//' copy_secrets.sh
./copy_secrets.sh
$COPY_UTIL secret keycloak-client-secrets keycloak $NS

echo Setting up dummy values for Resident OIDC Client ID
kubectl create secret generic resident-oidc-onboarder-key -n $NS --from-literal=resident-oidc-clientid='' --dry-run=client -o yaml | kubectl apply -f -
./copy_cm_func.sh secret resident-oidc-onboarder-key resident config-server
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions deploy/resident-uitestrig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# UITESTRIG

## Introduction
UITESTRIG will test end-to-end functional flows involving multiple UI modules.

## Install
* Install
```sh
./install.sh
```

## 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=<k8s-config-file> -n UITESTRIG create job --from=cronjob/<cronjob-name> <job-name>
```
example:
```
kubectl --kubeconfig=/home/xxx/Downloads/qa4.config -n UITESTRIG create job --from=cronjob/cronjob-uitestrig cronjob-uitestrig
```


30 changes: 30 additions & 0 deletions deploy/resident-uitestrig/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Uninstalls uitestrig
## Usage: ./delete.sh [kubeconfig]

if [ $# -ge 1 ] ; then
export KUBECONFIG=$1
fi

function deleting_uitestrig() {
NS=resident
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 resident-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
97 changes: 97 additions & 0 deletions deploy/resident-uitestrig/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash
# Installs uitestrig automation
## Usage: ./install.sh [kubeconfig]

if [ $# -ge 1 ] ; then
export KUBECONFIG=$1
fi

NS=resident
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 resident uitestrig
helm -n $NS install resident-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 resident 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
7 changes: 7 additions & 0 deletions deploy/resident-uitestrig/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
modules:
- name: residentui
enabled: true
image:
registry: docker.io
repository: mosipqa/residenttest
tag: develop

0 comments on commit b87fdf3

Please sign in to comment.