Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #183 from admin-ch/feature/cfenv
Browse files Browse the repository at this point in the history
  • Loading branch information
gstoehld authored Dec 16, 2022
2 parents 4a2bf8d + 7da5edf commit d790169
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 101 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: 'zulu'
- name: Cache SonarCloud packages
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tagged_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- uses: actions/checkout@v3
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
java-version: 17
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file: :
distribution: 'zulu'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.0</version>
<version>42.5.1</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
Expand All @@ -65,7 +65,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.17.5</version>
<version>1.17.6</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
<version>${spring-cloud-connectors-version}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.17.5</version>
<version>1.17.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.17.5</version>
<version>1.17.6</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.pivotal.cfenv</groupId>
<artifactId>java-cfenv-boot</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ public abstract class SyncBaseConfig {
@Value("${ws.keys.batch-size:1000}")
protected Integer dscBatchSize;

public abstract DataSource dataSource();

public abstract Flyway flyway();
public abstract Flyway flyway(DataSource dataSource);

public abstract String getDbType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,25 @@

import java.util.Map;
import javax.sql.DataSource;
import javax.xml.crypto.Data;

import org.flywaydb.core.Flyway;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.CloudFactory;
import org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig;
import org.springframework.cloud.service.relational.DataSourceConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.pivotal.cfenv.jdbc.CfJdbcEnv;
import io.pivotal.cfenv.jdbc.CfJdbcService;

@Configuration
public abstract class SyncCloudBaseConfig extends SyncBaseConfig {

@Value("${datasource.maximumPoolSize:5}")
int dataSourceMaximumPoolSize;

@Value("${datasource.connectionTimeout:30000}")
int dataSourceConnectionTimeout;

@Value("${datasource.leakDetectionThreshold:0}")
int dataSourceLeakDetectionThreshold;

@Bean
@Override
public DataSource dataSource() {
PoolConfig poolConfig =
new PoolConfig(dataSourceMaximumPoolSize, dataSourceConnectionTimeout);
DataSourceConfig dbConfig =
new DataSourceConfig(
poolConfig,
null,
null,
Map.of("leakDetectionThreshold", dataSourceLeakDetectionThreshold));
CloudFactory factory = new CloudFactory();
return factory.getCloud().getSingletonServiceConnector(DataSource.class, dbConfig);
}

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
Flyway flyWay =
Flyway.configure()
.dataSource(dataSource())
.dataSource(dataSource)
.locations("classpath:/db/migration/pgsql_cluster")
.load();
flyWay.migrate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public DataSource dataSource() {

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
Flyway flyWay =
Flyway.configure()
.dataSource(dataSource())
.dataSource(dataSource)
.locations("classpath:/db/migration/pgsql")
.load();
flyWay.migrate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<version>1.0.0-SNAPSHOT</version>

<properties>
<testcontainers.version>1.17.5</testcontainers.version>
<testcontainers.version>1.17.6</testcontainers.version>
<sonar.projectKey>${env.SONAR_PROJECTKEY}</sonar.projectKey>
</properties>

Expand Down Expand Up @@ -57,10 +57,10 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
<version>${spring-cloud-connectors-version}</version>
</dependency>
<groupId>io.pivotal.cfenv</groupId>
<artifactId>java-cfenv-boot</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ protected String[] getDisabledVerificationModes() {
return disabledVerificationModes;
}

public abstract DataSource dataSource();

public abstract Flyway flyway();
public abstract Flyway flyway(DataSource dataSource);

@Value("${ws.keys.release-bucket-duration:PT6H}")
public void setKeysBucketDuration(Duration bucketDuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,17 @@
import javax.sql.DataSource;
import org.flywaydb.core.Flyway;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.CloudFactory;
import org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig;
import org.springframework.cloud.service.relational.DataSourceConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public abstract class WsCloudBaseConfig extends WsBaseConfig {

@Value("${datasource.maximumPoolSize:5}")
int dataSourceMaximumPoolSize;

@Value("${datasource.connectionTimeout:30000}")
int dataSourceConnectionTimeout;

@Value("${datasource.leakDetectionThreshold:0}")
int dataSourceLeakDetectionThreshold;

@Bean
@Override
public DataSource dataSource() {
PoolConfig poolConfig =
new PoolConfig(dataSourceMaximumPoolSize, dataSourceConnectionTimeout);
DataSourceConfig dbConfig =
new DataSourceConfig(
poolConfig,
null,
null,
Map.of("leakDetectionThreshold", dataSourceLeakDetectionThreshold));
CloudFactory factory = new CloudFactory();
return factory.getCloud().getSingletonServiceConnector(DataSource.class, dbConfig);
}

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
Flyway flyWay =
Flyway.configure()
.dataSource(dataSource())
.dataSource(dataSource)
.locations("classpath:/db/migration/pgsql_cluster")
.load();
flyWay.migrate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public DataSource dataSource() {

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
Flyway flyWay =
Flyway.configure()
.dataSource(dataSource())
.dataSource(dataSource)
.locations("classpath:/db/migration/pgsql")
.load();
flyWay.migrate();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"validDuration": 172800000, "lastDownload": 1665473995987, "nextSince": "11843609"}
{"validDuration": 172800000, "lastDownload": 1670858784137, "nextSince": "11856236"}
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,9 @@ public class TestConfig extends WsBaseConfig {
@Value("${revocationList.baseurl}")
String baseurl = "https://covidcertificate-management-d.bag.admin.ch/api";

@Autowired DataSource dataSource;

@Override
public DataSource dataSource() {
return dataSource;
}

@Bean
@Override
public Flyway flyway() {
public Flyway flyway(DataSource dataSource) {
final var flyway =
Flyway.configure()
.dataSource(dataSource)
Expand Down
9 changes: 4 additions & 5 deletions ch-covidcertificate-backend-verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
<name>CH Covidcertificate Verifier Backend</name>

<properties>
<java-version>11</java-version>
<java-version>17</java-version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<spring-boot-version>2.7.4</spring-boot-version>
<spring-cloud-sleuth-version>3.1.4</spring-cloud-sleuth-version>
<spring-boot-version>2.7.6</spring-boot-version>
<spring-cloud-sleuth-version>3.1.5</spring-cloud-sleuth-version>
<jackson-version>2.11.1</jackson-version>
<jsonwebtoken-version>0.11.5</jsonwebtoken-version>
<testcontainers-version>1.17.5</testcontainers-version>
<testcontainers-version>1.17.6</testcontainers-version>
<shedlock.version>4.42.0</shedlock.version>
<spring-cloud-connectors-version>2.2.13.RELEASE</spring-cloud-connectors-version>

<itCoverageAgent></itCoverageAgent>

Expand Down
6 changes: 6 additions & 0 deletions update_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ python3 ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifie
sqlite3 revocations.sqlite "CREATE TABLE revocations ( uvci text NOT NULL );" ".mode csv" ".import revocations.csv revocations"
sqlite3 revocations.sqlite "CREATE TABLE \"metadata\" (\"validDuration\" integer NOT NULL DEFAULT '0',\"lastDownload\" integer NOT NULL DEFAULT '0',\"nextSince\" text);"
sqlite3 revocations.sqlite "INSERT INTO \"metadata\" (validDuration, lastDownload, nextSince) VALUES ($(cat revocation_metadata.json | jq .validDuration), $(cat revocation_metadata.json | jq .lastDownload), $(cat revocation_metadata.json | jq .nextSince));"

sqlite3 revocations-android.sqlite "CREATE TABLE revocations ( uvci text NOT NULL ,PRIMARY KEY (uvci));" ".mode csv" ".import revocations.csv revocations"
sqlite3 revocations-android.sqlite "CREATE TABLE \"metadata\" (\"validDuration\" integer NOT NULL DEFAULT '0',\"lastDownload\" integer NOT NULL DEFAULT '0',\"nextSince\" text NOT NULL DEFAULT '' , PRIMARY KEY (nextSince, validDuration, lastDownload));"
sqlite3 revocations-android.sqlite "INSERT INTO \"metadata\" (validDuration, lastDownload, nextSince) VALUES ($(cat revocation_metadata.json | jq .validDuration), $(cat revocation_metadata.json | jq .lastDownload), $(cat revocation_metadata.json | jq .nextSince));"

rm revocations.csv
mv revocations.sqlite ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/resources/
mv revocations-android.sqlite ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/resources/
mv revocation_metadata.json ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/resources/

./ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-valuesets/src/main/resources/test_rules.sh

0 comments on commit d790169

Please sign in to comment.