|
24 | 24 | import java.nio.charset.Charset; |
25 | 25 | import java.util.ArrayList; |
26 | 26 | import java.util.Set; |
| 27 | +import java.util.concurrent.TimeUnit; |
27 | 28 | import org.apache.avro.util.Utf8; |
28 | 29 | import org.apache.gora.examples.generated.Employee; |
29 | 30 | import org.apache.gora.examples.generated.Metadata; |
@@ -53,7 +54,35 @@ public class TestHiveStore extends DataStoreTestBase { |
53 | 54 |
|
54 | 55 | @Override |
55 | 56 | public void assertSchemaExists(String schemaName) throws Exception { |
56 | | - assertTrue(employeeStore.schemaExists()); |
| 57 | + if ("Employee".equals(schemaName)) { |
| 58 | + assertTrue(employeeStore.schemaExists()); |
| 59 | + return; |
| 60 | + } |
| 61 | + // Include WebPage because base tests call assertSchemaExists("WebPage") in DataStoreTestBase#testTruncateSchema. |
| 62 | + if ("WebPage".equals(schemaName)) { |
| 63 | + assertTrue(webPageStore.schemaExists()); |
| 64 | + return; |
| 65 | + } |
| 66 | + throw new AssertionError("unsupported schema name: " + schemaName); |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public void assertAutoCreateSchema() throws Exception { |
| 71 | + // Poll briefly for Hive metastore visibility only in the auto-create scenario. |
| 72 | + final long timeoutNanos = TimeUnit.SECONDS.toNanos(5); |
| 73 | + final long sleepMillis = 100L; |
| 74 | + long deadline = System.nanoTime() + timeoutNanos; |
| 75 | + employeeStore.flush(); |
| 76 | + while (System.nanoTime() < deadline) { |
| 77 | + if (employeeStore.schemaExists()) { |
| 78 | + assertSchemaExists(((HiveStore<String, Employee>) employeeStore).getSchemaName()); |
| 79 | + return; |
| 80 | + } |
| 81 | + TimeUnit.MILLISECONDS.sleep(sleepMillis); |
| 82 | + employeeStore.flush(); |
| 83 | + } |
| 84 | + // If still not visible by timeout, fail via the original assertion. |
| 85 | + assertSchemaExists(((HiveStore<String, Employee>) employeeStore).getSchemaName()); |
57 | 86 | } |
58 | 87 |
|
59 | 88 | @Override |
|
0 commit comments