Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
90525f7
Add a build action
Michael-A-McMahon Mar 8, 2021
855a07e
Disable tests when building
Michael-A-McMahon Mar 8, 2021
1d7a36f
Merge branch 'modular-jar' of https://github.com/oracle/oracle-r2dbc …
Michael-A-McMahon Mar 8, 2021
e84d6fb
Add test script
Michael-A-McMahon Mar 26, 2021
90eb9d2
Rename action .yml
Michael-A-McMahon Mar 26, 2021
6f7ab89
Merge branch 'main' into build-and-test-action
Michael-A-McMahon Mar 26, 2021
48dfe51
Merge branch 'main' of https://github.com/oracle/oracle-r2dbc into bu…
Michael-A-McMahon Apr 2, 2021
4f228c7
Allow the test user to query V$OPEN_CURSOR
Michael-A-McMahon Apr 2, 2021
4cedf29
Merge branch 'main' of https://github.com/oracle/oracle-r2dbc into bu…
Michael-A-McMahon Apr 13, 2021
06705c5
Add v$transaction grant to test user
Michael-A-McMahon Apr 15, 2021
6af162e
Merge branch 'main' of https://github.com/oracle/oracle-r2dbc into bu…
Michael-A-McMahon Jun 3, 2021
113cbd7
Close statement after a terminal signal
Michael-A-McMahon Jun 3, 2021
0eff261
Grant create session to the test user
Michael-A-McMahon Jun 3, 2021
b9997e9
Grant r2dbc_test_user role
Michael-A-McMahon Jun 3, 2021
65bc392
Print container logs while waiting
Michael-A-McMahon Jun 4, 2021
22064a5
Test with pool of 4 threads
Michael-A-McMahon Jun 4, 2021
92d50c7
Merge branch 'main' of https://github.com/oracle/oracle-r2dbc into bu…
Michael-A-McMahon Jun 13, 2021
db678d7
Set FJP parallelism to 1
Michael-A-McMahon Jun 13, 2021
a4edaf3
Try without setting FJP common parallelism
Michael-A-McMahon Jun 14, 2021
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
61 changes: 61 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
#
# This software is dual-licensed to you under the Universal Permissive License
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License
# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
# either license.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script will start an Oracle Database inside a Docker container and then
# execute the Oracle R2DBC test suite with a configuration that has it connect
# to that database.
#
# This script makes no attempt to clean up. The docker container is left
# running, and the database retains the test user and any other modifications
# that the test suite may have performed.
# It is assumed that the Github Runner will clean up any state this script
# leaves behind.

name: Build and Test Oracle R2DBC

on:
push:
branches:
- main
- development
pull_request:
branches:
- main
- development

jobs:
# Builds the Oracle R2DBC Driver using Maven
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml -DskipTests=true
# Tests the Oracle R2DBC Driver with an Oracle Database
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test with Oracle Database
run: cd $GITHUB_WORKSPACE/.github/workflows && bash test.sh
45 changes: 45 additions & 0 deletions .github/workflows/startup/01_createUser.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- Copyright (c) 2020, 2021, Oracle and/or its affiliates.
--
-- This software is dual-licensed to you under the Universal Permissive License
-- (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License
-- 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
-- either license.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

-- This script will start an Oracle Database inside a Docker container and then
-- execute the Oracle R2DBC test suite with a configuration that has it connect
-- to that database.
--
-- This script makes no attempt to clean up. The docker container is left
-- running, and the database retains the test user and any other modifications
-- that the test suite may have performed.
-- It is assumed that the Github Runner will clean up any state this script
-- leaves behind.


-- This script will be run as sysdba connected to the container database. This
-- script will create a test user in the xepdb1 pluggable database. The test
-- user is granted permission to connect to the database, create/query/modify
-- tables, and to query some V$ views:
-- v$open_cursor (to verify if cursors are being closed).
-- v$transaction (to verify if TransactionDefinitions are applied).
ALTER SESSION SET CONTAINER=xepdb1;
CREATE ROLE r2dbc_test_user;
GRANT SELECT ON v_$open_cursor TO r2dbc_test_user;
GRANT SELECT ON v_$transaction TO r2dbc_test_user;

CREATE USER test IDENTIFIED BY test;
GRANT connect, resource, unlimited tablespace, r2dbc_test_user TO test;
ALTER USER test DEFAULT TABLESPACE users;
ALTER USER test TEMPORARY TABLESPACE temp;
86 changes: 86 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash

# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
#
# This software is dual-licensed to you under the Universal Permissive License
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License
# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
# either license.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script will start an Oracle Database inside a Docker container and then
# execute the Oracle R2DBC test suite with a configuration that has it connect
# to that database.
#
# This script makes no attempt to clean up. The docker container is left
# running, and the database retains the test user and any other modifications
# that the test suite may have performed.
# It is assumed that the Github Runner will clean up any state this script
# leaves behind.


# The startup directory is mounted as a volume inside the docker container.
# The container's entry point script will execute any .sh and .sql scripts
# it finds under /opt/oracle/scripts/startup. The startup scripts are run
# after the database instance is active.A numeric prefix on the script name
# determines the order in which scripts are run. The final script, prefixed
# with "99_" will create a file named "done" in the mounted volumn. When the
# "done" file exists, this signals that the database is active and that all
# startup scripts have completed.
startUpScripts=$PWD/startup
startUpMount=/opt/oracle/scripts/startup
echo "touch $startUpMount/done" > $startUpScripts/99_done.sh


# The oracle/docker-images repo is cloned. This repo provides Dockerfiles along
# with a handy script to build images of Oracle Database. For now, this script
# is just going to build an 18.4.0 XE image, because this can be done in an
# automated fashion, without having to accept license agreements required by
# newer versions like 19 and 21.
# TODO: Also test with newer database versions
git clone https://github.com/oracle/docker-images.git
cd docker-images/OracleDatabase/SingleInstance/dockerfiles/
./buildContainerImage.sh -v 18.4.0 -x

# Run the image in a detached container
# The startup directory is mounted. It contains a createUser.sql script that
# creates a test user. The docker container will run this script once the
# database has started.
# The database port number, 1521, is mapped to the host system. The Oracle
# R2DBC test suite is configured to connect with this port.
docker run --name test_db --detach --rm -p 1521:1521 -v $startUpScripts:$startUpMount oracle/database:18.4.0-xe

# Wait for the database instance to start. The final startup script will create
# a file named "done" in the startup directory. When that file exists, it means
# the database is ready for testing.
echo "Waiting for database to start..."
until [ -f $startUpScripts/done ]
do
docker logs --since 3s test_db
sleep 3
done

# Create a configuration file and run the tests. The service name, "xepdb1",
# is always created for the 18.4.0 XE database, but it would probably change
# for other database versions (TODO). The test user is created by the
# startup/01_createUser.sql script
cd $GITHUB_WORKSPACE
echo "DATABASE=xepdb1" > src/test/resources/config.properties
echo "HOST=localhost" >> src/test/resources/config.properties
echo "PORT=1521" >> src/test/resources/config.properties
echo "USER=test" >> src/test/resources/config.properties
echo "PASSWORD=test" >> src/test/resources/config.properties
echo "CONNECT_TIMEOUT=30" >> src/test/resources/config.properties
echo "SQL_TIMEOUT=30" >> src/test/resources/config.properties
mvn clean compile test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/sample/.gradle/
/sample/build/
/sample/config.properties
.github/workflows/startup/99_done.sh
.github/workflows/startup/done
11 changes: 11 additions & 0 deletions sample/sample.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
49 changes: 49 additions & 0 deletions src/oracle-r2dbc-master.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/main/resources" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.10.RELEASE" level="project" />
<orderEntry type="library" name="com.oracle.database.jdbc:ojdbc11:21.1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.7.0" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-jdbc:5.2.6.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: io.projectreactor:reactor-test:3.3.10.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.assertj:assertj-core:3.17.2" level="project" />
<orderEntry type="library" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.0" level="project" />
<orderEntry type="library" name="Maven: org.junit.platform:junit-platform-engine:1.7.0" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../r2dbc-spi/r2dbc-spi-test/target/r2dbc-spi-test-0.9.0.BUILD-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../r2dbc-spi/r2dbc-spi/target/r2dbc-spi-0.9.0.BUILD-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
18 changes: 13 additions & 5 deletions src/test/java/oracle/r2dbc/impl/OracleReactiveJdbcAdapterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.file.Files;
Expand Down Expand Up @@ -198,6 +200,11 @@ public void testTnsAdmin() throws IOException {
String.format("test_alias=" + descriptor),
StandardOpenOption.CREATE_NEW);

// Get the current working directory, with percent encodings to replace
// any characters that are invalid in a URL
String userDir = System.getProperty("user.dir")
.replace(" ", "%20");

try {
// Expect to connect with the descriptor in the R2DBC URL
awaitNone(awaitOne(
Expand All @@ -221,13 +228,14 @@ public void testTnsAdmin() throws IOException {
awaitNone(awaitOne(
ConnectionFactories.get(String.format(
"r2dbc:oracle://%s:%s@?oracleNetDescriptor=%s&TNS_ADMIN=%s",
user(), password(), "test_alias", System.getProperty("user.dir")))
user(), password(), "test_alias", userDir))
.create())
.close());
awaitNone(awaitOne(
ConnectionFactories.get(ConnectionFactoryOptions.parse(String.format(
"r2dbc:oracle://@?oracleNetDescriptor=%s&TNS_ADMIN=%s",
"test_alias", System.getProperty("user.dir")))
ConnectionFactories.get(ConnectionFactoryOptions.parse(
String.format(
"r2dbc:oracle://@?oracleNetDescriptor=%s&TNS_ADMIN=%s",
"test_alias", userDir))
.mutate()
.option(USER, user())
.option(PASSWORD, password())
Expand Down Expand Up @@ -270,7 +278,7 @@ public void testTnsAdmin() throws IOException {
awaitNone(awaitOne(
ConnectionFactories.get(ConnectionFactoryOptions.parse(String.format(
"r2dbc:oracle://?oracleNetDescriptor=%s&TNS_ADMIN=%s",
"test_alias", System.getProperty("user.dir")))
"test_alias", userDir))
.mutate()
.option(PASSWORD, password())
.build())
Expand Down