Search in sources :

Example 1 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class DefaultStoreTest method testRemoveAll.

@Test
public void testRemoveAll() throws Exception {
    ApplicationSpecification spec = Specifications.from(new WordCountApp());
    NamespaceId namespaceId = new NamespaceId("account1");
    ApplicationId appId = namespaceId.app("application1");
    store.addApplication(appId, spec);
    Assert.assertNotNull(store.getApplication(appId));
    // removing flow
    store.removeAll(namespaceId);
    Assert.assertNull(store.getApplication(appId));
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) WordCountApp(co.cask.cdap.WordCountApp) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 2 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class DefaultStoreTest method testRemoveApplication.

@Test
public void testRemoveApplication() throws Exception {
    ApplicationSpecification spec = Specifications.from(new WordCountApp());
    NamespaceId namespaceId = new NamespaceId("account1");
    ApplicationId appId = namespaceId.app(spec.getName());
    store.addApplication(appId, spec);
    Assert.assertNotNull(store.getApplication(appId));
    // removing application
    store.removeApplication(appId);
    Assert.assertNull(store.getApplication(appId));
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) WordCountApp(co.cask.cdap.WordCountApp) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 3 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class MetadataHttpHandlerTestRun method testDeletedProgramHandlerStage.

@Test
public void testDeletedProgramHandlerStage() throws Exception {
    appClient.deploy(TEST_NAMESPACE1, createAppJarFile(WordCountApp.class));
    ProgramId program = TEST_NAMESPACE1.app("WordCountApp").flow("WordCountFlow");
    // Set some properties metadata
    Map<String, String> flowProperties = ImmutableMap.of("sKey", "sValue", "sK", "sV");
    addProperties(program, flowProperties);
    // Get properties
    Map<String, String> properties = getProperties(program, MetadataScope.USER);
    Assert.assertEquals(2, properties.size());
    // Deploy WordCount App without Flow program. No need to start/stop the flow.
    appClient.deploy(TEST_NAMESPACE1, createAppJarFile(WordCountMinusFlowApp.class));
    // Get properties from deleted (flow) program - should return 404
    getPropertiesFromInvalidEntity(program);
    // Delete the App after stopping the flow
    appClient.delete(TEST_NAMESPACE1.app("WordCountApp"));
}
Also used : WordCountApp(co.cask.cdap.WordCountApp) ProgramId(co.cask.cdap.proto.id.ProgramId) WordCountMinusFlowApp(co.cask.cdap.WordCountMinusFlowApp) Test(org.junit.Test)

Example 4 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class MetadataHttpHandlerTestRun method testScopeQueryParam.

@Test
public void testScopeQueryParam() throws Exception {
    appClient.deploy(NamespaceId.DEFAULT, createAppJarFile(WordCountApp.class));
    ApplicationId app = NamespaceId.DEFAULT.app(WordCountApp.class.getSimpleName());
    RESTClient restClient = new RESTClient(clientConfig);
    URL url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "apps/WordCountApp/metadata?scope=system");
    Assert.assertEquals(HttpResponseStatus.OK.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "datasets/mydataset/metadata/properties?scope=SySTeM");
    Assert.assertEquals(HttpResponseStatus.OK.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "apps/WordCountApp/flows/WordCountFlow/metadata/tags?scope=USER");
    Assert.assertEquals(HttpResponseStatus.OK.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "streams/text/metadata?scope=user");
    Assert.assertEquals(HttpResponseStatus.OK.code(), restClient.execute(HttpRequest.get(url).build(), null).getResponseCode());
    url = clientConfig.resolveNamespacedURLV3(NamespaceId.DEFAULT, "streams/text/metadata?scope=blah");
    Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), restClient.execute(HttpRequest.get(url).build(), null, HttpResponseStatus.BAD_REQUEST.code()).getResponseCode());
    appClient.delete(app);
    // deleting the app does not delete the dataset and stream, delete them explicitly to clear their system metadata
    datasetClient.delete(NamespaceId.DEFAULT.dataset("mydataset"));
    streamClient.delete(NamespaceId.DEFAULT.stream("text"));
}
Also used : RESTClient(co.cask.cdap.client.util.RESTClient) WordCountApp(co.cask.cdap.WordCountApp) ApplicationId(co.cask.cdap.proto.id.ApplicationId) URL(java.net.URL) Test(org.junit.Test)

Example 5 with WordCountApp

use of co.cask.cdap.WordCountApp in project cdap by caskdata.

the class MetadataHttpHandlerTestRun method testSearchMetadataDelete.

@Test
public void testSearchMetadataDelete() throws Exception {
    NamespaceId namespace = new NamespaceId("ns1");
    namespaceClient.create(new NamespaceMeta.Builder().setName(namespace).build());
    // Deploy app
    appClient.deploy(namespace, createAppJarFile(WordCountApp.class, WordCountApp.class.getSimpleName(), "1.0"));
    Set<String> tags = ImmutableSet.of("tag1", "tag2");
    ArtifactId artifact = namespace.artifact("WordCountApp", "1.0");
    ApplicationId app = namespace.app("WordCountApp");
    ProgramId flow = app.flow("WordCountFlow");
    ProgramId service = app.service("WordFrequencyService");
    StreamId stream = namespace.stream("text");
    DatasetId datasetInstance = namespace.dataset("mydataset");
    StreamViewId view = stream.view("view");
    streamViewClient.createOrUpdate(view, new ViewSpecification(new FormatSpecification("csv", null, null)));
    // Add metadata
    addTags(app, tags);
    addTags(flow, tags);
    addTags(stream, tags);
    addTags(datasetInstance, tags);
    addTags(view, tags);
    // Assert metadata
    Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(stream), new MetadataSearchResultRecord(view)), searchMetadata(namespace, "text"));
    Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(datasetInstance)), searchMetadata(namespace, "mydataset"));
    Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(app), new MetadataSearchResultRecord(flow), new MetadataSearchResultRecord(artifact), new MetadataSearchResultRecord(service)), searchMetadata(namespace, "word*"));
    Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(app), new MetadataSearchResultRecord(flow), new MetadataSearchResultRecord(stream), new MetadataSearchResultRecord(datasetInstance), new MetadataSearchResultRecord(view)), searchMetadata(namespace, "tag1"));
    // Delete entities
    appClient.delete(app);
    streamViewClient.delete(view);
    streamClient.delete(stream);
    datasetClient.delete(datasetInstance);
    artifactClient.delete(artifact);
    // Assert no metadata
    Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "text"));
    Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "mydataset"));
    Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "word*"));
    Assert.assertEquals(ImmutableSet.of(), searchMetadata(namespace, "tag1"));
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) ArtifactId(co.cask.cdap.proto.id.ArtifactId) FormatSpecification(co.cask.cdap.api.data.format.FormatSpecification) ViewSpecification(co.cask.cdap.proto.ViewSpecification) ProgramId(co.cask.cdap.proto.id.ProgramId) DatasetId(co.cask.cdap.proto.id.DatasetId) MetadataSearchResultRecord(co.cask.cdap.proto.metadata.MetadataSearchResultRecord) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) WordCountApp(co.cask.cdap.WordCountApp) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) StreamViewId(co.cask.cdap.proto.id.StreamViewId) Test(org.junit.Test)

Aggregations

WordCountApp (co.cask.cdap.WordCountApp)15 Test (org.junit.Test)15 ApplicationId (co.cask.cdap.proto.id.ApplicationId)9 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)8 NamespaceId (co.cask.cdap.proto.id.NamespaceId)6 ProgramId (co.cask.cdap.proto.id.ProgramId)6 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)3 FormatSpecification (co.cask.cdap.api.data.format.FormatSpecification)2 ApplicationSpecificationAdapter (co.cask.cdap.internal.app.ApplicationSpecificationAdapter)2 ReflectionSchemaGenerator (co.cask.cdap.internal.io.ReflectionSchemaGenerator)2 ViewSpecification (co.cask.cdap.proto.ViewSpecification)2 ArtifactId (co.cask.cdap.proto.id.ArtifactId)2 DatasetId (co.cask.cdap.proto.id.DatasetId)2 StreamId (co.cask.cdap.proto.id.StreamId)2 StreamViewId (co.cask.cdap.proto.id.StreamViewId)2 MetadataSearchResultRecord (co.cask.cdap.proto.metadata.MetadataSearchResultRecord)2 AllProgramsApp (co.cask.cdap.AllProgramsApp)1 WordCountMinusFlowApp (co.cask.cdap.WordCountMinusFlowApp)1 CloseableClassLoader (co.cask.cdap.api.artifact.CloseableClassLoader)1 ConfigResponse (co.cask.cdap.app.deploy.ConfigResponse)1