Skip to content

Commit

Permalink
[ MOSIP-26249 ] Added and updated scripts for DSLRIG and apitestrig (#…
Browse files Browse the repository at this point in the history
…1260)

* [ MOSIP-26249 ] Added and updated scripts for DSLRIG and apitestrig

* AUTHDEMO
* PACKETCREATOR
* APITESTRIG
* DSLRIG

* [ MOSIP-26249 ] added image for dslrig

* AUTHDEMO
* PACKETCREATOR
* APITESTRIG
* DSLRIG

---------

Co-authored-by: syed-salman-technoforte <[email protected]>
  • Loading branch information
syedsalman3753 and syed-salman-technoforte authored Mar 29, 2023
1 parent d68d8be commit 1e85f01
Show file tree
Hide file tree
Showing 29 changed files with 688 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deployment/v3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Following install sequence is recommended:
* [Kubernetes infra](https://github.com/mosip/k8s-infra)
* [External components](external/README.md)
* [MOSIP services](mosip/README.md)
* [Api Testrig](apitestrig/README.md)
* [Testrig](testrig/README.md)
* [Reporting](https://github.com/mosip/reporting/tree/develop)

## Production hardening
Expand Down
Binary file added deployment/v3/docs/images/dslrig-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions deployment/v3/testrig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TESTRIG

## Overview
The steps here install Testrig components, which include APITESTRIG and DSLRIG.
These components are used to test the working of APIs of MOSIP modules and the end-to-end functional flows involving multiple MOSIP modules.

## APITESTRIG Install
Install in the following order:
* [Authdemo](authdemo/README.md)
* [Apitestrig](apitestrig/README.md)

## DSLRIG Install
Install in the following order:
* [Packetcreator](packetcreator/README.md)
* [Authdemo](authdemo/README.md)
* [DSLRIG](dslrig/README.md)

## Delete
* Follow the steps mentioned in the below links to uninstall DSLRIG.
* [DSLRIG](dslrig/README.md#uninstall)
* [Authdemo](authdemo/README.md#uninstall)
* [Packetcreator](packetcreator/README.md#uninstall)
* Follow the steps mentioned in the below links to uninstall ApiTestrig.
* [Authdemo](authdemo/README.md#uninstall)
* [Apitestrig](apitestrig/README.md#uninstall)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ ApiTestRig will test the working of APIs of the MOSIP modules.
./install.sh
```

## Uninstall
* To uninstall ApiTestRig, run `delete.sh` script.
```sh
./delete.sh
```

## Run apitestrig manually

#### Rancher UI
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function installing_apitestrig() {
helm repo update

echo Copy configmaps
sed -i 's/\r$//' copy_cm.sh
./copy_cm.sh

echo Copy secrets
Expand All @@ -29,7 +28,7 @@ function installing_apitestrig() {
kubectl -n $NS delete --ignore-not-found=true configmap db
kubectl -n $NS delete --ignore-not-found=true configmap apitestrig

DB_HOST=$( kubectl -n default get cm global -o json |jq -r '.data."mosip-postgres-host"' )
DB_HOST=$( kubectl -n default get cm global -o json |jq -r '.data."mosip-api-internal-host"' )
API_INTERNAL_HOST=$( kubectl -n default get cm global -o json |jq -r '.data."mosip-api-internal-host"' )
ENV_USER=$( kubectl -n default get cm global -o json |jq -r '.data."mosip-api-internal-host"' | awk -F '.' '/api-internal/{print $1"."$2}')

Expand Down Expand Up @@ -87,4 +86,4 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
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_apitestrig # calling function
installing_apitestrig # calling function
File renamed without changes.
1 change: 1 addition & 0 deletions deployment/v3/testrig/authdemo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hosts.ini
16 changes: 16 additions & 0 deletions deployment/v3/testrig/authdemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Authdemo

## Introduction
Authdemo is used to execute IDA APIs used by Apitestrig & DSLrig.

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

## Uninstall
* To uninstall Authdemo, run `delete.sh` script.
```sh
./delete.sh
```
6 changes: 6 additions & 0 deletions deployment/v3/testrig/authdemo/copy_cm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Copy configmaps from other namespaces
# DST_NS: Destination namespace
COPY_UTIL=../../utils/copy_cm_func.sh
DST_NS=authdemo
$COPY_UTIL configmap config-server-share config-server $DST_NS
6 changes: 6 additions & 0 deletions deployment/v3/testrig/authdemo/copy_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Copy secrets from other namespaces
# DST_NS: Destination namespace
COPY_UTIL=../../utils/copy_cm_func.sh
DST_NS=authdemo
$COPY_UTIL secret keycloak-client-secrets keycloak $DST_NS
30 changes: 30 additions & 0 deletions deployment/v3/testrig/authdemo/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Uninstalls authdemo
## Usage: ./delete.sh [kubeconfig]

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

function deleting_authdemo() {
NS=authdemo
while true; do
read -p "Are you sure you want to delete authdemo helm charts?(Y/n) " yn
if [ $yn = "Y" ]
then
helm -n $NS delete authdemo
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_authdemo # calling function
63 changes: 63 additions & 0 deletions deployment/v3/testrig/authdemo/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# Installs authdemo
## Usage: ./install.sh [kubeconfig]

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

NS=authdemo
CHART_VERSION=12.0.1-B3

echo Create $NS namespace
kubectl create ns $NS


function installing_authdemo() {
echo Istio label
kubectl label ns $NS istio-injection=enabled --overwrite
helm repo update

echo Copy configmaps
./copy_cm.sh

echo Copy secrets
./copy_secrets.sh

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 authdemo.configmaps.authdemo.ENABLE_INSECURE=true';
fi

read -p "Please provide NFS host : " NFS_HOST
read -p "Please provide NFS pem file for SSH login : " NFS_PEM_FILE
read -p "Please provide user for SSH login : " NFS_USER
echo -e "[nfs_server]\nnfsserver ansible_user=$NFS_USER ansible_host=$NFS_HOST ansible_ssh_private_key_file=$NFS_PEM_FILE" > hosts.ini
ansible-playbook -i hosts.ini nfs-server.yaml


echo Installing authdemo
helm -n $NS install authdemo mosip/authdemo $ENABLE_INSECURE \
--set persistence.nfs.server="$NFS_HOST" \
--version $CHART_VERSION --wait

echo Installed authdemo.
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_authdemo # calling function
64 changes: 64 additions & 0 deletions deployment/v3/testrig/authdemo/nfs-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
- name: Install NFS server setup for authdemo
hosts: "nfs_server"
become: yes
become_method: sudo
vars:
nfs_directories:
- name: /srv/nfs/mosip/packetcreator-authdemo-authcerts
nfs_exports:
"*(rw,sync,no_root_squash,no_all_squash,insecure,subtree_check)"

tasks:
- name: Install NFS server
apt:
name: nfs-kernel-server
state: present

- name: Enable necessary TCP ports for NFS
ufw:
rule: allow
port: "{{ item }}"
proto: tcp
state: enabled
with_items:
- '111'
- '2049'

- name: Enable necessary UDP ports for NFS
ufw:
rule: allow
port: "{{ item }}"
proto: udp
state: enabled
with_items:
- '111'
- '2049'

- name: Enable nfs server
command: 'systemctl enable nfs-server'

- name: Start nfs server
command: 'systemctl start nfs-server'

- name: Add user mosip
user:
name: mosip

- name: Create nfs mount folder
file:
path: '{{ item.name }}'
state: directory
owner: mosip
group: mosip
with_items: "{{ nfs_directories }}"

- name: Export NFS directories
lineinfile:
path: /etc/exports
line: "{{ item.name }} {{ nfs_exports }}"
state: present
with_items: "{{ nfs_directories }}"

- name: exportfs
command: 'exportfs -rav'
1 change: 1 addition & 0 deletions deployment/v3/testrig/dslrig/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hosts.ini
47 changes: 47 additions & 0 deletions deployment/v3/testrig/dslrig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# DSLRIG

## Introduction
DSLRIG will test end-to-end functional flows involving multiple MOSIP modules.

## Prerequisites
* Packet utility running in rancher cluster exposed to be accessed by the cluster.
* Auth demo and DSLRIG to be running in the same cluster.
* NFS server already present and related details.

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

## Uninstall
* To uninstall DSLRIG, run `delete.sh` script.
```sh
./delete.sh
```

## Run dslrig manually

#### Rancher UI
* Run dslrig manually via Rancher UI.
![dslrig-1.png](../../docs/images/dslrig-1.png)
* There are two modes of dslrig `sanity` & `full`.
* By default, dslrig will execute in `full` mode.
* If you want to run dslrig with `sanity` mode,
Update the `TESTLEVEL` key in the `dslorchestrator` configmap and rerun the dslrig job.

#### CLI
* Download Kubernetes cluster `kubeconfig` file from `rancher dashboard` to your local.
![apitestrig-1.png](../../docs/images/apitestrig-1.png)
* Install `kubectl` package to your local machine.
* Run dslrig manually via CLI by creating a new job from an existing k8s cronjob.
```
kubectl --kubeconfig=<k8s-config-file> -n dslrig create job --from=cronjob/<cronjob-name> <job-name>
```
example:
```
kubectl --kubeconfig=/home/xxx/Downloads/qa4.config -n dslrig create job --from=cronjob/cronjob-dslorchestrator cronjob-dslorchestrator
```



9 changes: 9 additions & 0 deletions deployment/v3/testrig/dslrig/copy_cm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copy configmaps from other namespaces
# DST_NS: Destination namespace
COPY_UTIL=../../utils/copy_cm_func.sh
DST_NS=dslrig
$COPY_UTIL configmap global default $DST_NS
$COPY_UTIL configmap keycloak-host keycloak $DST_NS
$COPY_UTIL configmap artifactory-share artifactory $DST_NS
$COPY_UTIL configmap config-server-share config-server $DST_NS
8 changes: 8 additions & 0 deletions deployment/v3/testrig/dslrig/copy_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copy secrets from other namespaces
# DST_NS: Destination namespace
COPY_UTIL=../../utils/copy_cm_func.sh
DST_NS=dslrig
$COPY_UTIL secret keycloak-client-secrets keycloak $DST_NS
$COPY_UTIL secret s3 s3 $DST_NS
$COPY_UTIL secret postgres-postgresql postgres $DST_NS
30 changes: 30 additions & 0 deletions deployment/v3/testrig/dslrig/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Uninstalls dslrig
## Usage: ./delete.sh [kubeconfig]

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

function deleting_dslrig() {
NS=dslrig
while true; do
read -p "Are you sure you want to delete dslrig helm charts?(Y/n) " yn
if [ $yn = "Y" ]
then
helm -n $NS delete dslorchestrator
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_dslrig # calling function
Loading

0 comments on commit 1e85f01

Please sign in to comment.