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

Commit 386ab7b

Browse files
tzolovjvalkeal
authored andcommitted
Generate standalone ITs tests jar
- use the maven-jar-plugin to generate standalone jar for the ITs. - Harden the ITs getApplicationUri utilities to ensure it works with k8s platforms. - Fix an issue with the logfile path to ensure proper working with K8s platforms. Resolves #4400 Part of the spring-attic/spring-cloud-dataflow-acceptance-tests#332 Epic.
1 parent 2eaadb3 commit 386ab7b

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

spring-cloud-dataflow-server/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@
153153
</images>
154154
</configuration>
155155
</plugin>
156+
<plugin>
157+
<groupId>org.apache.maven.plugins</groupId>
158+
<artifactId>maven-jar-plugin</artifactId>
159+
<executions>
160+
<execution>
161+
<goals>
162+
<goal>test-jar</goal>
163+
</goals>
164+
</execution>
165+
</executions>
166+
</plugin>
156167
</plugins>
157168
</build>
158169

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

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,9 @@ public void streamTransform() {
326326

327327
Awaitility.await().until(() -> stream.getStatus().equals(DEPLOYED));
328328

329-
Map<String, String> httpApp = runtimeApps.getApplicationInstances(stream.getName(), "http")
330-
.values().iterator().next();
331-
332329
String message = "Unique Test message: " + new Random().nextInt();
333330

334-
httpPost(runtimeApps.getApplicationInstanceUrl(httpApp), message);
331+
httpPost(runtimeApps.getApplicationInstanceUrl(stream.getName(), "http"), message);
335332

336333
Awaitility.await().until(() -> stream.logs(app("log")).contains(message.toUpperCase()));
337334
}
@@ -360,13 +357,8 @@ public void streamPartitioning() {
360357

361358
Awaitility.await().until(() -> stream.getStatus().equals(DEPLOYED));
362359

363-
Map<String, String> httpApp = runtimeApps.getApplicationInstances(stream.getName(), "http")
364-
.values().iterator().next();
365-
366-
String httpAppUrl = runtimeApps.getApplicationInstanceUrl(httpApp);
367-
368360
String message = "How much wood would a woodchuck chuck if a woodchuck could chuck wood";
369-
httpPost(httpAppUrl, message);
361+
httpPost(runtimeApps.getApplicationInstanceUrl(stream.getName(), "http"), message);
370362

371363
Awaitility.await().until(() -> {
372364
Collection<String> logs = runtimeApps.applicationInstanceLogs(stream.getName(), "log").values();
@@ -509,8 +501,7 @@ public void namedChannelDestination() {
509501

510502
String message = "Unique Test message: " + new Random().nextInt();
511503

512-
String httpAppUrl = runtimeApps.getApplicationInstanceUrl(httpStream.getName(), "http");
513-
httpPost(httpAppUrl, message);
504+
httpPost(runtimeApps.getApplicationInstanceUrl(httpStream.getName(), "http"), message);
514505

515506
Awaitility.await().until(() -> logStream.logs(app("log")).contains(message));
516507
}
@@ -536,8 +527,7 @@ public void namedChannelTap() {
536527

537528
String message = "Unique Test message: " + new Random().nextInt();
538529

539-
String httpAppUrl = runtimeApps.getApplicationInstanceUrl(httpLogStream.getName(), "http");
540-
httpPost(httpAppUrl, message);
530+
httpPost(runtimeApps.getApplicationInstanceUrl(httpLogStream.getName(), "http"), message);
541531

542532
Awaitility.await().until(
543533
() -> tapStream.logs(app("log")).contains(message));
@@ -570,16 +560,14 @@ public void namedChannelManyToOne() {
570560

571561
String messageOne = "Unique Test message: " + new Random().nextInt();
572562

573-
String httpAppUrl = runtimeApps.getApplicationInstanceUrl(httpStreamOne.getName(), "http");
574-
httpPost(httpAppUrl, messageOne);
563+
httpPost(runtimeApps.getApplicationInstanceUrl(httpStreamOne.getName(), "http"), messageOne);
575564

576565
Awaitility.await().until(
577566
() -> logStream.logs(app("log")).contains(messageOne));
578567

579568
String messageTwo = "Unique Test message: " + new Random().nextInt();
580569

581-
String httpAppUrl2 = runtimeApps.getApplicationInstanceUrl(httpStreamTwo.getName(), "http");
582-
httpPost(httpAppUrl2, messageTwo);
570+
httpPost(runtimeApps.getApplicationInstanceUrl(httpStreamTwo.getName(), "http"), messageTwo);
583571

584572
Awaitility.await().until(
585573
() -> logStream.logs(app("log")).contains(messageTwo));
@@ -735,15 +723,15 @@ public void streamWithConfigServer() {
735723
private Map<String, String> testDeploymentProperties() {
736724
DeploymentPropertiesBuilder propertiesBuilder = new DeploymentPropertiesBuilder()
737725
.put(SPRING_CLOUD_DATAFLOW_SKIPPER_PLATFORM_NAME, runtimeApps.getPlatformName())
738-
.put("app.*.logging.file", "${PID}-test.log") // Keep it for Boot 2.x compatibility.
739-
.put("app.*.logging.file.name", "${PID}-test.log")
726+
.put("app.*.logging.file", "/tmp/${PID}-test.log") // Keep it for Boot 2.x compatibility.
727+
.put("app.*.logging.file.name", "/tmp/${PID}-test.log")
740728
.put("app.*.endpoints.logfile.sensitive", "false")
741729
.put("app.*.endpoints.logfile.enabled", "true")
742730
.put("app.*.management.endpoints.web.exposure.include", "*")
743731
.put("app.*.spring.cloud.streamapp.security.enabled", "false");
744732

745733
if (this.runtimeApps.getPlatformType().equalsIgnoreCase(RuntimeApplicationHelper.KUBERNETES_PLATFORM_TYPE)) {
746-
propertiesBuilder.put("app.*.server.port", "80");
734+
propertiesBuilder.put("app.*.server.port", "8080");
747735
propertiesBuilder.put("deployer.*.kubernetes.createLoadBalancer", "true"); // requires LoadBalancer support on the platform
748736
}
749737

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Map;
2020
import java.util.stream.Collectors;
2121

22+
import org.awaitility.Awaitility;
2223
import org.slf4j.Logger;
2324
import org.slf4j.LoggerFactory;
2425

@@ -108,6 +109,10 @@ public Map<String, Map<String, String>> getApplicationInstances(String streamNam
108109
* @return Returns a map of app instance GUIDs and their Log content. A single entry per app instance.
109110
*/
110111
public Map<String, String> applicationInstanceLogs(String streamName, String appName) {
112+
// For K8s platforms the availability of the app's external URI is not dependent on the application state but
113+
// on the availability of the configured Load Balancer. So we need to wait until valid URI is returned.
114+
Awaitility.await().until(() -> getApplicationInstanceUrl(getApplicationInstances(streamName, appName)
115+
.values().iterator().next()) != null );
111116
return this.appInstanceAttributes().values().stream()
112117
.filter(v -> v.get(StreamRuntimePropertyKeys.ATTRIBUTE_SKIPPER_RELEASE_NAME).equals(streamName))
113118
.filter(v -> v.get(StreamRuntimePropertyKeys.ATTRIBUTE_SKIPPER_APPLICATION_NAME).equals(appName))
@@ -123,9 +128,12 @@ public Map<String, String> applicationInstanceLogs(String streamName, String app
123128
* @return Application URL
124129
*/
125130
public String getApplicationInstanceUrl(String streamName, String appName) {
126-
Map<String, String> instanceAttributes = getApplicationInstances(streamName, appName)
127-
.values().iterator().next();
128-
return getApplicationInstanceUrl(instanceAttributes);
131+
// For K8s platforms the availability of the app's external URI is not dependent on the application state but
132+
// on the availability of the configured Load Balancer. So we need to wait until valid URI is returned.
133+
Awaitility.await().until(() -> getApplicationInstanceUrl(getApplicationInstances(streamName, appName)
134+
.values().iterator().next()) != null );
135+
return getApplicationInstanceUrl(getApplicationInstances(streamName, appName)
136+
.values().iterator().next());
129137
}
130138

131139
/**

0 commit comments

Comments
 (0)