Skip to content

Commit 3935e9b

Browse files
authored
Testcontainers: Add Oracle JDBC test (#104)
Add new tests to cover Cloudberry -> PXF -> JDBC path. In this test we are verifying that main data Cloudberry and Oracle types can be converted back and forth. Test covers Oracle 23 (only supported by Testcontainers version).
1 parent 076aae6 commit 3935e9b

9 files changed

Lines changed: 482 additions & 7 deletions

File tree

automation/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,18 @@
258258
<classifier>all</classifier>
259259
</dependency>
260260

261+
<dependency>
262+
<groupId>com.oracle.database.jdbc</groupId>
263+
<artifactId>ojdbc11</artifactId>
264+
<version>23.3.0.23.09</version>
265+
</dependency>
266+
267+
<dependency>
268+
<groupId>org.testcontainers</groupId>
269+
<artifactId>testcontainers-oracle-free</artifactId>
270+
<version>2.0.4</version>
271+
</dependency>
272+
261273
<dependency>
262274
<groupId>org.springframework</groupId>
263275
<artifactId>spring</artifactId>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
-- start_ignore
2+
-- end_ignore
3+
-- Licensed to the Apache Software Foundation (ASF) under one
4+
-- or more contributor license agreements. See the NOTICE file
5+
-- distributed with this work for additional information
6+
-- regarding copyright ownership. The ASF licenses this file
7+
-- to you under the Apache License, Version 2.0 (the
8+
-- "License"); you may not use this file except in compliance
9+
-- with the License. You may obtain a copy of the License at
10+
--
11+
-- http://www.apache.org/licenses/LICENSE-2.0
12+
--
13+
-- Unless required by applicable law or agreed to in writing,
14+
-- software distributed under the License is distributed on an
15+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
-- KIND, either express or implied. See the License for the
17+
-- specific language governing permissions and limitations
18+
-- under the License.
19+
20+
-- @description Oracle JDBC read: expect one row of primitive types from PXF
21+
SET timezone='utc';
22+
SET
23+
24+
SELECT
25+
i_int,
26+
b_big,
27+
f_real,
28+
d_double,
29+
dec_num,
30+
t_text,
31+
d_date,
32+
d_ts
33+
FROM pxf_ora_oracle_read_types
34+
LIMIT 1;
35+
i_int | b_big | f_real | d_double | dec_num | t_text | d_date | d_ts
36+
-------+-------+--------+-----------+------------------+--------+------------+-------------------------
37+
1 | 3 | 1.25 | 3.1415926 | 12345.6789012345 | hello | 2020-01-02 | 2020-01-02 03:04:05.006
38+
(1 row)
39+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- @description Oracle JDBC read: expect one row of primitive types from PXF
19+
SET timezone='utc';
20+
21+
SELECT
22+
i_int,
23+
b_big,
24+
f_real,
25+
d_double,
26+
dec_num,
27+
t_text,
28+
d_date,
29+
d_ts
30+
FROM pxf_ora_oracle_read_types
31+
LIMIT 1;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
-- start_ignore
2+
-- end_ignore
3+
-- Licensed to the Apache Software Foundation (ASF) under one
4+
-- or more contributor license agreements. See the NOTICE file
5+
-- distributed with this work for additional information
6+
-- regarding copyright ownership. The ASF licenses this file
7+
-- to you under the Apache License, Version 2.0 (the
8+
-- "License"); you may not use this file except in compliance
9+
-- with the License. You may obtain a copy of the License at
10+
--
11+
-- http://www.apache.org/licenses/LICENSE-2.0
12+
--
13+
-- Unless required by applicable law or agreed to in writing,
14+
-- software distributed under the License is distributed on an
15+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
-- KIND, either express or implied. See the License for the
17+
-- specific language governing permissions and limitations
18+
-- under the License.
19+
-- @description Oracle JDBC write: insert full row then verify via readable external table/fdw
20+
SET timezone='utc';
21+
SET
22+
INSERT INTO pxf_ora_oracle_write_types (
23+
i_int,
24+
b_big,
25+
f_real,
26+
d_double,
27+
dec_num,
28+
t_text,
29+
d_date,
30+
d_ts
31+
) VALUES (
32+
1,
33+
3,
34+
1.25,
35+
3.1415926,
36+
CAST('12345.6789012345' AS numeric),
37+
'hello',
38+
DATE '2020-01-02',
39+
TIMESTAMP '2020-01-02 03:04:05.006'
40+
);
41+
INSERT 0 1
42+
SELECT
43+
i_int,
44+
b_big,
45+
f_real,
46+
d_double,
47+
dec_num,
48+
t_text,
49+
d_date,
50+
d_ts
51+
FROM pxf_ora_oracle_write_verify
52+
LIMIT 1;
53+
i_int | b_big | f_real | d_double | dec_num | t_text | d_date | d_ts
54+
-------+-------+--------+-----------+------------------+--------+------------+-------------------------
55+
1 | 3 | 1.25 | 3.1415926 | 12345.6789012345 | hello | 2020-01-02 | 2020-01-02 03:04:05.006
56+
(1 row)
57+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- @description Oracle JDBC write: insert full row then verify via readable external table/fdw
19+
SET timezone='utc';
20+
21+
INSERT INTO pxf_ora_oracle_write_types (
22+
i_int,
23+
b_big,
24+
f_real,
25+
d_double,
26+
dec_num,
27+
t_text,
28+
d_date,
29+
d_ts
30+
) VALUES (
31+
1,
32+
3,
33+
1.25,
34+
3.1415926,
35+
CAST('12345.6789012345' AS numeric),
36+
'hello',
37+
DATE '2020-01-02',
38+
TIMESTAMP '2020-01-02 03:04:05.006'
39+
);
40+
41+
SELECT
42+
i_int,
43+
b_big,
44+
f_real,
45+
d_double,
46+
dec_num,
47+
t_text,
48+
d_date,
49+
d_ts
50+
FROM pxf_ora_oracle_write_verify
51+
LIMIT 1;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.apache.cloudberry.pxf.automation.testcontainers;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import org.testcontainers.containers.Network;
23+
import org.testcontainers.utility.DockerImageName;
24+
25+
/**
26+
* TestContainers wrapper around Oracle Database Free.
27+
*
28+
* The container joins a shared Docker network with alias `oracle`,
29+
* so PXF inside the Cloudberry container can reach it at `oracle:1521`
30+
*
31+
*/
32+
public class OracleContainer extends org.testcontainers.oracle.OracleContainer {
33+
34+
private static final String DEFAULT_IMAGE = "gvenzl/oracle-free:23-slim";
35+
private static final String NETWORK_ALIAS = "oracle";
36+
37+
public static final int ORACLE_PORT = 1521;
38+
public static final String SERVICE_NAME = "FREE";
39+
40+
public static final String ORACLE_USER = "system";
41+
public static final String ORACLE_PASSWORD = "pxf-test";
42+
43+
public OracleContainer(Network network) {
44+
super(DockerImageName.parse(DEFAULT_IMAGE));
45+
46+
withPassword(ORACLE_PASSWORD);
47+
withNetwork(network);
48+
withNetworkAliases(NETWORK_ALIAS);
49+
}
50+
51+
/** JDBC URL reachable from the host (mapped `ORACLE_PORT`) */
52+
@Override
53+
public String getJdbcUrl() {
54+
return "jdbc:oracle:thin:@localhost:" + getMappedPort(ORACLE_PORT) + "/" + SERVICE_NAME;
55+
}
56+
57+
/** JDBC URL for PXF / other containers on the same Docker network */
58+
public String getInternalJdbcUrl() {
59+
return "jdbc:oracle:thin:@" + NETWORK_ALIAS + ":" + ORACLE_PORT + "/" + SERVICE_NAME;
60+
}
61+
}

0 commit comments

Comments
 (0)