@@ -1401,6 +1401,57 @@ void logsTailLogCache() {
14011401 .verify (Duration .ofSeconds (5 ));
14021402 }
14031403
1404+ @ Test
1405+ void logsTailLogCacheMultipleEnvelopes () {
1406+ TailLogsRequest tailRequest =
1407+ TailLogsRequest .builder ().sourceId ("test-source-id" ).build ();
1408+ requestLogsTailLogCacheMultiple (this .logCacheClient , tailRequest );
1409+
1410+ this .applications
1411+ .logsTail (tailRequest )
1412+ .take (3 )
1413+ .map (e -> e .getLog ().getType ())
1414+ .as (StepVerifier ::create )
1415+ .expectNext (LogType .OUT )
1416+ .expectNext (LogType .ERR )
1417+ .expectNext (LogType .OUT )
1418+ .expectComplete ()
1419+ .verify (Duration .ofSeconds (5 ));
1420+ }
1421+
1422+ @ Test
1423+ void logsTailLogCacheError () {
1424+ TailLogsRequest tailRequest =
1425+ TailLogsRequest .builder ().sourceId ("test-source-id" ).build ();
1426+ when (this .logCacheClient .logsTail (tailRequest ))
1427+ .thenReturn (Flux .error (new RuntimeException ("log-cache unavailable" )));
1428+
1429+ this .applications
1430+ .logsTail (tailRequest )
1431+ .as (StepVerifier ::create )
1432+ .expectErrorMatches (
1433+ t ->
1434+ t instanceof RuntimeException
1435+ && "log-cache unavailable" .equals (t .getMessage ()))
1436+ .verify (Duration .ofSeconds (5 ));
1437+ }
1438+
1439+ @ Test
1440+ void logsTailLogCacheOutAndErrEnvelopes () {
1441+ TailLogsRequest tailRequest =
1442+ TailLogsRequest .builder ().sourceId ("test-source-id" ).build ();
1443+ requestLogsTailLogCacheOutAndErr (this .logCacheClient , tailRequest );
1444+
1445+ this .applications
1446+ .logsTail (tailRequest )
1447+ .take (2 )
1448+ .as (StepVerifier ::create )
1449+ .expectNextMatches (e -> LogType .OUT .equals (e .getLog ().getType ()))
1450+ .expectNextMatches (e -> LogType .ERR .equals (e .getLog ().getType ()))
1451+ .expectComplete ()
1452+ .verify (Duration .ofSeconds (5 ));
1453+ }
1454+
14041455 @ SuppressWarnings ("deprecation" )
14051456 @ Test
14061457 void logsRecentNotSetDoppler () {
@@ -5418,6 +5469,54 @@ private static void requestLogsTailLogCache(
54185469 .build ()));
54195470 }
54205471
5472+ /**
5473+ * Three envelopes with types OUT, ERR, OUT and strictly ascending timestamps so ordering
5474+ * is deterministic.
5475+ */
5476+ private static void requestLogsTailLogCacheMultiple (
5477+ LogCacheClient logCacheClient , TailLogsRequest tailRequest ) {
5478+ long base = System .nanoTime ();
5479+ when (logCacheClient .logsTail (tailRequest ))
5480+ .thenReturn (
5481+ Flux .just (
5482+ Envelope .builder ()
5483+ .sourceId (tailRequest .getSourceId ())
5484+ .timestamp (base )
5485+ .log (Log .builder ().payload ("msg1" ).type (LogType .OUT ).build ())
5486+ .build (),
5487+ Envelope .builder ()
5488+ .sourceId (tailRequest .getSourceId ())
5489+ .timestamp (base + 1 )
5490+ .log (Log .builder ().payload ("msg2" ).type (LogType .ERR ).build ())
5491+ .build (),
5492+ Envelope .builder ()
5493+ .sourceId (tailRequest .getSourceId ())
5494+ .timestamp (base + 2 )
5495+ .log (Log .builder ().payload ("msg3" ).type (LogType .OUT ).build ())
5496+ .build ()));
5497+ }
5498+
5499+ /**
5500+ * Two envelopes – one STDOUT, one STDERR – to verify both log types are forwarded.
5501+ */
5502+ private static void requestLogsTailLogCacheOutAndErr (
5503+ LogCacheClient logCacheClient , TailLogsRequest tailRequest ) {
5504+ long base = System .nanoTime ();
5505+ when (logCacheClient .logsTail (tailRequest ))
5506+ .thenReturn (
5507+ Flux .just (
5508+ Envelope .builder ()
5509+ .sourceId (tailRequest .getSourceId ())
5510+ .timestamp (base )
5511+ .log (Log .builder ().payload ("stdout" ).type (LogType .OUT ).build ())
5512+ .build (),
5513+ Envelope .builder ()
5514+ .sourceId (tailRequest .getSourceId ())
5515+ .timestamp (base + 1 )
5516+ .log (Log .builder ().payload ("stderr" ).type (LogType .ERR ).build ())
5517+ .build ()));
5518+ }
5519+
54215520 private static void requestLogsStream (DopplerClient dopplerClient , String applicationId ) {
54225521 when (dopplerClient .stream (StreamRequest .builder ().applicationId (applicationId ).build ()))
54235522 .thenReturn (
0 commit comments