Skip to content

Commit

Permalink
feat(testdata): enable seeding via configMap, remove consortia files (#…
Browse files Browse the repository at this point in the history
…241)

Refs: #205
Reviewed-By: Evelyn Gurschler <evelyn.gurschler@bmw.de>
Co-authored-by: Evelyn Gurschler <evelyn.gurschler@bmw.de>
  • Loading branch information
Phil91 and evegufy authored Sep 27, 2024
1 parent f08ddd5 commit e3c92d3
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 55 deletions.
7 changes: 4 additions & 3 deletions charts/ssi-credential-issuer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ dependencies:
| migrations.image.pullSecrets | list | `[]` | |
| migrations.imagePullPolicy | string | `"IfNotPresent"` | |
| 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. |
| migrations.seeding.testDataEnvironments | string | `""` | |
| migrations.seeding.testDataPaths | string | `"Seeder/Data"` | |
| migrations.seeding.seedTestData | object | `{"useDefault":false,"useOwnConfigMap":{"configMap":"","filename":""}}` | Option to seed testdata |
| 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 |
| 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. |
| migrations.seeding.seedTestData.useOwnConfigMap.filename | string | `""` | Filename identifying the test data files e.g. for companies.test.json the value would be "test" |
| migrations.logging.default | string | `"Information"` | |
| migrations.processIdentity.identityId | string | `"ac1cf001-7fbc-1f2f-817f-bce058020006"` | |
| processesworker.name | string | `"processesworker"` | |
| processesworker.image.name | string | `"docker.io/tractusx/ssi-credential-issuer-processes-worker"` | |
| processesworker.image.tag | string | `""` | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- /*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/}}

{{- if .Values.migrations.seeding.seedTestData.useDefault -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "issuer.fullname" . }}-default-testdata
namespace: {{ .Release.Namespace }}
data:
use_cases.defaulttest.json: |-
[
{
"id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9",
"name": "None",
"shortname": "None"
}
]
verified_credential_external_type_detail_versions.defaulttest.json: |-
[
{
"id": "d0f05b79-792c-4cb8-9b8d-6e476ac2e926",
"verified_credential_external_type_id": 2,
"version": "0.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_PCF.pdf",
"valid_from": "2023-01-01 00:00:00.000000 +00:00",
"expiry": "2023-12-31 00:00:00.000000 +00:00"
},
{
"id": "2d17a933-f65f-49cd-84a9-cff299a79f85",
"verified_credential_external_type_id": 11,
"version": "1.0",
"template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/example.pdf",
"valid_from": "2024-10-16 00:00:00.000000 +00:00",
"expiry": "2025-10-16 00:00:00.000000 +00:00"
}
]
verified_credential_type_assigned_external_types.defaulttest.json: |-
[
{
"verified_credential_external_type_id": 11,
"verified_credential_type_id": 11
}
]
verified_credential_type_assigned_use_cases.defaulttest.json: |-
[
{
"verified_credential_type_id": 11,
"use_case_id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9"
}
]
{{- end -}}
51 changes: 47 additions & 4 deletions charts/ssi-credential-issuer/templates/job-issuer-migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,60 @@ spec:
- name: "CONNECTIONSTRINGS__ISSUERDB"
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 }};"
{{- end }}
- name: "SEEDING__TESTDATAENVIRONMENTS__0"
value: "{{ .Values.migrations.seeding.testDataEnvironments }}"
- name: "SEEDING__DATAPATHS__0"
value: "{{ .Values.migrations.seeding.testDataPaths }}"
value: "Seeder/Data"
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
- name: "SEEDING__DATAPATHS__1"
value: "Seeder/Data/import/default-test-data"
- name: "SEEDING__TESTDATAENVIRONMENTS__1"
value: "defaulttest"
{{- end }}
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
- name: "SEEDING__DATAPATHS__2"
value: "Seeder/Data/import/custom-test-data"
- name: "SEEDING__TESTDATAENVIRONMENTS__2"
value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}"
{{- else }}
- name: "SEEDING__DATAPATHS__1"
value: "Seeder/Data/import/custom-test-data"
- name: "SEEDING__TESTDATAENVIRONMENTS__1"
value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}"
{{- end }}
{{- end }}
- name: "SERILOG__MINIMUMLEVEL__Default"
value: "{{ .Values.migrations.logging.default }}"
- name: "PROCESSIDENTITY__IDENTITYID"
value: "{{ .Values.migrations.processIdentity.identityId }}"
value: "ac1cf001-7fbc-1f2f-817f-bce058020006"
ports:
- name: http
containerPort: {{ .Values.portContainer }}
protocol: TCP
resources:
{{- toYaml .Values.migrations.resources | nindent 10 }}
{{- if or (.Values.migrations.seeding.seedTestData.useDefault) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }}
volumeMounts:
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
- name: test-data-default
mountPath: /migrations/Seeder/Data/import/default-test-data
{{- end }}
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
- name: test-data-custom
mountPath: /migrations/Seeder/Data/import/custom-test-data
{{- end }}
{{- end }}
{{- if or (.Values.migrations.seeding.seedTestData.useDefault) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }}
volumes:
{{- if (.Values.migrations.seeding.seedTestData.useDefault) }}
- name: test-data-default
configMap:
name: "{{ include "issuer.fullname" . }}-default-testdata"
optional: true
{{- end }}
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
- name: test-data-custom
configMap:
name: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap }}"
optional: true
{{- end }}
{{- end }}
13 changes: 9 additions & 4 deletions charts/ssi-credential-issuer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ migrations:
cpu: 45m
memory: 200M
seeding:
testDataEnvironments: ""
testDataPaths: "Seeder/Data"
# -- Option to seed testdata
seedTestData:
# -- If set to true the data configured in the config map 'configmap-seeding-testdata.yaml' will be taken to insert the default test data
useDefault: false
useOwnConfigMap:
# -- ConfigMap containing json files for the tables to seed, e.g. use_cases.json, verified_credential_external_type_detail_versions.test.json, etc.
configMap: ""
# -- Filename identifying the test data files e.g. for companies.test.json the value would be "test"
filename: ""
logging:
default: "Information"
processIdentity:
identityId: ac1cf001-7fbc-1f2f-817f-bce058020006

processesworker:
name: "processesworker"
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ await _container.StartAsync()

var seederOptions = Options.Create(new SeederSettings
{
TestDataEnvironments = new[] { "test" },
TestDataEnvironments = new[] { "unittest" },
DataPaths = new[] { "Seeder/Data" }
});
var insertSeeder = new BatchInsertSeeder(context,
Expand Down

0 comments on commit e3c92d3

Please sign in to comment.