Search in sources :

Example 6 with ReportSourceTag

use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.

the class ReportSourceTagHandlerTest method testSourceAddDescription.

@Test
public void testSourceAddDescription() {
    ReportSourceTag sourceTag = new ReportSourceTag(SourceOperationType.SOURCE_DESCRIPTION, SourceTagAction.SAVE, "dummy", ImmutableList.of("description"));
    EasyMock.expect(mockAgentAPI.setDescription("dummy", "description")).andReturn(Response.ok().build()).once();
    EasyMock.replay(mockAgentAPI);
    sourceTagHandler.report(sourceTag);
    ((SenderTaskFactoryImpl) senderTaskFactory).flushNow(handlerKey);
    EasyMock.verify(mockAgentAPI);
}
Also used : ReportSourceTag(wavefront.report.ReportSourceTag) Test(org.junit.Test)

Example 7 with ReportSourceTag

use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.

the class ReportSourceTagHandlerTest method testSourceTagAppend.

@Test
public void testSourceTagAppend() {
    ReportSourceTag sourceTag = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.ADD, "dummy", ImmutableList.of("tag1"));
    EasyMock.expect(mockAgentAPI.appendTag("dummy", "tag1")).andReturn(Response.ok().build()).once();
    EasyMock.replay(mockAgentAPI);
    sourceTagHandler.report(sourceTag);
    ((SenderTaskFactoryImpl) senderTaskFactory).flushNow(handlerKey);
    EasyMock.verify(mockAgentAPI);
}
Also used : ReportSourceTag(wavefront.report.ReportSourceTag) Test(org.junit.Test)

Example 8 with ReportSourceTag

use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.

the class ReportSourceTagHandlerTest method testSourceDeleteDescription.

@Test
public void testSourceDeleteDescription() {
    ReportSourceTag sourceTag = new ReportSourceTag(SourceOperationType.SOURCE_DESCRIPTION, SourceTagAction.DELETE, "dummy", ImmutableList.of());
    EasyMock.expect(mockAgentAPI.removeDescription("dummy")).andReturn(Response.ok().build()).once();
    EasyMock.replay(mockAgentAPI);
    sourceTagHandler.report(sourceTag);
    ((SenderTaskFactoryImpl) senderTaskFactory).flushNow(handlerKey);
    EasyMock.verify(mockAgentAPI);
}
Also used : ReportSourceTag(wavefront.report.ReportSourceTag) Test(org.junit.Test)

Example 9 with ReportSourceTag

use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.

the class ReportSourceTagHandlerTest method testSourceTagsTaskAffinity.

@Test
public void testSourceTagsTaskAffinity() {
    ReportSourceTag sourceTag1 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy", ImmutableList.of("tag1", "tag2"));
    ReportSourceTag sourceTag2 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy", ImmutableList.of("tag2", "tag3"));
    ReportSourceTag sourceTag3 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy-2", ImmutableList.of("tag3"));
    ReportSourceTag sourceTag4 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy", ImmutableList.of("tag1", "tag4", "tag5"));
    List<SenderTask<SourceTag>> tasks = new ArrayList<>();
    SourceTagSenderTask task1 = EasyMock.createMock(SourceTagSenderTask.class);
    SourceTagSenderTask task2 = EasyMock.createMock(SourceTagSenderTask.class);
    tasks.add(task1);
    tasks.add(task2);
    ReportSourceTagHandlerImpl sourceTagHandler = new ReportSourceTagHandlerImpl(HandlerKey.of(ReportableEntityType.SOURCE_TAG, "4878"), 10, tasks, null, blockedLogger);
    task1.add(new SourceTag(sourceTag1));
    EasyMock.expectLastCall();
    task1.add(new SourceTag(sourceTag2));
    EasyMock.expectLastCall();
    task2.add(new SourceTag(sourceTag3));
    EasyMock.expectLastCall();
    task1.add(new SourceTag(sourceTag4));
    EasyMock.expectLastCall();
    task1.add(new SourceTag(sourceTag4));
    EasyMock.expectLastCall();
    task2.add(new SourceTag(sourceTag3));
    EasyMock.expectLastCall();
    task1.add(new SourceTag(sourceTag2));
    EasyMock.expectLastCall();
    task1.add(new SourceTag(sourceTag1));
    EasyMock.expectLastCall();
    EasyMock.replay(task1);
    EasyMock.replay(task2);
    sourceTagHandler.report(sourceTag1);
    sourceTagHandler.report(sourceTag2);
    sourceTagHandler.report(sourceTag3);
    sourceTagHandler.report(sourceTag4);
    sourceTagHandler.report(sourceTag4);
    sourceTagHandler.report(sourceTag3);
    sourceTagHandler.report(sourceTag2);
    sourceTagHandler.report(sourceTag1);
    EasyMock.verify();
}
Also used : ArrayList(java.util.ArrayList) ReportSourceTag(wavefront.report.ReportSourceTag) SourceTag(com.wavefront.dto.SourceTag) ReportSourceTag(wavefront.report.ReportSourceTag) Test(org.junit.Test)

Example 10 with ReportSourceTag

use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.

the class SourceTagSubmissionTaskTest method test200.

@Test
public void test200() {
    TaskQueue<SourceTagSubmissionTask> queue = createMock(TaskQueue.class);
    reset(sourceTagAPI, queue);
    ReportSourceTag sourceDescDelete = new ReportSourceTag(SourceOperationType.SOURCE_DESCRIPTION, SourceTagAction.DELETE, "dummy", ImmutableList.of());
    ReportSourceTag sourceTagDelete = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.DELETE, "src", ImmutableList.of("tag"));
    ReportSourceTag sourceTagAdd = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.ADD, "src", ImmutableList.of("tag"));
    SourceTagSubmissionTask task = new SourceTagSubmissionTask(sourceTagAPI, props, queue, "2878", new SourceTag(sourceDescDelete), System::currentTimeMillis);
    SourceTagSubmissionTask task2 = new SourceTagSubmissionTask(sourceTagAPI, props, queue, "2878", new SourceTag(sourceTagDelete), System::currentTimeMillis);
    SourceTagSubmissionTask task3 = new SourceTagSubmissionTask(sourceTagAPI, props, queue, "2878", new SourceTag(sourceTagAdd), System::currentTimeMillis);
    expect(sourceTagAPI.removeDescription("dummy")).andReturn(Response.status(200).build()).once();
    expect(sourceTagAPI.removeTag("src", "tag")).andReturn(Response.status(200).build()).once();
    expect(sourceTagAPI.appendTag("src", "tag")).andReturn(Response.status(200).build()).once();
    replay(sourceTagAPI, queue);
    assertEquals(TaskResult.DELIVERED, task.execute());
    assertEquals(TaskResult.DELIVERED, task2.execute());
    assertEquals(TaskResult.DELIVERED, task3.execute());
    verify(sourceTagAPI, queue);
}
Also used : ReportSourceTag(wavefront.report.ReportSourceTag) SourceTag(com.wavefront.dto.SourceTag) ReportSourceTag(wavefront.report.ReportSourceTag) Test(org.junit.Test)

Aggregations

ReportSourceTag (wavefront.report.ReportSourceTag)19 Test (org.junit.Test)12 SourceTag (com.wavefront.dto.SourceTag)6 ArrayList (java.util.ArrayList)4 DataFormat (com.wavefront.agent.formatter.DataFormat)1 SpanUtils.handleSpanLogs (com.wavefront.agent.listeners.tracing.SpanUtils.handleSpanLogs)1 SpanUtils.preprocessAndHandleSpan (com.wavefront.agent.listeners.tracing.SpanUtils.preprocessAndHandleSpan)1 TimerContext (com.yammer.metrics.core.TimerContext)1 Response (javax.ws.rs.core.Response)1 Token (org.antlr.v4.runtime.Token)1 ReportEvent (wavefront.report.ReportEvent)1 ReportPoint (wavefront.report.ReportPoint)1 Span (wavefront.report.Span)1 SpanLogs (wavefront.report.SpanLogs)1