use of co.cask.cdap.app.verification.VerifyResult in project cdap by caskdata.
the class ApplicationVerificationStage method verifyData.
protected void verifyData(ApplicationId appId, ApplicationSpecification specification, @Nullable KerberosPrincipalId specifiedOwnerPrincipal) throws DatasetManagementException, UnauthorizedException {
// NOTE: no special restrictions on dataset module names, etc
VerifyResult result;
for (DatasetCreationSpec dataSetCreateSpec : specification.getDatasets().values()) {
result = getVerifier(DatasetCreationSpec.class).verify(appId, dataSetCreateSpec);
if (!result.isSuccess()) {
throw new RuntimeException(result.getMessage());
}
String dsName = dataSetCreateSpec.getInstanceName();
DatasetId datasetInstanceId = appId.getParent().dataset(dsName);
DatasetSpecification existingSpec = dsFramework.getDatasetSpec(datasetInstanceId);
if (existingSpec != null && !existingSpec.getType().equals(dataSetCreateSpec.getTypeName())) {
// New app trying to deploy an dataset with same instanceName but different Type than that of existing.
throw new DataSetException(String.format("Cannot Deploy Dataset : %s with Type : %s : Dataset with different Type Already Exists", dsName, dataSetCreateSpec.getTypeName()));
}
// if the dataset existed verify its owner is same.
if (existingSpec != null) {
verifyOwner(datasetInstanceId, specifiedOwnerPrincipal);
}
}
for (StreamSpecification spec : specification.getStreams().values()) {
result = getVerifier(StreamSpecification.class).verify(appId, spec);
if (!result.isSuccess()) {
throw new RuntimeException(result.getMessage());
}
// if the stream existed verify the owner to be the same
if (store.getStream(appId.getNamespaceId(), spec.getName()) != null) {
verifyOwner(appId.getParent().stream(spec.getName()), specifiedOwnerPrincipal);
}
}
}
use of co.cask.cdap.app.verification.VerifyResult in project cdap by caskdata.
the class FlowVerificationTest method testValidFlow.
@Test
public void testValidFlow() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new WebCrawlApp());
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
FlowVerification flowSpec = new FlowVerification();
for (Map.Entry<String, FlowSpecification> entry : newSpec.getFlows().entrySet()) {
VerifyResult result = flowSpec.verify(new ApplicationId("test", newSpec.getName()), entry.getValue());
Assert.assertTrue(result.getStatus() == VerifyResult.Status.SUCCESS);
}
}
Aggregations