ConvertedConfigValidator { public void validateConvertedConfig(String outputDir) throws Exception { QueueMetrics.clearQueueMetrics(); Path configPath = new Path(outputDir, "capacity-scheduler.xml"); CapacitySchedulerConfiguration csConfig = new CapacitySchedulerConfiguration( new Configuration(false), false); csConfig.addResource(configPath); Path convertedSiteConfigPath = new Path(outputDir, "yarn-site.xml"); Configuration siteConf = new YarnConfiguration( new Configuration(false)); siteConf.addResource(convertedSiteConfigPath); RMContextImpl rmContext = new RMContextImpl(); siteConf.set(YarnConfiguration.FS_BASED_RM_CONF_STORE, outputDir); ConfigurationProvider provider = new FileSystemBasedConfigurationProvider(); provider.init(siteConf); rmContext.setConfigurationProvider(provider); RMNodeLabelsManager mgr = new RMNodeLabelsManager(); mgr.init(siteConf); rmContext.setNodeLabelManager(mgr); try (CapacityScheduler cs = new CapacityScheduler()) { cs.setConf(siteConf); cs.setRMContext(rmContext); cs.serviceInit(csConfig); cs.serviceStart(); LOG.info("Capacity scheduler was successfully started"); cs.serviceStop(); } catch (Exception e) { LOG.error("Could not start Capacity Scheduler", e); throw new VerificationException( "Verification of converted configuration failed", e); } }  void validateConvertedConfig(String outputDir);  }
@Test public void testValidationPassed() throws Exception { validator.validateConvertedConfig(CONFIG_DIR_PASSES); }
@Test(expected = VerificationException.class) public void testValidationFails() throws Exception { validator.validateConvertedConfig(CONFIG_DIR_FAIL); }