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