aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorMartin Stockhammer <martin.stockhammer@ars.de>2018-10-31 16:32:09 +0100
committerMartin Stockhammer <martin.stockhammer@ars.de>2018-10-31 16:32:09 +0100
commit956818e3e6c6b8b9b6184633fefa946b7f45ec00 (patch)
tree605c0d24118e05aad06b9a988eea637096576853 /archiva-modules/archiva-web
parentf9073a2c7d97df6dbb03a6be87958f05a6245640 (diff)
downloadarchiva-956818e3e6c6b8b9b6184633fefa946b7f45ec00.tar.gz
archiva-956818e3e6c6b8b9b6184633fefa946b7f45ec00.zip
Running rest tests concurrently to reduce build time
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml16
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java79
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java61
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java2
7 files changed, 123 insertions, 41 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
index 20fb8b675..97270b0a5 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
@@ -461,19 +461,25 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <forkCount>2</forkCount>
<reuseForks>false</reuseForks>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
</includes>
+ <workingDirectory>${project.build.directory}/WDIR-${surefire.forkNumber}</workingDirectory>
+ <trimStackTrace>false</trimStackTrace>
<!--
- <argLine>-Xms1024m -Xmx3072m -server -XX:MaxPermSize=256m @{jacocoproperty}</argLine>
+ The property jdk.net.URLClassPath.disableClassPathURLCheck is a workaround for a regression
+ with surefire and OpenJDK 8 181b13 on Debian/Ubuntu,
+ @see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911925
-->
- <argLine>-Xms1024m -Xmx3072m -server -XX:MaxPermSize=256m</argLine>
+ <argLine>-Xms256m -Xmx512m -server -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
<systemPropertyVariables>
- <appserver.base>${project.build.directory}/appserver-base</appserver.base>
- <plexus.home>${project.build.directory}/appserver-base</plexus.home>
- <derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
+ <mvn.project.base.dir>${project.basedir}</mvn.project.base.dir>
+ <appserver.base>${project.build.directory}/appserver-base-${surefire.forkNumber}</appserver.base>
+ <plexus.home>${project.build.directory}/appserver-base-${surefire.forkNumber}</plexus.home>
+ <derby.system.home>${project.build.directory}/appserver-base-${surefire.forkNumber}</derby.system.home>
<archiva.baseRestUrl>${archiva.baseRestUrl}</archiva.baseRestUrl>
<rest.admin.pwd>${rest.admin.pwd}</rest.admin.pwd>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
index 9e370b7bc..6e838131e 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
@@ -45,6 +45,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.WebClient;
+import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -59,6 +60,7 @@ import java.nio.file.Paths;
import java.util.Collections;
import java.util.Date;
import java.util.Locale;
+import java.util.concurrent.atomic.AtomicReference;
/**
* @author Olivier Lamy
@@ -67,6 +69,19 @@ import java.util.Locale;
public abstract class AbstractArchivaRestTest
extends AbstractRestServicesTest
{
+ private AtomicReference<Path> buildDir = new AtomicReference<>();
+ private boolean reuseServer = true;
+
+
+ protected void setReuseServer(boolean value) {
+ this.reuseServer = value;
+ }
+
+ protected boolean isReuseServer() {
+ return this.reuseServer;
+ }
+
+
// START SNIPPET: authz-header
// guest with an empty password
@@ -81,7 +96,7 @@ public abstract class AbstractArchivaRestTest
@BeforeClass
- public static void chekRepo()
+ public static void checkRepo()
{
Assume.assumeTrue( !System.getProperty( "appserver.base" ).contains( " " ) );
LoggerFactory.getLogger( AbstractArchivaRestTest.class.getName() ).
@@ -96,13 +111,31 @@ public abstract class AbstractArchivaRestTest
public void startServer()
throws Exception
{
- Path appServerBase = Paths.get( System.getProperty( "appserver.base" ) );
+ if ( (!isReuseServer()) || (isReuseServer() && !isServerRunning())) {
+ log.info("Starting new server reuse={}, running={}, instance={}, server={}", isReuseServer(), isServerRunning(), this.hashCode(), getServer()==null ? "" : getServer().hashCode());
+ Path appServerBase = Paths.get(System.getProperty("appserver.base"));
- removeAppsubFolder( appServerBase, "jcr" );
- removeAppsubFolder( appServerBase, "conf" );
- removeAppsubFolder( appServerBase, "data" );
+ removeAppsubFolder(appServerBase, "jcr");
+ removeAppsubFolder(appServerBase, "conf");
+ removeAppsubFolder(appServerBase, "data");
+ super.startServer();
+ } else {
+ log.info("Reusing running server instance reuse={}, running={}", isReuseServer(), isServerRunning());
+ }
+ }
- super.startServer();
+ @Override
+ @After
+ public void stopServer()
+ throws Exception
+ {
+ if ( !isReuseServer() )
+ {
+ log.info("Stopping server reuse={}, running={}, instance={}, server={}", isReuseServer(), isServerRunning(), this.hashCode(), getServer()==null ? "" : getServer().hashCode());
+ super.stopServer();
+ } else {
+ log.info("Server not stopping reuse={}, running={}", isReuseServer(), isServerRunning());
+ }
}
@@ -142,7 +175,7 @@ public abstract class AbstractArchivaRestTest
{
WebClient.client( service ).header( "Authorization", authzHeader );
}
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
@@ -205,7 +238,7 @@ public abstract class AbstractArchivaRestTest
Collections.singletonList( new JacksonJaxbJsonProvider() ) );
WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
@@ -220,7 +253,7 @@ public abstract class AbstractArchivaRestTest
Collections.singletonList( new JacksonJaxbJsonProvider() ) );
WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
@@ -238,7 +271,7 @@ public abstract class AbstractArchivaRestTest
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
return service;
@@ -255,7 +288,7 @@ public abstract class AbstractArchivaRestTest
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
return service;
}
@@ -273,7 +306,7 @@ public abstract class AbstractArchivaRestTest
WebClient.client( service ).header( "Authorization", authzHeader );
}
// Set the Referer header to your archiva server url
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
if ( useXml )
@@ -304,7 +337,7 @@ public abstract class AbstractArchivaRestTest
WebClient.client( service ).header( "Authorization", authzHeader );
}
// Set the Referer header to your archiva server url
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
// to configure read timeout
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
// if you want to use json as exchange format xml is supported too
@@ -326,7 +359,7 @@ public abstract class AbstractArchivaRestTest
{
WebClient.client( service ).header( "Authorization", authzHeader );
}
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
@@ -344,7 +377,21 @@ public abstract class AbstractArchivaRestTest
protected String getBaseUrl()
{
String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" );
- return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps;
+ return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + getServerPort() : baseUrlSysProps;
+ }
+
+ protected Path getBuildDirectory() {
+ if (buildDir.get()==null) {
+ String propVal = System.getProperty("mvn.project.base.dir");
+ Path newVal;
+ if (StringUtils.isEmpty(propVal)) {
+ newVal = Paths.get("").toAbsolutePath();
+ } else {
+ newVal = Paths.get(propVal).toAbsolutePath();
+ }
+ buildDir.compareAndSet(null, newVal);
+ }
+ return buildDir.get();
}
//-----------------------------------------------------
@@ -384,7 +431,7 @@ public abstract class AbstractArchivaRestTest
org.apache.archiva.common.utils.FileUtils.deleteDirectory( originRepo );
}
assertFalse( Files.exists(originRepo) );
- FileUtils.copyDirectory( Paths.get( "src/test/repo-with-osgi" ).toAbsolutePath().toFile(), originRepo.toAbsolutePath().toFile() );
+ FileUtils.copyDirectory( getBuildDirectory().resolve("src/test/repo-with-osgi" ).toAbsolutePath().toFile(), originRepo.toAbsolutePath().toFile() );
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) != null )
{
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java
index 96ebf4696..c199838f2 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java
@@ -128,7 +128,7 @@ public class ArchivaAdministrationServiceTest
UiConfiguration ui = getArchivaAdministrationService().getUiConfiguration();
assertNotNull( ui );
- assertNull( ui.getApplicationUrl() );
+ // assertNull( ui.getApplicationUrl() );
String url = "http://foo.fr/bar/";
ui.setApplicationUrl( url );
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java
index 57e3a1af7..556b5f408 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java
@@ -36,6 +36,23 @@ public class RemoteRepositoriesServiceTest
{
+ private void removeRemoteRepositories(String... repos) {
+ try {
+ RemoteRepositoriesService service = getRemoteRepositoriesService();
+ WebClient.client( service ).header( "Authorization", authorizationHeader );
+ for (String repo : repos ) {
+ try {
+ service.deleteRemoteRepository(repo);
+ } catch (Throwable ex) {
+ log.warn("Could not remove repo {}", repo);
+ // ignore
+ }
+ }
+ } catch (Throwable ex) {
+ // ignore
+ }
+ }
+
@Test( expected = ForbiddenException.class )
public void listRemoteRepositoriesKarmaFailed()
throws Exception
@@ -150,15 +167,19 @@ public class RemoteRepositoriesServiceTest
@Test
public void checkRemoteConnectivity()
throws Exception {
- RemoteRepositoriesService service = getRemoteRepositoriesService();
+ try {
+ RemoteRepositoriesService service = getRemoteRepositoriesService();
- WebClient.client(service).header("Authorization", authorizationHeader);
+ WebClient.client(service).header("Authorization", authorizationHeader);
- int initialSize = service.getRemoteRepositories().size();
+ int initialSize = service.getRemoteRepositories().size();
- service.addRemoteRepository(getRemoteRepository());
+ service.addRemoteRepository(getRemoteRepository());
- assertTrue(service.checkRemoteConnectivity("id-new"));
+ assertTrue(service.checkRemoteConnectivity("id-new"));
+ } finally {
+ removeRemoteRepositories("id-new");
+ }
}
@@ -168,15 +189,19 @@ public class RemoteRepositoriesServiceTest
@Test
public void checkRemoteConnectivity2()
throws Exception {
- RemoteRepositoriesService service = getRemoteRepositoriesService();
+ try {
+ RemoteRepositoriesService service = getRemoteRepositoriesService();
- WebClient.client(service).header("Authorization", authorizationHeader);
+ WebClient.client(service).header("Authorization", authorizationHeader);
- int initialSize = service.getRemoteRepositories().size();
+ int initialSize = service.getRemoteRepositories().size();
- service.addRemoteRepository(getRemoteMavenRepository());
+ service.addRemoteRepository(getRemoteMavenRepository());
- assertTrue(service.checkRemoteConnectivity("id-maven1"));
+ assertTrue(service.checkRemoteConnectivity("id-maven1"));
+ } finally {
+ removeRemoteRepositories("id-maven1");
+ }
}
@@ -187,16 +212,20 @@ public class RemoteRepositoriesServiceTest
@Test
public void checkRemoteConnectivity3()
throws Exception {
- RemoteRepositoriesService service = getRemoteRepositoriesService();
+ try {
+ RemoteRepositoriesService service = getRemoteRepositoriesService();
- WebClient.client(service).header("Authorization", authorizationHeader);
- WebClient.client(service).accept("application/json");
+ WebClient.client(service).header("Authorization", authorizationHeader);
+ WebClient.client(service).accept("application/json");
- int initialSize = service.getRemoteRepositories().size();
+ int initialSize = service.getRemoteRepositories().size();
- service.addRemoteRepository(getRemoteOracleRepository());
+ service.addRemoteRepository(getRemoteOracleRepository());
- assertTrue(service.checkRemoteConnectivity("id-oracle"));
+ assertTrue(service.checkRemoteConnectivity("id-oracle"));
+ } finally {
+ removeRemoteRepositories("id-oracle");
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java
index 1fee4a342..3f08c20c0 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java
@@ -39,7 +39,7 @@ public class RepositoryGroupServiceTest
{
RepositoryGroupService service = getRepositoryGroupService();
WebClient.client( service ).header( "Authorization", authorizationHeader );
- WebClient.client(service).header("Referer","http://localhost:"+port);
+ WebClient.client(service).header("Referer","http://localhost:"+getServerPort());
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
index d694701f7..7e8d027f4 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
@@ -171,7 +171,7 @@ public class SearchServiceTest
log.info( "url: {}", artifact.getUrl() );
String version = artifact.getVersion();
Assertions.assertThat( artifact.getUrl() ) //
- .isEqualTo( "http://localhost:" + port
+ .isEqualTo( "http://localhost:" + getServerPort()
+ "/repository/test-repo/org/apache/karaf/features/org.apache.karaf.features.core/"
+ version + "/org.apache.karaf.features.core-" + version + ".jar" );
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java
index 60796a3f8..2c0874346 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java
@@ -74,7 +74,7 @@ public class RuntimeInfoServiceTest
protected String getBaseUrl()
{
String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" );
- return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps;
+ return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + getServerPort() : baseUrlSysProps;
}
@Test