You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2021/06/08 07:00:38 UTC
[sling-org-apache-sling-starter] branch master updated: SLING-10402
- add more paths to test and simplify definitions
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter.git
The following commit(s) were added to refs/heads/master by this push:
new d55945f SLING-10402 - add more paths to test and simplify definitions
d55945f is described below
commit d55945f7e3a704405678f26ab0b694a6d4a9de43
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jun 8 09:00:20 2021 +0200
SLING-10402 - add more paths to test and simplify definitions
---
pom.xml | 12 +++++++---
.../java/org/apache/sling/launchpad/SmokeIT.java | 27 ++++++++++++++--------
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/pom.xml b/pom.xml
index f17fe36..ae3cf03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -334,9 +334,15 @@
<systemPropertyVariables>
<starter.http.test.ports>false:${http.port},${docker.skip}:${http.port.mongo}</starter.http.test.ports>
<starter.min.bundles.count>${starter.min.bundles.count}</starter.min.bundles.count>
- <!-- Specify any number of starter.readable.N props for relative paths to check for a successful get request. -->
- <!-- Check the affected path for SLING-10402 regression checking -->
- <starter.readable.1>/slingshot/users/slingshot1/travel/home/images/home.jpg</starter.readable.1>
+ <!-- Comma-separated list of paths to check for 200 status (added for SLING-10402) -->
+ <starter.check.paths>
+ /slingshot/users/slingshot1/travel/home/images/home.jpg,
+ /slingshot/resources/images/background.jpg,
+ /slingshot/users/slingshot2/places/landing/images/landing.jpg,
+ /starter.html,
+ /bin/browser.html,
+ /system/console/bundles,
+ </starter.check.paths>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/src/test/java/org/apache/sling/launchpad/SmokeIT.java b/src/test/java/org/apache/sling/launchpad/SmokeIT.java
index 29372fb..05291cd 100644
--- a/src/test/java/org/apache/sling/launchpad/SmokeIT.java
+++ b/src/test/java/org/apache/sling/launchpad/SmokeIT.java
@@ -19,12 +19,15 @@ package org.apache.sling.launchpad;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import javax.xml.parsers.DocumentBuilder;
@@ -57,7 +60,7 @@ import org.w3c.dom.Node;
@RunWith(Parameterized.class)
public class SmokeIT {
- private static final String READABLE_PROP_PREFIX = "starter.readable.";
+ private static final String CHECK_PATHS_PROPERTY = "starter.check.paths";
private static final int MAX_READABLE_INDEX = 50;
private final int slingHttpPort;
@@ -208,20 +211,26 @@ public class SmokeIT {
*/
@Test
public void verifyReadableUrls() throws Exception {
+ final AtomicInteger checkedPaths = new AtomicInteger();
try ( CloseableHttpClient client = newClient() ) {
- for (int i = 0; i <= MAX_READABLE_INDEX ; i++) {
- final String propName = READABLE_PROP_PREFIX + i;
- final String readable = System.getProperty(propName, "");
- if (!readable.isEmpty()) {
- HttpGet get = new HttpGet(String.format("http://localhost:%d%s", slingHttpPort, readable));
+ Stream.of(System.getProperty(CHECK_PATHS_PROPERTY).split(","))
+ .map(path -> path.trim())
+ .filter(path -> !path.isEmpty())
+ .forEach(path -> {
+ HttpGet get = new HttpGet(String.format("http://localhost:%d%s", slingHttpPort, path));
try (CloseableHttpResponse response = client.execute(get, httpClientContext)) {
+ checkedPaths.incrementAndGet();
if ( response.getStatusLine().getStatusCode() != 200 ) {
- fail(String.format("Unexpected status line \"%s\" for %s", response.getStatusLine(), readable));
+ fail(String.format("Unexpected status line \"%s\" for %s", response.getStatusLine(), path));
}
+ } catch(Exception ex) {
+ throw new RuntimeException(ex);
}
- }
- }
+ });
}
+
+ final int minTests = 6;
+ assertTrue(String.format("Expecting at least %d tests, got %d", minTests, checkedPaths.get()), checkedPaths.get() >= minTests);
}
static class BundleStatus {