Skip to content

Commit 2dbfae8

Browse files
gaborgsomogyidongjoon-hyun
authored andcommitted
[SPARK-32049][SQL][TESTS] Upgrade Oracle JDBC Driver 8
### What changes were proposed in this pull request? `OracleIntegrationSuite` is not using the latest oracle JDBC driver. In this PR I've upgraded the driver to the latest which supports JDK8, JDK9, and JDK11. ### Why are the changes needed? Old JDBC driver. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing unit tests. Existing integration tests (especially `OracleIntegrationSuite`) Closes apache#28893 from gaborgsomogyi/SPARK-32049. Authored-by: Gabor Somogyi <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 2bcbe3d commit 2dbfae8

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

external/docker-integration-tests/pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,9 @@
130130
<artifactId>postgresql</artifactId>
131131
<scope>test</scope>
132132
</dependency>
133-
<!-- Oracle ojdbc jar, used for oracle integration suite for docker testing.
134-
See https://github.com/apache/spark/pull/11306 for background on why we need
135-
to use a an ojdbc jar for the testcase. The maven dependency here is commented
136-
because currently the maven repository does not contain the ojdbc jar mentioned.
137-
Once the jar is available in maven, this could be uncommented. -->
138-
<dependency>
139-
<groupId>com.oracle</groupId>
140-
<artifactId>ojdbc6</artifactId>
141-
<version>11.2.0.1.0</version>
133+
<dependency>
134+
<groupId>com.oracle.database.jdbc</groupId>
135+
<artifactId>ojdbc8</artifactId>
142136
<scope>test</scope>
143137
</dependency>
144138

external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/DockerJDBCIntegrationSuite.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ abstract class DockerJDBCIntegrationSuite extends SharedSparkSession with Eventu
9595

9696
protected val dockerIp = DockerUtils.getDockerIp()
9797
val db: DatabaseOnDocker
98+
val connectionTimeout = timeout(2.minutes)
9899

99100
private var docker: DockerClient = _
100101
protected var externalPort: Int = _
@@ -155,7 +156,7 @@ abstract class DockerJDBCIntegrationSuite extends SharedSparkSession with Eventu
155156
docker.startContainer(containerId)
156157
jdbcUrl = db.getJdbcUrl(dockerIp, externalPort)
157158
var conn: Connection = null
158-
eventually(timeout(2.minutes), interval(1.second)) {
159+
eventually(connectionTimeout, interval(1.second)) {
159160
conn = getConnection()
160161
}
161162
// Run any setup queries:

external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import java.math.BigDecimal
2121
import java.sql.{Connection, Date, Timestamp}
2222
import java.util.{Properties, TimeZone}
2323

24+
import org.scalatest.time.SpanSugar._
25+
2426
import org.apache.spark.sql.{Row, SaveMode}
2527
import org.apache.spark.sql.execution.{RowDataSourceScanExec, WholeStageCodegenExec}
2628
import org.apache.spark.sql.execution.datasources.LogicalRelation
@@ -31,27 +33,27 @@ import org.apache.spark.sql.types._
3133
import org.apache.spark.tags.DockerTest
3234

3335
/**
34-
* This patch was tested using the Oracle docker. Created this integration suite for the same.
35-
* The ojdbc6-11.2.0.2.0.jar was to be downloaded from the maven repository. Since there was
36-
* no jdbc jar available in the maven repository, the jar was downloaded from oracle site
37-
* manually and installed in the local; thus tested. So, for SparkQA test case run, the
38-
* ojdbc jar might be manually placed in the local maven repository(com/oracle/ojdbc6/11.2.0.2.0)
39-
* while Spark QA test run.
40-
*
4136
* The following would be the steps to test this
4237
* 1. Build Oracle database in Docker, please refer below link about how to.
4338
* https://github.com/oracle/docker-images/blob/master/OracleDatabase/SingleInstance/README.md
4439
* 2. export ORACLE_DOCKER_IMAGE_NAME=$ORACLE_DOCKER_IMAGE_NAME
4540
* Pull oracle $ORACLE_DOCKER_IMAGE_NAME image - docker pull $ORACLE_DOCKER_IMAGE_NAME
4641
* 3. Start docker - sudo service docker start
47-
* 4. Download oracle 11g driver jar and put it in maven local repo:
48-
* (com/oracle/ojdbc6/11.2.0.2.0/ojdbc6-11.2.0.2.0.jar)
49-
* 5. The timeout and interval parameter to be increased from 60,1 to a high value for oracle test
50-
* in DockerJDBCIntegrationSuite.scala (Locally tested with 200,200 and executed successfully).
51-
* 6. Run spark test - ./build/sbt "test-only org.apache.spark.sql.jdbc.OracleIntegrationSuite"
42+
* 4. Run spark test - ./build/sbt -Pdocker-integration-tests
43+
* "test-only org.apache.spark.sql.jdbc.OracleIntegrationSuite"
44+
*
45+
* An actual sequence of commands to run the test is as follows
5246
*
53-
* All tests in this suite are ignored because of the dependency with the oracle jar from maven
54-
* repository.
47+
* $ git clone https://github.com/oracle/docker-images.git
48+
* // Head SHA: 3e352a22618070595f823977a0fd1a3a8071a83c
49+
* $ cd docker-images/OracleDatabase/SingleInstance/dockerfiles
50+
* $ ./buildDockerImage.sh -v 18.4.0 -x
51+
* $ export ORACLE_DOCKER_IMAGE_NAME=oracle/database:18.4.0-xe
52+
* $ cd $SPARK_HOME
53+
* $ ./build/sbt -Pdocker-integration-tests
54+
* "test-only org.apache.spark.sql.jdbc.OracleIntegrationSuite"
55+
*
56+
* It has been validated with 18.4.0 Express Edition.
5557
*/
5658
@DockerTest
5759
class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSparkSession {
@@ -60,15 +62,19 @@ class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSpark
6062
override val db = new DatabaseOnDocker {
6163
override val imageName = sys.env("ORACLE_DOCKER_IMAGE_NAME")
6264
override val env = Map(
63-
"ORACLE_ROOT_PASSWORD" -> "oracle"
65+
"ORACLE_PWD" -> "oracle"
6466
)
6567
override val usesIpc = false
6668
override val jdbcPort: Int = 1521
6769
override def getJdbcUrl(ip: String, port: Int): String =
6870
s"jdbc:oracle:thin:system/oracle@//$ip:$port/xe"
6971
}
7072

73+
override val connectionTimeout = timeout(7.minutes)
74+
7175
override def dataPreparation(conn: Connection): Unit = {
76+
// In 18.4.0 Express Edition auto commit is enabled by default.
77+
conn.setAutoCommit(false)
7278
conn.prepareStatement("CREATE TABLE datetime (id NUMBER(10), d DATE, t TIMESTAMP)")
7379
.executeUpdate()
7480
conn.prepareStatement(

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,12 @@
984984
<version>8.2.2.jre8</version>
985985
<scope>test</scope>
986986
</dependency>
987+
<dependency>
988+
<groupId>com.oracle.database.jdbc</groupId>
989+
<artifactId>ojdbc8</artifactId>
990+
<version>19.6.0.0</version>
991+
<scope>test</scope>
992+
</dependency>
987993
<dependency>
988994
<groupId>org.apache.curator</groupId>
989995
<artifactId>curator-recipes</artifactId>

0 commit comments

Comments
 (0)