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);
}
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());
}
Aggregations