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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations