@@ -94,12 +94,13 @@ private void configureContainer() {
9494 waitingFor (Wait .forLogMessage (".*Hive container ready \\ (pre-initialized\\ )!.*" , 1 )
9595 .withStartupTimeout (Duration .ofMinutes (2 )));
9696 } else if (useFallbackImage ) {
97- // Fallback to apache/hive:3.1.3 - wait for both metastore port AND HiveServer2 to be ready
98- // The metastore must be accepting connections before Drill can use it
97+ // apache/hive:3.1.3 official image - wait for HiveServer2 to be fully started
98+ // The official image outputs "HiveServer2 Web UI available at..." when ready
99+ // or we can wait for the listening port plus a reasonable log message
99100 WaitAllStrategy waitStrategy = new WaitAllStrategy ()
100- .withStrategy (Wait .forListeningPort ()) // Wait for metastore port 9083 to be listening
101- .withStrategy (Wait .forLogMessage (".*Starting HiveServer2.*" , 1 ))
102- .withStartupTimeout (Duration .ofMinutes (10 )); // Allow up to 10 minutes for full startup
101+ .withStrategy (Wait .forListeningPort ())
102+ .withStrategy (Wait .forLogMessage (".*HiveServer2.*" , 1 ))
103+ .withStartupTimeout (Duration .ofMinutes (15 )); // Official image can be slow
103104 waitingFor (waitStrategy );
104105 } else {
105106 // Custom image: wait for metastore port AND test data initialization message
@@ -121,9 +122,8 @@ private void configureContainer() {
121122 /**
122123 * Gets the singleton instance of HiveContainer.
123124 * Container is started on first access and reused for all subsequent tests.
124- * If the custom image is not available, falls back to apache/hive:3.1.3.
125125 *
126- * @return Shared HiveContainer instance, or null if Docker is unavailable
126+ * @return Shared HiveContainer instance
127127 * @throws RuntimeException if container fails to start
128128 */
129129 public static synchronized HiveContainer getInstance () {
@@ -141,25 +141,19 @@ public static synchronized HiveContainer getInstance() {
141141
142142 System .out .println ("========================================" );
143143 System .out .println ("Starting Hive Docker container..." );
144- System .out .println ("Requested image : " + HIVE_IMAGE );
144+ System .out .println ("Image : " + HIVE_IMAGE );
145145 System .out .println ("========================================" );
146146
147- // Try the requested image first
148147 try {
149- instance = tryStartContainer (HIVE_IMAGE , false );
148+ instance = tryStartContainer (HIVE_IMAGE , HIVE_IMAGE . equals ( FALLBACK_IMAGE ) );
150149 return instance ;
151150 } catch (Exception e ) {
152- logger .warn ("Failed to start container with image '{}': {}" , HIVE_IMAGE , e .getMessage ());
153- System .out .println ("Failed to start with " + HIVE_IMAGE + ", trying fallback image..." );
154- }
155-
156- // Fall back to apache/hive:3.1.3
157- System .out .println ("Falling back to: " + FALLBACK_IMAGE );
158- try {
159- instance = tryStartContainer (FALLBACK_IMAGE , true );
160- return instance ;
161- } catch (Exception e ) {
162- initializationError = "Failed to start Hive container with both custom and fallback images: " + e .getMessage ();
151+ initializationError = "Failed to start Hive container with image '" + HIVE_IMAGE + "': " + e .getMessage () +
152+ "\n \n To build the required Docker image, run:" +
153+ "\n cd contrib/storage-hive/core/src/test/resources/docker" +
154+ "\n docker build -f Dockerfile.fast -t drill-hive-test:fast ." +
155+ "\n \n Or use the public Apache Hive image (slower startup):" +
156+ "\n mvn test -Dhive.image=apache/hive:3.1.3" ;
163157 logger .error (initializationError , e );
164158 throw new RuntimeException (initializationError , e );
165159 }
@@ -170,16 +164,16 @@ private static HiveContainer tryStartContainer(String imageName, boolean isFallb
170164 if (usePreinit ) {
171165 System .out .println ("Using pre-initialized image (~1 minute startup)" );
172166 } else if (isFallback ) {
173- System .out .println ("Using fallback apache/hive image (~5 minute startup)" );
167+ System .out .println ("Using apache/hive official image (~10-15 minute startup)" );
174168 } else {
175- System .out .println ("Using custom image (~15 minute startup on first run)" );
169+ System .out .println ("Using custom image (~3-5 minute startup on first run)" );
176170 }
177- System .out .println ("Image: " + imageName );
178171
179172 logger .info ("Creating Hive container with image: {}" , imageName );
180173 HiveContainer container = new HiveContainer (imageName , isFallback );
181174
182175 System .out .println ("Pulling Docker image and starting container..." );
176+ System .out .println ("This may take several minutes on first run..." );
183177 long startTime = System .currentTimeMillis ();
184178 container .start ();
185179
@@ -195,9 +189,6 @@ private static HiveContainer tryStartContainer(String imageName, boolean isFallb
195189 System .out .println ("Metastore: " + container .getMetastoreUri ());
196190 System .out .println ("JDBC: " + container .getJdbcUrl ());
197191 System .out .println ("Container will be reused for all tests" );
198- if (isFallback ) {
199- System .out .println ("NOTE: Using fallback image - test data must be created via JDBC" );
200- }
201192 System .out .println ("========================================" );
202193 logger .info ("Hive container started and ready for tests" );
203194
0 commit comments