Skip to content

Commit af93109

Browse files
David O'SullivanZPascal
David O'Sullivan
authored andcommitted
test only recent logs request
1 parent 85e6462 commit af93109

File tree

3 files changed

+50
-46
lines changed

3 files changed

+50
-46
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/Applications.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public interface Applications {
124124
* @param request the application logs request
125125
* @return the applications logs
126126
*/
127-
Flux<Log> logs(ReadRequest request);
127+
Flux<Log> logs(LogsRequest request);
128128

129129
/**
130130
* Push a specific application

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/DefaultApplications.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,13 @@ public Flux<Task> listTasks(ListApplicationTasksRequest request) {
542542
}
543543

544544
@Override
545-
public Flux<Log> logs(ReadRequest request) {
545+
public Flux<Log> logs(LogsRequest request) {
546546
return Mono.zip(this.cloudFoundryClient, this.spaceId)
547547
.flatMap(
548548
function(
549549
(cloudFoundryClient, spaceId) ->
550550
getApplicationId(
551-
cloudFoundryClient, request.getSourceId(), spaceId)))
551+
cloudFoundryClient, request.getName(), spaceId)))
552552
.flatMapMany(
553553
applicationId ->
554554
getRecentLogs(this.logCacheClient, applicationId))

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/DefaultApplicationsTest.java

+47-43
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
import org.cloudfoundry.util.DateUtils;
157157
import org.cloudfoundry.util.FluentMap;
158158
import org.cloudfoundry.util.ResourceMatchingUtils;
159+
import org.junit.jupiter.api.Disabled;
159160
import org.junit.jupiter.api.Test;
160161
import org.springframework.core.io.ClassPathResource;
161162
import reactor.core.publisher.Flux;
@@ -1325,7 +1326,7 @@ void logs() {
13251326
requestLogsRecentLogCache(this.logCacheClient, "test-application-name");
13261327

13271328
this.applications
1328-
.logs(ReadRequest.builder().sourceId("test-application-name").build())
1329+
.logs(LogsRequest.builder().name("test-application-name").recent(true).build())
13291330
.as(StepVerifier::create)
13301331
.expectNextMatches(log -> log.getPayload().equals("test-payload"))
13311332
.expectComplete()
@@ -1337,7 +1338,7 @@ void logsNoApp() {
13371338
requestApplicationsEmpty(this.cloudFoundryClient, "test-application-name", TEST_SPACE_ID);
13381339

13391340
this.applications
1340-
.logs(ReadRequest.builder().sourceId("test-application-name").build())
1341+
.logs(LogsRequest.builder().name("test-application-name").build())
13411342
.as(StepVerifier::create)
13421343
.consumeErrorWith(
13431344
t ->
@@ -1348,39 +1349,40 @@ void logsNoApp() {
13481349
.verify(Duration.ofSeconds(5));
13491350
}
13501351

1351-
@Test
1352-
void logsRecent() {
1353-
requestApplications(
1354-
this.cloudFoundryClient,
1355-
"test-application-name",
1356-
TEST_SPACE_ID,
1357-
"test-metadata-id");
1358-
requestLogsRecentLogCache(this.logCacheClient, "test-metadata-id");
1359-
1360-
this.applications
1361-
.logs(ReadRequest.builder().sourceId("test-application-name").build())
1362-
.as(StepVerifier::create)
1363-
.expectNext(fill(Log.builder(), "log-message-").build())
1364-
.expectComplete()
1365-
.verify(Duration.ofSeconds(5));
1366-
}
1367-
1368-
@Test
1369-
void logsRecentNotSet() {
1370-
requestApplications(
1371-
this.cloudFoundryClient,
1372-
"test-application-name",
1373-
TEST_SPACE_ID,
1374-
"test-metadata-id");
1375-
requestLogsStream(this.dopplerClient, "test-metadata-id");
1376-
1377-
this.applications
1378-
.logs(ReadRequest.builder().sourceId("test-application-name").build())
1379-
.as(StepVerifier::create)
1380-
.expectNext(fill(Log.builder(), "log-message-").build())
1381-
.expectComplete()
1382-
.verify(Duration.ofSeconds(5));
1383-
}
1352+
// TODO: it's not passing since recentLogs is not properly implemented yet with logcacheclient
1353+
@Test
1354+
void logsRecent() {
1355+
requestApplications(
1356+
this.cloudFoundryClient,
1357+
"test-application-name",
1358+
TEST_SPACE_ID,
1359+
"test-metadata-id");
1360+
requestLogsRecentLogCache(this.logCacheClient, "test-metadata-id");
1361+
1362+
this.applications
1363+
.logs(LogsRequest.builder().name("test-application-name").build())
1364+
.as(StepVerifier::create)
1365+
.expectNext(fill(Log.builder(), "log-message-").build())
1366+
.expectComplete()
1367+
.verify(Duration.ofSeconds(5));
1368+
}
1369+
// TODO: it's not passing since recentLogs is not properly implemented yet with logcacheclient
1370+
@Test
1371+
void logsRecentNotSet() {
1372+
requestApplications(
1373+
this.cloudFoundryClient,
1374+
"test-application-name",
1375+
TEST_SPACE_ID,
1376+
"test-metadata-id");
1377+
requestLogsStream(this.dopplerClient, "test-metadata-id");
1378+
1379+
this.applications
1380+
.logs(LogsRequest.builder().name("test-application-name").build())
1381+
.as(StepVerifier::create)
1382+
.expectNext(fill(Log.builder(), "log-message-").build())
1383+
.expectComplete()
1384+
.verify(Duration.ofSeconds(5));
1385+
}
13841386

13851387
@Test
13861388
void pushDocker() {
@@ -5262,14 +5264,16 @@ private static void requestLogsRecentLogCache(LogCacheClient logCacheClient, Str
52625264
any()))
52635265
.thenReturn(
52645266
Mono.just(fill(ReadResponse.builder())
5265-
.envelopes(fill(EnvelopeBatch.builder())
5266-
.batch(fill(org.cloudfoundry.logcache.v1.Envelope.builder())
5267-
.log(fill(Log.builder())
5268-
.payload("test-payload")
5269-
.type(LogType.OUT).build())
5270-
.build())
5271-
.build())
5272-
.build()));
5267+
.envelopes(fill(EnvelopeBatch.builder())
5268+
.batch(fill(org.cloudfoundry.logcache.v1.Envelope
5269+
.builder())
5270+
.log(fill(Log.builder())
5271+
.payload("test-payload")
5272+
.type(LogType.OUT)
5273+
.build())
5274+
.build())
5275+
.build())
5276+
.build()));
52735277
}
52745278

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

0 commit comments

Comments
 (0)