use of org.zalando.nakadi.webservice.utils.TestStreamingClient in project nakadi by zalando.
the class HilaAT method whenThereAreNoEmptySlotsThenConflict.
@Test(timeout = 10000)
public void whenThereAreNoEmptySlotsThenConflict() {
final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "batch_flush_timeout=1");
client.start();
waitFor(() -> assertThat(client.getBatches(), hasSize(1)));
given().get(format("/subscriptions/{0}/events", subscription.getId())).then().statusCode(SC_CONFLICT);
}
use of org.zalando.nakadi.webservice.utils.TestStreamingClient in project nakadi by zalando.
the class HilaAT method whenBatchLimitAndTimeoutAreSetTheyAreConsidered.
@Test(timeout = 10000)
public void whenBatchLimitAndTimeoutAreSetTheyAreConsidered() {
publishEvents(eventType.getName(), 12, i -> "{\"foo\":\"bar\"}");
final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "batch_limit=5&batch_flush_timeout=1&max_uncommitted_events=20").start();
waitFor(() -> assertThat(client.getBatches(), hasSize(3)));
assertThat(client.getBatches().get(0).getEvents(), hasSize(5));
assertThat(client.getBatches().get(0).getCursor().getOffset(), is("001-0001-000000000000000004"));
assertThat(client.getBatches().get(1).getEvents(), hasSize(5));
assertThat(client.getBatches().get(1).getCursor().getOffset(), is("001-0001-000000000000000009"));
assertThat(client.getBatches().get(2).getEvents(), hasSize(2));
assertThat(client.getBatches().get(2).getCursor().getOffset(), is("001-0001-000000000000000011"));
}
use of org.zalando.nakadi.webservice.utils.TestStreamingClient in project nakadi by zalando.
the class HilaAT method whenConsumerIsBlocked403.
@Test(timeout = 10000)
public void whenConsumerIsBlocked403() throws Exception {
SettingsControllerAT.blacklist(eventType.getName(), BlacklistService.Type.CONSUMER_ET);
final TestStreamingClient client1 = TestStreamingClient.create(subscription.getId()).start();
waitFor(() -> Assert.assertEquals(403, client1.getResponseCode()));
SettingsControllerAT.whitelist(eventType.getName(), BlacklistService.Type.CONSUMER_ET);
final TestStreamingClient client2 = TestStreamingClient.create(subscription.getId()).start();
waitFor(() -> Assert.assertEquals(HttpStatus.SC_OK, client2.getResponseCode()));
}
use of org.zalando.nakadi.webservice.utils.TestStreamingClient in project nakadi by zalando.
the class HilaAT method whenStreamTimeout0ThenInfiniteStreaming.
@Test(timeout = 15000)
public void whenStreamTimeout0ThenInfiniteStreaming() {
publishEvents(eventType.getName(), 5, i -> "{\"foo\":\"bar\"}");
final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "stream_timeout=0").start();
waitFor(() -> assertThat(client.getBatches(), hasSize(5)));
Assert.assertFalse(client.getBatches().stream().anyMatch(streamBatch -> streamBatch.getMetadata() != null && streamBatch.getMetadata().getDebug().equals("Stream timeout reached")));
}
use of org.zalando.nakadi.webservice.utils.TestStreamingClient in project nakadi by zalando.
the class HilaAT method testGetSubscriptionStat.
@Test(timeout = 10000)
public void testGetSubscriptionStat() throws Exception {
publishEvents(eventType.getName(), 15, i -> "{\"foo\":\"bar\"}");
final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "max_uncommitted_events=20").start();
waitFor(() -> assertThat(client.getBatches(), hasSize(15)));
List<SubscriptionEventTypeStats> subscriptionStats = Collections.singletonList(new SubscriptionEventTypeStats(eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 15L, client.getSessionId(), AUTO))));
NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats))));
final String partition = client.getBatches().get(0).getCursor().getPartition();
final SubscriptionCursor cursor = new SubscriptionCursor(partition, "9", eventType.getName(), "token");
commitCursors(subscription.getId(), ImmutableList.of(cursor), client.getSessionId());
subscriptionStats = Collections.singletonList(new SubscriptionEventTypeStats(eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 5L, client.getSessionId(), AUTO))));
NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats))));
}
Aggregations