Skip to content

Commit

Permalink
Revert "Add detach-history command to the ContentGenerator tool (#7867
Browse files Browse the repository at this point in the history
)" (#7907)

This reverts commit b07a1fe.
  • Loading branch information
snazy authored Jan 2, 2024
1 parent 08640f6 commit 3c4d2f6
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 430 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import org.junit.jupiter.params.provider.ValueSource;
import org.projectnessie.client.api.NessieApiV2;
import org.projectnessie.error.NessieConflictException;
import org.projectnessie.error.NessieNamespaceAlreadyExistsException;
import org.projectnessie.error.NessieNotFoundException;
import org.projectnessie.model.Branch;
import org.projectnessie.model.CommitMeta;
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.FetchOption;
import org.projectnessie.model.IcebergTable;
Expand All @@ -63,8 +65,31 @@ void setUp() {
api = buildNessieApi();
}

private void create(IcebergTable table, ContentKey key)
throws NessieConflictException, NessieNotFoundException {
if (key.getElementCount() > 1) {
try {
api.createNamespace()
.namespace(key.getNamespace())
.reference(api.getDefaultBranch())
.create();
} catch (NessieNamespaceAlreadyExistsException ignore) {
//
}
}
api.commitMultipleOperations()
.branch(api.getDefaultBranch())
.commitMeta(CommitMeta.fromMessage("test-commit"))
.operation(Operation.Put.of(key, table))
.commit();
}

private IcebergTable get(ContentKey key) throws NessieNotFoundException {
return (IcebergTable) get(api, "main", key);
return get("main", key);
}

private IcebergTable get(String refName, ContentKey key) throws NessieNotFoundException {
return (IcebergTable) api.getContent().refName(refName).key(key).get().get(key);
}

private List<LogResponse.LogEntry> log(int depth) throws NessieNotFoundException {
Expand All @@ -89,7 +114,7 @@ private int runMain(String... args) {

@Test
void refreshOneKey() throws NessieNotFoundException, NessieConflictException {
create(api, table1, key1);
create(table1, key1);
IcebergTable stored1 = get(key1);

assertThat(
Expand Down Expand Up @@ -122,7 +147,7 @@ void refreshEmptyBatch() throws NessieNotFoundException {

@Test
void failOnExplicitTagArgument() throws NessieNotFoundException, NessieConflictException {
create(api, table3, key3);
create(table3, key3);
IcebergTable stored3 = get(key3);

String tagName = "testTag_" + UUID.randomUUID();
Expand Down Expand Up @@ -156,9 +181,9 @@ private void writeInputFile(File file, ContentKey... keys) throws IOException {
@ParameterizedTest
@ValueSource(ints = {1, 2, 3, 4, 100})
void refreshFromFile(int batchSize, @TempDir File tempDir) throws IOException {
create(api, table1, key1);
create(api, table2, key2);
create(api, table3, key3);
create(table1, key1);
create(table2, key2);
create(table3, key3);
IcebergTable stored1 = get(key1);
IcebergTable stored2 = get(key2);
IcebergTable stored3 = get(key3);
Expand Down Expand Up @@ -196,8 +221,8 @@ void refreshFromFile(int batchSize, @TempDir File tempDir) throws IOException {
}

@Test
void partialRefreshFromFileWithRefOverride(@TempDir File tempDir) throws IOException {
create(api, table1, key1);
void partialRefreshFromFileWithRefOveride(@TempDir File tempDir) throws IOException {
create(table1, key1);
IcebergTable stored1 = get(key1);

Branch main = api.getDefaultBranch();
Expand Down Expand Up @@ -230,15 +255,15 @@ void partialRefreshFromFileWithRefOverride(@TempDir File tempDir) throws IOExcep
.collect(Collectors.toList()))
.containsExactly(key1); // Note: key2 is not present

assertThat(get(api, ref.getName(), key1)).isEqualTo(stored1);
assertThat(get(ref.getName(), key1)).isEqualTo(stored1);
}

@ParameterizedTest
@ValueSource(ints = {1, 2, 3, 4, 5, 6, 100})
void refreshAllKeys(int batchSize) throws IOException {
create(api, table1, key1);
create(api, table2, key2);
create(api, table3, key3);
create(table1, key1);
create(table2, key2);
create(table3, key3);
IcebergTable stored1 = get(key1);
IcebergTable stored2 = get(key2);
IcebergTable stored3 = get(key3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
ReadReferences.class,
ReadContent.class,
RefreshContent.class,
DetachHistory.class,
DeleteContent.class,
CreateMissingNamespaces.class,
CommandLine.HelpCommand.class
Expand Down
Loading

0 comments on commit 3c4d2f6

Please sign in to comment.