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

CRF-9: Create a Judgment Reporting DB for RTL feed #94

Merged
merged 42 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9c5f99c
Create a Judgment Reporting DB
ssivas6 Aug 23, 2024
a887482
Create a Judgment Reporting DB
ssivas6 Aug 23, 2024
12195b6
Create a Judgment Reporting DB
ssivas6 Sep 2, 2024
312cc52
Adding fixes to the Judgment Reporting DB for RTL feed
ssivas6 Sep 3, 2024
78c033f
Adding fixes to the Judgment Reporting DB for RTL feed
ssivas6 Sep 4, 2024
e17511b
Adding fix to allow successful running on integration tests
ssivas6 Sep 4, 2024
d7231cf
Updating postgres versions for integration tests
ssivas6 Sep 9, 2024
9174f1e
Deleted redundant migration scripts
ssivas6 Sep 9, 2024
86ce082
adding files for infrastructure development
ssivas6 Sep 10, 2024
bf548ee
adding files for infrastructure development
ssivas6 Sep 10, 2024
c94b01d
adding files for infrastructure development
ssivas6 Sep 10, 2024
d56591d
adding files for infrastructure development
ssivas6 Sep 11, 2024
4c84f9c
adding files for infrastructure development
ssivas6 Sep 11, 2024
4d452cd
adding files for infrastructure development
ssivas6 Sep 11, 2024
4a1b854
Modifying infrastructure files
ssivas6 Sep 12, 2024
150d004
Modifying infrastructure files
ssivas6 Sep 12, 2024
07a259f
Bumping chart version/ fixing aliases
hmcts-jenkins-a-to-c[bot] Sep 12, 2024
5092408
CRF-9-key-vault infrastructure change
ssivas6 Sep 13, 2024
2405503
Update plugin org.springframework.boot to v3.3.3
renovate[bot] Aug 26, 2024
01f2720
Update log4j2 monorepo to v2.24.0
renovate[bot] Sep 9, 2024
83b6d32
Update dependency gradle to v8.10.1
renovate[bot] Sep 10, 2024
bbfae20
CRF-9-key-vault infrastructure change
ssivas6 Sep 13, 2024
6082abd
Merge branch 'master' into CRF-9
ssivas6 Sep 13, 2024
8062390
CRF-9-database configuration fix
ssivas6 Sep 18, 2024
36b044a
Merge branch 'master' into CRF-9
ssivas6 Sep 18, 2024
2a41ded
Modifying the import in application.yaml
ssivas6 Sep 18, 2024
d6fdafa
Modifying the environment's database name in values.yaml
ssivas6 Sep 18, 2024
27ce176
Adding fix for smoke test error
ssivas6 Sep 19, 2024
49674ca
Adding fix for smoke test error
ssivas6 Sep 19, 2024
e811573
Adding fix for smoke test error
ssivas6 Sep 19, 2024
8164681
Adding fix for functional test error
ssivas6 Sep 19, 2024
d5c7917
Addressing review comments for CRF-9
ssivas6 Sep 23, 2024
3399879
Removing the Autowired annotation to use constructor method instead
ssivas6 Sep 23, 2024
8a06a76
Reformatting of index,constraint and sequence names
ssivas6 Sep 23, 2024
eda30fc
Reformatting of index,constraint and sequence names
ssivas6 Sep 23, 2024
cb227c3
Reformatting of index,constraint and sequence names
ssivas6 Sep 24, 2024
4e8b2c5
dependency change update
ssivas6 Oct 1, 2024
dbb0b6d
Bumping chart version/ fixing aliases
hmcts-jenkins-a-to-c[bot] Oct 1, 2024
3207fd4
Merge branch 'master' into CRF-9
paulridout Oct 2, 2024
a2b99dd
Updating judgment name and adding version_number column
ssivas6 Oct 9, 2024
8ec7da9
Corrected indentation in build.gradle
ssivas6 Oct 9, 2024
352b8d1
Merge branch 'master' into CRF-9
ssivas6 Oct 9, 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
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'org.springframework.boot' version '3.3.4'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonarqube' version '5.1.0.4882'
id "org.flywaydb.flyway" version "10.17.2"
/*
Applies analysis tools including checkstyle and OWASP Dependency checker.
See https://github.com/hmcts/gradle-java-plugin
Expand Down Expand Up @@ -156,6 +157,7 @@ dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-json'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.6.0'

implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: '6.1.6'
Expand All @@ -165,6 +167,11 @@ dependencies {

implementation group: 'io.rest-assured', name: 'rest-assured'

implementation group: 'org.flywaydb', name: 'flyway-database-postgresql', version: '10.17.2'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.4'

testImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.20.1'

testImplementation(platform('org.junit:junit-bom:5.11.2'))
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', {
Expand All @@ -173,6 +180,15 @@ dependencies {
}
}

// Gradle 7.x issue, workaround from: https://github.com/gradle/gradle/issues/17236#issuecomment-894768083
rootProject.tasks.named("processIntegrationTestResources") {
duplicatesStrategy = 'include'
}

rootProject.tasks.named("processFunctionalTestResources") {
duplicatesStrategy = 'include'
}

mainClassName = 'uk.gov.hmcts.reform.civil.Application'

bootJar {
Expand All @@ -189,5 +205,5 @@ rootProject.tasks.named("processSmokeTestResources") {
}

wrapper {
distributionType = Wrapper.DistributionType.ALL
distributionType = Wrapper.DistributionType.ALL
}
2 changes: 1 addition & 1 deletion charts/civil-rtl-export/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: "1.0"
description: A Helm chart for civil-rtl-export App
name: civil-rtl-export
home: https://github.com/hmcts/civil-rtl-export
version: 0.0.18
version: 0.0.19
maintainers:
- name: HMCTS civil team
dependencies:
Expand Down
11 changes: 11 additions & 0 deletions charts/civil-rtl-export/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ java:
- name: AppInsightsInstrumentationKey
alias: APPINSIGHTS_CONNECTION_STRING
environment:
JF_DB_NAME: civil_rtl_export
JF_DB_PORT: 5432
keyVaults:
civil-rtl-export:
secrets:
- name: civil-rtl-export-POSTGRES-USER-V15
alias: JF_DB_USERNAME
- name: civil-rtl-export-POSTGRES-PASS-V15
alias: JF_DB_PASSWORD
- name: civil-rtl-export-POSTGRES-HOST-V15
alias: JF_DB_HOST
26 changes: 25 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- http_proxy
- https_proxy
- no_proxy
image: hmctspublic.azurecr.io/spring-boot/template
image: hmcts/civil-rtl-export
environment:
# these environment variables are used by java-logging library
- ROOT_APPENDER
Expand All @@ -22,5 +22,29 @@ services:
- LOGBACK_REQUIRE_THREAD
- LOGBACK_REQUIRE_ALERT_LEVEL=false
- LOGBACK_REQUIRE_ERROR_CODE=false
- JF_DB_HOST=civil-rtl-export-database
ports:
- $SERVER_PORT:$SERVER_PORT
depends_on:
- civil-rtl-export-database
links:
- civil-rtl-export-database
civil-rtl-export-database:
build:
context: docker/database
image: hmcts/civil-rtl-export-database
healthcheck:
interval: 10s
timeout: 10s
retries: 10
environment:
- JF_DB_USERNAME=jf_user
- JF_DB_PASSWORD=jf_pass
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- 5455:5432
volumes:
- civil-rtl-export-database-data:/var/lib/postgresql/data

volumes:
civil-rtl-export-database-data:
49 changes: 49 additions & 0 deletions docker/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '2.1'

services:
civil-rtl-export:
build:
context: .
args:
- http_proxy
- https_proxy
- no_proxy
image: hmcts/civil-rtl-export
environment:
# these environment variables are used by java-logging library
- ROOT_APPENDER
- JSON_CONSOLE_PRETTY_PRINT
- ROOT_LOGGING_LEVEL
- REFORM_SERVICE_TYPE
- REFORM_SERVICE_NAME
- REFORM_TEAM
- REFORM_ENVIRONMENT
- LOGBACK_DATE_FORMAT
- LOGBACK_REQUIRE_THREAD
- LOGBACK_REQUIRE_ALERT_LEVEL=false
- LOGBACK_REQUIRE_ERROR_CODE=false
ports:
- $SERVER_PORT:$SERVER_PORT
depends_on:
- civil-rtl-export-database
links:
- civil-rtl-export-database

civil-rtl-export-database:
build:
context: docker/database
image: hmcts/civil-rtl-export-database
healthcheck:
interval: 10s
timeout: 10s
retries: 10
environment:
- JF_DB_USERNAME=jf_user
- JF_DB_PASSWORD=jf_pass
ports:
- 5455:5432
volumes:
- civil-rtl-export-database-data:/var/lib/postgresql/data

volumes:
civil-rtl-export-database-data:
7 changes: 7 additions & 0 deletions docker/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM postgres:15

COPY init-db.sh /docker-entrypoint-initdb.d

HEALTHCHECK --interval=10s --timeout=10s --retries=10 CMD psql -c 'select 1' -d civil_rtl_export -U ${JF_DB_USERNAME}

EXPOSE 5432
18 changes: 18 additions & 0 deletions docker/database/init-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

# Civil Judgement Feed database
if [ -z "$JF_DB_PASSWORD" ] || [ -z "$JF_DB_USERNAME" ]; then
echo "ERROR: Missing environment variable. Set value for both 'JF_DB_USERNAME' and 'JF_DB_PASSWORD'."
exit 1
fi

psql -v ON_ERROR_STOP=1 --username postgres --set USERNAME=${JF_DB_USERNAME} --set PASSWORD=${JF_DB_PASSWORD} <<-EOSQL
CREATE USER :USERNAME WITH PASSWORD :'PASSWORD';

CREATE DATABASE civil_rtl_export
WITH OWNER = :USERNAME
ENCODING = 'UTF-8'
CONNECTION LIMIT = -1;
EOSQL
2 changes: 1 addition & 1 deletion infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ variable "jenkins_AAD_objectId" {
variable "database_backup_retention_days" {
default = 35
description = "Backup retention period in days for the PGSql instance. Valid values are between 7 & 35 days"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import static io.restassured.RestAssured.given;

@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ActiveProfiles("functional")
class SampleFunctionalTest {
protected static final String CONTENT_TYPE_VALUE = "application/json";

Expand Down
5 changes: 5 additions & 0 deletions src/functionalTest/resources/application-functional.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spring:
datasource:
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver
url: jdbc:tc:postgresql:15:///databasename?stringtype=unspecified

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;

Expand All @@ -23,10 +24,15 @@
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@ActiveProfiles("itest")
class OpenAPIPublisherTest {

private final MockMvc mvc;

@Autowired
private MockMvc mvc;
public OpenAPIPublisherTest(MockMvc mockMvc) {
mvc = mockMvc;
}

@DisplayName("Generate swagger documentation")
@Test
Expand Down
5 changes: 5 additions & 0 deletions src/integrationTest/resources/application-itest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spring:
datasource:
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver
url: jdbc:tc:postgresql:15:///databasename?stringtype=unspecified

94 changes: 67 additions & 27 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,74 @@ springdoc:
packagesToScan: uk.gov.hmcts.reform.civil.controllers
writer-with-order-by-keys: true

#If you use a database then uncomment below lines and update db properties accordingly
spring:
aop:
proxy-target-class: false
main:
allow-bean-definition-overriding: true
allow-circular-references: true
config:
import: "optional:configtree:/mnt/secrets/civil/"
import: "optional:configtree:/mnt/secrets/civil-rtl-export/"
application:
name: Spring Boot Template
# datasource:
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}${DB_OPTIONS:}
# username: ${DB_USER_NAME}
# password: ${DB_PASSWORD}
# properties:
# charSet: UTF-8
# hikari:
# minimumIdle: 2
# maximumPoolSize: 10
# idleTimeout: 10000
# poolName: {to-be-defined}HikariCP
# maxLifetime: 7200000
# connectionTimeout: 30000
# jpa:
# properties:
# hibernate:
# jdbc:
# lob:
# # silence the 'wall-of-text' - unnecessary exception throw about blob types
# non_contextual_creation: true
name: Civil Judgement Feed
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://${JF_DB_HOST:localhost}:${JF_DB_PORT:5432}/${JF_DB_NAME:civil_rtl_export}${JF_DB_OPTIONS:}
username: ${JF_DB_USERNAME:jf_user}
password: ${JF_DB_PASSWORD:jf_pass}
hikari:
minimumIdle: ${JF_DB_MIN_IDLE:2}
maximumPoolSize: ${JF_DB_MAX_POOL_SIZE:8}
idleTimeout: ${JF_DB_IDLE_TIMEOUT:300000}
maxLifetime: ${JF_DB_MAX_LIFTIME:7200000}
connectionTimeout: 60000
jpa:
open-in-view: false
database: postgresql
properties:
hibernate:
order_inserts: true
order_updates: true
jdbc:
batch_versioned_data: true
batch_size: 100
temp:
use_jdbc_metadata_defaults: false
flyway:
ignore-missing-migrations: 'true'
baseline-version: '0001'
out-of-order: 'true'
baseline-on-migrate: 'true'

azure:
application-insights:
instrumentation-key: ${civil.AppInsightsInstrumentationKey:00000000-0000-0000-0000-000000000000}
feign:
circuitbreaker:
enabled: true
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
loggerLevel: BASIC
postFeignClient:
loggerLevel: FULL
#idam:
# s2s-authorised:
# services: ${CIVIL_SDT_S2S_AUTHORISED_SERVICES:civil_sdt}
# s2s-auth:
# microservice: civil_sdt
# totp_secret: ${CIVIL_SDT_S2S_KEY:AAAAAAAAAAAAAAAA}
# url: ${IDAM_S2S_URL:http://localhost:4502}
# sdt:
# username: ${IDAM_SDT_USERNAME:master.sdt@gmail.com}
# password: ${IDAM_SDT_PASSWORD:Pa55word11}
# api:
# url: ${IDAM_API_URL:http://localhost:5000}
# client:
# id: civil_sdt
# secret: ${IDAM_SDT_CLIENT_SECRET:civil_sdt_secret}
# scope: openid profile roles
# # The redirect_uri property is not used by SDT. Included as required by IDAM for token generation.
# redirect_uri: http://civil-sdt/oauth2redirect
#civil:
# api:
# url: ${CIVIL_API_URL:http://localhost:5000}
Loading