Skip to content

Commit e3c92d3

Browse files
Phil91evegufy
andauthored
feat(testdata): enable seeding via configMap, remove consortia files (#241)
Refs: #205 Reviewed-By: Evelyn Gurschler <[email protected]> Co-authored-by: Evelyn Gurschler <[email protected]>
1 parent f08ddd5 commit e3c92d3

19 files changed

+129
-55
lines changed

charts/ssi-credential-issuer/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ dependencies:
7676
| migrations.image.pullSecrets | list | `[]` | |
7777
| migrations.imagePullPolicy | string | `"IfNotPresent"` | |
7878
| migrations.resources | object | `{"limits":{"cpu":"45m","memory":"200M"},"requests":{"cpu":"15m","memory":"200M"}}` | We recommend to review the default resource limits as this should a conscious choice. |
79-
| migrations.seeding.testDataEnvironments | string | `""` | |
80-
| migrations.seeding.testDataPaths | string | `"Seeder/Data"` | |
79+
| migrations.seeding.seedTestData | object | `{"useDefault":false,"useOwnConfigMap":{"configMap":"","filename":""}}` | Option to seed testdata |
80+
| migrations.seeding.seedTestData.useDefault | bool | `false` | If set to true the data configured in the config map 'configmap-seeding-testdata.yaml' will be taken to insert the default test data |
81+
| migrations.seeding.seedTestData.useOwnConfigMap.configMap | string | `""` | ConfigMap containing json files for the tables to seed, e.g. use_cases.json, verified_credential_external_type_detail_versions.test.json, etc. |
82+
| migrations.seeding.seedTestData.useOwnConfigMap.filename | string | `""` | Filename identifying the test data files e.g. for companies.test.json the value would be "test" |
8183
| migrations.logging.default | string | `"Information"` | |
82-
| migrations.processIdentity.identityId | string | `"ac1cf001-7fbc-1f2f-817f-bce058020006"` | |
8384
| processesworker.name | string | `"processesworker"` | |
8485
| processesworker.image.name | string | `"docker.io/tractusx/ssi-credential-issuer-processes-worker"` | |
8586
| processesworker.image.tag | string | `""` | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{- /*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License, Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* SPDX-License-Identifier: Apache-2.0
18+
*/}}
19+
20+
{{- if .Values.migrations.seeding.seedTestData.useDefault -}}
21+
apiVersion: v1
22+
kind: ConfigMap
23+
metadata:
24+
name: {{ include "issuer.fullname" . }}-default-testdata
25+
namespace: {{ .Release.Namespace }}
26+
data:
27+
use_cases.defaulttest.json: |-
28+
[
29+
{
30+
"id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9",
31+
"name": "None",
32+
"shortname": "None"
33+
}
34+
]
35+
verified_credential_external_type_detail_versions.defaulttest.json: |-
36+
[
37+
{
38+
"id": "d0f05b79-792c-4cb8-9b8d-6e476ac2e926",
39+
"verified_credential_external_type_id": 2,
40+
"version": "0.0",
41+
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_PCF.pdf",
42+
"valid_from": "2023-01-01 00:00:00.000000 +00:00",
43+
"expiry": "2023-12-31 00:00:00.000000 +00:00"
44+
},
45+
{
46+
"id": "2d17a933-f65f-49cd-84a9-cff299a79f85",
47+
"verified_credential_external_type_id": 11,
48+
"version": "1.0",
49+
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/example.pdf",
50+
"valid_from": "2024-10-16 00:00:00.000000 +00:00",
51+
"expiry": "2025-10-16 00:00:00.000000 +00:00"
52+
}
53+
]
54+
verified_credential_type_assigned_external_types.defaulttest.json: |-
55+
[
56+
{
57+
"verified_credential_external_type_id": 11,
58+
"verified_credential_type_id": 11
59+
}
60+
]
61+
verified_credential_type_assigned_use_cases.defaulttest.json: |-
62+
[
63+
{
64+
"verified_credential_type_id": 11,
65+
"use_case_id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9"
66+
}
67+
]
68+
{{- end -}}

charts/ssi-credential-issuer/templates/job-issuer-migrations.yaml

+47-4
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,60 @@ spec:
6767
- name: "CONNECTIONSTRINGS__ISSUERDB"
6868
value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.username }};Password=$(ISSUER_PASSWORD);Ssl Mode={{ .Values.dbConnection.sslMode }};"
6969
{{- end }}
70-
- name: "SEEDING__TESTDATAENVIRONMENTS__0"
71-
value: "{{ .Values.migrations.seeding.testDataEnvironments }}"
7270
- name: "SEEDING__DATAPATHS__0"
73-
value: "{{ .Values.migrations.seeding.testDataPaths }}"
71+
value: "Seeder/Data"
72+
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
73+
- name: "SEEDING__DATAPATHS__1"
74+
value: "Seeder/Data/import/default-test-data"
75+
- name: "SEEDING__TESTDATAENVIRONMENTS__1"
76+
value: "defaulttest"
77+
{{- end }}
78+
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
79+
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
80+
- name: "SEEDING__DATAPATHS__2"
81+
value: "Seeder/Data/import/custom-test-data"
82+
- name: "SEEDING__TESTDATAENVIRONMENTS__2"
83+
value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}"
84+
{{- else }}
85+
- name: "SEEDING__DATAPATHS__1"
86+
value: "Seeder/Data/import/custom-test-data"
87+
- name: "SEEDING__TESTDATAENVIRONMENTS__1"
88+
value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}"
89+
{{- end }}
90+
{{- end }}
7491
- name: "SERILOG__MINIMUMLEVEL__Default"
7592
value: "{{ .Values.migrations.logging.default }}"
7693
- name: "PROCESSIDENTITY__IDENTITYID"
77-
value: "{{ .Values.migrations.processIdentity.identityId }}"
94+
value: "ac1cf001-7fbc-1f2f-817f-bce058020006"
7895
ports:
7996
- name: http
8097
containerPort: {{ .Values.portContainer }}
8198
protocol: TCP
8299
resources:
83100
{{- toYaml .Values.migrations.resources | nindent 10 }}
101+
{{- if or (.Values.migrations.seeding.seedTestData.useDefault) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }}
102+
volumeMounts:
103+
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
104+
- name: test-data-default
105+
mountPath: /migrations/Seeder/Data/import/default-test-data
106+
{{- end }}
107+
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
108+
- name: test-data-custom
109+
mountPath: /migrations/Seeder/Data/import/custom-test-data
110+
{{- end }}
111+
{{- end }}
112+
{{- if or (.Values.migrations.seeding.seedTestData.useDefault) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }}
113+
volumes:
114+
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
115+
- name: test-data-default
116+
configMap:
117+
name: "{{ include "issuer.fullname" . }}-default-testdata"
118+
optional: true
119+
{{- end }}
120+
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
121+
- name: test-data-custom
122+
configMap:
123+
name: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap }}"
124+
optional: true
125+
{{- end }}
126+
{{- end }}

charts/ssi-credential-issuer/values.yaml

+9-4
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ migrations:
8787
cpu: 45m
8888
memory: 200M
8989
seeding:
90-
testDataEnvironments: ""
91-
testDataPaths: "Seeder/Data"
90+
# -- Option to seed testdata
91+
seedTestData:
92+
# -- If set to true the data configured in the config map 'configmap-seeding-testdata.yaml' will be taken to insert the default test data
93+
useDefault: false
94+
useOwnConfigMap:
95+
# -- ConfigMap containing json files for the tables to seed, e.g. use_cases.json, verified_credential_external_type_detail_versions.test.json, etc.
96+
configMap: ""
97+
# -- Filename identifying the test data files e.g. for companies.test.json the value would be "test"
98+
filename: ""
9299
logging:
93100
default: "Information"
94-
processIdentity:
95-
identityId: ac1cf001-7fbc-1f2f-817f-bce058020006
96101

97102
processesworker:
98103
name: "processesworker"

src/database/SsiCredentialIssuer.Migrations/Seeder/Data/use_cases.consortia.json

-7
This file was deleted.

src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_external_type_detail_versions.consortia.json

-18
This file was deleted.

src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_external_types.consortia.json

-6
This file was deleted.

src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_use_cases.consortia.json

-6
This file was deleted.

tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_kinds.test.json

-6
This file was deleted.

tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ await _container.StartAsync()
9292

9393
var seederOptions = Options.Create(new SeederSettings
9494
{
95-
TestDataEnvironments = new[] { "test" },
95+
TestDataEnvironments = new[] { "unittest" },
9696
DataPaths = new[] { "Seeder/Data" }
9797
});
9898
var insertSeeder = new BatchInsertSeeder(context,

0 commit comments

Comments
 (0)