Skip to content

Commit 919ad85

Browse files
committed
SOLR-15089: Solidify S3 tests when running with less resources.
1 parent 26b8fa5 commit 919ad85

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

solr/contrib/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ private boolean parentDirectoryExist(String path) throws S3Exception {
460460
return true;
461461
}
462462

463-
return pathExists(parentDirectory);
463+
// Check for existence twice, because s3Mock has issues in the tests
464+
if (pathExists(parentDirectory)) {
465+
return true;
466+
} else {
467+
return pathExists(parentDirectory);
468+
}
464469
}
465470

466471
private String getParentDirectory(String path) {
@@ -475,7 +480,7 @@ private String getParentDirectory(String path) {
475480
}
476481
return fromEnd > 0
477482
? path.substring(0, path.lastIndexOf(S3_FILE_PATH_DELIMITER, fromEnd) + 1)
478-
: S3_FILE_PATH_DELIMITER;
483+
: "";
479484
}
480485

481486
/** Ensures path adheres to some rules: -Doesn't start with a leading slash */

solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void testBackupIncremental() throws Exception {
234234
try (BackupRepository repository = cluster.getJettySolrRunner(0).getCoreContainer()
235235
.newBackupRepository(BACKUP_REPO_NAME)) {
236236
String backupLocation = repository.getBackupLocation(getBackupLocation());
237-
URI fullBackupLocationURI = repository.resolve(repository.createURI(backupLocation), backupName, getCollectionName());
237+
URI fullBackupLocationURI = repository.resolveDirectory(repository.createDirectoryURI(backupLocation), backupName, getCollectionName());
238238
BackupFilePaths backupPaths = new BackupFilePaths(repository, fullBackupLocationURI);
239239
IncrementalBackupVerifier verifier = new IncrementalBackupVerifier(repository, backupLocation, backupName, getCollectionName(), 3);
240240

@@ -448,7 +448,7 @@ private class IncrementalBackupVerifier {
448448
String backupName, String collection, int maxNumberOfBackupToKeep) {
449449
this.repository = repository;
450450
this.backupLocation = backupLocation;
451-
this.backupURI = repository.resolve(repository.createURI(backupLocation), backupName, collection);
451+
this.backupURI = repository.resolveDirectory(repository.createURI(backupLocation), backupName, collection);
452452
this.incBackupFiles = new BackupFilePaths(repository, this.backupURI);
453453
this.backupName = backupName;
454454
this.maxNumberOfBackupToKeep = maxNumberOfBackupToKeep;
@@ -536,7 +536,7 @@ public void verify(List<URI> newFilesCopiedOver) throws IOException {
536536
URI zkBackupFolder = repository.resolve(backupURI, "zk_backup_"+numBackup);
537537
assertTrue(repository.exists(backupPropertiesFile));
538538
assertTrue(repository.exists(zkBackupFolder));
539-
assertFolderAreSame(repository.resolve(backupURI, BackupFilePaths.getZkStateDir(prevBackupId)), zkBackupFolder);
539+
assertFolderAreSame(repository.resolveDirectory(backupURI, BackupFilePaths.getZkStateDir(prevBackupId)), zkBackupFolder);
540540

541541
// verify indexes file
542542
for(Slice slice : getCollectionState(getCollectionName()).getSlices()) {

0 commit comments

Comments
 (0)