AmClusterValidator { public boolean validateBlueprint(ClusterBlueprint blueprint) { logger.info("Start to validate blueprint for cluster " + blueprint.getName()); HadoopStack hadoopStack = blueprint.getHadoopStack(); String distro = hadoopStack.getDistro(); String stackVendor = hadoopStack.getVendor(); String stackVersion = hadoopStack.getFullVersion(); List<String> unRecogConfigTypes = new ArrayList<String>(); List<String> unRecogConfigKeys = new ArrayList<>(); validateRoles(blueprint, unRecogConfigTypes, unRecogConfigKeys, stackVendor, stackVersion, distro); validateRacks(blueprint.getNodeGroups()); validateConfigs(blueprint.getConfiguration(), unRecogConfigTypes, unRecogConfigKeys, stackVendor, stackVersion); validateSupportComputeOnly(blueprint); if (!unRecogConfigTypes.isEmpty()) { errorMsgList.add("Configurations for " + unRecogConfigTypes.toString() + " are not available by distro " + distro); } if (!unRecogConfigKeys.isEmpty()) { errorMsgList.add("Configuration items " + unRecogConfigKeys.toString() + " are invalid"); } if (!warningMsgList.isEmpty() || !errorMsgList.isEmpty()) { throw ValidationException.VALIDATION_FAIL("Blueprint", errorMsgList, warningMsgList); } return true; } AmClusterValidator(); ApiManager getApiManager(); void setApiManager(ApiManager apiManager); boolean validateBlueprint(ClusterBlueprint blueprint); @Override String toString();  }
@Test(groups = { "TestAmClusterValidator" },expectedExceptions = ValidationException.class) public void testSuccess() { try { Assert.assertTrue(validator.validateBlueprint(blueprint)); } catch (ValidationException e) { System.out.println("warning_msg_list: " + e.getWarningMsgList()); System.out.println("error_msg_list: " + e.getFailedMsgList()); throw e; } }
@Test(groups = { "TestAmClusterValidator" },expectedExceptions = ValidationException.class) public void testUnrecogConfigTypes() { try { blueprint.getConfiguration().put("hdfs-site.xml", new HashMap<String, String>()); Assert.assertTrue(validator.validateBlueprint(blueprint)); } catch (ValidationException e) { System.out.println("warning_msg_list: " + e.getWarningMsgList()); System.out.println("error_msg_list: " + e.getFailedMsgList()); throw e; } }
@Test(groups = { "TestAmClusterValidator" },expectedExceptions = ValidationException.class) public void testRecogConfigTypes() { try { Map<String, String> configItem = new HashMap<String, String>(); configItem.put("dfs.blocksize", "value"); blueprint.getConfiguration().put("hdfs-site", configItem); Assert.assertTrue(validator.validateBlueprint(blueprint)); } catch (ValidationException e) { System.out.println("warning_msg_list: " + e.getWarningMsgList()); System.out.println("error_msg_list: " + e.getFailedMsgList()); throw e; } }
@Test(groups = { "TestAmClusterValidator" },expectedExceptions = ValidationException.class) public void testBadConfigItems() { try { Map<String, String> configItem = new HashMap<String, String>(); configItem.put("hbase.master.keytab.file", "value"); blueprint.getConfiguration().put("hdfs-site", configItem); Assert.assertFalse(validator.validateBlueprint(blueprint)); } catch (ValidationException e) { System.out.println("warning_msg_list: " + e.getWarningMsgList()); System.out.println("error_msg_list: " + e.getFailedMsgList()); throw e; } }
@Test(groups = { "TestAmClusterValidator" },expectedExceptions = ValidationException.class) public void testMissedRoles() { try { blueprint.getNodeGroups().get(1).getRoles().remove("HDFS_DATANODE"); blueprint.getNodeGroups().get(0).getRoles() .remove("YARN_RESOURCE_MANAGER"); Assert.assertFalse(validator.validateBlueprint(blueprint)); } catch (ValidationException e) { System.out.println("warning_msg_list: " + e.getWarningMsgList()); System.out.println("error_msg_list: " + e.getFailedMsgList()); throw e; } }