Search in sources :

Example 16 with ProvisionerInfo

use of io.cdap.cdap.proto.provisioner.ProvisionerInfo in project cdap by cdapio.

the class SystemProfileCreatorTest method testMissingProfileName.

@Test
public void testMissingProfileName() throws Exception {
    List<ProvisionerPropertyValue> properties = new ArrayList<>();
    properties.add(new ProvisionerPropertyValue("name1", "val1", true));
    properties.add(new ProvisionerPropertyValue("name2", "val2", true));
    ProvisionerInfo provisionerInfo = new ProvisionerInfo(MockProvisioner.NAME, properties);
    SystemProfileCreator.Arguments arguments = new SystemProfileCreator.Arguments("", "label", "desc", provisionerInfo);
    BootstrapStepResult result = profileCreator.execute("label", GSON.toJsonTree(arguments).getAsJsonObject());
    Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus());
}
Also used : ProvisionerPropertyValue(io.cdap.cdap.proto.provisioner.ProvisionerPropertyValue) ProvisionerInfo(io.cdap.cdap.proto.provisioner.ProvisionerInfo) ArrayList(java.util.ArrayList) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Example 17 with ProvisionerInfo

use of io.cdap.cdap.proto.provisioner.ProvisionerInfo in project cdap by cdapio.

the class ProvisioningServiceTest method testCancelProvision.

@Test
public void testCancelProvision() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    ProvisionerInfo provisionerInfo = new MockProvisioner.PropertyBuilder().waitCreate(1, TimeUnit.MINUTES).build();
    TaskFields taskFields = createTaskInfo(provisionerInfo);
    ProvisionRequest provisionRequest = new ProvisionRequest(taskFields.programRunId, taskFields.programOptions, taskFields.programDescriptor, "Bob");
    Runnable task = TransactionRunners.run(transactionRunner, context -> {
        return provisioningService.provision(provisionRequest, context);
    });
    task.run();
    Assert.assertTrue(provisioningService.cancelProvisionTask(taskFields.programRunId).isPresent());
    // check that the state of the task is cancelled
    ProvisioningTaskKey taskKey = new ProvisioningTaskKey(taskFields.programRunId, ProvisioningOp.Type.PROVISION);
    waitForExpectedProvisioningState(taskKey, ProvisioningOp.Status.CANCELLED);
}
Also used : ProvisionerInfo(io.cdap.cdap.proto.provisioner.ProvisionerInfo) Test(org.junit.Test)

Example 18 with ProvisionerInfo

use of io.cdap.cdap.proto.provisioner.ProvisionerInfo in project cdap by cdapio.

the class ProvisioningServiceTest method testRetryableFailures.

@Test
public void testRetryableFailures() throws Exception {
    // will throw a retryable exception every other method call
    ProvisionerInfo provisionerInfo = new MockProvisioner.PropertyBuilder().failRetryablyEveryN(2).build();
    TaskFields taskFields = testProvision(ProvisioningOp.Status.CREATED, provisionerInfo);
    testDeprovision(taskFields.programRunId, ProvisioningOp.Status.DELETED);
}
Also used : ProvisionerInfo(io.cdap.cdap.proto.provisioner.ProvisionerInfo) Test(org.junit.Test)

Example 19 with ProvisionerInfo

use of io.cdap.cdap.proto.provisioner.ProvisionerInfo in project cdap by cdapio.

the class ProvisioningServiceTest method testCancelDeprovision.

@Test
public void testCancelDeprovision() throws Exception {
    ProvisionerInfo provisionerInfo = new MockProvisioner.PropertyBuilder().waitDelete(1, TimeUnit.MINUTES).build();
    TaskFields taskFields = testProvision(ProvisioningOp.Status.CREATED, provisionerInfo);
    Runnable task = TransactionRunners.run(transactionRunner, context -> {
        return provisioningService.deprovision(taskFields.programRunId, context, t -> {
        });
    });
    task.run();
    Assert.assertTrue(provisioningService.cancelDeprovisionTask(taskFields.programRunId).isPresent());
    // check that the state of the task is cancelled
    ProvisioningTaskKey taskKey = new ProvisioningTaskKey(taskFields.programRunId, ProvisioningOp.Type.DEPROVISION);
    waitForExpectedProvisioningState(taskKey, ProvisioningOp.Status.CANCELLED);
}
Also used : ProvisionerInfo(io.cdap.cdap.proto.provisioner.ProvisionerInfo) Test(org.junit.Test)

Example 20 with ProvisionerInfo

use of io.cdap.cdap.proto.provisioner.ProvisionerInfo in project cdap by cdapio.

the class ProvisioningServiceTest method testNoErrors.

@Test
public void testNoErrors() throws Exception {
    ProvisionerInfo provisionerInfo = new MockProvisioner.PropertyBuilder().setExpectedAppCDAPVersion(APP_CDAP_VERSION).build();
    TaskFields taskFields = testProvision(ProvisioningOp.Status.CREATED, provisionerInfo);
    testDeprovision(taskFields.programRunId, ProvisioningOp.Status.DELETED);
}
Also used : ProvisionerInfo(io.cdap.cdap.proto.provisioner.ProvisionerInfo) Test(org.junit.Test)

Aggregations

ProvisionerInfo (io.cdap.cdap.proto.provisioner.ProvisionerInfo)44 Test (org.junit.Test)40 Profile (io.cdap.cdap.proto.profile.Profile)32 ProfileId (io.cdap.cdap.proto.id.ProfileId)26 ProvisionerPropertyValue (io.cdap.cdap.proto.provisioner.ProvisionerPropertyValue)12 ArrayList (java.util.ArrayList)12 NotFoundException (io.cdap.cdap.common.NotFoundException)6 BootstrapStepResult (io.cdap.cdap.proto.bootstrap.BootstrapStepResult)6 MetricsSystemClient (io.cdap.cdap.api.metrics.MetricsSystemClient)4 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)4 TransactionRunner (io.cdap.cdap.spi.data.transaction.TransactionRunner)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 ProgramOptions (io.cdap.cdap.app.runtime.ProgramOptions)2 BadRequestException (io.cdap.cdap.common.BadRequestException)2 ProfileConflictException (io.cdap.cdap.common.ProfileConflictException)2 MockProvisioner (io.cdap.cdap.internal.provision.MockProvisioner)2 ProgramType (io.cdap.cdap.proto.ProgramType)2 ProgramId (io.cdap.cdap.proto.id.ProgramId)2 ProvisionerDetail (io.cdap.cdap.proto.provisioner.ProvisionerDetail)2