28
28
import org .cloudfoundry .AbstractIntegrationTest ;
29
29
import org .cloudfoundry .CloudFoundryVersion ;
30
30
import org .cloudfoundry .IfCloudFoundryVersion ;
31
- import org .cloudfoundry .doppler .LogMessage ;
32
- import org .cloudfoundry .doppler .MessageType ;
31
+ import org .cloudfoundry .logcache .v1 .Envelope ;
32
+ import org .cloudfoundry .logcache .v1 .EnvelopeBatch ;
33
+ import org .cloudfoundry .logcache .v1 .EnvelopeType ;
34
+ import org .cloudfoundry .logcache .v1 .Log ;
35
+ import org .cloudfoundry .logcache .v1 .LogCacheClient ;
36
+ import org .cloudfoundry .logcache .v1 .LogType ;
37
+ import org .cloudfoundry .logcache .v1 .ReadRequest ;
38
+ import org .cloudfoundry .logcache .v1 .ReadResponse ;
33
39
import org .cloudfoundry .operations .applications .ApplicationDetail ;
34
40
import org .cloudfoundry .operations .applications .ApplicationEnvironments ;
35
41
import org .cloudfoundry .operations .applications .ApplicationEvent ;
36
42
import org .cloudfoundry .operations .applications .ApplicationHealthCheck ;
43
+ import org .cloudfoundry .operations .applications .ApplicationLog ;
44
+ import org .cloudfoundry .operations .applications .ApplicationLogType ;
45
+ import org .cloudfoundry .operations .applications .ApplicationLogsRequest ;
37
46
import org .cloudfoundry .operations .applications .ApplicationManifest ;
38
47
import org .cloudfoundry .operations .applications .ApplicationSshEnabledRequest ;
39
48
import org .cloudfoundry .operations .applications .ApplicationSummary ;
47
56
import org .cloudfoundry .operations .applications .GetApplicationManifestRequest ;
48
57
import org .cloudfoundry .operations .applications .GetApplicationRequest ;
49
58
import org .cloudfoundry .operations .applications .ListApplicationTasksRequest ;
50
- import org .cloudfoundry .operations .applications .LogsRequest ;
51
59
import org .cloudfoundry .operations .applications .ManifestV3 ;
52
60
import org .cloudfoundry .operations .applications .ManifestV3Application ;
53
61
import org .cloudfoundry .operations .applications .PushApplicationManifestRequest ;
@@ -96,6 +104,8 @@ public final class ApplicationsTest extends AbstractIntegrationTest {
96
104
97
105
@ Autowired private String serviceName ;
98
106
107
+ @ Autowired private LogCacheClient logCacheClient ;
108
+
99
109
@ Test
100
110
public void copySource () throws IOException {
101
111
String sourceName = this .nameFactory .getApplicationName ();
@@ -486,7 +496,12 @@ public void listTasks() throws IOException {
486
496
.verify (Duration .ofMinutes (5 ));
487
497
}
488
498
499
+ /**
500
+ * Doppler was dropped in PCF 4.x in favor of logcache. This test does not work
501
+ * on TAS 4.x.
502
+ */
489
503
@ Test
504
+ @ IfCloudFoundryVersion (lessThan = CloudFoundryVersion .PCF_4_v2 )
490
505
public void logs () throws IOException {
491
506
String applicationName = this .nameFactory .getApplicationName ();
492
507
@@ -499,14 +514,53 @@ public void logs() throws IOException {
499
514
this .cloudFoundryOperations
500
515
.applications ()
501
516
.logs (
502
- LogsRequest .builder ()
517
+ ApplicationLogsRequest .builder ()
503
518
.name (applicationName )
504
519
.recent (true )
505
520
.build ()))
506
- .map (LogMessage ::getMessageType )
521
+ .map (ApplicationLog ::getLogType )
522
+ .next ()
523
+ .as (StepVerifier ::create )
524
+ .expectNext (ApplicationLogType .OUT )
525
+ .expectComplete ()
526
+ .verify (Duration .ofMinutes (5 ));
527
+ }
528
+
529
+ /**
530
+ * Exercise the LogCache client. Serves as a reference for using the logcache client,
531
+ * and will help with the transition to the new
532
+ * {@link org.cloudfoundry.operations.applications.Applications#logs(ApplicationLogsRequest)}.
533
+ */
534
+ @ Test
535
+ public void logCacheLogs () throws IOException {
536
+ String applicationName = this .nameFactory .getApplicationName ();
537
+
538
+ createApplication (
539
+ this .cloudFoundryOperations ,
540
+ new ClassPathResource ("test-application.zip" ).getFile ().toPath (),
541
+ applicationName ,
542
+ false )
543
+ .then (
544
+ this .cloudFoundryOperations
545
+ .applications ()
546
+ .get (GetApplicationRequest .builder ().name (applicationName ).build ()))
547
+ .map (ApplicationDetail ::getId )
548
+ .flatMapMany (
549
+ appGuid ->
550
+ this .logCacheClient .read (
551
+ ReadRequest .builder ()
552
+ .sourceId (appGuid )
553
+ .envelopeType (EnvelopeType .LOG )
554
+ .limit (1 )
555
+ .build ()))
556
+ .map (ReadResponse ::getEnvelopes )
557
+ .map (EnvelopeBatch ::getBatch )
558
+ .flatMap (Flux ::fromIterable )
559
+ .map (Envelope ::getLog )
560
+ .map (Log ::getType )
507
561
.next ()
508
562
.as (StepVerifier ::create )
509
- .expectNext (MessageType .OUT )
563
+ .expectNext (LogType .OUT )
510
564
.expectComplete ()
511
565
.verify (Duration .ofMinutes (5 ));
512
566
}
0 commit comments