Retry failing integration tests

This uses 'RetryingTest' from junit jupiter to retry integration tests that are known to fail from time to time. We explicitly mark single tests in contrast to set a global retry to be able to trace those, whenever this is intended.

To do so, we have to update to the latest version of JUnit. Unfortunately, this brought a new behaviour for the @TempDir annotation: In contrast to the former behaviour where for one test all annotated parameters got the same directory, in the new version the parameters get different directories assigned. This led to the need of some consolidation between @BeforeEach methods and the related tests.

Committed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
Rene Pfeuffer
2023-03-22 06:24:33 +01:00
committed by SCM-Manager
parent 796330f883
commit 68110ee6b3
17 changed files with 133 additions and 108 deletions

View File

@@ -41,7 +41,6 @@ import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryLocationResolver;
import sonia.scm.repository.RepositoryManager;
import java.io.IOException;
import java.nio.file.Path;
import static org.assertj.core.api.Assertions.assertThat;
@@ -72,15 +71,18 @@ class GitRepositoryContextResolverTest {
@Nested
class WithRepository {
@TempDir
Path repositoryPath;
@BeforeEach
void mockRepository(@TempDir Path repositoryPath) throws IOException {
void mockRepository() {
when(scmConfiguration.getBaseUrl()).thenReturn("https://hog.hitchhiker.com/scm");
when(repositoryManager.get(new NamespaceAndName("space", "X"))).thenReturn(REPOSITORY);
when(locationResolver.forClass(any()).getLocation("id")).thenReturn(repositoryPath);
}
@Test
void shouldResolveCorrectRepository(@TempDir Path repositoryPath) {
void shouldResolveCorrectRepository() {
RepositoryContext context = resolver.resolve(new String[]{"git", "repo/space/X/something/else"});
assertThat(context.getRepository()).isSameAs(REPOSITORY);
@@ -88,7 +90,7 @@ class GitRepositoryContextResolverTest {
}
@Test
void shouldResolveCorrectRepositoryWithContextPath(@TempDir Path repositoryPath) throws IOException {
void shouldResolveCorrectRepositoryWithContextPath() {
RepositoryContext context = resolver.resolve(new String[]{"git", "scm/repo/space/X/something/else"});
assertThat(context.getRepository()).isSameAs(REPOSITORY);

View File

@@ -58,13 +58,16 @@ class GitV2UpdateStepTest {
@InjectMocks
GitV2UpdateStep updateStep;
@TempDir
Path temp;
@BeforeEach
void createDataDirectory(@TempDir Path temp) throws IOException {
void createDataDirectory() throws IOException {
Files.createDirectories(temp.resolve("data"));
}
@BeforeEach
void initRepositoryFolder(@TempDir Path temp) {
void initRepositoryFolder() {
when(locationResolver.forClass(Path.class)).thenReturn(locationResolverInstance);
when(repositoryMetadataAccess.read(temp)).thenReturn(new Repository("123", "git", "space", "X"));
doAnswer(invocation -> {
@@ -74,14 +77,14 @@ class GitV2UpdateStepTest {
}
@Test
void shouldWriteConfigFileForBareRepositories(@TempDir Path temp) {
void shouldWriteConfigFileForBareRepositories() {
updateStep.doUpdate();
assertThat(temp.resolve("data").resolve("config")).exists();
}
@Test
void shouldWriteConfigFileForNonBareRepositories(@TempDir Path temp) throws IOException {
void shouldWriteConfigFileForNonBareRepositories() throws IOException {
Files.createDirectories(temp.resolve("data").resolve(".git"));
updateStep.doUpdate();