Commit cbbf2ef7 authored by Anastasios Poimenidis's avatar Anastasios Poimenidis
Browse files

feat!: introduce flyway for maintaining the database

parent 4ea02efb
Loading
Loading
Loading
Loading

mvnw

100644 → 100755
+0 −0

File mode changed from 100644 to 100755.

+5 −0
Changes for pom.xml: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -144,6 +144,11 @@
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-postgresql</artifactId>
    </dependency>
    <!-- Quarkus Flyway Extension -->
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-flyway</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-validator</artifactId>
+8 −8
Changes for src/main/java/org/etsi/osl/hypo/clients/oss/util/TranslateToServiceOrder.java: 8 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ import static org.etsi.osl.hypo.core.common.constants.OssClientConstants.UPF_IP;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.common.util.StringUtils;
import java.time.Clock;
import java.time.OffsetDateTime;
import java.util.HashSet;
@@ -25,6 +24,7 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.etsi.osl.hypo.clients.oss.oss.external.dto.svc.order.schema.Characteristic;
import org.etsi.osl.hypo.clients.oss.oss.external.dto.svc.order.schema.ServiceOrder;
import org.etsi.osl.hypo.clients.oss.oss.external.dto.svc.order.schema.ServiceOrderActionType;
@@ -167,7 +167,7 @@ public class TranslateToServiceOrder {
        kubernetesServiceChars.add(numberOfNodesCharacteristic);

        String flavorOfNodes = k8sServiceOrderSpecs.getFlavorOfNodes();
        if (!StringUtils.isEmpty(flavorOfNodes)) {
        if (StringUtils.isNotBlank(flavorOfNodes)) {
            Characteristic flavorOfNodesCharacteristic =
                    getServiceRestrictionCharacteristics(FLAVOR_OF_NODES, TEXT, flavorOfNodes);
            kubernetesServiceChars.add(flavorOfNodesCharacteristic);
@@ -223,39 +223,39 @@ public class TranslateToServiceOrder {
        Set<Characteristic> serviceChars5GAAS = new HashSet<>();

        String mccValue = k8sServiceOrderSpecs.getServiceChar5GCoreMCC();
        if (!StringUtils.isEmpty(mccValue)) {
        if (StringUtils.isNotBlank(mccValue)) {
            Characteristic mncCharacteristic = getServiceRestrictionCharacteristics(MCC, TEXT, mccValue);
            serviceChars5GAAS.add(mncCharacteristic);
        }

        String mncValue = k8sServiceOrderSpecs.getServiceChar5GCoreMNC();
        if (!StringUtils.isEmpty(mncValue)) {
        if (StringUtils.isNotBlank(mncValue)) {
            Characteristic mccCharacteristic = getServiceRestrictionCharacteristics(MNC, TEXT, mncValue);
            serviceChars5GAAS.add(mccCharacteristic);
        }

        String tacValue = k8sServiceOrderSpecs.getServiceChar5GCoreTAC();
        if (!StringUtils.isEmpty(tacValue)) {
        if (StringUtils.isNotBlank(tacValue)) {
            Characteristic tacCharacteristic = getServiceRestrictionCharacteristics(TAC, TEXT, tacValue);
            serviceChars5GAAS.add(tacCharacteristic);
        }

        String upfIpValue = k8sServiceOrderSpecs.getServiceChar5GCoreUPFIP();
        if (!StringUtils.isEmpty(upfIpValue)) {
        if (StringUtils.isNotBlank(upfIpValue)) {
            Characteristic upfIpCharacteristic =
                    getServiceRestrictionCharacteristics(UPF_IP, TEXT, upfIpValue);
            serviceChars5GAAS.add(upfIpCharacteristic);
        }

        String radioNodesValue = k8sServiceOrderSpecs.getServiceChar5GCoreRadioNodes();
        if (!StringUtils.isEmpty(radioNodesValue)) {
        if (StringUtils.isNotBlank(radioNodesValue)) {
            Characteristic radioNodesCharacteristic =
                    getServiceRestrictionCharacteristics(RADIO_NODES, SET, radioNodesValue);
            serviceChars5GAAS.add(radioNodesCharacteristic);
        }

        String ranProfileValue = k8sServiceOrderSpecs.getServiceChar5GCoreRanProfile();
        if (!StringUtils.isEmpty(ranProfileValue)) {
        if (StringUtils.isNotBlank(ranProfileValue)) {
            Characteristic ranProfileCharacteristic =
                    getServiceRestrictionCharacteristics(RAN_PROFILE, ENUM, ranProfileValue);
            serviceChars5GAAS.add(ranProfileCharacteristic);
+14 −18
Changes for src/main/resources/application.properties: 14 added lines, 18 removed lines.
Original line number Diff line number Diff line
#mp.messaging.incoming.oss-order-k8s-req.topic=words
#mp.messaging.incoming.oss-order-k8s-req.auto.offset.reset=earliest

quarkus.http.port=8090
quarkus.datasource.devservices.image-name=labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/postgres:14
quarkus.kafka.devservices.image-name=labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/vectorized/redpanda:v24.1.2
quarkus.keycloak.devservices.image-name=labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/keycloak/keycloak:22.0.3
quarkus.http.root-path=/tmf-api
quarkus.http.root-path=/oss-client

quarkus.datasource.db-version=14
# No need to configure this property.It is just for passing the mvn clean install
quarkus.log.handler.kafka.enabled=false
@@ -19,7 +14,6 @@ mp.openapi.extensions.smallrye.info.title=Oss Client Management
mp.openapi.extensions.smallrye.info.version=1.0.0
mp.openapi.extensions.smallrye.info.description=This API is an orchestrator


################## PROMETHEUS METRICS ##################
quarkus.micrometer.export.json.enabled=true
quarkus.micrometer.export.prometheus.path=metrics/prometheus
@@ -36,10 +30,7 @@ quarkus.micrometer.export.json.path=metrics/json
#Open Telemetry for Tracing
%dev.quarkus.otel.enabled=false
%dev.quarkus.otel.metrics.enabled=false
#%dev.quarkus.otel.logs.enabled=true
#%dev.quarkus.application.name=myservice
%dev.quarkus.otel.exporter.otlp.endpoint=http://localhost:4317 
#%dev.quarkus.otel.exporter.otlp.headers=authorization=Bearer my_secret

# Alternative to the console log
quarkus.http.access-log.pattern="...traceId=%{X,traceId} spanId=%{X,spanId}" 
%dev.quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n 
@@ -64,7 +55,6 @@ quarkus.http.access-log.pattern="...traceId=%{X,traceId} spanId=%{X,spanId}"
%unittest.quarkus.otel.enabled=false
%test.quarkus.otel.enabled=false


################## Prod Environment ##################

### The Kafka broker location
@@ -145,15 +135,17 @@ quarkus.rest-client.open-slice.url=${OPEN_SLICE_URL:http://localhost:8089}
quarkus.rest-client.open-slice.scope=jakarta.enterprise.context.RequestScoped

##database
quarkus.flyway.migrate-at-start=true
quarkus.flyway.baseline-on-migrate=true
quarkus.flyway.baseline-version=1.0.0
quarkus.flyway.baseline-description=Initial state before Flyway

%dev.quarkus.hibernate-orm.database.generation=drop-and-create
%test.quarkus.hibernate-orm.database.generation=drop-and-create
%unittest.quarkus.hibernate-orm.database.generation=drop-and-create
# Force Flyway to execute both main schema AND test mock data
%test.quarkus.flyway.locations=db/migration,db/migration-test

quarkus.hibernate-orm.enabled=true
quarkus.hibernate-orm.packages=org.etsi.osl.hypo.clients.oss.entity
quarkus.hibernate-orm.dialect=org.hibernate.dialect.CockroachDialect
%prod.quarkus.hibernate-orm.database.generation=update

quarkus.datasource.db-kind=postgresql
%prod.quarkus.datasource.jdbc.url=${_PROD_QUARKUS_DATASOURCE_JDBC_URL:jdbc:postgresql://postgresql-db:3000/OSS_CLIENT}
%prod.quarkus.datasource.username=${_PROD_QUARKUS_DATASOURCE_USERNAME:username}
@@ -173,3 +165,7 @@ quarkus.datasource.db-kind=postgresql

open.slice.kubernetes.spec.id=${KUBERNETES_AS_A_SERVICE_SPECIFICATION_ID:8089ea3d-9279-419a-9c8d-2cde8394adfb}
open.slice.five-g.spec.id=${FIVEG_AS_A_SERVICE_SPECIFICATION_ID:dcbc9ed6-bf01-41cc-9c0c-3fe4e2788a77}

quarkus.datasource.devservices.image-name=labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/postgres:14
quarkus.kafka.devservices.image-name=labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/vectorized/redpanda:v24.1.2
quarkus.keycloak.devservices.image-name=labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/keycloak/keycloak:22.0.3
 No newline at end of file
+27 −0
Changes for src/main/resources/db/migration/V1.0.0__initialize_database.sql: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
create sequence OssClientData_SEQ start with 1 increment by 50;

create sequence ServiceOrderData_SEQ start with 1 increment by 50;

create table OssClientData (
                               id bigint not null,
                               baseUrl varchar(255),
                               name varchar(255),
                               organizationId varchar(255),
                               primary key (id)
);

create table ServiceOrderData (
                                  id bigint not null,
                                  completionDate timestamp(6) with time zone,
                                  isMessageSentToSonata boolean,
                                  kogitoProcessInstanceId uuid,
                                  kubeConfig TEXT,
                                  locationId uuid,
                                  openSliceResourceId varchar(255),
                                  openSliceServiceId varchar(255),
                                  openSliceServiceOrderId varchar(255),
                                  openSliceServiceOrderStatus smallint check ((openSliceServiceOrderStatus between 0 and 8)),
                                  sonataServiceId varchar(255),
                                  sonataServiceOrderId varchar(255),
                                  primary key (id)
);
Loading