use of io.cdap.cdap.proto.DatasetSpecificationSummary in project cdap by cdapio.
the class ConversionHelpers method spec2Summary.
static Collection<DatasetSpecificationSummary> spec2Summary(Collection<DatasetSpecification> specs) {
List<DatasetSpecificationSummary> datasetSummaries = Lists.newArrayList();
for (DatasetSpecification spec : specs) {
// TODO: (CDAP-3097) handle system datasets specially within a namespace instead of filtering them out
// by the handler. This filter is only in the list endpoint because the other endpoints are used by
// HBaseQueueAdmin through DatasetFramework.
spec = DatasetsUtil.fixOriginalProperties(spec);
datasetSummaries.add(new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getDescription(), spec.getOriginalProperties()));
}
return datasetSummaries;
}
use of io.cdap.cdap.proto.DatasetSpecificationSummary in project cdap by cdapio.
the class DatasetInstanceHandlerTest method testUpdateInstance.
@Test
public void testUpdateInstance() throws Exception {
// nothing has been created, modules and types list is empty
List<DatasetSpecificationSummary> instances = getInstances().getResponseObject();
// nothing in the beginning
Assert.assertEquals(0, instances.size());
try {
DatasetProperties props = DatasetProperties.builder().add("prop1", "val1").add(TestModule2.NOT_RECONFIGURABLE, "this").build();
// deploy modules
deployModule("module1", TestModule1.class);
deployModule("module2", TestModule2.class);
// create dataset instance
Assert.assertEquals(HttpStatus.SC_OK, createInstance("dataset1", "datasetType2", props).getResponseCode());
// verify instance was created
instances = getInstances().getResponseObject();
Assert.assertEquals(1, instances.size());
DatasetMeta meta = getInstanceObject("dataset1").getResponseObject();
Map<String, String> storedOriginalProps = meta.getSpec().getOriginalProperties();
Assert.assertEquals(props.getProperties(), storedOriginalProps);
Map<String, String> retrievedProps = getInstanceProperties("dataset1").getResponseObject();
Assert.assertEquals(props.getProperties(), retrievedProps);
// these properties are incompatible because TestModule1.NOT_RECONFIGURABLE may not change
DatasetProperties newProps = DatasetProperties.builder().add("prop2", "val2").add(TestModule2.NOT_RECONFIGURABLE, "that").build();
Assert.assertEquals(HttpStatus.SC_CONFLICT, updateInstance("dataset1", newProps).getResponseCode());
// update dataset instance with valid properties
newProps = DatasetProperties.builder().add("prop2", "val2").add(TestModule2.NOT_RECONFIGURABLE, "this").build();
Assert.assertEquals(HttpStatus.SC_OK, updateInstance("dataset1", newProps).getResponseCode());
meta = getInstanceObject("dataset1").getResponseObject();
Assert.assertEquals(newProps.getProperties(), meta.getSpec().getOriginalProperties());
Assert.assertEquals("val2", meta.getSpec().getProperty("prop2"));
Assert.assertNull(meta.getSpec().getProperty("prop1"));
retrievedProps = getInstanceProperties("dataset1").getResponseObject();
Assert.assertEquals(newProps.getProperties(), retrievedProps);
} finally {
// delete dataset instance
Assert.assertEquals(HttpStatus.SC_OK, deleteInstance("dataset1").getResponseCode());
Assert.assertEquals(0, getInstances().getResponseObject().size());
// delete dataset modules
Assert.assertEquals(HttpStatus.SC_OK, deleteModule("module2").getResponseCode());
Assert.assertEquals(HttpStatus.SC_OK, deleteModule("module1").getResponseCode());
}
}
use of io.cdap.cdap.proto.DatasetSpecificationSummary in project cdap by cdapio.
the class IntegrationTestBase method doClear.
private void doClear(NamespaceId namespace, boolean deleteNamespace) throws Exception {
// stop all programs in the namespace
getProgramClient().stopAll(namespace);
if (deleteNamespace) {
getNamespaceClient().delete(namespace);
return;
}
// delete all apps in the namespace
for (ApplicationRecord app : getApplicationClient().list(namespace)) {
getApplicationClient().delete(namespace.app(app.getName(), app.getAppVersion()));
}
// delete all dataset instances
for (DatasetSpecificationSummary datasetSpecSummary : getDatasetClient().list(namespace)) {
getDatasetClient().delete(namespace.dataset(datasetSpecSummary.getName()));
}
ArtifactClient artifactClient = new ArtifactClient(getClientConfig(), getRestClient());
for (ArtifactSummary artifactSummary : artifactClient.list(namespace, ArtifactScope.USER)) {
artifactClient.delete(namespace.artifact(artifactSummary.getName(), artifactSummary.getVersion()));
}
assertIsClear(namespace);
}
Aggregations