FSConfigToCSConfigConverter { public void convert(FSConfigToCSConfigConverterParams params) throws Exception { validateParams(params); this.clusterResource = getClusterResource(params); this.convertPlacementRules = params.isConvertPlacementRules(); this.outputDirectory = params.getOutputDirectory(); prepareOutputFiles(params.isConsole()); loadConversionRules(params.getConversionRulesConfig()); Configuration inputYarnSiteConfig = getInputYarnSiteConfig(params); handleFairSchedulerConfig(params, inputYarnSiteConfig); convert(inputYarnSiteConfig); } FSConfigToCSConfigConverter(FSConfigToCSConfigRuleHandler
      ruleHandler, ConversionOptions conversionOptions); void convert(FSConfigToCSConfigConverterParams params); static final Logger LOG; static final String WARNING_TEXT; }
@Test public void testQueueMaxChildCapacityNotSupported() throws Exception { expectedException.expect(UnsupportedPropertyException.class); expectedException.expectMessage("test"); Mockito.doThrow(new UnsupportedPropertyException("test")) .when(ruleHandler).handleMaxChildCapacity(); converter.convert(config); }
@Test public void testReservationSystemNotSupported() throws Exception { expectedException.expect(UnsupportedPropertyException.class); expectedException.expectMessage("maxCapacity"); Mockito.doThrow(new UnsupportedPropertyException("maxCapacity")) .when(ruleHandler).handleMaxChildCapacity(); config.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true); converter.convert(config); }
@Test public void testConvertFSConfigurationClusterResourceInvalid() throws Exception { FSConfigToCSConfigConverterParams params = createDefaultParamsBuilder() .withClusterResource("vcores=20, memory-mb=240G") .build(); expectedException.expect(ConversionException.class); expectedException.expectMessage("Error while parsing resource"); converter.convert(params); }
@Test public void testConvertFSConfigurationClusterResourceInvalid2() throws Exception { FSConfigToCSConfigConverterParams params = createDefaultParamsBuilder() .withClusterResource("vcores=20, memmmm=240") .build(); expectedException.expect(ConversionException.class); expectedException.expectMessage("Error while parsing resource"); converter.convert(params); }
@Test public void testConvertFSConfigurationUndefinedYarnSiteConfig() throws Exception { FSConfigToCSConfigConverterParams params = FSConfigToCSConfigConverterParams.Builder.create() .withYarnSiteXmlConfig(null) .withOutputDirectory(FSConfigConverterTestCommons.OUTPUT_DIR) .build(); expectedException.expect(PreconditionException.class); expectedException.expectMessage( "yarn-site.xml configuration is not defined"); converter.convert(params); }
@Test public void testConvertCheckOutputDir() throws Exception { FSConfigToCSConfigConverterParams params = createDefaultParamsBuilder() .withClusterResource(CLUSTER_RESOURCE_STRING) .withConvertPlacementRules(true) .build(); converter.convert(params); Configuration conf = getConvertedCSConfig(FSConfigConverterTestCommons.OUTPUT_DIR); File capacityFile = new File(FSConfigConverterTestCommons.OUTPUT_DIR, "capacity-scheduler.xml"); assertTrue("Capacity file exists", capacityFile.exists()); assertTrue("Capacity file length > 0", capacityFile.length() > 0); assertTrue("No. of configuration elements > 0", conf.size() > 0); File yarnSiteFile = new File(FSConfigConverterTestCommons.OUTPUT_DIR, "yarn-site.xml"); assertTrue("Yarn site exists", yarnSiteFile.exists()); assertTrue("Yarn site length > 0", yarnSiteFile.length() > 0); File mappingRulesFile = new File(FSConfigConverterTestCommons.OUTPUT_DIR, "mapping-rules.json"); assertTrue("Mapping rules file exists", mappingRulesFile.exists()); assertTrue("Mapping rules file length > 0", mappingRulesFile.length() > 0); }
@Test public void testFairSchedulerXmlIsNotDefinedNeitherDirectlyNorInYarnSiteXml() throws Exception { FSConfigToCSConfigConverterParams params = createParamsBuilder(YARN_SITE_XML_NO_REF_TO_FS_XML) .withClusterResource(CLUSTER_RESOURCE_STRING) .build(); expectedException.expect(PreconditionException.class); expectedException.expectMessage("fair-scheduler.xml is not defined"); converter.convert(params); }
@Test public void testInvalidFairSchedulerXml() throws Exception { FSConfigToCSConfigConverterParams params = createDefaultParamsBuilder() .withClusterResource(CLUSTER_RESOURCE_STRING) .withFairSchedulerXmlConfig(FAIR_SCHEDULER_XML_INVALID) .build(); expectedException.expect(RuntimeException.class); converter.convert(params); }
@Test public void testInvalidYarnSiteXml() throws Exception { FSConfigToCSConfigConverterParams params = createParamsBuilder(YARN_SITE_XML_INVALID) .withClusterResource(CLUSTER_RESOURCE_STRING) .build(); expectedException.expect(RuntimeException.class); converter.convert(params); }
@Test public void testConversionWithInvalidPlacementRules() throws Exception { config = new Configuration(false); config.set(FairSchedulerConfiguration.ALLOCATION_FILE, FS_INVALID_PLACEMENT_RULES_XML); config.setBoolean(FairSchedulerConfiguration.MIGRATION_MODE, true); expectedException.expect(ServiceStateException.class); converter.convert(config); }
@Test public void testConversionWhenInvalidPlacementRulesIgnored() throws Exception { FSConfigToCSConfigConverterParams params = createDefaultParamsBuilder() .withClusterResource(CLUSTER_RESOURCE_STRING) .withFairSchedulerXmlConfig(FS_INVALID_PLACEMENT_RULES_XML) .build(); ConversionOptions conversionOptions = createDefaultConversionOptions(); conversionOptions.setNoTerminalRuleCheck(true); converter = new FSConfigToCSConfigConverter(ruleHandler, conversionOptions); converter.convert(params); }