Search in sources :

Example 6 with Branch

use of org.projectnessie.model.Branch in project nessie by projectnessie.

the class AbstractSparkSqlTest method commitAndReturnLog.

private List<Object[]> commitAndReturnLog(String branch) throws NessieConflictException, NessieNotFoundException {
    assertThat(sql("CREATE BRANCH %s IN nessie", branch)).containsExactly(row("Branch", branch, hash));
    ContentKey key = ContentKey.of("table", "name");
    CommitMeta cm1 = ImmutableCommitMeta.builder().author("sue").authorTime(Instant.ofEpochMilli(1)).message("1").putProperties("test", "123").build();
    CommitMeta cm2 = ImmutableCommitMeta.builder().author("janet").authorTime(Instant.ofEpochMilli(10)).message("2").putProperties("test", "123").build();
    CommitMeta cm3 = ImmutableCommitMeta.builder().author("alice").authorTime(Instant.ofEpochMilli(100)).message("3").putProperties("test", "123").build();
    Operations ops = ImmutableOperations.builder().addOperations(Operation.Put.of(key, IcebergTable.of("foo", 42, 42, 42, 42))).commitMeta(cm1).build();
    Operations ops2 = ImmutableOperations.builder().addOperations(Operation.Put.of(key, IcebergTable.of("bar", 42, 42, 42, 42))).commitMeta(cm2).build();
    Operations ops3 = ImmutableOperations.builder().addOperations(Operation.Put.of(key, IcebergTable.of("baz", 42, 42, 42, 42))).commitMeta(cm3).build();
    Branch ref1 = api.commitMultipleOperations().branchName(branch).hash(hash).operations(ops.getOperations()).commitMeta(ops.getCommitMeta()).commit();
    Branch ref2 = api.commitMultipleOperations().branchName(branch).hash(ref1.getHash()).operations(ops2.getOperations()).commitMeta(ops2.getCommitMeta()).commit();
    Branch ref3 = api.commitMultipleOperations().branchName(branch).hash(ref2.getHash()).operations(ops3.getOperations()).commitMeta(ops3.getCommitMeta()).commit();
    List<Object[]> resultList = new ArrayList<>();
    resultList.add(cmToRow(cm3, ref3.getHash()));
    resultList.add(cmToRow(cm2, ref2.getHash()));
    resultList.add(cmToRow(cm1, ref1.getHash()));
    return resultList;
}
Also used : ContentKey(org.projectnessie.model.ContentKey) Branch(org.projectnessie.model.Branch) ArrayList(java.util.ArrayList) ImmutableCommitMeta(org.projectnessie.model.ImmutableCommitMeta) CommitMeta(org.projectnessie.model.CommitMeta) ImmutableOperations(org.projectnessie.model.ImmutableOperations) Operations(org.projectnessie.model.Operations)

Example 7 with Branch

use of org.projectnessie.model.Branch in project nessie by projectnessie.

the class AbstractCompatibilityTests method getDefaultBranch.

@Test
void getDefaultBranch() throws Exception {
    Branch defaultBranch = api.getDefaultBranch();
    assertThat(defaultBranch).extracting(Branch::getName).isEqualTo("main");
    ReferencesResponse allRefs = api.getAllReferences().get();
    assertThat(allRefs.getReferences()).contains(defaultBranch);
}
Also used : Branch(org.projectnessie.model.Branch) ReferencesResponse(org.projectnessie.model.ReferencesResponse) Test(org.junit.jupiter.api.Test)

Example 8 with Branch

use of org.projectnessie.model.Branch in project nessie by projectnessie.

the class ITUpgradePath method commit.

@Test
@Order(103)
void commit() throws Exception {
    ContentKey key = ContentKey.of("my", "tables", "table_name");
    IcebergTable content = IcebergTable.of("metadata-location", 42L, 43, 44, 45, "content-id-" + version);
    String commitMessage = "hello world " + version;
    Put operation = Put.of(key, content);
    Branch branchNew = commitMaybeRetry(api.commitMultipleOperations().commitMeta(CommitMeta.fromMessage(commitMessage)).operation(operation).branch(versionBranch));
    assertThat(branchNew).isNotEqualTo(versionBranch).extracting(Branch::getName).isEqualTo(versionBranch.getName());
    expectedRefLogEntry("COMMIT");
}
Also used : ContentKey(org.projectnessie.model.ContentKey) Branch(org.projectnessie.model.Branch) IcebergTable(org.projectnessie.model.IcebergTable) Put(org.projectnessie.model.Operation.Put) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 9 with Branch

use of org.projectnessie.model.Branch in project nessie by projectnessie.

the class ITUpgradePath method keysUpgradeCreateBranch.

@Test
@Order(201)
void keysUpgradeCreateBranch() throws Exception {
    assumeThat(keysUpgradeBranch).isNull();
    Branch main = api.getDefaultBranch();
    keysUpgradeBranch = (Branch) api.createReference().sourceRefName(main.getName()).reference(Branch.of("keyUpgradeBranch", main.getHash())).create();
}
Also used : Branch(org.projectnessie.model.Branch) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 10 with Branch

use of org.projectnessie.model.Branch in project nessie by projectnessie.

the class ITUpgradePath method createReference.

@Test
@Order(101)
void createReference() throws Exception {
    Branch main = api.getDefaultBranch();
    versionBranch = Branch.of(VERSION_BRANCH_PREFIX + version, main.getHash());
    createdBranches.add(versionBranch.getName());
    api.createReference().sourceRefName(main.getName()).reference(versionBranch).create();
    expectedRefLogEntry("CREATE_REFERENCE");
}
Also used : Branch(org.projectnessie.model.Branch) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Aggregations

Branch (org.projectnessie.model.Branch)81 Test (org.junit.jupiter.api.Test)56 IcebergTable (org.projectnessie.model.IcebergTable)30 ContentKey (org.projectnessie.model.ContentKey)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)27 LogResponse (org.projectnessie.model.LogResponse)19 Reference (org.projectnessie.model.Reference)19 CommitMeta (org.projectnessie.model.CommitMeta)18 Instant (java.time.Instant)16 LogEntry (org.projectnessie.model.LogResponse.LogEntry)13 List (java.util.List)12 BaseNessieClientServerException (org.projectnessie.error.BaseNessieClientServerException)12 Tag (org.projectnessie.model.Tag)12 Collectors (java.util.stream.Collectors)11 NessieNotFoundException (org.projectnessie.error.NessieNotFoundException)11 Content (org.projectnessie.model.Content)11 Entry (org.projectnessie.model.EntriesResponse.Entry)10 Put (org.projectnessie.model.Operation.Put)10 IcebergView (org.projectnessie.model.IcebergView)9 Map (java.util.Map)8