Skip to content

Commit 6a1134d

Browse files
Simplify running SQL test against external database servers
Fixes #7316
1 parent c223b07 commit 6a1134d

File tree

4 files changed

+30
-119
lines changed

4 files changed

+30
-119
lines changed

integration-tests/sql/README.adoc

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,54 @@
22

33
=== Default database type
44

5-
When the tests are executed without any special configuration, dev-service `H2` database is used (more details will follow).
5+
When the tests are executed without any special configuration, dev service `H2` database is used (more details will follow).
66

7-
=== Dev-service databases
7+
=== Quarkus Dev Service databases
88

9-
As is described in the https://quarkus.io/guides/datasource#dev-services[documentation], several database types could be started in dev-service mode.
10-
Running the tests against a database in dev-service mode could be achieved by addition of build property `cq.sqlJdbcKind`. Example of usage:
9+
As described in the https://quarkus.io/guides/datasource#dev-services[documentation], several database types can be started in dev service mode.
10+
Running the tests against a database in dev service mode can be achieved by addition of build property `cq.sqlJdbcKind`. For example.
1111

12-
`mvn clean test -f integration-tests/sql/ -Dcq.sqlJdbcKind=postgresql`
12+
[source]
13+
----
14+
mvn clean test -f integration-tests/sql/ -Dcq.sqlJdbcKind=postgresql
15+
----
1316

14-
Following databases could be started in the dev-service mode:
17+
The following databases can be started in dev service mode:
1518

1619
- Postgresql (container) - add `-Dcq.sqlJdbcKind=postgresql`
1720
- MySQL (container) - add `-Dcq.sqlJdbcKind=mysql`
1821
- MariaDB (container) - add `-Dcq.sqlJdbcKind=mariadb`
1922
- H2 (in-process) used by default
20-
- Apache Derby (in-process) - add `-Dcq.sqlJdbcKind=derby`
23+
- Apache Derby (container) - add `-Dcq.sqlJdbcKind=derby`
2124
- DB2 (container) (requires license acceptance) - add `-Dcq.sqlJdbcKind=db2`
2225
- MSSQL (container) (requires license acceptance) - add `-Dcq.sqlJdbcKind=mssql`
26+
- Oracle (container) - add `-Dcq.sqlJdbcKind=oracle`
2327

24-
For more information about dev-service mode, see https://quarkus.io/guides/datasource#dev-services[documentation].
28+
For more information about dev service mode, see https://quarkus.io/guides/datasource#dev-services[documentation].
2529

2630
=== External databases
2731

28-
To execute the tests against external database, configure database type by providing a build property in the same way as with dev-service mode (see previous chapter).
29-
Provide the rest of database's connection information by setting environment variables
32+
To execute the tests against external database, configure database type by providing a build property in the same way as with dev service mode (see previous chapter).
3033

31-
```
32-
export SQL_JDBC_URL=#jdbc_url
33-
export SQL_JDBC_USERNAME=#username
34-
export SQL_JDBC_PASSWORD=#password
35-
```
34+
The database JDBC connection URL and username / password credentials can be provided via environment variables.
3635

37-
or for windows:
36+
[source]
37+
----
38+
export QUARKUS_DATASOURCE_JDBC_URL=#jdbc_url
39+
export QUARKUS_DATASOURCE_USERNAME=#username
40+
export QUARKUS_DATASOURCE_PASSWORD=#password
41+
----
3842

39-
```
40-
$Env:SQL_JDBC_URL = "#jdbc_url"
41-
$Env:SQL_JDBC_USERNAME="#username"
42-
$Env:SQL_JDBC_PASSWORD="#password"
43-
```
43+
or for windows:
4444

45-
Oracle database could be used as external db. In that case use parameter `-Dcq.sqlJdbcKind=oracle`.
45+
[source]
46+
----
47+
$Env:QUARKUS_DATASOURCE_JDBC_URL="#jdbc_url"
48+
$Env:QUARKUS_DATASOURCE_USERNAME="#username"
49+
$Env:QUARKUS_DATASOURCE_PASSWORD="#password"
50+
----
4651

4752
=== External Derby database
4853

49-
To execute tests against external Derby database, stored procedure has to be uploaded into the database classpath.
50-
Jar with stored procedure for the derby database is creaed by module `sql-derby`.
51-
Jar could be uploaded via following commands through `ij`:
52-
```
53-
CALL sqlj.install_jar('/PATH_TO_JAR/camel-quarkus-integration-test-sql-derby-stored-procedure-*.jar', 'AddNumsProcedure' , 0)
54-
55-
CALL syscs_util.syscs_set_database_property('derby.database.classpath', 'APP.ADDNUMSPROCEDURE')
56-
```
57-
58-
=== External Derby database via Docker
59-
60-
To avoid manual upload of the jar, test can automatically use external derby database created via docker.
61-
To execute the tests against external derby database, set the environment variable `SQL_USE_DERBY_DOCKER` to value `true`:
62-
63-
```
64-
export SQL_USE_DERBY_DOCKER=true
65-
```
66-
67-
or for windows:
68-
69-
```
70-
$Env:SQL_USE_DERBY_DOCKER = "true"
54+
To avoid complexities around having to upload stored procedure JARs to the DB server, Apache Derby is always tested within a container.
55+
Therefore, you should avoid setting `QUARKUS_DATASOURCE` environment variables for Derby.

integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlConfigSourceFactory.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlHelper.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
import java.util.HashSet;
2121
import java.util.Set;
2222

23-
import org.eclipse.microprofile.config.ConfigProvider;
24-
2523
public class SqlHelper {
2624

27-
private static Set<String> BOOLEAN_AS_NUMBER = new HashSet<>(Arrays.asList("db2", "mssql", "oracle"));
25+
private static final Set<String> BOOLEAN_AS_NUMBER = new HashSet<>(Arrays.asList("db2", "mssql", "oracle"));
2826

2927
static String convertBooleanToSqlDialect(String dbKind, boolean value) {
3028
return convertBooleanToSqlResult(dbKind, value).toString();
@@ -41,12 +39,4 @@ static Object convertBooleanToSqlResult(String dbKind, boolean value) {
4139
static String getSelectProjectsScriptName(String dbKind) {
4240
return BOOLEAN_AS_NUMBER.contains(dbKind) ? "selectProjectsAsNumber.sql" : "selectProjectsAsBoolean.sql";
4341
}
44-
45-
public static boolean useDocker() {
46-
return Boolean.parseBoolean(System.getenv("SQL_USE_DERBY_DOCKER")) &&
47-
"derby".equals(ConfigProvider.getConfig().getOptionalValue("quarkus.datasource.db-kind", String.class)
48-
.orElse(System.getProperty("cq.sqlJdbcKind")))
49-
&& System.getenv("SQL_JDBC_URL") == null;
50-
}
51-
5242
}

integration-tests/sql/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)