protected ConfTree buildConfTree(Map<String, String> optionsMap) throws BadCommandArgumentsException { ConfTree confTree = new ConfTree(); ConfTreeOperations ops = new ConfTreeOperations(confTree); confTree.global.putAll(optionsMap); return confTree; } }
protected ConfTree buildConfTree(Map<String, String> optionsMap) throws BadCommandArgumentsException { ConfTree confTree = new ConfTree(); ConfTreeOperations ops = new ConfTreeOperations(confTree); confTree.global.putAll(optionsMap); return confTree; } }
@Test public void testComponentCommandOrderBadComponent() throws Exception { ConfTreeOperations resourcesGood = new ConfTreeOperations(new ConfTree()); resourcesGood.getOrAddComponent("A"); resourcesGood.getOrAddComponent("Z"); ConfTreeOperations resourcesBad = new ConfTreeOperations(new ConfTree()); CommandOrder co1 = new CommandOrder(); co1.setCommand("A-START"); co1.setRequires("Z-STARTED"); CommandOrder co2 = new CommandOrder(); co2.setCommand("Z-START"); co2.setRequires("A-STARTED"); ComponentCommandOrder cco = new ComponentCommandOrder( Arrays.asList(co1), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co1), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } }
@Test public void testComponentCommandOrderBadComponent() throws Exception { ConfTreeOperations resourcesGood = new ConfTreeOperations(new ConfTree()); resourcesGood.getOrAddComponent("A"); resourcesGood.getOrAddComponent("Z"); ConfTreeOperations resourcesBad = new ConfTreeOperations(new ConfTree()); CommandOrder co1 = new CommandOrder(); co1.setCommand("A-START"); co1.setRequires("Z-STARTED"); CommandOrder co2 = new CommandOrder(); co2.setCommand("Z-START"); co2.setRequires("A-STARTED"); ComponentCommandOrder cco = new ComponentCommandOrder( Arrays.asList(co1), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co1), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } }
expect(access.getPublishedExportsSet()).andReturn(pubExpSet).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(new ConfTreeOperations( new ConfTree())).anyTimes(); replay(access);
expect(access.getPublishedExportsSet()).andReturn(pubExpSet).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(new ConfTreeOperations( new ConfTree())).anyTimes(); replay(access);
expect(access.getPublishedExportsSet()).andReturn(pubExpSet).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(new ConfTreeOperations( new ConfTree())).anyTimes(); replay(access);
@Test public void testPrepareAMAndConfigForLaunch() throws Exception { AgentClientProvider provider = new AgentClientProvider(null); SliderFileSystem sfs = PowerMock.createMock(SliderFileSystem.class); FileSystem fs = PowerMock.createMock(FileSystem.class); Configuration serviceConf = PowerMock.createMock(Configuration.class); PowerMock.mockStatic(ProviderUtils.class); expect(sfs.getFileSystem()).andReturn(fs); expect(fs.mkdirs(anyObject(Path.class))).andReturn(true); expect(ProviderUtils.addAgentTar( anyObject(), anyObject(String.class), anyObject(SliderFileSystem.class), anyObject(Path.class))). andReturn(true); AggregateConf instanceDefinition = new AggregateConf(); ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); instanceDefinition.setInternal(tree); PowerMock.replay(sfs, fs, serviceConf, ProviderUtils.class); provider.prepareAMAndConfigForLaunch( sfs, serviceConf, null, instanceDefinition, null, null, null, null, null, false); Assert.assertTrue(tree.global.containsKey(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH)); tree.global.remove(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH); // Verify that slider-agent.tar.gz got added Path tempPath = new Path(".", "temp"); provider.prepareAMAndConfigForLaunch( sfs, serviceConf, null, instanceDefinition, null, null, null, null, tempPath, false); PowerMock.verify(sfs, fs, ProviderUtils.class); Assert.assertTrue(tree.global.containsKey(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH)); }
@Test public void testPrepareAMAndConfigForLaunch() throws Exception { AgentClientProvider provider = new AgentClientProvider(null); SliderFileSystem sfs = PowerMock.createMock(SliderFileSystem.class); FileSystem fs = PowerMock.createMock(FileSystem.class); Configuration serviceConf = PowerMock.createMock(Configuration.class); PowerMock.mockStatic(ProviderUtils.class); expect(sfs.getFileSystem()).andReturn(fs); expect(fs.mkdirs(anyObject(Path.class))).andReturn(true); expect(ProviderUtils.addAgentTar( anyObject(), anyObject(String.class), anyObject(SliderFileSystem.class), anyObject(Path.class))). andReturn(true); AggregateConf instanceDefinition = new AggregateConf(); ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); instanceDefinition.setInternal(tree); PowerMock.replay(sfs, fs, serviceConf, ProviderUtils.class); provider.prepareAMAndConfigForLaunch( sfs, serviceConf, null, instanceDefinition, null, null, null, null, null, false); Assert.assertTrue(tree.global.containsKey(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH)); tree.global.remove(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH); // Verify that slider-agent.tar.gz got added Path tempPath = new Path(".", "temp"); provider.prepareAMAndConfigForLaunch( sfs, serviceConf, null, instanceDefinition, null, null, null, null, tempPath, false); PowerMock.verify(sfs, fs, ProviderUtils.class); Assert.assertTrue(tree.global.containsKey(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH)); }
expect(access.getPublishedExportsSet()).andReturn(pubExpSet).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(new ConfTreeOperations( new ConfTree())).anyTimes(); replay(access);
@Test public void testRegistration() throws Exception { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, ".");
InputStream metainfo_1 = new ByteArrayInputStream(metainfo_1_str.getBytes()); Metainfo metainfo = new MetainfoParser().fromXmlStream(metainfo_1); ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, ".");
private AggregateConf prepareConfForAgentStateTests() { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_VERSION, "."); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_MASTER"); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_REGIONSERVER"); return instanceDefinition; }
private AggregateConf prepareConfForAgentStateTests() { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_VERSION, "."); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_MASTER"); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_REGIONSERVER"); return instanceDefinition; }
@Test public void testComponentCommandOrderPrefixes() throws Exception { ConfTreeOperations resources = new ConfTreeOperations(new ConfTree()); resources.getOrAddComponent("a-A").put(ROLE_PREFIX, "a-"); resources.getOrAddComponent("b-B1").put(ROLE_PREFIX, "b-");
@Test public void testComponentCommandOrderPrefixes() throws Exception { ConfTreeOperations resources = new ConfTreeOperations(new ConfTree()); resources.getOrAddComponent("a-A").put(ROLE_PREFIX, "a-"); resources.getOrAddComponent("b-B1").put(ROLE_PREFIX, "b-");