Search in sources :

Example 6 with BootstrapStepResult

use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.

the class BootstrapServiceTest method testRunCondition.

@Test
public void testRunCondition() throws Exception {
    BootstrapResult result = bootstrapService.bootstrap(step -> step.getRunCondition() == BootstrapStep.RunCondition.ONCE);
    List<BootstrapStepResult> stepResults = new ArrayList<>(3);
    stepResults.add(new BootstrapStepResult(STEP1.getLabel(), BootstrapStepResult.Status.SKIPPED));
    stepResults.add(new BootstrapStepResult(STEP2.getLabel(), BootstrapStepResult.Status.SUCCEEDED));
    stepResults.add(new BootstrapStepResult(STEP3.getLabel(), BootstrapStepResult.Status.SKIPPED));
    Assert.assertEquals(new BootstrapResult(stepResults), result);
}
Also used : ArrayList(java.util.ArrayList) BootstrapResult(io.cdap.cdap.proto.bootstrap.BootstrapResult) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Example 7 with BootstrapStepResult

use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.

the class BootstrapServiceTest method testContinuesAfterFailures.

@Test
public void testContinuesAfterFailures() throws Exception {
    EXECUTOR1.shouldFail();
    BootstrapResult result = bootstrapService.bootstrap();
    List<BootstrapStepResult> stepResults = new ArrayList<>(3);
    stepResults.add(new BootstrapStepResult(STEP1.getLabel(), BootstrapStepResult.Status.FAILED));
    stepResults.add(new BootstrapStepResult(STEP2.getLabel(), BootstrapStepResult.Status.SUCCEEDED));
    stepResults.add(new BootstrapStepResult(STEP3.getLabel(), BootstrapStepResult.Status.SUCCEEDED));
    BootstrapResult expected = new BootstrapResult(stepResults);
    Assert.assertEquals(expected, result);
}
Also used : ArrayList(java.util.ArrayList) BootstrapResult(io.cdap.cdap.proto.bootstrap.BootstrapResult) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Example 8 with BootstrapStepResult

use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.

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 9 with BootstrapStepResult

use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.

the class NativeProfileCreatorTest method testAlreadyExistsDoesNotError.

@Test
public void testAlreadyExistsDoesNotError() throws Exception {
    profileService.saveProfile(ProfileId.NATIVE, Profile.NATIVE);
    BootstrapStepResult result = nativeProfileCreator.execute("label", new JsonObject());
    BootstrapStepResult expected = new BootstrapStepResult("label", BootstrapStepResult.Status.SUCCEEDED);
    Assert.assertEquals(expected, result);
    Assert.assertEquals(Profile.NATIVE, profileService.getProfile(ProfileId.NATIVE));
}
Also used : JsonObject(com.google.gson.JsonObject) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Example 10 with BootstrapStepResult

use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.

the class SystemPreferencesSetterTest method testAllPreferenceSet.

@Test
public void testAllPreferenceSet() throws Exception {
    Map<String, String> preferences = new HashMap<>();
    preferences.put("p1", "v1");
    preferences.put("p2", "v2");
    SystemPreferenceSetter.Arguments arguments = new SystemPreferenceSetter.Arguments(preferences);
    BootstrapStepResult result = systemPreferenceSetter.execute("label", GSON.toJsonTree(arguments).getAsJsonObject());
    Assert.assertEquals(BootstrapStepResult.Status.SUCCEEDED, result.getStatus());
    Assert.assertEquals(preferences, preferencesService.getProperties());
}
Also used : HashMap(java.util.HashMap) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Aggregations

BootstrapStepResult (io.cdap.cdap.proto.bootstrap.BootstrapStepResult)34 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)14 JsonObject (com.google.gson.JsonObject)12 BootstrapResult (io.cdap.cdap.proto.bootstrap.BootstrapResult)8 ProvisionerInfo (io.cdap.cdap.proto.provisioner.ProvisionerInfo)6 ProvisionerPropertyValue (io.cdap.cdap.proto.provisioner.ProvisionerPropertyValue)6 NotFoundException (io.cdap.cdap.common.NotFoundException)4 ProfileId (io.cdap.cdap.proto.id.ProfileId)4 Profile (io.cdap.cdap.proto.profile.Profile)4 HashMap (java.util.HashMap)4 JsonParseException (com.google.gson.JsonParseException)2 RetryableException (io.cdap.cdap.api.retry.RetryableException)2 NamespaceNotFoundException (io.cdap.cdap.common.NamespaceNotFoundException)2