omalley commented on code in PR #5138:
URL: https://github.com/apache/hadoop/pull/5138#discussion_r1024312684


##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/records/TestRouterState.java:
##########
@@ -82,4 +96,141 @@ public void testSerialization() throws IOException {
 
     validateRecord(newRecord);
   }
+
+  /**
+   * A mock StateStoreDriver that runs in memory and can cause errors.
+   */
+  public static class MockStateStoreDriver extends StateStoreBaseImpl {
+    boolean giveErrors = false;
+    boolean initialized = false;
+    Map<String, Map<String, BaseRecord>> valueMap = new HashMap<>();
+
+    @Override
+    public boolean initDriver() {
+      initialized = true;
+      return true;
+    }
+
+    @Override
+    public <T extends BaseRecord> boolean initRecordStorage(String className,
+                                                            Class<T> clazz) {
+      return true;
+    }
+
+    @Override
+    public boolean isDriverReady() {
+      return initialized;
+    }
+
+    @Override
+    public void close() throws Exception {
+      valueMap.clear();
+      initialized = false;
+    }
+
+    private void checkErrors() throws IOException {
+      if (giveErrors) {
+        throw new IOException("Induced errors");
+      }
+    }
+
+    @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public <T extends BaseRecord> QueryResult get(Class<T> clazz) throws 
IOException {
+      checkErrors();
+      Map<String, BaseRecord> map = 
valueMap.get(StateStoreUtils.getRecordName(clazz));
+      List<BaseRecord> results = map != null

Review Comment:
   I'll take a look.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to