use of com.wavefront.agent.data.DefaultEntityPropertiesForTesting in project java by wavefrontHQ.
the class RetryTaskConverterTest method testTaskSerialize.
@Test
public void testTaskSerialize() {
UUID proxyId = UUID.randomUUID();
LineDelimitedDataSubmissionTask task = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), null, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item1", "item2", "item3"), () -> 12345L);
RetryTaskConverter<LineDelimitedDataSubmissionTask> converter = new RetryTaskConverter<>("2878", RetryTaskConverter.CompressionType.NONE);
assertNull(converter.fromBytes(new byte[] { 0, 0, 0 }));
assertNull(converter.fromBytes(new byte[] { 'W', 'F', 0 }));
assertNull(converter.fromBytes(new byte[] { 'W', 'F', 1 }));
assertNull(converter.fromBytes(new byte[] { 'W', 'F', 1, 0 }));
}
use of com.wavefront.agent.data.DefaultEntityPropertiesForTesting in project java by wavefrontHQ.
the class SQSSubmissionQueueTest method testTaskRead.
@Test
public void testTaskRead() throws IOException {
SQSSubmissionQueue queue = getTaskQueue();
UUID proxyId = UUID.randomUUID();
DataSubmissionTask<? extends DataSubmissionTask<?>> task;
if (this.expectedTask instanceof LineDelimitedDataSubmissionTask) {
task = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item1", "item2", "item3"), time::get);
} else if (this.expectedTask instanceof EventDataSubmissionTask) {
task = new EventDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "2878", ImmutableList.of(new Event(ReportEvent.newBuilder().setStartTime(time.get() * 1000).setEndTime(time.get() * 1000 + 1).setName("Event name for testing").setHosts(ImmutableList.of("host1", "host2")).setDimensions(ImmutableMap.of("multi", ImmutableList.of("bar", "baz"))).setAnnotations(ImmutableMap.of("severity", "INFO")).setTags(ImmutableList.of("tag1")).build())), time::get);
} else {
task = null;
}
expect(client.sendMessage(new SendMessageRequest(queueUrl, queue.encodeMessageForDelivery(this.expectedTask)))).andReturn(null);
replay(client);
task.enqueue(QueueingReason.RETRY);
reset(client);
ReceiveMessageRequest msgRequest = new ReceiveMessageRequest().withMaxNumberOfMessages(1).withWaitTimeSeconds(1).withQueueUrl(queueUrl);
ReceiveMessageResult msgResult = new ReceiveMessageResult().withMessages(new Message().withBody(queue.encodeMessageForDelivery(task)).withReceiptHandle("handle1"));
expect(client.receiveMessage(msgRequest)).andReturn(msgResult);
replay(client);
if (this.expectedTask instanceof LineDelimitedDataSubmissionTask) {
LineDelimitedDataSubmissionTask readTask = (LineDelimitedDataSubmissionTask) queue.peek();
assertEquals(((LineDelimitedDataSubmissionTask) task).payload(), readTask.payload());
assertEquals(((LineDelimitedDataSubmissionTask) this.expectedTask).payload(), readTask.payload());
assertEquals(77777, readTask.getEnqueuedMillis());
}
if (this.expectedTask instanceof EventDataSubmissionTask) {
EventDataSubmissionTask readTask = (EventDataSubmissionTask) queue.peek();
assertEquals(((EventDataSubmissionTask) task).payload(), readTask.payload());
assertEquals(((EventDataSubmissionTask) this.expectedTask).payload(), readTask.payload());
assertEquals(77777, readTask.getEnqueuedMillis());
}
}
use of com.wavefront.agent.data.DefaultEntityPropertiesForTesting in project java by wavefrontHQ.
the class QueueExporterTest method testQueueExporterWithRetainData.
@Test
public void testQueueExporterWithRetainData() throws Exception {
File file = new File(File.createTempFile("proxyTestConverter", null).getPath() + ".queue");
file.deleteOnExit();
String bufferFile = file.getAbsolutePath();
TaskQueueFactory taskQueueFactory = new TaskQueueFactoryImpl(bufferFile, false, false, 128);
EntityPropertiesFactory entityPropFactory = new DefaultEntityPropertiesFactoryForTesting();
QueueExporter qe = new QueueExporter(bufferFile, "2878", bufferFile + "-output", true, taskQueueFactory, entityPropFactory);
BufferedWriter mockedWriter = EasyMock.createMock(BufferedWriter.class);
reset(mockedWriter);
HandlerKey key = HandlerKey.of(ReportableEntityType.POINT, "2878");
TaskQueue<LineDelimitedDataSubmissionTask> queue = taskQueueFactory.getTaskQueue(key, 0);
queue.clear();
UUID proxyId = UUID.randomUUID();
LineDelimitedDataSubmissionTask task = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item1", "item2", "item3"), () -> 12345L);
task.enqueue(QueueingReason.RETRY);
LineDelimitedDataSubmissionTask task2 = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item4", "item5"), () -> 12345L);
task2.enqueue(QueueingReason.RETRY);
qe.export();
File outputTextFile = new File(file.getAbsolutePath() + "-output.points.2878.0.txt");
assertEquals(ImmutableList.of("item1", "item2", "item3", "item4", "item5"), Files.asCharSource(outputTextFile, Charsets.UTF_8).readLines());
assertEquals(2, taskQueueFactory.getTaskQueue(key, 0).size());
}
Aggregations