Search in sources :

Example 1 with BootstrapStepResult

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

the class AppCreatorTest method invalidStructureFails.

@Test
public void invalidStructureFails() throws Exception {
    JsonObject argumentsObj = new JsonObject();
    argumentsObj.addProperty("namespace", "ns");
    argumentsObj.addProperty("name", "app");
    argumentsObj.addProperty("artifact", "name-1.0.0");
    BootstrapStepResult result = appCreator.execute("label", argumentsObj);
    Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus());
}
Also used : JsonObject(com.google.gson.JsonObject) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Example 2 with BootstrapStepResult

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

the class DefaultNamespaceCreatorTest method test.

// NOTE: can't actually delete the default namespace... so everything needs to be tested in a single test case
@Test
public void test() throws Exception {
    try {
        namespaceAdmin.get(NamespaceId.DEFAULT);
        Assert.fail("Default namespace should not exist.");
    } catch (NamespaceNotFoundException e) {
    // expected
    }
    // test that it creates the default namespace
    BootstrapStepResult result = defaultNamespaceCreator.execute("label", new JsonObject());
    BootstrapStepResult expected = new BootstrapStepResult("label", BootstrapStepResult.Status.SUCCEEDED);
    Assert.assertEquals(expected, result);
    Assert.assertEquals(NamespaceMeta.DEFAULT, namespaceAdmin.get(NamespaceId.DEFAULT));
    // test trying to create when it's already there won't error
    result = defaultNamespaceCreator.execute("label", new JsonObject());
    expected = new BootstrapStepResult("label", BootstrapStepResult.Status.SUCCEEDED);
    Assert.assertEquals(expected, result);
    Assert.assertEquals(NamespaceMeta.DEFAULT, namespaceAdmin.get(NamespaceId.DEFAULT));
}
Also used : JsonObject(com.google.gson.JsonObject) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) NamespaceNotFoundException(io.cdap.cdap.common.NamespaceNotFoundException) Test(org.junit.Test)

Example 3 with BootstrapStepResult

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

the class ProgramStarterTest method invalidStructureFails.

@Test
public void invalidStructureFails() throws Exception {
    JsonObject argumentsObj = new JsonObject();
    argumentsObj.addProperty("namespace", "ns");
    argumentsObj.addProperty("application", "app");
    argumentsObj.addProperty("type", "WORKFLOW");
    argumentsObj.add("name", new JsonObject());
    BootstrapStepResult result = programStarter.execute("label", argumentsObj);
    Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus());
}
Also used : JsonObject(com.google.gson.JsonObject) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Example 4 with BootstrapStepResult

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

the class SystemProfileCreatorTest method testCreation.

@Test
public void testCreation() throws Exception {
    ProfileId profileId = NamespaceId.SYSTEM.profile("p1");
    try {
        profileService.getProfile(profileId);
        Assert.fail("profile should not exist.");
    } catch (NotFoundException e) {
    // expected
    }
    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);
    Profile profile = new Profile(profileId.getProfile(), "profile label", "profile description", EntityScope.SYSTEM, provisionerInfo);
    SystemProfileCreator.Arguments arguments = new SystemProfileCreator.Arguments(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getProvisioner());
    BootstrapStepResult result = profileCreator.execute("label", GSON.toJsonTree(arguments).getAsJsonObject());
    BootstrapStepResult expected = new BootstrapStepResult("label", BootstrapStepResult.Status.SUCCEEDED);
    Assert.assertEquals(expected, result);
    Assert.assertEquals(profile, profileService.getProfile(profileId));
}
Also used : ProfileId(io.cdap.cdap.proto.id.ProfileId) ProvisionerPropertyValue(io.cdap.cdap.proto.provisioner.ProvisionerPropertyValue) ProvisionerInfo(io.cdap.cdap.proto.provisioner.ProvisionerInfo) ArrayList(java.util.ArrayList) NotFoundException(io.cdap.cdap.common.NotFoundException) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Profile(io.cdap.cdap.proto.profile.Profile) Test(org.junit.Test)

Example 5 with BootstrapStepResult

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

the class BootstrapServiceTest method testAllSuccess.

@Test
public void testAllSuccess() throws Exception {
    BootstrapResult result = bootstrapService.bootstrap();
    List<BootstrapStepResult> expectedStepResults = new ArrayList<>();
    for (BootstrapStep step : bootstrapConfig.getSteps()) {
        expectedStepResults.add(new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.SUCCEEDED));
    }
    BootstrapResult expected = new BootstrapResult(expectedStepResults);
    Assert.assertEquals(expected, result);
    Assert.assertTrue(bootstrapService.isBootstrapped());
}
Also used : ArrayList(java.util.ArrayList) BootstrapResult(io.cdap.cdap.proto.bootstrap.BootstrapResult) BootstrapStepResult(io.cdap.cdap.proto.bootstrap.BootstrapStepResult) Test(org.junit.Test)

Aggregations

BootstrapStepResult (io.cdap.cdap.proto.bootstrap.BootstrapStepResult)17 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)7 JsonObject (com.google.gson.JsonObject)6 BootstrapResult (io.cdap.cdap.proto.bootstrap.BootstrapResult)4 ProvisionerInfo (io.cdap.cdap.proto.provisioner.ProvisionerInfo)3 ProvisionerPropertyValue (io.cdap.cdap.proto.provisioner.ProvisionerPropertyValue)3 NotFoundException (io.cdap.cdap.common.NotFoundException)2 ProfileId (io.cdap.cdap.proto.id.ProfileId)2 Profile (io.cdap.cdap.proto.profile.Profile)2 HashMap (java.util.HashMap)2 JsonParseException (com.google.gson.JsonParseException)1 RetryableException (io.cdap.cdap.api.retry.RetryableException)1 NamespaceNotFoundException (io.cdap.cdap.common.NamespaceNotFoundException)1