@Test
public void testServicesWithLogsearchRoleCommandOrder() 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 zookeeperServerRoleCommand = Role.ZOOKEEPER_SERVER + "-" + RoleCommand.START;
  String logsearchServerRoleCommand = Role.LOGSEARCH_SERVER + "-" + RoleCommand.START;
  String infraSolrRoleCommand = Role.INFRA_SOLR + "-" + RoleCommand.START;
  String logsearchLogfeederRoleCommand = Role.LOGSEARCH_LOGFEEDER + "-" + 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");
  // HDFS/YARN - verify that the stack level rco still works as expected
  String nameNodeRoleCommand = Role.NAMENODE + "-" + RoleCommand.START;
  String rangerUserSyncRoleCommand = Role.RANGER_USERSYNC + "-" + RoleCommand.START;
  ArrayList<String> nameNodeBlockers = (ArrayList<String>) optionalNoGlusterfs.get(nameNodeRoleCommand);
  assertTrue(nameNodeRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, nameNodeBlockers.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));
  // verify logsearch rco
  // LogSearch Solr
  ArrayList<String> logsearchSolrBlockers = (ArrayList<String>) generalDeps.get(infraSolrRoleCommand);
  assertTrue(infraSolrRoleCommand + " should be dependent of " + zookeeperServerRoleCommand, logsearchSolrBlockers.contains(zookeeperServerRoleCommand));
  // LogSearch Server
  ArrayList<String> logsearchServerBlockers = (ArrayList<String>) generalDeps.get(logsearchServerRoleCommand);
  assertTrue(logsearchServerRoleCommand + " should be dependent of " + infraSolrRoleCommand, logsearchServerBlockers.contains(infraSolrRoleCommand));
  // LogSearch LogFeeder
  ArrayList<String> logsearchLogfeederBlockers = (ArrayList<String>) generalDeps.get(logsearchLogfeederRoleCommand);
  assertTrue(logsearchLogfeederRoleCommand + " should be dependent of " + infraSolrRoleCommand, logsearchLogfeederBlockers.contains(infraSolrRoleCommand));
  assertTrue(logsearchLogfeederRoleCommand + " should be dependent of " + logsearchServerRoleCommand, logsearchLogfeederBlockers.contains(logsearchServerRoleCommand));
}