Repository: apache/hadoop
File: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestZKConfigurationStore.java (Java)

Code before:

      assertEquals(data, ((ZKConfigurationStore) confStore).getZkData(logsPath));
    });
  }

  @Test
  public void testDisableAuditLogs() throws Exception {
    conf.setLong(YarnConfiguration.RM_SCHEDCONF_MAX_LOGS, 0);
    confStore.initialize(conf, schedConf, rmContext);
    String logsPath = getZkPath("LOGS");
    byte[] data = null;
    ((ZKConfigurationStore) confStore).setZkData(logsPath, data);

    prepareLogMutation("key1", "val1");

    data = ((ZKConfigurationStore) confStore).getZkData(logsPath);
    assertEquals("Failed to Disable Audit Logs", 0, data.length);
  }

  @Test
  public void testZkData() throws Exception {
    conf.setInt(YarnConfiguration.RM_SCHEDCONF_STORE_ZK_READ_RETRY_SECS, 0);
    confStore.initialize(conf, schedConf, rmContext);
    String confStorePath = getZkPath("CONF_STORE");
    byte[] data = ((ZKConfigurationStore) confStore).getZkData(confStorePath);
    assertTrue("ConfStore data expected to be not null.", data.length > 0);
  }

  @Test
  public void testEmptyZkData() throws Exception {
    conf.setInt(YarnConfiguration.RM_SCHEDCONF_STORE_ZK_READ_RETRY_SECS, 0);
    confStore.initialize(conf, schedConf, rmContext);
    confStore.format();
    String confStorePath = getZkPath("CONF_STORE");
    byte[] data = ((ZKConfigurationStore) confStore).getZkData(confStorePath);
    assertEquals("ConfStore data expected to be empty.", 0,
        data.length);
  }

  public Configuration createRMHAConf(String rmIds, String rmId,
      int adminPort) {
    Configuration conf = new YarnConfiguration();
    this.conf.setClass(YarnConfiguration.RM_SCHEDULER,
        CapacityScheduler.class, CapacityScheduler.class);
    conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
    conf.set(YarnConfiguration.RM_HA_IDS, rmIds);
    conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
    conf.set(YarnConfiguration.SCHEDULER_CONFIGURATION_STORE_CLASS,
        YarnConfiguration.ZK_CONFIGURATION_STORE);
    conf.set(YarnConfiguration.RM_STORE, ZKRMStateStore.class.getName());
    conf.set(YarnConfiguration.RM_ZK_ADDRESS,

Review comment (suggestion):
I think it would be nice to add the configuration data here.
Because it seems like we are checking against empty configuration [here](https://github.com/apache/hadoop/blob/90150aff3f84183cebaf21e977834b8a77e8ede7/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ConfigurationStoreBaseTest.java#L50) 

E.g. setting data ([code](https://github.com/apache/hadoop/blob/90150aff3f84183cebaf21e977834b8a77e8ede7/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestZKConfigurationStore.java#L138))

Code after:

      assertEquals(data, ((ZKConfigurationStore) confStore).getZkData(logsPath));
    });
  }

  @Test
  public void testDisableAuditLogs() throws Exception {
    conf.setLong(YarnConfiguration.RM_SCHEDCONF_MAX_LOGS, 0);
    confStore.initialize(conf, schedConf, rmContext);
    String logsPath = getZkPath("LOGS");
    byte[] data = null;
    ((ZKConfigurationStore) confStore).setZkData(logsPath, data);

    prepareLogMutation("key1", "val1");

    data = ((ZKConfigurationStore) confStore).getZkData(logsPath);
    assertEquals(0, data.length, "Failed to Disable Audit Logs");
  }

  @Test
  public void testZkData() throws Exception {
    conf.setInt(YarnConfiguration.RM_SCHEDCONF_STORE_ZK_READ_RETRY_SECS, 0);
    schedConf.set("key", "val");
    confStore.initialize(conf, schedConf, rmContext);
    String confStorePath = getZkPath("CONF_STORE");
    byte[] data = ((ZKConfigurationStore) confStore).getZkData(confStorePath);
    assertTrue(data.length > 0, "ConfStore data expected to be not null.");
  }

  @Test
  public void testEmptyZkData() throws Exception {
    conf.setInt(YarnConfiguration.RM_SCHEDCONF_STORE_ZK_READ_RETRY_SECS, 0);
    schedConf.set("key", "val");
    confStore.initialize(conf, schedConf, rmContext);
    confStore.format();
    String confStorePath = getZkPath("CONF_STORE");
    byte[] data = ((ZKConfigurationStore) confStore).getZkData(confStorePath);
    assertEquals(0, data.length, "ConfStore data expected to be empty.");
  }

  public Configuration createRMHAConf(String rmIds, String rmId,
      int adminPort) {
    Configuration conf = new YarnConfiguration();
    this.conf.setClass(YarnConfiguration.RM_SCHEDULER,
        CapacityScheduler.class, CapacityScheduler.class);
    conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
    conf.set(YarnConfiguration.RM_HA_IDS, rmIds);
    conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
    conf.set(YarnConfiguration.SCHEDULER_CONFIGURATION_STORE_CLASS,
        YarnConfiguration.ZK_CONFIGURATION_STORE);
    conf.set(YarnConfiguration.RM_STORE, ZKRMStateStore.class.getName());