You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2019/08/29 17:34:10 UTC
[archiva] branch feature/storage_refactoring updated: Using test
loop for browse service test
This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a commit to branch feature/storage_refactoring
in repository https://gitbox.apache.org/repos/asf/archiva.git
The following commit(s) were added to refs/heads/feature/storage_refactoring by this push:
new 32c4ada Using test loop for browse service test
32c4ada is described below
commit 32c4ada25968a30fceab5da885c893debbe24cf7
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Thu Aug 29 19:04:00 2019 +0200
Using test loop for browse service test
---
.../services/MergeRepositoriesServiceTest.java | 53 ++++++++++++++++++----
1 file changed, 45 insertions(+), 8 deletions(-)
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
index 7497642..aaa601e 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
@@ -46,6 +46,9 @@ public class MergeRepositoriesServiceTest
private Path repoStage = getAppserverBase().resolve("data/repositories").resolve( "test-repository-stage" );
+ private int maxChecks = 10;
+ private int checkWaitMs = 500;
+
@Test
public void getMergeConflictedArtifacts()
throws Exception
@@ -56,12 +59,28 @@ public class MergeRepositoriesServiceTest
waitForScanToComplete( TEST_REPOSITORY_STAGE );
- List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( TEST_REPOSITORY_STAGE,
- TEST_REPOSITORY );
-
- log.info( "conflicts: {}", artifactMetadatas );
+ int checks = maxChecks;
+ Throwable ex = null;
+ while(checks-->0) {
+ try {
+ log.info("Test Try " + checks);
+ List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( TEST_REPOSITORY_STAGE,
+ TEST_REPOSITORY );
+ log.info("conflicts: {}", artifactMetadatas);
+
+ assertThat(artifactMetadatas).isNotNull().isNotEmpty().hasSize(8);
+ return;
+ } catch (Throwable e) {
+ ex = e;
+ }
+ Thread.currentThread().sleep(checkWaitMs);
+ }
+ if (ex!=null && ex instanceof AssertionError) {
+ throw (AssertionError)ex;
+ } else {
+ throw new Exception(ex);
+ }
- assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
}
@Test
@@ -81,10 +100,28 @@ public class MergeRepositoriesServiceTest
MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
- service.mergeRepositories( TEST_REPOSITORY_STAGE, TEST_REPOSITORY, true );
+ int checks = maxChecks;
+ Throwable ex = null;
+ while(checks-->0) {
+ try {
+ log.info("Test Try " + checks);
+ service.mergeRepositories(TEST_REPOSITORY_STAGE, TEST_REPOSITORY, true);
+
+ assertTrue(Files.exists(repo.resolve(mergedArtifactPath)));
+ assertTrue(Files.exists(repo.resolve(mergedArtifactPomPath)));
+ return;
+ } catch (Throwable e) {
+ log.info("Exception {}, {}", e.getMessage(), e.getClass());
+ ex = e;
+ }
+ Thread.currentThread().sleep(checkWaitMs);
+ }
+ if (ex!=null && ex instanceof AssertionError) {
+ throw (AssertionError)ex;
+ } else if (ex!=null) {
+ throw new Exception(ex);
+ }
- assertTrue( Files.exists(repo.resolve(mergedArtifactPath)) );
- assertTrue( Files.exists(repo.resolve(mergedArtifactPomPath)) );
}
@After