|
39 | 39 | import org.cloudfoundry.logcache.v1.LogType; |
40 | 40 | import org.cloudfoundry.logcache.v1.ReadRequest; |
41 | 41 | import org.cloudfoundry.logcache.v1.ReadResponse; |
| 42 | +import org.cloudfoundry.logcache.v1.TailLogsRequest; |
42 | 43 | import org.cloudfoundry.operations.applications.ApplicationDetail; |
43 | 44 | import org.cloudfoundry.operations.applications.ApplicationEnvironments; |
44 | 45 | import org.cloudfoundry.operations.applications.ApplicationEvent; |
@@ -606,6 +607,94 @@ public void logCacheLogs() throws IOException { |
606 | 607 | .verify(Duration.ofMinutes(5)); |
607 | 608 | } |
608 | 609 |
|
| 610 | + /** |
| 611 | + * Integration test for {@link org.cloudfoundry.operations.applications.Applications#logsTail}. |
| 612 | + * Verifies that streaming a single LOG envelope from a running application succeeds. |
| 613 | + */ |
| 614 | + @Test |
| 615 | + public void logsTail() throws IOException { |
| 616 | + String applicationName = this.nameFactory.getApplicationName(); |
| 617 | + |
| 618 | + createApplication( |
| 619 | + this.cloudFoundryOperations, |
| 620 | + new ClassPathResource("test-application.zip").getFile().toPath(), |
| 621 | + applicationName, |
| 622 | + false) |
| 623 | + .then( |
| 624 | + this.cloudFoundryOperations |
| 625 | + .applications() |
| 626 | + .get( |
| 627 | + GetApplicationRequest.builder() |
| 628 | + .name(applicationName) |
| 629 | + .build())) |
| 630 | + .map(ApplicationDetail::getId) |
| 631 | + .flatMapMany( |
| 632 | + appGuid -> |
| 633 | + this.cloudFoundryOperations |
| 634 | + .applications() |
| 635 | + .logsTail( |
| 636 | + TailLogsRequest.builder() |
| 637 | + .sourceId(appGuid) |
| 638 | + .envelopeTypes( |
| 639 | + Collections.singletonList( |
| 640 | + EnvelopeType.LOG)) |
| 641 | + .build()) |
| 642 | + .take(1)) |
| 643 | + .map(Envelope::getLog) |
| 644 | + .map(Log::getType) |
| 645 | + .as(StepVerifier::create) |
| 646 | + .expectNextMatches( |
| 647 | + logType -> LogType.OUT.equals(logType) || LogType.ERR.equals(logType)) |
| 648 | + .expectComplete() |
| 649 | + .verify(Duration.ofMinutes(5)); |
| 650 | + } |
| 651 | + |
| 652 | + /** |
| 653 | + * Integration test for {@link org.cloudfoundry.operations.applications.Applications#logsTail} |
| 654 | + * verifying that multiple LOG envelopes can be streamed from a running application. |
| 655 | + */ |
| 656 | + @Test |
| 657 | + public void logsTailMultipleEnvelopes() throws IOException { |
| 658 | + String applicationName = this.nameFactory.getApplicationName(); |
| 659 | + |
| 660 | + createApplication( |
| 661 | + this.cloudFoundryOperations, |
| 662 | + new ClassPathResource("test-application.zip").getFile().toPath(), |
| 663 | + applicationName, |
| 664 | + false) |
| 665 | + .then( |
| 666 | + this.cloudFoundryOperations |
| 667 | + .applications() |
| 668 | + .get( |
| 669 | + GetApplicationRequest.builder() |
| 670 | + .name(applicationName) |
| 671 | + .build())) |
| 672 | + .map(ApplicationDetail::getId) |
| 673 | + .flatMapMany( |
| 674 | + appGuid -> |
| 675 | + this.cloudFoundryOperations |
| 676 | + .applications() |
| 677 | + .logsTail( |
| 678 | + TailLogsRequest.builder() |
| 679 | + .sourceId(appGuid) |
| 680 | + .envelopeTypes( |
| 681 | + Collections.singletonList( |
| 682 | + EnvelopeType.LOG)) |
| 683 | + .build()) |
| 684 | + .take(3)) |
| 685 | + .map(Envelope::getLog) |
| 686 | + .map(Log::getType) |
| 687 | + .as(StepVerifier::create) |
| 688 | + .expectNextMatches( |
| 689 | + logType -> LogType.OUT.equals(logType) || LogType.ERR.equals(logType)) |
| 690 | + .expectNextMatches( |
| 691 | + logType -> LogType.OUT.equals(logType) || LogType.ERR.equals(logType)) |
| 692 | + .expectNextMatches( |
| 693 | + logType -> LogType.OUT.equals(logType) || LogType.ERR.equals(logType)) |
| 694 | + .expectComplete() |
| 695 | + .verify(Duration.ofMinutes(5)); |
| 696 | + } |
| 697 | + |
609 | 698 | @Test |
610 | 699 | public void pushBindServices() throws IOException { |
611 | 700 | String applicationName = this.nameFactory.getApplicationName(); |
|
0 commit comments