Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit ab3560d

Browse files
committed
Add IT/AT for updating multi-instance apps streams
Extend the lifecycle stream test to allow testing with multiple instances. Resolves #4504
1 parent 484eb79 commit ab3560d

File tree

2 files changed

+30
-7
lines changed
  • spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client/dsl
  • spring-cloud-dataflow-server/src/test/java/org/springframework/cloud/dataflow/integration/test

2 files changed

+30
-7
lines changed

spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client/dsl/Stream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ public String logs(StreamApplication app) {
217217
return this.client.streamOperations().streamExecutionLog(this.name, appDeploymentId);
218218
}
219219

220+
/**
221+
* @return Returns a map of the stream applications, associating every application with its applications instances
222+
* and their current runtime states: (App -> (AppInstanceId -> AppInstanceState)).
223+
*/
220224
public Map<StreamApplication, Map<String, String>> runtimeApps() {
221225

222226
StreamStatusResource streamStatus = client.runtimeOperations()

spring-cloud-dataflow-server/src/test/java/org/springframework/cloud/dataflow/integration/test/DataFlowIT.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,18 +464,36 @@ public void streamAppCrossVersion() {
464464

465465
@Test
466466
public void streamLifecycle() {
467+
streamLifecycleHelper(1, s -> { });
468+
}
469+
470+
@Test
471+
public void streamLifecycleWithTwoInstance() {
472+
final int numberOfInstancePerApp = 2;
473+
streamLifecycleHelper(numberOfInstancePerApp, stream -> {
474+
Map<StreamApplication, Map<String, String>> streamApps = stream.runtimeApps();
475+
assertThat(streamApps.size()).isEqualTo(2);
476+
for (Map<String, String> instanceMap : streamApps.values()) {
477+
assertThat(instanceMap.size()).isEqualTo(numberOfInstancePerApp); //every apps should have 2 instances.
478+
}
479+
});
480+
}
481+
482+
private void streamLifecycleHelper(int appInstanceCount, Consumer<Stream> streamAssertions) {
467483
logger.info("stream-lifecycle-test: DEPLOY");
468484
try (Stream stream = Stream.builder(dataFlowOperations)
469485
.name("lifecycle-test" + randomSuffix())
470486
.definition("time | log --log.name='TEST' --log.expression='TICKTOCK - TIMESTAMP: '.concat(payload)")
471487
.create()
472-
.deploy(testDeploymentProperties())) {
473-
474-
assertThat(stream.getStatus()).is(
475-
condition(status -> status.equals(DEPLOYING) || status.equals(PARTIAL)));
488+
.deploy(new DeploymentPropertiesBuilder()
489+
.putAll(testDeploymentProperties())
490+
.put("deployer.*.count", "" + appInstanceCount)
491+
.build())) {
476492

477493
Awaitility.await().until(() -> stream.getStatus().equals(DEPLOYED));
478494

495+
streamAssertions.accept(stream);
496+
479497
Awaitility.await().until(
480498
() -> stream.logs(app("log")).contains("TICKTOCK - TIMESTAMP:"));
481499

@@ -489,12 +507,13 @@ public void streamLifecycle() {
489507
logger.info("stream-lifecycle-test: UPDATE");
490508
stream.update(new DeploymentPropertiesBuilder()
491509
.put("app.log.log.expression", "'Updated TICKTOCK - TIMESTAMP: '.concat(payload)")
492-
// TODO investigate why on update the app-starters-core overrides the original web.exposure.include!!!
493510
.put("app.*.management.endpoints.web.exposure.include", "*")
494511
.build());
495512

496513
Awaitility.await().until(() -> stream.getStatus().equals(DEPLOYED));
497514

515+
streamAssertions.accept(stream);
516+
498517
Awaitility.await().until(
499518
() -> stream.logs(app("log")).contains("Updated TICKTOCK - TIMESTAMP:"));
500519

@@ -507,7 +526,8 @@ public void streamLifecycle() {
507526
stream.rollback(0);
508527

509528
Awaitility.await().until(() -> stream.getStatus().equals(DEPLOYED));
510-
assertThat(stream.getStatus()).isEqualTo(DEPLOYED);
529+
530+
streamAssertions.accept(stream);
511531

512532
Awaitility.await().until(
513533
() -> stream.logs(app("log")).contains("TICKTOCK - TIMESTAMP:"));
@@ -522,7 +542,6 @@ public void streamLifecycle() {
522542
stream.undeploy();
523543

524544
Awaitility.await().until(() -> stream.getStatus().equals(UNDEPLOYED));
525-
assertThat(stream.getStatus()).isEqualTo(UNDEPLOYED);
526545

527546
assertThat(stream.history().size()).isEqualTo(3);
528547
Awaitility.await().until(() -> stream.history().get(1).equals(DELETED));

0 commit comments

Comments
 (0)