use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by cdapio.
the class NativeProfileCreatorTest method testCreation.
@Test
public void testCreation() throws Exception {
try {
profileService.getProfile(ProfileId.NATIVE);
Assert.fail("Native profile should not exist.");
} catch (NotFoundException e) {
// expected
}
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));
}
use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by cdapio.
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 cdapio.
the class SystemPreferencesSetterTest method testExistingIsUnmodified.
@Test
public void testExistingIsUnmodified() throws Exception {
Map<String, String> preferences = new HashMap<>();
preferences.put("p1", "v1");
preferencesService.setProperties(preferences);
preferences.put("p2", "v2");
preferences.put("p1", "v3");
SystemPreferenceSetter.Arguments arguments = new SystemPreferenceSetter.Arguments(preferences);
BootstrapStepResult result = systemPreferenceSetter.execute("label", GSON.toJsonTree(arguments).getAsJsonObject());
Assert.assertEquals(BootstrapStepResult.Status.SUCCEEDED, result.getStatus());
Map<String, String> expected = new HashMap<>();
// p1 should not have been overridden
expected.put("p1", "v1");
expected.put("p2", "v2");
Assert.assertEquals(expected, preferencesService.getProperties());
}
use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.
the class BootstrapServiceTest method testRetries.
@Test
public void testRetries() throws Exception {
EXECUTOR1.setNumRetryableFailures(3);
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);
}
use of io.cdap.cdap.proto.bootstrap.BootstrapStepResult in project cdap by caskdata.
the class SystemProfileCreatorTest method testExistingIsUnmodified.
@Test
public void testExistingIsUnmodified() throws Exception {
// write a profile
ProfileId profileId = NamespaceId.SYSTEM.profile("p1");
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);
profileService.saveProfile(profileId, profile);
// run the bootstrap step and make sure it succeeded
SystemProfileCreator.Arguments arguments = new SystemProfileCreator.Arguments(profile.getName(), "different label", "different desciption", profile.getProvisioner());
BootstrapStepResult result = profileCreator.execute("label", GSON.toJsonTree(arguments).getAsJsonObject());
BootstrapStepResult expected = new BootstrapStepResult("label", BootstrapStepResult.Status.SUCCEEDED);
Assert.assertEquals(expected, result);
// check that it didn't overwrite the existing profile
Assert.assertEquals(profile, profileService.getProfile(profileId));
}
Aggregations