Skip to content

Commit 383ed4d

Browse files
committed
feat(docs, testcontainers): add MariaDB support and usage examples
- Updated `CONTRIBUTING.md` and `README.md` with MariaDB-specific details and examples. - Added `withImage` and MariaDB configuration options to `ClouderaHiveMetastoreContainer`. - Incremented project version to `0.1.73-SNAPSHOT`.
1 parent 51299f3 commit 383ed4d

4 files changed

Lines changed: 102 additions & 4 deletions

File tree

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ GRADLE_USER_HOME=/data/.gradle ./gradlew :image:jibAll
8484

8585
The PostgreSQL variant uses `ghcr.io/openprojectx/postgres14-jdk17:latest` as its base and keeps the existing tag. The MariaDB variant uses `ghcr.io/openprojectx/mariadb10.6-jdk17:latest` as its base and gets a `-mariadb` tag suffix. The MariaDB image is built with `HMS_DATABASE_TYPE=mariadb`, so it uses `/hive-schema-3.1.3000.mysql.sql`, `org.mariadb.jdbc.Driver`, `useMysqlMetadata=true`, and MariaDB environment variables by default.
8686

87+
Smoke-run the published images with Docker:
88+
89+
```bash
90+
docker run --rm --name cloudera-hms -p 9083:9083 -p 5432:5432 ghcr.io/openprojectx/cloudera-hms:latest
91+
docker run --rm --name cloudera-hms-mariadb -p 9083:9083 -p 3306:3306 ghcr.io/openprojectx/cloudera-hms:latest-mariadb
92+
```
93+
94+
Use `POSTGRES_*` environment variables for the PostgreSQL image and `MARIADB_*` environment variables for the MariaDB image. Both variants expose the Hive Metastore Thrift service on port `9083`.
95+
8796
The Jib tasks in `:image` are marked incompatible with Gradle configuration cache because that path has been unstable in this build.
8897

8998
## Tests

README.md

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dependencies {
5555
}
5656
```
5757

58-
Use the default image:
58+
Use the default PostgreSQL image:
5959

6060
```kotlin
6161
val metastore = ClouderaHiveMetastoreContainer()
@@ -65,16 +65,32 @@ val metastore = ClouderaHiveMetastoreContainer()
6565
.withDatabasePassword("hive-password")
6666
```
6767

68+
Use the MariaDB image:
69+
70+
```kotlin
71+
val metastore = ClouderaHiveMetastoreContainer
72+
.withImage("ghcr.io/openprojectx/cloudera-hms:latest-mariadb")
73+
.withDatabaseType("mariadb")
74+
.withDatabaseName("metastore_db")
75+
.withDatabaseUser("hive")
76+
.withDatabasePassword("hive-password")
77+
```
78+
6879
Use a custom image explicitly:
6980

7081
```kotlin
7182
val metastore = ClouderaHiveMetastoreContainer.withImage("my-registry/cloudera-hms:test")
83+
.withDatabaseType("postgresql")
7284
.withDatabaseName("metastore_db")
7385
.withDatabaseUser("hive")
7486
.withDatabasePassword("hive-password")
7587
```
7688

77-
Or set `CLOUDERA_HMS_TEST_IMAGE` and keep using the default constructor.
89+
Or set `CLOUDERA_HMS_TEST_IMAGE` and keep using the default constructor. For MariaDB, point it at a `-mariadb` image tag and set `HMS_DATABASE_TYPE` through the wrapper:
90+
91+
```bash
92+
export CLOUDERA_HMS_TEST_IMAGE=ghcr.io/openprojectx/cloudera-hms:latest-mariadb
93+
```
7894

7995
Typical JUnit 5 and Testcontainers usage:
8096

@@ -84,9 +100,35 @@ import org.testcontainers.junit.jupiter.Container
84100
import org.testcontainers.junit.jupiter.Testcontainers
85101

86102
@Testcontainers
87-
class MyMetastoreContainerTest {
103+
class MyPostgreSqlMetastoreContainerTest {
88104
@Container
89105
private val metastore = ClouderaHiveMetastoreContainer()
106+
.withDatabaseType("postgresql")
107+
.withDatabaseName("metastore_db")
108+
.withDatabaseUser("hive")
109+
.withDatabasePassword("hive-password")
110+
111+
@Test
112+
fun testMetastore() {
113+
val thriftUri = metastore.thriftUri()
114+
// Create a HiveMetaStoreClient or your application client here.
115+
}
116+
}
117+
```
118+
119+
MariaDB JUnit 5 and Testcontainers usage:
120+
121+
```kotlin
122+
import org.junit.jupiter.api.Test
123+
import org.testcontainers.junit.jupiter.Container
124+
import org.testcontainers.junit.jupiter.Testcontainers
125+
126+
@Testcontainers
127+
class MyMariaDbMetastoreContainerTest {
128+
@Container
129+
private val metastore = ClouderaHiveMetastoreContainer
130+
.withImage("ghcr.io/openprojectx/cloudera-hms:latest-mariadb")
131+
.withDatabaseType("mariadb")
90132
.withDatabaseName("metastore_db")
91133
.withDatabaseUser("hive")
92134
.withDatabasePassword("hive-password")
@@ -130,6 +172,50 @@ GRADLE_USER_HOME=/data/.gradle ./gradlew :image:jibDockerBuildMariadb
130172

131173
Run the MariaDB image normally; it is built with `HMS_DATABASE_TYPE=mariadb` and defaults to `/hive-schema-3.1.3000.mysql.sql`, `org.mariadb.jdbc.Driver`, and a `jdbc:mariadb://127.0.0.1:3306/metastore_db?useMysqlMetadata=true` URL.
132174

175+
Run the PostgreSQL image with Docker:
176+
177+
```bash
178+
docker run --rm \
179+
--name cloudera-hms \
180+
-p 9083:9083 \
181+
-p 5432:5432 \
182+
ghcr.io/openprojectx/cloudera-hms:latest
183+
```
184+
185+
Run the MariaDB image with Docker:
186+
187+
```bash
188+
docker run --rm \
189+
--name cloudera-hms-mariadb \
190+
-p 9083:9083 \
191+
-p 3306:3306 \
192+
ghcr.io/openprojectx/cloudera-hms:latest-mariadb
193+
```
194+
195+
Both images expose the Hive Metastore Thrift service on `9083`. The PostgreSQL variant also exposes `5432`; the MariaDB variant also exposes `3306`.
196+
197+
Override the default database credentials when needed:
198+
199+
```bash
200+
docker run --rm \
201+
--name cloudera-hms \
202+
-p 9083:9083 \
203+
-e POSTGRES_DB=metastore_db \
204+
-e POSTGRES_USER=hive \
205+
-e POSTGRES_PASSWORD=hive-password \
206+
ghcr.io/openprojectx/cloudera-hms:latest
207+
```
208+
209+
```bash
210+
docker run --rm \
211+
--name cloudera-hms-mariadb \
212+
-p 9083:9083 \
213+
-e MARIADB_DATABASE=metastore_db \
214+
-e MARIADB_USER=hive \
215+
-e MARIADB_PASSWORD=hive-password \
216+
ghcr.io/openprojectx/cloudera-hms:latest-mariadb
217+
```
218+
133219
For contributor-oriented build commands, version alignment, and verification notes, see [CONTRIBUTING.md](/data/Git/cloudera-hms/CONTRIBUTING.md).
134220

135221
## Modules

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 0.1.72-SNAPSHOT
1+
version = 0.1.73-SNAPSHOT
22

33
kotlin.code.style=official
44

testcontainers/src/main/kotlin/org/openprojectx/cloudera/hms/testcontainers/ClouderaHiveMetastoreContainer.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class ClouderaHiveMetastoreContainer(
7373
return DockerImageName.parse(configuredImage)
7474
}
7575

76+
fun withImage(dockerImageName: String): ClouderaHiveMetastoreContainer =
77+
ClouderaHiveMetastoreContainer(DockerImageName.parse(dockerImageName))
78+
7679
private fun encodeConfigKey(key: String): String =
7780
key.lowercase(Locale.ROOT)
7881
.replace("-", "__")

0 commit comments

Comments
 (0)