Search in sources :

Example 1 with AdminEventPublisher

use of io.cdap.cdap.internal.profile.AdminEventPublisher in project cdap by caskdata.

the class MetadataSubscriberServiceTest method testAppDeletionMessage.

@Test
public void testAppDeletionMessage() throws Exception {
    Injector injector = getInjector();
    // get the alert publisher
    CConfiguration cConf = injector.getInstance(CConfiguration.class);
    MessagingService messagingService = injector.getInstance(MessagingService.class);
    MultiThreadMessagingContext messagingContext = new MultiThreadMessagingContext(messagingService);
    AdminEventPublisher publisher = new AdminEventPublisher(cConf, messagingContext);
    // get the mds and put some workflow metadata in that, the publish of app deletion message should get the metadata
    // deleted
    MetadataStorage mds = injector.getInstance(MetadataStorage.class);
    // use an app with all program types to get all specification tested
    ApplicationId appId = NamespaceId.DEFAULT.app(AllProgramsApp.NAME);
    ProgramId workflowId = appId.workflow(AllProgramsApp.NoOpWorkflow.NAME);
    // generate an app spec from the application
    ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp());
    // need to put metadata on workflow since we currently only set or delete workflow metadata
    mds.apply(new MetadataMutation.Update(workflowId.toMetadataEntity(), new Metadata(MetadataScope.SYSTEM, Collections.singletonMap("profile", ProfileId.NATIVE.getScopedName()))), MutationOptions.DEFAULT);
    Assert.assertEquals(ProfileId.NATIVE.getScopedName(), getProfileProperty(mds, workflowId));
    // publish app deletion message
    publisher.publishAppDeletion(appId, appSpec);
    // Verify the workflow profile metadata is removed because of the publish app deletion message
    Tasks.waitFor(true, () -> mds.read(new Read(workflowId.toMetadataEntity())).isEmpty(), 10, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) AdminEventPublisher(io.cdap.cdap.internal.profile.AdminEventPublisher) Metadata(io.cdap.cdap.spi.metadata.Metadata) MultiThreadMessagingContext(io.cdap.cdap.messaging.context.MultiThreadMessagingContext) AllProgramsApp(io.cdap.cdap.AllProgramsApp) ProgramId(io.cdap.cdap.proto.id.ProgramId) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) MessagingService(io.cdap.cdap.messaging.MessagingService) CoreMessagingService(io.cdap.cdap.messaging.service.CoreMessagingService) Read(io.cdap.cdap.spi.metadata.Read) MetadataMutation(io.cdap.cdap.spi.metadata.MetadataMutation) Injector(com.google.inject.Injector) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 2 with AdminEventPublisher

use of io.cdap.cdap.internal.profile.AdminEventPublisher in project cdap by caskdata.

the class MetadataSubscriberServiceTest method publishBogusCreationEvent.

private void publishBogusCreationEvent() {
    MultiThreadMessagingContext messagingContext = new MultiThreadMessagingContext(getInjector().getInstance(MessagingService.class));
    AdminEventPublisher adminEventPublisher = new AdminEventPublisher(getInjector().getInstance(CConfiguration.class), messagingContext);
    adminEventPublisher.publishScheduleCreation(NamespaceId.DEFAULT.app("nosuch").schedule("none"), System.currentTimeMillis());
}
Also used : AdminEventPublisher(io.cdap.cdap.internal.profile.AdminEventPublisher) MultiThreadMessagingContext(io.cdap.cdap.messaging.context.MultiThreadMessagingContext) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) MessagingService(io.cdap.cdap.messaging.MessagingService) CoreMessagingService(io.cdap.cdap.messaging.service.CoreMessagingService)

Aggregations

CConfiguration (io.cdap.cdap.common.conf.CConfiguration)2 AdminEventPublisher (io.cdap.cdap.internal.profile.AdminEventPublisher)2 MessagingService (io.cdap.cdap.messaging.MessagingService)2 MultiThreadMessagingContext (io.cdap.cdap.messaging.context.MultiThreadMessagingContext)2 CoreMessagingService (io.cdap.cdap.messaging.service.CoreMessagingService)2 Injector (com.google.inject.Injector)1 AllProgramsApp (io.cdap.cdap.AllProgramsApp)1 ApplicationSpecification (io.cdap.cdap.api.app.ApplicationSpecification)1 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)1 ProgramId (io.cdap.cdap.proto.id.ProgramId)1 Metadata (io.cdap.cdap.spi.metadata.Metadata)1 MetadataMutation (io.cdap.cdap.spi.metadata.MetadataMutation)1 MetadataStorage (io.cdap.cdap.spi.metadata.MetadataStorage)1 Read (io.cdap.cdap.spi.metadata.Read)1 Test (org.junit.Test)1