-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10182: feat: s3 backup store can restore a backup r=deepthidevaki a=oleschoenburg Restores a backup by downloading snapshot and segment objects and storing them as files in a given target folder. closes #10179 Co-authored-by: Ole Schönburg <ole.schoenburg@gmail.com>
- Loading branch information
Showing
6 changed files
with
167 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
backup-stores/s3/src/test/java/io/camunda/zeebe/backup/s3/BackupAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.backup.s3; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.camunda.zeebe.backup.api.Backup; | ||
import java.nio.file.Path; | ||
import org.assertj.core.api.AbstractAssert; | ||
|
||
final class BackupAssert extends AbstractAssert<BackupAssert, Backup> { | ||
|
||
private BackupAssert(final Backup actual, final Class<?> selfType) { | ||
super(actual, selfType); | ||
} | ||
|
||
public static BackupAssert assertThatBackup(Backup actual) { | ||
return new BackupAssert(actual, BackupAssert.class); | ||
} | ||
|
||
@SuppressWarnings("UnusedReturnValue") | ||
public BackupAssert hasSameContentsAs(Backup expected) { | ||
assertThat(actual.id()).isEqualTo(expected.id()); | ||
assertThat(actual.descriptor()).isEqualTo(expected.descriptor()); | ||
assertThat(actual.snapshot().names()).isEqualTo(expected.snapshot().names()); | ||
assertThat(actual.segments().names()).isEqualTo(expected.segments().names()); | ||
|
||
NamedFileSetAssert.assertThatNamedFileSet(actual.snapshot()) | ||
.hasSameContentsAs(expected.snapshot()); | ||
NamedFileSetAssert.assertThatNamedFileSet(actual.segments()) | ||
.hasSameContentsAs(expected.segments()); | ||
|
||
return this; | ||
} | ||
|
||
@SuppressWarnings("UnusedReturnValue") | ||
public BackupAssert residesInPath(Path expectedPath) { | ||
NamedFileSetAssert.assertThatNamedFileSet(actual.snapshot()).residesInPath(expectedPath); | ||
NamedFileSetAssert.assertThatNamedFileSet(actual.segments()).residesInPath(expectedPath); | ||
return this; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
backup-stores/s3/src/test/java/io/camunda/zeebe/backup/s3/NamedFileSetAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.backup.s3; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.camunda.zeebe.backup.api.NamedFileSet; | ||
import java.nio.file.Path; | ||
import org.assertj.core.api.AbstractAssert; | ||
|
||
final class NamedFileSetAssert extends AbstractAssert<NamedFileSetAssert, NamedFileSet> { | ||
|
||
private NamedFileSetAssert(final NamedFileSet namedFileSet, final Class<?> selfType) { | ||
super(namedFileSet, selfType); | ||
} | ||
|
||
public static NamedFileSetAssert assertThatNamedFileSet(NamedFileSet actual) { | ||
return new NamedFileSetAssert(actual, NamedFileSetAssert.class); | ||
} | ||
|
||
@SuppressWarnings("UnusedReturnValue") | ||
public NamedFileSetAssert hasSameContentsAs(NamedFileSet expected) { | ||
for (final var expectedEntry : expected.namedFiles().entrySet()) { | ||
final var expectedName = expectedEntry.getKey(); | ||
final var expectedPath = expectedEntry.getValue(); | ||
final var actualNamedFiles = actual.namedFiles(); | ||
|
||
assertThat(actualNamedFiles).containsKey(expectedName); | ||
final var actualPath = actualNamedFiles.get(expectedEntry.getKey()); | ||
assertThat(actualPath).hasSameBinaryContentAs(expectedPath); | ||
} | ||
return this; | ||
} | ||
|
||
@SuppressWarnings("UnusedReturnValue") | ||
public NamedFileSetAssert residesInPath(Path expectedPath) { | ||
assertThat(actual.files()) | ||
.allSatisfy( | ||
actualPath -> { | ||
assertThat(actualPath).hasParent(expectedPath); | ||
}); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters