ClaireLytt commented on code in PR #36492:
URL: https://github.com/apache/shardingsphere/pull/36492#discussion_r2347274153
##########
test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/HiveContainer.java:
##########
@@ -95,13 +98,37 @@ protected Optional<String> getDefaultDatabaseName() {
@Override
protected void postStart() {
try {
+ createDatabasesFromConfiguration();
+ log.info("Databases created successfully in postStart()");
execInContainer("bash", "-c",
- "beeline -u \"jdbc:hive2://localhost:10000/default\" -e
\"CREATE DATABASE IF NOT EXISTS encrypt; CREATE DATABASE IF NOT EXISTS
expected_dataset;\"");
- System.out.println("Databases created successfully in
postStart()");
+ "if [ -f /docker-entrypoint-initdb.d/01-actual-init.sql ];
then beeline -u \"jdbc:hive2://localhost:10000/default\" -f
/docker-entrypoint-initdb.d/01-actual-init.sql; fi");
+ execInContainer("bash", "-c",
+ "if [ -f /docker-entrypoint-initdb.d/01-expected-init.sql
]; then beeline -u \"jdbc:hive2://localhost:10000/default\" -f
/docker-entrypoint-initdb.d/01-expected-init.sql; fi");
+ log.info("Initialization SQL files executed successfully");
} catch (final InterruptedException | IOException ex) {
- System.err.println("Failed to create databases in postStart(): " +
ex.getMessage());
+ log.error("Failed to execute postStart operations: {}",
ex.getMessage());
}
super.postStart();
- System.out.println("Hive container postStart completed successfully");
+ log.info("Hive container postStart completed successfully");
+ }
+
+ private void createDatabasesFromConfiguration() throws
InterruptedException, IOException {
+ Collection<String> actualDatabaseNames = getDatabaseNames();
+ Collection<String> expectedDatabaseNames = getExpectedDatabaseNames();
+ Collection<String> allDatabaseNames = new HashSet<>();
+ allDatabaseNames.addAll(actualDatabaseNames);
+ allDatabaseNames.addAll(expectedDatabaseNames);
+
Review Comment:
done
##########
test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/HiveContainer.java:
##########
@@ -95,13 +98,37 @@ protected Optional<String> getDefaultDatabaseName() {
@Override
protected void postStart() {
try {
+ createDatabasesFromConfiguration();
+ log.info("Databases created successfully in postStart()");
execInContainer("bash", "-c",
- "beeline -u \"jdbc:hive2://localhost:10000/default\" -e
\"CREATE DATABASE IF NOT EXISTS encrypt; CREATE DATABASE IF NOT EXISTS
expected_dataset;\"");
- System.out.println("Databases created successfully in
postStart()");
+ "if [ -f /docker-entrypoint-initdb.d/01-actual-init.sql ];
then beeline -u \"jdbc:hive2://localhost:10000/default\" -f
/docker-entrypoint-initdb.d/01-actual-init.sql; fi");
+ execInContainer("bash", "-c",
+ "if [ -f /docker-entrypoint-initdb.d/01-expected-init.sql
]; then beeline -u \"jdbc:hive2://localhost:10000/default\" -f
/docker-entrypoint-initdb.d/01-expected-init.sql; fi");
+ log.info("Initialization SQL files executed successfully");
} catch (final InterruptedException | IOException ex) {
- System.err.println("Failed to create databases in postStart(): " +
ex.getMessage());
+ log.error("Failed to execute postStart operations: {}",
ex.getMessage());
}
super.postStart();
- System.out.println("Hive container postStart completed successfully");
+ log.info("Hive container postStart completed successfully");
+ }
+
+ private void createDatabasesFromConfiguration() throws
InterruptedException, IOException {
+ Collection<String> actualDatabaseNames = getDatabaseNames();
+ Collection<String> expectedDatabaseNames = getExpectedDatabaseNames();
+ Collection<String> allDatabaseNames = new HashSet<>();
+ allDatabaseNames.addAll(actualDatabaseNames);
+ allDatabaseNames.addAll(expectedDatabaseNames);
+
+ if (allDatabaseNames.isEmpty()) {
+ log.warn("No databases configured for Hive container");
+ return;
+ }
+ StringBuilder createDatabaseSQL = new StringBuilder();
+ for (String databaseName : allDatabaseNames) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]