Skip to content

Commit 9c81f30

Browse files
committed
Converted project to multi-module, added CI workflow
1 parent 1c14c6c commit 9c81f30

File tree

10 files changed

+158
-44
lines changed

10 files changed

+158
-44
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Main CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-test:
11+
name: Build & Test
12+
runs-on: ubuntu-latest
13+
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
14+
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up JDK 22
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: 22
25+
distribution: 'temurin'
26+
cache: maven
27+
28+
- name: Build
29+
run: mvn clean install -DskipTests
30+
31+
- name: Run ojp-server
32+
run: mvn verify -pl ojp-server -Prun-ojp-server
33+
34+
- name: Run tests
35+
run: mvn test -DdisablePostgresTests

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
# ignore all files in any directory named .idea
55
*/.idea/
6-
6+
.idea/

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,31 @@ This intelligent allocation of connections helps prevent overloading databases a
5858

5959
### ojp-server
6060
The ojp-server is a gRPC server that manages a Hikari connection pool and abstracts the creation and management of database connections. It supports one or multiple relational databases and provides virtual connections to the ojp-jdbc-driver. The server ensures the number of open real connections is always under control, according to predefined settings, improving database scalability.
61-
#### How to start from source code
62-
>Build the ojp-grpc-commons first.
63-
64-
> Run the class GrpcServer main method.
6561

6662
#### How to start a docker image
6763

6864
> docker run --rm -d -p 1059:1059 rrobetti/ojp:0.0.1-alpha
6965
7066
### ojp-jdbc-driver
7167
The ojp-jdbc-driver is an implementation of the JDBC specification. It connects to the ojp-server via the gRPC protocol, sending SQL statements to be executed against the database and reading the responses. The driver works with virtual connections provided by the ojp-server, allowing the application to interact with the database without directly managing real database connections.
72-
#### How to run
73-
>Build the ojp-grpc-commons first.
74-
75-
>Run any integration tests, the ojp-server is expected to be running in the same machine.
76-
77-
Connections configuration: There are csv files under test/resources with connection details defaulted to H2 database, the name of each file implies which database connections can be added to it, for example the file h2_postgres_connections.csv can contain connections to H2 and/or postgres databases, integration tests classes that relly on this file will run all their tests against each connection in the file.
7868

7969
### ojp-grpc-commons
8070
The ojp-grpc-commons module contains the shared gRPC contracts used between the ojp-server and ojp-jdbc-driver. These contracts define the communication protocol and structure for requests and responses exchanged between the server and the driver.
81-
#### How to build
82-
``mvn clean install``
71+
72+
## How to build & test
73+
74+
### Build modules
75+
76+
``mvn clean install -DskipTests``
77+
78+
### Run ojp-server
79+
80+
``mvn verify -pl ojp-server -Prun-ojp-server``
81+
82+
### Run tests
83+
Connections configuration: There are csv files under test/resources with connection details defaulted to H2 database, the name of each file implies which database connections can be added to it, for example the file h2_postgres_connections.csv can contain connections to H2 and/or postgres databases, integration tests classes that relly on this file will run all their tests against each connection in the file.
84+
85+
``mvn test``
8386

8487
## Partners
8588
<a href=https://www.linkedin.com/in/devsjava/>

ojp-grpc-commons/pom.xml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>org.openjdbcproxy</groupId>
87
<artifactId>ojp-grpc-commons</artifactId>
98
<version>1.0-SNAPSHOT</version>
109

10+
<parent>
11+
<groupId>org.openjdbcproxy</groupId>
12+
<artifactId>ojp-parent</artifactId>
13+
<version>1.0-SNAPSHOT</version>
14+
<relativePath>../pom.xml</relativePath>
15+
</parent>
16+
1117
<properties>
12-
<maven.compiler.source>22</maven.compiler.source>
13-
<maven.compiler.target>22</maven.compiler.target>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<grpc.version>1.70.0</grpc.version>
18+
<grpc.version>1.73.0</grpc.version>
19+
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
20+
<lombok.version>1.18.38</lombok.version>
1621
</properties>
1722

1823
<dependencies>
@@ -36,25 +41,24 @@
3641
<dependency>
3742
<groupId>kr.motd.maven</groupId>
3843
<artifactId>os-maven-plugin</artifactId>
39-
<version>1.7.1</version>
44+
<version>${os-maven-plugin.version}</version>
4045
</dependency>
4146

4247
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
4348
<dependency>
4449
<groupId>org.projectlombok</groupId>
4550
<artifactId>lombok</artifactId>
46-
<version>1.18.30</version>
51+
<version>${lombok.version}</version>
4752
<scope>provided</scope>
4853
</dependency>
49-
5054
</dependencies>
5155

5256
<build>
5357
<extensions>
5458
<extension>
5559
<groupId>kr.motd.maven</groupId>
5660
<artifactId>os-maven-plugin</artifactId>
57-
<version>1.6.1</version>
61+
<version>1.7.0</version>
5862
</extension>
5963
</extensions>
6064
<plugins>

ojp-jdbc-driver/pom.xml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>org.openjdbcproxy</groupId>
87
<artifactId>ojp-jdbc-driver</artifactId>
98
<version>1.0-SNAPSHOT</version>
109

10+
<parent>
11+
<groupId>org.openjdbcproxy</groupId>
12+
<artifactId>ojp-parent</artifactId>
13+
<version>1.0-SNAPSHOT</version>
14+
<relativePath>../pom.xml</relativePath>
15+
</parent>
16+
1117
<properties>
12-
<maven.compiler.source>22</maven.compiler.source>
13-
<maven.compiler.target>22</maven.compiler.target>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<grpc.version>1.70.0</grpc.version>
1618
<slf4j.version>2.0.17</slf4j.version>
1719
</properties>
1820

@@ -23,17 +25,11 @@
2325
<version>1.0-SNAPSHOT</version>
2426
</dependency>
2527

26-
<dependency>
27-
<groupId>io.grpc</groupId>
28-
<artifactId>grpc-netty</artifactId>
29-
<version>${grpc.version}</version>
30-
</dependency>
31-
3228
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
3329
<dependency>
3430
<groupId>org.projectlombok</groupId>
3531
<artifactId>lombok</artifactId>
36-
<version>1.18.36</version>
32+
<version>1.18.38</version>
3733
<scope>provided</scope>
3834
</dependency>
3935

@@ -88,7 +84,6 @@
8884
<version>5.12.1</version>
8985
<scope>test</scope>
9086
</dependency>
91-
9287
</dependencies>
9388

9489
<build>

ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BasicCrudIntegrationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import org.junit.Assert;
5+
import org.junit.jupiter.api.Assumptions;
6+
import org.junit.jupiter.api.BeforeAll;
57
import org.junit.jupiter.params.ParameterizedTest;
68
import org.junit.jupiter.params.provider.CsvFileSource;
79

@@ -15,9 +17,18 @@
1517
@Slf4j
1618
public class BasicCrudIntegrationTest {
1719

20+
private static boolean isTestDisabled;
21+
22+
@BeforeAll
23+
public static void setup() {
24+
isTestDisabled = Boolean.parseBoolean(System.getProperty("disablePostgresTests", "false"));
25+
}
26+
1827
@ParameterizedTest
1928
@CsvFileSource(resources = "/h2_postgres_connections.csv")
2029
public void crudTestSuccessful(String driverClass, String url, String user, String pwd) throws SQLException, ClassNotFoundException {
30+
Assumptions.assumeFalse(isTestDisabled, "Skipping Postgres tests");
31+
2132
Class.forName(driverClass);
2233
Connection conn = DriverManager.getConnection(url, user, pwd);
2334

ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BinaryStreamIntegrationTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package openjdbcproxy.jdbc;
22

33
import org.junit.Assert;
4+
import org.junit.jupiter.api.Assumptions;
5+
import org.junit.jupiter.api.BeforeAll;
46
import org.junit.jupiter.params.ParameterizedTest;
57
import org.junit.jupiter.params.provider.CsvFileSource;
68

@@ -17,9 +19,18 @@
1719

1820
public class BinaryStreamIntegrationTest {
1921

22+
private static boolean isTestDisabled;
23+
24+
@BeforeAll
25+
public static void setup() {
26+
isTestDisabled = Boolean.parseBoolean(System.getProperty("disablePostgresTests", "false"));
27+
}
28+
2029
@ParameterizedTest
2130
@CsvFileSource(resources = "/postgres_connection.csv")
2231
public void createAndReadingBinaryStreamSuccessful(String driverClass, String url, String user, String pwd) throws SQLException, ClassNotFoundException, IOException {
32+
Assumptions.assumeFalse(isTestDisabled, "Skipping Postgres tests");
33+
2334
Class.forName(driverClass);
2435
Connection conn = DriverManager.getConnection(url, user, pwd);
2536

@@ -90,6 +101,8 @@ insert into test_table_blob (val_blob1, val_blob2) values (?, ?)
90101
@ParameterizedTest
91102
@CsvFileSource(resources = "/postgres_connection.csv")
92103
public void createAndReadingLargeBinaryStreamSuccessful(String driverClass, String url, String user, String pwd) throws SQLException, ClassNotFoundException, IOException {
104+
Assumptions.assumeFalse(isTestDisabled, "Skipping Postgres tests");
105+
93106
Class.forName(driverClass);
94107
Connection conn = DriverManager.getConnection(url, user, pwd);
95108

ojp-server/dependency-reduced-pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>ojp-parent</artifactId>
5+
<groupId>org.openjdbcproxy</groupId>
6+
<version>1.0-SNAPSHOT</version>
7+
</parent>
38
<modelVersion>4.0.0</modelVersion>
4-
<groupId>org.example</groupId>
59
<artifactId>ojp-server</artifactId>
610
<version>1.0-SNAPSHOT</version>
711
<build>
@@ -52,10 +56,7 @@
5256
</dependency>
5357
</dependencies>
5458
<properties>
55-
<maven.compiler.target>22</maven.compiler.target>
5659
<slf4j.version>2.0.17</slf4j.version>
57-
<maven.compiler.source>22</maven.compiler.source>
58-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5960
<grpc.version>1.70.0</grpc.version>
6061
</properties>
6162
</project>

ojp-server/pom.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>org.example</groupId>
87
<artifactId>ojp-server</artifactId>
98
<version>1.0-SNAPSHOT</version>
109

10+
<parent>
11+
<groupId>org.openjdbcproxy</groupId>
12+
<artifactId>ojp-parent</artifactId>
13+
<version>1.0-SNAPSHOT</version>
14+
<relativePath>../pom.xml</relativePath>
15+
</parent>
16+
1117
<properties>
12-
<maven.compiler.source>22</maven.compiler.source>
13-
<maven.compiler.target>22</maven.compiler.target>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1518
<grpc.version>1.70.0</grpc.version>
1619
<slf4j.version>2.0.17</slf4j.version>
1720
<jib.plugin.version>3.4.5</jib.plugin.version>
@@ -87,7 +90,6 @@
8790
<artifactId>slf4j-simple</artifactId>
8891
<version>${slf4j.version}</version>
8992
</dependency>
90-
9193
</dependencies>
9294

9395
<build>

pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.openjdbcproxy</groupId>
7+
<artifactId>ojp-parent</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<packaging>pom</packaging>
10+
11+
<modules>
12+
<module>ojp-grpc-commons</module>
13+
<module>ojp-jdbc-driver</module>
14+
<module>ojp-server</module>
15+
</modules>
16+
17+
<properties>
18+
<maven.compiler.source>22</maven.compiler.source>
19+
<maven.compiler.target>22</maven.compiler.target>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
</properties>
22+
23+
<profiles>
24+
<profile>
25+
<id>run-ojp-server</id>
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.codehaus.mojo</groupId>
30+
<artifactId>exec-maven-plugin</artifactId>
31+
<version>3.5.1</version>
32+
<executions>
33+
<execution>
34+
<id>run-grpc-server</id>
35+
<phase>verify</phase>
36+
<goals>
37+
<goal>java</goal>
38+
</goals>
39+
<configuration>
40+
<mainClass>org.openjdbcproxy.grpc.server.GrpcServer</mainClass>
41+
</configuration>
42+
</execution>
43+
</executions>
44+
</plugin>
45+
</plugins>
46+
</build>
47+
</profile>
48+
</profiles>
49+
50+
</project>

0 commit comments

Comments
 (0)