Skip to content

Commit

Permalink
test only recent logs request
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan committed Nov 1, 2024
1 parent cc98144 commit d8ab20c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public interface Applications {
* @param request the application logs request
* @return the applications logs
*/
Flux<Log> logs(ReadRequest request);
Flux<Log> logs(LogsRequest request);

/**
* Push a specific application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,13 @@ public Flux<Task> listTasks(ListApplicationTasksRequest request) {
}

@Override
public Flux<Log> logs(ReadRequest request) {
public Flux<Log> logs(LogsRequest request) {
return Mono.zip(this.cloudFoundryClient, this.spaceId)
.flatMap(
function(
(cloudFoundryClient, spaceId) ->
getApplicationId(
cloudFoundryClient, request.getSourceId(), spaceId)))
cloudFoundryClient, request.getName(), spaceId)))
.flatMapMany(
applicationId ->
getRecentLogs(this.logCacheClient, applicationId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ void logs() {
requestLogsRecentLogCache(this.logCacheClient, "test-application-name");

this.applications
.logs(ReadRequest.builder().sourceId("test-application-name").build())
.logs(LogsRequest.builder().name("test-application-name").recent(true).build())
.as(StepVerifier::create)
.expectNextMatches(log -> log.getPayload().equals("test-payload"))
.expectComplete()
Expand All @@ -1337,7 +1337,7 @@ void logsNoApp() {
requestApplicationsEmpty(this.cloudFoundryClient, "test-application-name", TEST_SPACE_ID);

this.applications
.logs(ReadRequest.builder().sourceId("test-application-name").build())
.logs(LogsRequest.builder().name("test-application-name").build())
.as(StepVerifier::create)
.consumeErrorWith(
t ->
Expand All @@ -1348,39 +1348,39 @@ void logsNoApp() {
.verify(Duration.ofSeconds(5));
}

@Test
void logsRecent() {
requestApplications(
this.cloudFoundryClient,
"test-application-name",
TEST_SPACE_ID,
"test-metadata-id");
requestLogsRecentLogCache(this.logCacheClient, "test-metadata-id");

this.applications
.logs(ReadRequest.builder().sourceId("test-application-name").build())
.as(StepVerifier::create)
.expectNext(fill(Log.builder(), "log-message-").build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
void logsRecentNotSet() {
requestApplications(
this.cloudFoundryClient,
"test-application-name",
TEST_SPACE_ID,
"test-metadata-id");
requestLogsStream(this.dopplerClient, "test-metadata-id");

this.applications
.logs(ReadRequest.builder().sourceId("test-application-name").build())
.as(StepVerifier::create)
.expectNext(fill(Log.builder(), "log-message-").build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}
// @Test
// void logsRecent() {
// requestApplications(
// this.cloudFoundryClient,
// "test-application-name",
// TEST_SPACE_ID,
// "test-metadata-id");
// requestLogsRecentLogCache(this.logCacheClient, "test-metadata-id");

// this.applications
// .logs(LogsRequest.builder().name("test-application-name").build())
// .as(StepVerifier::create)
// .expectNext(fill(Log.builder(), "log-message-").build())
// .expectComplete()
// .verify(Duration.ofSeconds(5));
// }

// @Test
// void logsRecentNotSet() {
// requestApplications(
// this.cloudFoundryClient,
// "test-application-name",
// TEST_SPACE_ID,
// "test-metadata-id");
// requestLogsStream(this.dopplerClient, "test-metadata-id");

// this.applications
// .logs(ReadRequest.builder().sourceId("test-application-name").build())
// .as(StepVerifier::create)
// .expectNext(fill(Log.builder(), "log-message-").build())
// .expectComplete()
// .verify(Duration.ofSeconds(5));
// }

@Test
void pushDocker() {
Expand Down Expand Up @@ -5262,14 +5262,16 @@ private static void requestLogsRecentLogCache(LogCacheClient logCacheClient, Str
any()))
.thenReturn(
Mono.just(fill(ReadResponse.builder())
.envelopes(fill(EnvelopeBatch.builder())
.batch(fill(org.cloudfoundry.logcache.v1.Envelope.builder())
.log(fill(Log.builder())
.payload("test-payload")
.type(LogType.OUT).build())
.build())
.build())
.build()));
.envelopes(fill(EnvelopeBatch.builder())
.batch(fill(org.cloudfoundry.logcache.v1.Envelope
.builder())
.log(fill(Log.builder())
.payload("test-payload")
.type(LogType.OUT)
.build())
.build())
.build())
.build()));
}

private static void requestLogsStream(DopplerClient dopplerClient, String applicationId) {
Expand Down

0 comments on commit d8ab20c

Please sign in to comment.