Skip to content

Commit c04c383

Browse files
David O'SullivanZPascal
authored andcommitted
test only recent logs request
1 parent 94f0222 commit c04c383

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public interface Applications {
127127
* @deprecated Use {@link #logs(ApplicationLogsRequest)} instead.
128128
*/
129129
@Deprecated
130-
Flux<Log> logs(ReadRequest request);
130+
Flux<Log> logs(LogsRequest request);
131131

132132
/**
133133
* List the applications logs.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ public Flux<Task> listTasks(ListApplicationTasksRequest request) {
544544
}
545545

546546
@Override
547-
public Flux<Log> logs(ReadRequest request) {
547+
public Flux<Log> logs(LogsRequest request) {
548548
return Mono.zip(this.cloudFoundryClient, this.spaceId)
549549
.flatMap(
550550
function(
551551
(cloudFoundryClient, spaceId) ->
552552
getApplicationId(
553-
cloudFoundryClient, request.getSourceId(), spaceId)))
553+
cloudFoundryClient, request.getName(), spaceId)))
554554
.flatMapMany(
555555
applicationId ->
556556
getRecentLogs(this.logCacheClient, applicationId))

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

Lines changed: 47 additions & 43 deletions
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() {
@@ -5331,14 +5333,16 @@ private static void requestLogsRecentLogCache(LogCacheClient logCacheClient, Str
53315333
any()))
53325334
.thenReturn(
53335335
Mono.just(fill(ReadResponse.builder())
5334-
.envelopes(fill(EnvelopeBatch.builder())
5335-
.batch(fill(org.cloudfoundry.logcache.v1.Envelope.builder())
5336-
.log(fill(Log.builder())
5337-
.payload("test-payload")
5338-
.type(LogType.OUT).build())
5339-
.build())
5340-
.build())
5341-
.build()));
5336+
.envelopes(fill(EnvelopeBatch.builder())
5337+
.batch(fill(org.cloudfoundry.logcache.v1.Envelope
5338+
.builder())
5339+
.log(fill(Log.builder())
5340+
.payload("test-payload")
5341+
.type(LogType.OUT)
5342+
.build())
5343+
.build())
5344+
.build())
5345+
.build()));
53425346
}
53435347

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

0 commit comments

Comments
 (0)