@Test public void testValidateTopology_autoDeploy_hasDependency() throws Exception { group1Components.add("component2"); dependencies1.add(dependency1); services.addAll(Collections.singleton("service1")); expect(blueprint.getHostGroupsForComponent("component1")).andReturn(Collections.<HostGroup>emptyList()).anyTimes(); expect(blueprint.getHostGroupsForComponent("component2")).andReturn(Arrays.asList(group1, group2)).anyTimes(); expect(blueprint.getHostGroupsForComponent("component3")).andReturn(Collections.<HostGroup>emptyList()).anyTimes(); expect(stack.getComponents("service1")).andReturn(Arrays.asList("component1", "component2")).anyTimes(); expect(stack.getComponents("service2")).andReturn(Collections.singleton("component3")).anyTimes(); expect(stack.getAutoDeployInfo("component1")).andReturn(autoDeploy).anyTimes(); AutoDeployInfo dependencyAutoDeploy = new AutoDeployInfo(); dependencyAutoDeploy.setEnabled(true); dependencyAutoDeploy.setCoLocate("service1/component1"); expect(dependency1.getScope()).andReturn("host").anyTimes(); expect(dependency1.getAutoDeploy()).andReturn(dependencyAutoDeploy).anyTimes(); expect(dependency1.getComponentName()).andReturn("component3").anyTimes(); expect(dependency1.getServiceName()).andReturn("service1").anyTimes(); expect(dependency1.getName()).andReturn("dependency1").anyTimes(); expect(dependencyComponentInfo.isClient()).andReturn(true).anyTimes(); expect(stack.getComponentInfo("component3")).andReturn(dependencyComponentInfo).anyTimes(); expect(group1.addComponent("component1")).andReturn(true).once(); expect(group1.addComponent("component3")).andReturn(true).once(); replay(blueprint, stack, group1, group2, dependency1, dependencyComponentInfo); BlueprintValidator validator = new BlueprintValidatorImpl(blueprint); validator.validateTopology(); verify(group1); }
@Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } BlueprintValidatorImpl(Blueprint blueprint); }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } BlueprintValidatorImpl(Blueprint blueprint); @Override void validateTopology(); @Override void validateRequiredProperties(); Collection<String> verifyComponentCardinalityCount(String component,
                                                            Cardinality cardinality,
                                                            AutoDeployInfo autoDeploy); }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } BlueprintValidatorImpl(Blueprint blueprint); @Override void validateTopology(); @Override void validateRequiredProperties(); Collection<String> verifyComponentCardinalityCount(String component,
                                                            Cardinality cardinality,
                                                            AutoDeployInfo autoDeploy);  }