@Test public void testServicesWithRangerPluginRoleCommandOrder() throws AmbariException { URL rootDirectoryURL = StackManagerTest.class.getResource("/"); Assert.notNull(rootDirectoryURL); File resourcesDirectory = new File(new File(rootDirectoryURL.getFile()).getParentFile().getParentFile(), "src/main/resources"); File stackRoot = new File(resourcesDirectory, "stacks"); File commonServices = new File(resourcesDirectory, "common-services"); File extensions = null; try { URL extensionsURL = ClassLoader.getSystemClassLoader().getResource("extensions"); if (extensionsURL != null) { extensions = new File(extensionsURL.getPath().replace("test-classes","classes")); } } catch (Exception e) {} MetainfoDAO metaInfoDao = createNiceMock(MetainfoDAO.class); StackDAO stackDao = createNiceMock(StackDAO.class); ExtensionDAO extensionDao = createNiceMock(ExtensionDAO.class); ExtensionLinkDAO linkDao = createNiceMock(ExtensionLinkDAO.class); ActionMetadata actionMetadata = createNiceMock(ActionMetadata.class); Configuration config = createNiceMock(Configuration.class); ExtensionEntity extensionEntity = createNiceMock(ExtensionEntity.class); expect(config.getSharedResourcesDirPath()).andReturn( ClassLoader.getSystemClassLoader().getResource("").getPath()).anyTimes(); expect( extensionDao.find(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(extensionEntity).atLeastOnce(); List<ExtensionLinkEntity> list = Collections.emptyList(); expect( linkDao.findByStack(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(list).atLeastOnce(); replay(config, metaInfoDao, stackDao, extensionDao, linkDao, actionMetadata); OsFamily osFamily = new OsFamily(config); StackManager stackManager = new StackManager(stackRoot, commonServices, extensions, osFamily, false, metaInfoDao, actionMetadata, stackDao, extensionDao, linkDao); String rangerUserSyncRoleCommand = Role.RANGER_USERSYNC + "-" + RoleCommand.START; String rangerAdminRoleCommand = Role.RANGER_ADMIN + "-" + RoleCommand.START; String zookeeperServerRoleCommand = Role.ZOOKEEPER_SERVER + "-" + RoleCommand.START; String nodeManagerRoleCommand = Role.NODEMANAGER + "-" + RoleCommand.START; String mySqlServerRoleCommand = Role.MYSQL_SERVER + "-" + RoleCommand.START; StackInfo hdp = stackManager.getStack("HDP", "2.3"); Map<String, Object> rco = hdp.getRoleCommandOrder().getContent(); Map<String, Object> generalDeps = (Map<String, Object>)rco.get("general_deps"); Map<String, Object> optionalNoGlusterfs = (Map<String, Object>)rco.get("optional_no_glusterfs"); String nameNodeRoleCommand = Role.NAMENODE + "-" + RoleCommand.START; ArrayList<String> nameNodeBlockers = (ArrayList<String>)optionalNoGlusterfs.get(nameNodeRoleCommand); assertTrue(nameNodeRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, nameNodeBlockers.contains(rangerUserSyncRoleCommand)); String dataNodeRoleCommand = Role.DATANODE + "-" + RoleCommand.START; ArrayList<String> dataNodeBlockers = (ArrayList<String>)optionalNoGlusterfs.get(dataNodeRoleCommand); assertTrue(dataNodeRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, dataNodeBlockers.contains(rangerUserSyncRoleCommand)); String resourceManagerCommandRoleCommand = Role.RESOURCEMANAGER + "-" + RoleCommand.START; ArrayList<String> resourceManagerBlockers = (ArrayList<String>)generalDeps.get(resourceManagerCommandRoleCommand); assertTrue(resourceManagerCommandRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, resourceManagerBlockers.contains(rangerUserSyncRoleCommand)); String hbaseRoleCommand = Role.HBASE_MASTER + "-" + RoleCommand.START; ArrayList<String> hbaseBlockers = (ArrayList<String>)generalDeps.get(hbaseRoleCommand); assertTrue(hbaseRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, hbaseBlockers.contains(rangerUserSyncRoleCommand)); assertTrue(hbaseRoleCommand + " should be dependent of " + zookeeperServerRoleCommand, hbaseBlockers.contains(zookeeperServerRoleCommand)); String knoxRoleCommand = Role.KNOX_GATEWAY + "-" + RoleCommand.START; ArrayList<String> knoxBlockers = (ArrayList<String>)generalDeps.get(knoxRoleCommand); assertTrue(knoxRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, knoxBlockers.contains(rangerUserSyncRoleCommand)); String kafkaRoleCommand = Role.KAFKA_BROKER + "-" + RoleCommand.START; ArrayList<String> kafkaBlockers = (ArrayList<String>)generalDeps.get(kafkaRoleCommand); assertTrue(Role.KAFKA_BROKER + "-" + RoleCommand.START + " should be dependent of " + rangerUserSyncRoleCommand, kafkaBlockers.contains(rangerUserSyncRoleCommand)); String hiveRoleCommand = Role.HIVE_SERVER + "-" + RoleCommand.START; ArrayList<String> hiveBlockers = (ArrayList<String>)generalDeps.get(hiveRoleCommand); assertTrue(hiveRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, hiveBlockers.contains(rangerUserSyncRoleCommand)); assertTrue(hiveRoleCommand + " should be dependent of " + nodeManagerRoleCommand, hiveBlockers.contains(nodeManagerRoleCommand)); assertTrue(hiveRoleCommand + " should be dependent of " + mySqlServerRoleCommand, hiveBlockers.contains(mySqlServerRoleCommand)); String stormRoleCommand = Role.NIMBUS + "-" + RoleCommand.START; ArrayList<String> stormBlockers = (ArrayList<String>)generalDeps.get(stormRoleCommand); assertTrue(stormRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, stormBlockers.contains(rangerUserSyncRoleCommand)); assertTrue(stormRoleCommand + " should be dependent of " + zookeeperServerRoleCommand, stormBlockers.contains(zookeeperServerRoleCommand)); String kmsRoleCommand = Role.RANGER_KMS_SERVER + "-" + RoleCommand.START; ArrayList<String> rangerKmsBlockers = (ArrayList<String>)generalDeps.get(kmsRoleCommand); assertTrue(kmsRoleCommand + " should be dependent of " + rangerAdminRoleCommand, rangerKmsBlockers.contains(rangerAdminRoleCommand)); ArrayList<String> rangerUserSyncBlockers = (ArrayList<String>)generalDeps.get(rangerUserSyncRoleCommand); assertTrue(rangerUserSyncRoleCommand + " should be dependent of " + rangerAdminRoleCommand, rangerUserSyncBlockers.contains(rangerAdminRoleCommand)); assertTrue(rangerUserSyncRoleCommand + " should be dependent of " + kmsRoleCommand, rangerUserSyncBlockers.contains(kmsRoleCommand)); }
public StackInfo getStack(String name, String version) { return stackMap.get(name + StackManager.PATH_DELIMITER + version); }
StackManager { public StackInfo getStack(String name, String version) { return stackMap.get(name + StackManager.PATH_DELIMITER + version); } }
StackManager { public StackInfo getStack(String name, String version) { return stackMap.get(name + StackManager.PATH_DELIMITER + version); } @AssistedInject  StackManager(@Assisted("stackRoot") File stackRoot,
      @Assisted("commonServicesRoot") @Nullable File commonServicesRoot,
      @Assisted("extensionRoot") @Nullable File extensionRoot,
      @Assisted OsFamily osFamily, @Assisted boolean validate,
      MetainfoDAO metaInfoDAO, ActionMetadata actionMetadata, StackDAO stackDao,
      ExtensionDAO extensionDao, ExtensionLinkDAO linkDao); }
StackManager { public StackInfo getStack(String name, String version) { return stackMap.get(name + StackManager.PATH_DELIMITER + version); } @AssistedInject  StackManager(@Assisted("stackRoot") File stackRoot,
      @Assisted("commonServicesRoot") @Nullable File commonServicesRoot,
      @Assisted("extensionRoot") @Nullable File extensionRoot,
      @Assisted OsFamily osFamily, @Assisted boolean validate,
      MetainfoDAO metaInfoDAO, ActionMetadata actionMetadata, StackDAO stackDao,
      ExtensionDAO extensionDao, ExtensionLinkDAO linkDao); StackInfo getStack(String name, String version); Collection<StackInfo> getStacks(String name); Collection<StackInfo> getStacks(); ExtensionInfo getExtension(String name, String version); Collection<ExtensionInfo> getExtensions(String name); Collection<ExtensionInfo> getExtensions(); boolean haveAllRepoUrlsBeenResolved(); static Validator getPropertySchemaValidator(); static void validateAllPropertyXmlsInFolderRecursively(File stackRoot, Validator validator); void linkStackToExtension(StackInfo stack, ExtensionInfo extension); void unlinkStackAndExtension(StackInfo stack, ExtensionInfo extension); }
StackManager { public StackInfo getStack(String name, String version) { return stackMap.get(name + StackManager.PATH_DELIMITER + version); } @AssistedInject  StackManager(@Assisted("stackRoot") File stackRoot,
      @Assisted("commonServicesRoot") @Nullable File commonServicesRoot,
      @Assisted("extensionRoot") @Nullable File extensionRoot,
      @Assisted OsFamily osFamily, @Assisted boolean validate,
      MetainfoDAO metaInfoDAO, ActionMetadata actionMetadata, StackDAO stackDao,
      ExtensionDAO extensionDao, ExtensionLinkDAO linkDao); StackInfo getStack(String name, String version); Collection<StackInfo> getStacks(String name); Collection<StackInfo> getStacks(); ExtensionInfo getExtension(String name, String version); Collection<ExtensionInfo> getExtensions(String name); Collection<ExtensionInfo> getExtensions(); boolean haveAllRepoUrlsBeenResolved(); static Validator getPropertySchemaValidator(); static void validateAllPropertyXmlsInFolderRecursively(File stackRoot, Validator validator); void linkStackToExtension(StackInfo stack, ExtensionInfo extension); void unlinkStackAndExtension(StackInfo stack, ExtensionInfo extension); static final String PROPERTY_SCHEMA_PATH; static String PATH_DELIMITER; static final String COMMON_SERVICES; static final String EXTENSIONS; static final String METAINFO_FILE_NAME; }