Search in sources :

Example 1 with Capabilities

use of io.cdap.cdap.runtime.spi.provisioner.Capabilities in project cdap by caskdata.

the class ProvisioningServiceTest method testUnfulfilledRequirements.

@Test
public void testUnfulfilledRequirements() {
    Capabilities provisionerCapabilities = new Capabilities(ImmutableSet.of(Table.TYPE));
    Set<PluginRequirement> requirements = ImmutableSet.of(new PluginRequirement("source1", "batchsource", new Requirements(ImmutableSet.of(Table.TYPE, "unicorn"))), new PluginRequirement("sink1", "batchsink", new Requirements(ImmutableSet.of(Table.TYPE, "dragon"))));
    Set<PluginRequirement> expectedUnfulfilledRequirements = ImmutableSet.of(new PluginRequirement("source1", "batchsource", new Requirements(ImmutableSet.of("unicorn"))), new PluginRequirement("sink1", "batchsink", new Requirements(ImmutableSet.of("dragon"))));
    assertRequirementFulfillment(provisionerCapabilities, requirements, expectedUnfulfilledRequirements);
    // check when there are multiple plugins with same name but different type
    requirements = ImmutableSet.of(new PluginRequirement("source1", "batchsource", new Requirements(ImmutableSet.of(Table.TYPE, "unicorn"))), new PluginRequirement("sink1", "batchsink", new Requirements(ImmutableSet.of(Table.TYPE, "dragon"))), new PluginRequirement("sink1", "anothersink", new Requirements(ImmutableSet.of(Table.TYPE, "narwhal"))));
    expectedUnfulfilledRequirements = ImmutableSet.of(new PluginRequirement("source1", "batchsource", new Requirements(ImmutableSet.of("unicorn"))), new PluginRequirement("sink1", "batchsink", new Requirements(ImmutableSet.of("dragon"))), new PluginRequirement("sink1", "anothersink", new Requirements(ImmutableSet.of("narwhal"))));
    assertRequirementFulfillment(provisionerCapabilities, requirements, expectedUnfulfilledRequirements);
    // check when provisioner does not have any specified capability
    provisionerCapabilities = Capabilities.EMPTY;
    assertRequirementFulfillment(provisionerCapabilities, requirements, requirements);
}
Also used : Capabilities(io.cdap.cdap.runtime.spi.provisioner.Capabilities) PluginRequirement(io.cdap.cdap.internal.pipeline.PluginRequirement) Requirements(io.cdap.cdap.api.plugin.Requirements) Test(org.junit.Test)

Example 2 with Capabilities

use of io.cdap.cdap.runtime.spi.provisioner.Capabilities in project cdap by caskdata.

the class ProvisioningServiceTest method testFulfilledRequirements.

@Test
public void testFulfilledRequirements() {
    Capabilities provisionerCapabilities = new Capabilities(ImmutableSet.of(Table.TYPE));
    Set<PluginRequirement> requirements = ImmutableSet.of(new PluginRequirement("source1", "batchsource", new Requirements(Collections.emptySet())), new PluginRequirement("sink1", "batchsink", new Requirements(ImmutableSet.of(Table.TYPE))));
    // there should not be any incapability
    assertRequirementFulfillment(provisionerCapabilities, requirements, Collections.emptySet());
    provisionerCapabilities = new Capabilities(ImmutableSet.of(Table.TYPE));
    requirements = ImmutableSet.of(new PluginRequirement("source1", "batchsource", new Requirements(ImmutableSet.of(Table.TYPE))), new PluginRequirement("sink1", "batchsink", new Requirements(ImmutableSet.of(Table.TYPE))));
    // there should not be any incapability
    assertRequirementFulfillment(provisionerCapabilities, requirements, Collections.emptySet());
}
Also used : Capabilities(io.cdap.cdap.runtime.spi.provisioner.Capabilities) PluginRequirement(io.cdap.cdap.internal.pipeline.PluginRequirement) Requirements(io.cdap.cdap.api.plugin.Requirements) Test(org.junit.Test)

Aggregations

Requirements (io.cdap.cdap.api.plugin.Requirements)2 PluginRequirement (io.cdap.cdap.internal.pipeline.PluginRequirement)2 Capabilities (io.cdap.cdap.runtime.spi.provisioner.Capabilities)2 Test (org.junit.Test)2