Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NOD-745 coverage 80 unit test #7

Merged
merged 26 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4fea23b
NOD-745: fix some Sonar Issues
fparisitas Mar 25, 2024
d45a347
NOD-745: fix tests
fparisitas Mar 26, 2024
9bb2dd8
NOD-745: fix coverage
fparisitas Mar 26, 2024
0f4ce8d
NOD-745: fix coverage
fparisitas Mar 26, 2024
523766d
NOD-745: fix coverage
fparisitas Mar 26, 2024
645df0a
NOD-745: fix coverage
fparisitas Mar 26, 2024
e9f9ca2
NOD-745: fix coverage
fparisitas Mar 26, 2024
f9630ce
NOD-745: fix coverage
fparisitas Mar 26, 2024
7d47275
NOD-745: fix coverage
fparisitas Mar 26, 2024
ead35f2
NOD-745: fix coverage
fparisitas Mar 27, 2024
e683bb1
NOD-745: fix coverage
fparisitas Mar 27, 2024
5d05d23
NOD-745: fix coverage
fparisitas Mar 27, 2024
10c4187
NOD-745: fix coverage
fparisitas Mar 27, 2024
548f4ab
NOD-745: fix coverage
fparisitas Mar 27, 2024
7756bd4
NOD-745: fix coverage
fparisitas Mar 27, 2024
f7dd48a
NOD-745: fix coverage
fparisitas Mar 27, 2024
66a02b6
NOD-745: fix coverage
fparisitas Mar 27, 2024
aa559af
Bump to version 0.0.1-1-NOD-745-nodo-cfg-sync-coprire-l-80-del-codice…
pagopa-github-bot Mar 27, 2024
8b89cf4
Bump to version 0.0.1-2-NOD-745-coverage-80-unit-test [skip ci]
pagopa-github-bot Mar 27, 2024
364c7a2
NOD-745: fix Hikari props
fparisitas Mar 27, 2024
a8f640a
Bump to version 0.0.1-3-NOD-745-coverage-80-unit-test [skip ci]
pagopa-github-bot Mar 27, 2024
77b7a17
NOD-745: fix log + Hikari props
fparisitas Mar 27, 2024
de530d5
Bump to version 0.0.1-4-NOD-745-coverage-80-unit-test [skip ci]
pagopa-github-bot Mar 27, 2024
80bb963
NOD-745: fix log for alarm
fparisitas Mar 28, 2024
4891540
NOD-745: fix Hikari connection-test-query
fparisitas Mar 28, 2024
6e95eb5
Bump to version 0.0.1-5-NOD-745-coverage-80-unit-test [skip ci]
pagopa-github-bot Mar 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-afm-calculator
description: Microservice that handles calculation for pagoPA Advanced Fees Management
type: application
version: 0.35.0
appVersion: 0.0.1
version: 0.40.0
appVersion: 0.0.1-5-NOD-745-coverage-80-unit-test
dependencies:
- name: microservice-chart
version: 2.8.0
Expand Down
8 changes: 4 additions & 4 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.1"
tag: "0.0.1-5-NOD-745-coverage-80-unit-test"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -64,12 +64,12 @@ microservice-chart:
envConfig:
WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync'
ENV: 'azure-dev'
APP_LOGGING_LEVEL: 'DEBUG'
APP_LOGGING_LEVEL: 'INFO'
DEFAULT_LOGGING_LEVEL: 'INFO'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
DB_NEXI_POSTGRES_URL: "jdbc:postgresql://db-postgres-ndp.d.db-nodo-pagamenti.com:5444/ndpspct?prepareThreshold=0&currentSchema=NODO4_CFG"
DB_NEXI_POSTGRES_USER: "pp_nodo4_cfg"
DB_NEXI_POSTGRES_ENABLED: "true"
DB_NEXI_POSTGRES_ENABLED: "false"
DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV"
DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))"
DB_NEXI_ORACLE_USER: "NODO4_CFG"
Expand All @@ -79,7 +79,7 @@ microservice-chart:
DB_PAGOPA_POSTGRES_USER: "cfg"
DB_PAGOPA_POSTGRES_ENABLED: "true"
DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV"
API_CONFIG_CACHE_URL: "https://api.dev.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1"
API_CONFIG_CACHE_URL: "https://api.dev.platform.pagopa.it/api-config-cache/o/v1/stakeholders/node/cache/schemas/v1"
STAND_IN_MANAGER_URL: "https://api.dev.platform.pagopa.it/stand-in-manager/api/v1"
OTEL_SERVICE_NAME: "pagopanodecfgsync"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev"
Expand Down
37 changes: 28 additions & 9 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.1"
tag: "0.0.1-5-NOD-745-coverage-80-unit-test"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -47,8 +47,8 @@ microservice-chart:
memory: "512Mi"
cpu: "0.25"
limits:
memory: "512Mi"
cpu: "0.5"
memory: "1G"
cpu: "1.0"
autoscaling:
enable: true
minReplica: 1
Expand All @@ -64,10 +64,23 @@ microservice-chart:
envConfig:
WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync' # required to show cloud role name in application insights
ENV: 'azure-prod'
APP_LOGGING_LEVEL: 'DEBUG'
APP_LOGGING_LEVEL: 'INFO'
DEFAULT_LOGGING_LEVEL: 'INFO'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
CACHET_TX_NAME: "nodo-dei-pagamenti-cache"
DB_NEXI_POSTGRES_URL: "jdbc:postgresql://db-postgres-ndp.p.db-nodo-pagamenti.com:5444/ndpspcp?prepareThreshold=0&currentSchema=NODO4_CFG"
DB_NEXI_POSTGRES_USER: "pp_nodo4_cfg"
DB_NEXI_POSTGRES_ENABLED: "false"
DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV"
DB_CONFIG_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1521)(HOST=db-nodo-pagamenti.p.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))"
DB_NEXI_ORACLE_USER: "NODO4_CFG"
DB_NEXI_ORACLE_ENABLED: "true"
DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV"
DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.p.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_PAGOPA_POSTGRES_USER: "cfg"
DB_PAGOPA_POSTGRES_ENABLED: "true"
DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV"
API_CONFIG_CACHE_URL: "https://api.uat.platform.pagopa.it/api-config-cache/o/v1/stakeholders/node/cache/schemas/v1"
STAND_IN_MANAGER_URL: "https://api.uat.platform.pagopa.it/stand-in-manager/api/v1"
OTEL_SERVICE_NAME: "pagopanodecfgsync"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=prod"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
Expand All @@ -78,12 +91,18 @@ microservice-chart:
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string'
CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key"
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password"
DB_NEXI_POSTGRES_PASSWORD: "db-nexi-cfg-password"
DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password"
API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key"
API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key"
STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key"
STAND_IN_MANAGER_SA_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-sa-connection-string-key"
API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
OTEL_EXPORTER_OTLP_HEADERS: "elastic-apm-secret-token"
keyvault:
name: "pagopa-d-nodo-kv"
name: "pagopa-p-nodo-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: {}
tolerations: []
Expand Down Expand Up @@ -119,7 +138,7 @@ microservice-chart:
deployment:
create: true
image:
repository: ghcr.io/pagopa/yourname # TODO
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.0"
pullPolicy: Always
envConfig: {}
Expand Down
37 changes: 27 additions & 10 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.1"
tag: "0.0.1-5-NOD-745-coverage-80-unit-test"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -47,8 +47,8 @@ microservice-chart:
memory: "512Mi"
cpu: "0.25"
limits:
memory: "512Mi"
cpu: "0.5"
memory: "1G"
cpu: "1.0"
autoscaling:
enable: true
minReplica: 1
Expand All @@ -62,13 +62,24 @@ microservice-chart:
type: Utilization # Allowed types are 'Utilization' or 'AverageValue'
value: "75"
envConfig:
WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync' # required to show cloud role name in application insights
WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync'
ENV: 'azure-uat'
APP_LOGGING_LEVEL: 'DEBUG'
APP_LOGGING_LEVEL: 'INFO'
DEFAULT_LOGGING_LEVEL: 'INFO'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
CACHET_TX_NAME: "nodo-dei-pagamenti-cache"
API_CONFIG_CACHE_URL: "https://api.uat.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1"
DB_NEXI_POSTGRES_URL: "jdbc:postgresql://db-postgres-ndp.u.db-nodo-pagamenti.com:5444/ndpspca?prepareThreshold=0&currentSchema=NODO4_CFG"
DB_NEXI_POSTGRES_USER: "pp_nodo4_cfg"
DB_NEXI_POSTGRES_ENABLED: "false"
DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV"
DB_CONFIG_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1524)(HOST=db-nodo-pagamenti.u.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCA_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))"
DB_NEXI_ORACLE_USER: "NODO4_CFG"
DB_NEXI_ORACLE_ENABLED: "true"
DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV"
DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.u.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_PAGOPA_POSTGRES_USER: "cfg"
DB_PAGOPA_POSTGRES_ENABLED: "true"
DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV"
API_CONFIG_CACHE_URL: "https://api.uat.platform.pagopa.it/api-config-cache/o/v1/stakeholders/node/cache/schemas/v1"
STAND_IN_MANAGER_URL: "https://api.uat.platform.pagopa.it/stand-in-manager/api/v1"
OTEL_SERVICE_NAME: "pagopanodecfgsync"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat"
Expand All @@ -80,12 +91,18 @@ microservice-chart:
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string'
CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key"
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password"
DB_NEXI_POSTGRES_PASSWORD: "db-nexi-cfg-password"
DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password"
API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key"
API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key"
STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key"
STAND_IN_MANAGER_SA_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-sa-connection-string-key"
API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
OTEL_EXPORTER_OTLP_HEADERS: "elastic-apm-secret-token"
keyvault:
name: "pagopa-d-nodo-kv"
name: "pagopa-u-nodo-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: {}
tolerations: []
Expand Down
10 changes: 5 additions & 5 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "cfg-sync",
"description": "Microservice to update configuration schema of Nodo dei Pagamenti",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.0.1"
"version": "0.0.1-5-NOD-745-coverage-80-unit-test"
},
"servers": [
{
Expand Down Expand Up @@ -265,10 +265,10 @@
"description": "Database sync status result",
"example": "done",
"enum": [
"done",
"disabled",
"rollback",
"error"
"DONE",
"DISABLED",
"ROLLBACK",
"ERROR"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>it.gov.pagopa.node</groupId>
<artifactId>cfg-sync</artifactId>
<version>0.0.1</version>
<version>0.0.1-5-NOD-745-coverage-80-unit-test</version>
<description>Microservice to update configuration schema of Nodo dei Pagamenti</description>

<properties>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.responses.ApiResponses;
import io.swagger.v3.oas.models.security.SecurityScheme;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import it.gov.pagopa.node.cfgsync.util.Constants;
import org.springdoc.core.customizers.OpenApiCustomiser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

@Configuration
public class OpenApiConfig {

Expand Down
16 changes: 6 additions & 10 deletions src/main/java/it/gov/pagopa/node/cfgsync/config/RequestFilter.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package it.gov.pagopa.node.cfgsync.config;

import java.io.IOException;
import java.util.UUID;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import it.gov.pagopa.node.cfgsync.util.Constants;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;

@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package it.gov.pagopa.node.cfgsync.config;

import it.gov.pagopa.node.cfgsync.exception.AppException;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
Expand All @@ -13,6 +10,10 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Set;

@Aspect
@Component
public class ResponseValidator {
Expand All @@ -28,7 +29,7 @@ public class ResponseValidator {
* @param result the response to validate
*/

@AfterReturning(pointcut = "execution(* it.gov.pagopa.node.cfg_sync.controller.*.*(..))", returning = "result")
@AfterReturning(pointcut = "execution(* it.gov.pagopa.node.cfgsync.controller.*.*(..))", returning = "result")
public void validateResponse(JoinPoint joinPoint, Object result) {
if (result instanceof ResponseEntity) {
validateResponse((ResponseEntity<?>) result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import it.gov.pagopa.node.cfgsync.model.ProblemJson;
import it.gov.pagopa.node.cfgsync.model.SyncStatusEnum;
import it.gov.pagopa.node.cfgsync.model.SyncStatusResponse;
import it.gov.pagopa.node.cfgsync.model.TargetRefreshEnum;
import it.gov.pagopa.node.cfgsync.service.ApiConfigCacheService;
import it.gov.pagopa.node.cfgsync.service.StandInManagerService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
Expand All @@ -29,14 +30,12 @@
@RestController
@RequestMapping("/ndp")
@Validated
@AllArgsConstructor
public class SyncCacheController {

@Autowired
private ApiConfigCacheService apiConfigCacheService;
@Autowired
private StandInManagerService standInManagerService;


@Operation(
summary = "Force stand-in configuration to update",
security = {@SecurityRequirement(name = "ApiKey")},
Expand Down Expand Up @@ -81,8 +80,8 @@ public class SyncCacheController {
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<SyncStatusResponse>> standin() {

log.debug("Force stand-in configuration to update");
Map<String, SyncStatusEnum> syncStatusEnumMap = standInManagerService.forceStandIn();
log.debug("[NODE-CFG-SYNC] Force {}, configuration to update", TargetRefreshEnum.standin.label);
Map<String, SyncStatusEnum> syncStatusEnumMap = standInManagerService.syncStandIn();

List<SyncStatusResponse> syncStatusResponseList = syncStatusEnumMap.entrySet()
.stream()
Expand Down Expand Up @@ -136,8 +135,8 @@ public ResponseEntity<List<SyncStatusResponse>> standin() {
value = "/cache",
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<SyncStatusResponse>> cache() {
log.debug("Force cache configuration to update");
Map<String, SyncStatusEnum> syncStatusEnumMap = apiConfigCacheService.forceCacheUpdate();
log.debug("[NODE-CFG-SYNC] Force {} configuration to update", TargetRefreshEnum.cache.label);
Map<String, SyncStatusEnum> syncStatusEnumMap = apiConfigCacheService.syncCache();

List<SyncStatusResponse> syncStatusResponseList = syncStatusEnumMap.entrySet()
.stream()
Expand Down
Loading