Skip to content

Commit e33a3dd

Browse files
authored
Merge pull request #1833 from Mohanraj209/develop
[MOSIP-43470] Perform pms delete query in cellbox21 env to get 0 failures for PMS apitestrig
2 parents b0a1d9b + 5b64ca5 commit e33a3dd

5 files changed

Lines changed: 139 additions & 2 deletions

File tree

deploy/apitestrig/copy_cm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
2222
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
2323
set -o errtrace # trace ERR through 'time command' and other functions
2424
set -o pipefail # trace ERR through pipes
25-
copying_cm # calling function
25+
copying_cm # calling function

deploy/apitestrig/copy_secrets.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
2121
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
2222
set -o errtrace # trace ERR through 'time command' and other functions
2323
set -o pipefail # trace ERR through pipes
24-
copying_secrets # calling function
24+
copying_secrets # calling function
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
-- Below should be delete queries for the Auth Partner - pms-111999:
2+
3+
-- From PMS DB:
4+
\c mosip_pms postgres
5+
delete FROM pms.oidc_client where policy_id in (select id from pms.auth_policy where cr_by='pms-111999');
6+
delete FROM pms.partner_policy where policy_id in (select id from pms.auth_policy where cr_by='pms-111999');
7+
delete FROM pms.partner_policy_request where policy_id in (select id from pms.auth_policy where cr_by='pms-111999');
8+
delete from pms.auth_policy where cr_by='pms-111999';
9+
delete from pms.policy_group where cr_by='pms-111999';
10+
delete FROM pms.partner_policy where cr_by='pms-111999';
11+
delete FROM pms.partner_policy_request where cr_by='pms-111999';
12+
delete from pms.partner where cr_by='pms-111999';
13+
delete FROM pms.user_details where cr_by='pms-111999';
14+
15+
-- From Esignet DB:
16+
\c mosip_esignet postgres
17+
delete FROM esignet.client_detail where rp_id='pms-111999';
18+
19+
-- From IDA DB:
20+
\c mosip_ida postgres
21+
delete FROM ida.oidc_client_data where partner_id='pms-111999';
22+
delete FROM ida.partner_data where partner_id = 'pms-111999';
23+
24+
-- From KeyManager DB:
25+
\c mosip_keymgr postgres
26+
delete from keymgr.key_alias where app_id = 'PARTNER' AND ref_id = 'pms-111999';
27+
28+
-- Below should be delete queries for the Device Partner - pms-111998:
29+
30+
-- From PMS DB:
31+
\c mosip_pms postgres
32+
delete from pms.device_detail_sbi where dprovider_id='pms-111998';
33+
delete from pms.device_detail where dprovider_id='pms-111998';
34+
delete from pms.secure_biometric_interface where provider_id='pms-111998';
35+
delete from pms.partner where cr_by='pms-111998';
36+
delete FROM pms.user_details where cr_by='pms-111998';
37+
38+
-- From KeyManager DB:
39+
\c mosip_keymgr postgres
40+
delete from keymgr.key_alias where app_id = 'PARTNER' AND ref_id = 'pms-111998';
41+
42+
-- From IDA DB:
43+
\c mosip_ida postgres
44+
delete FROM ida.partner_data where partner_id = 'pms-111998';
45+
46+
-- Below should be delete queries for the FTM Partner - pms-111888:
47+
-- From PMS DB:
48+
\c mosip_pms postgres
49+
delete from pms.ftp_chip_detail where foundational_trust_provider_id='pms-111888';
50+
delete from pms.partner where cr_by='pms-111888';
51+
delete FROM pms.user_details where cr_by='pms-111888';
52+
53+
-- From IDA DB:
54+
\c mosip_ida postgres
55+
delete FROM ida.partner_data where partner_id = 'pms-111888';
56+
57+
-- Below should be delete queries for the Partner ADMIN - pms-111777:
58+
-- From PMS DB:
59+
\c mosip_pms postgres
60+
delete from pms.auth_policy where cr_by='pms-111777';
61+
delete from pms.policy_group where cr_by='pms-111777';
62+
delete from pms.partner where cr_by='pms-111777';
63+
delete FROM pms.user_details where cr_by='pms-111777';
64+
65+
-- From KeyManager DB:
66+
\c mosip_keymgr postgres
67+
delete from keymgr.key_alias where app_id = 'PARTNER' AND ref_id = 'pms-111777';
68+
69+
-- Below should be delete all uploaded certs:
70+
-- From IDA DB:
71+
\c mosip_ida postgres
72+
delete FROM ida.ca_cert_store where cert_subject ='CN=PMS_API_CA,OU=PMS_API_CA,O=PMS_API_CA,L=PN,ST=MH,C=IN';
73+
delete FROM ida.ca_cert_store where cert_subject ='CN=PMS_API_SUB_CA,OU=PMS_API_SUB_CA,O=PMS_API_SUB_CA,L=PN,ST=MH,C=IN';
74+
delete from ida.ca_cert_store where cert_subject ='CN=PMS_API_ABC_ORG,OU=PMS_API_ABC_ORG,O=PMS_API_ABC_ORG,L=PN,ST=MH,C=IN';
75+
76+
-- From KeyManager DB:
77+
\c mosip_keymgr postgres
78+
delete FROM keymgr.ca_cert_store where cert_subject ='CN=PMS_API_CA,OU=PMS_API_CA,O=PMS_API_CA,L=PN,ST=MH,C=IN';
79+
delete FROM keymgr.ca_cert_store where cert_subject ='CN=PMS_API_SUB_CA,OU=PMS_API_SUB_CA,O=PMS_API_SUB_CA,L=PN,ST=MH,C=IN';
80+
delete from keymgr.ca_cert_store where cert_subject ='CN=PMS_API_ABC_ORG,OU=PMS_API_ABC_ORG,O=PMS_API_ABC_ORG,L=PN,ST=MH,C=IN';
81+
delete from keymgr.partner_cert_store where cert_subject ='CN=PMS_API_ABC_ORG,OU=PMS_API_ABC_ORG,O=PMS_API_ABC_ORG,L=PN,ST=MH,C=IN';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if .Values.modules.pms.enabled }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: db-cleanup-sql
6+
labels:
7+
app.kubernetes.io/managed-by: Helm
8+
data:
9+
cleanup.sql: |
10+
{{ .Files.Get "scripts/cleanup.sql" | indent 4 }}
11+
{{- end }}

helm/apitestrig/templates/cronjob.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,45 @@ spec:
4040
{{- if $.Values.enable_insecure }}
4141
{{- include "common.tplvalues.render" (dict "value" $.Values.initContainers "context" $) | nindent 12 }}
4242
{{- end }}
43+
{{- if $.Values.modules.pms.enabled }}
44+
- name: db-cleanup
45+
image: postgres:15-alpine
46+
imagePullPolicy: IfNotPresent
47+
env:
48+
- name: PGPASSWORD
49+
valueFrom:
50+
secretKeyRef:
51+
name: postgres-postgresql
52+
key: postgres-password
53+
- name: PGHOST
54+
valueFrom:
55+
configMapKeyRef:
56+
name: db
57+
key: db-server
58+
- name: PGPORT
59+
valueFrom:
60+
configMapKeyRef:
61+
name: db
62+
key: db-port
63+
- name: PGUSER
64+
valueFrom:
65+
configMapKeyRef:
66+
name: db
67+
key: db-su-user
68+
- name: PGDATABASE
69+
value: mosip_pms
70+
volumeMounts:
71+
- name: cleanup-sql
72+
mountPath: /scripts
73+
readOnly: true
74+
command:
75+
- sh
76+
- -c
77+
- |
78+
set -euo pipefail
79+
# stop on first SQL error
80+
psql -v ON_ERROR_STOP=1 -f /scripts/cleanup.sql
81+
{{- end }}
4382
containers:
4483
- name: {{ template "apitestrig.serviceAccountName" $ }}-{{ $modulename }}
4584
image: {{ $module.image.repository }}:{{ $module.image.tag }}
@@ -124,5 +163,11 @@ spec:
124163
persistentVolumeClaim:
125164
claimName: {{ $.Values.apitestrig.volumes.reports.name }}-{{ $.Release.Namespace }}-{{ $modulename }}-pvc
126165
{{- end }}
166+
{{- if $.Values.modules.pms.enabled }}
167+
- name: cleanup-sql
168+
configMap:
169+
name: db-cleanup-sql
170+
defaultMode: 0440
171+
{{- end }}
127172
{{- end }}
128173
{{- end }}

0 commit comments

Comments
 (0)