use of org.projectnessie.model.Branch in project nessie by projectnessie.
the class AbstractRestGCTest method testSingleRefMultiTable.
@Test
public void testSingleRefMultiTable() throws BaseNessieClientServerException {
// ------ Time ---- | ---------- branch1 ------------------|
// t0 | create branch
// t1 | TABLE_ONE : 42 (expired)
// t2 | TABLE_TWO : 42 (expired)
// t3 | TABLE_TWO : 43
// t4 | TABLE_ONE : 43
// t5 | ------- cut off time ----------------|
// t6 | TABLE_TWO : 44
// t7 | DROP TABLE_TWO
String prefix = "singleRefMultiTable";
IdentifiedResult expectedResult = new IdentifiedResult();
Branch branch1 = createBranch(prefix);
// one commit for TABLE_ONE on branch1
CommitOutput table1 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_ONE, TABLE_ONE, METADATA_ONE, null, null);
// two commits for TABLE_TWO on branch1
CommitOutput table2 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_TWO, TABLE_TWO, METADATA_ONE, null, null);
// both commits are expected to be expired as it is before the cutoff time and not the head
// commits after cutoff time.
fillExpectedContents(Branch.of(branch1.getName(), table2.hash), 2, expectedResult);
// one commit for TABLE_TWO on branch1, before cutoff time but as head commit for TABLE_TWO.
table2 = commitSingleOp(prefix, branch1, table2.hash, 43, CID_TWO, TABLE_TWO, METADATA_TWO, table2.content, null);
// one commit for TABLE_ONE on branch1, before cutoff time but as head commit for TABLE_ONE
table1 = commitSingleOp(prefix, branch1, table1.hash, 43, CID_ONE, TABLE_ONE, METADATA_TWO, table1.content, null);
final Instant cutoffTime = Instant.now();
// one commit for TABLE_TWO on branch1
table2 = commitSingleOp(prefix, branch1, table2.hash, 44, CID_TWO, TABLE_TWO, METADATA_THREE, table2.content, null);
// drop table TABLE_TWO.
// this should not affect as it is done after the cutoff timestamp
dropTableCommit(prefix, branch1, table2.hash, TABLE_TWO);
// test GC with commit protection. No commits should be expired.
performGc(cutoffTime, null, new IdentifiedResult(), Collections.singletonList(branch1.getName()), false, null);
// test GC without commit protection.
performGc(cutoffTime, null, expectedResult, Collections.singletonList(branch1.getName()), true, null);
}
use of org.projectnessie.model.Branch in project nessie by projectnessie.
the class AbstractRestGCTest method testSingleRefRenameTable.
@Test
public void testSingleRefRenameTable() throws BaseNessieClientServerException {
// ------ Time ---- | ---------- branch1 -----------|
// t0 | create branch
// t1 | TABLE_TWO : 42 (expired)
// t2 | TABLE_TWO : 43
// t3 | ------- cut off time ---------|
// t4 | TABLE_TWO : 44
// t5 | RENAME TABLE_TWO to TABLE_TWO_RENAMED
String prefix = "singleRefRenameTable";
IdentifiedResult expectedResult = new IdentifiedResult();
Branch branch1 = createBranch(prefix);
// one commit for TABLE_TWO on branch1
CommitOutput table2 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_TWO, TABLE_TWO, METADATA_ONE, null, null);
// expected to be expired as it is before the cutoff time and not the head commit after cutoff
// time.
fillExpectedContents(Branch.of(branch1.getName(), table2.hash), 1, expectedResult);
// commit for TABLE_TWO on branch1
table2 = commitSingleOp(prefix, branch1, table2.hash, 43, CID_TWO, TABLE_TWO, METADATA_TWO, table2.content, null);
final Instant cutoffTime = Instant.now();
// commit for TABLE_TWO on branch1
table2 = commitSingleOp(prefix, branch1, table2.hash, 44, CID_TWO, TABLE_TWO, METADATA_THREE, table2.content, null);
// Rename table TABLE_TWO to "table_2_renamed" on branch1.
// Note that passing "beforeRename" argument.
// So, internally commitSingleOp will do put + delete operation.
table2 = commitSingleOp(prefix, branch1, table2.hash, 44, CID_TWO, TABLE_TWO_RENAMED, METADATA_THREE, table2.content, TABLE_TWO);
// rename table should not expire the live commits after cutoff timestamp.
performGc(cutoffTime, null, expectedResult, Collections.singletonList(branch1.getName()), true, null);
}
use of org.projectnessie.model.Branch in project nessie by projectnessie.
the class AbstractRestGCTest method testSingleRefRenameTableBeforeCutoff.
@Test
public void testSingleRefRenameTableBeforeCutoff() throws BaseNessieClientServerException {
// ------ Time ---- | ---------- branch1 -------------------------------|
// t0 | create branch
// t1 | TABLE_TWO : 42 (expired)
// t2 | TABLE_TWO : 43
// t3 | RENAME TABLE_TWO to TABLE_TWO_RENAMED
// t4 | ------- cut off time -----------------------------|
// t5 | TABLE_TWO_RENAMED : 44
String prefix = "singleRefRenameTableBeforeCutoff";
IdentifiedResult expectedResult = new IdentifiedResult();
Branch branch1 = createBranch(prefix);
// one commit for TABLE_TWO on branch1
CommitOutput table2 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_TWO, TABLE_TWO, METADATA_ONE, null, null);
// expected to be expired as it is before the cutoff time and not the head commit after cutoff
// time.
fillExpectedContents(Branch.of(branch1.getName(), table2.hash), 1, expectedResult);
// commit for TABLE_TWO on branch1
table2 = commitSingleOp(prefix, branch1, table2.hash, 43, CID_TWO, TABLE_TWO, METADATA_TWO, table2.content, null);
// Rename table TABLE_TWO to "table_2_renamed" on branch1.
// Note that passing "beforeRename" argument.
// So, internally commitSingleOp will do put + delete operation.
table2 = commitSingleOp(prefix, branch1, table2.hash, 43, CID_TWO, TABLE_TWO_RENAMED, METADATA_TWO, table2.content, TABLE_TWO);
final Instant cutoffTime = Instant.now();
// commit for TABLE_TWO_RENAMED on branch1
table2 = commitSingleOp(prefix, branch1, table2.hash, 44, CID_TWO, TABLE_TWO_RENAMED, METADATA_THREE, table2.content, null);
performGc(cutoffTime, null, expectedResult, Collections.singletonList(branch1.getName()), true, null);
}
use of org.projectnessie.model.Branch in project nessie by projectnessie.
the class AbstractRestGCTest method testMultiRefCutoffTimeStampPerRef.
@Test
public void testMultiRefCutoffTimeStampPerRef() throws BaseNessieClientServerException {
// ------ Time ---- | --- branch1 -------------| ---- branch2 ----------- |
// t0 | create branch | |
// t1 | | create branch |
// t2 | TABLE_ONE : 42 | |
// t3 | | TABLE_TWO : 42 (expired) |
// t4 |-- cut off time -------- | |
// t5 | TABLE_ONE : 44 | |
// t6 | TABLE_ONE : 45 | |
// t7 | | TABLE_TWO : 44 |
// t8 | |-- cut off time ----------- |
// t9 | | TABLE_TWO : 45 |
String prefix = "multiRefCutoffTimeStampPerRef";
IdentifiedResult expectedResult = new IdentifiedResult();
Branch branch1 = createBranch(prefix + "_1");
Branch branch2 = createBranch(prefix + "_2");
// commit for TABLE_ONE on branch1
CommitOutput table1 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_ONE, TABLE_ONE, METADATA_ONE, null, null);
// commit for TABLE_TWO on branch2
CommitOutput table2 = commitSingleOp(prefix, branch2, branch2.getHash(), 42, CID_TWO, TABLE_TWO, METADATA_ONE, null, null);
// expect this commit to be expired as it is before cutoff time and is not commit head.
fillExpectedContents(Branch.of(branch2.getName(), table2.hash), 1, expectedResult);
Instant defaultCutoffTime = Instant.now();
// commits for TABLE_ONE
table1 = commitSingleOp(prefix, branch1, table1.hash, 44, CID_ONE, TABLE_ONE, METADATA_THREE, table1.content, null);
table1 = commitSingleOp(prefix, branch1, table1.hash, 45, CID_ONE, TABLE_ONE, METADATA_FOUR, table1.content, null);
// commits for TABLE_TWO
table2 = commitSingleOp(prefix, branch2, table2.hash, 44, CID_TWO, TABLE_TWO, METADATA_THREE, table2.content, null);
Instant branch2CutoffTime = Instant.now();
Map<String, Instant> perRefCutoffTime = new HashMap<>();
perRefCutoffTime.put(branch2.getName(), branch2CutoffTime);
// commits for TABLE_TWO
table2 = commitSingleOp(prefix, branch2, table2.hash, 45, CID_TWO, TABLE_TWO, METADATA_FOUR, table2.content, null);
performGc(defaultCutoffTime, perRefCutoffTime, expectedResult, Arrays.asList(branch1.getName(), branch2.getName()), true, null);
}
use of org.projectnessie.model.Branch in project nessie by projectnessie.
the class AbstractRestGCTest method testSingleRefDropTable.
@Test
public void testSingleRefDropTable() throws BaseNessieClientServerException {
// ------ Time ---- | ---------- branch1 ------------------|
// t0 | create branch
// t1 | TABLE_ONE : 42
// t2 | TABLE_TWO : 42 (expired)
// t3 | TABLE_TWO : 43 (expired)
// t4 | DROP TABLE_TWO
// t5 | ------- cut off time ----------------|
// t6 | TABLE_ONE : 43
String prefix = "singleRefDropTable";
IdentifiedResult expectedResult = new IdentifiedResult();
Branch branch1 = createBranch(prefix);
// one commit for TABLE_ONE on branch1
CommitOutput table1 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_ONE, TABLE_ONE, METADATA_ONE, null, null);
// two commits for TABLE_TWO on branch1
CommitOutput table2 = commitSingleOp(prefix, branch1, branch1.getHash(), 42, CID_TWO, TABLE_TWO, METADATA_ONE, null, null);
// one commit for TABLE_TWO on branch1
table2 = commitSingleOp(prefix, branch1, table2.hash, 43, CID_TWO, TABLE_TWO, METADATA_TWO, table2.content, null);
// both commits on table2 are expected to be expired due to drop table before cutoff time.
fillExpectedContents(Branch.of(branch1.getName(), table2.hash), 2, expectedResult);
// drop table TABLE_TWO.
dropTableCommit(prefix, branch1, table2.hash, TABLE_TWO);
final Instant cutoffTime = Instant.now();
// one commit for TABLE_ONE on branch1
table1 = commitSingleOp(prefix, branch1, table1.hash, 43, CID_ONE, TABLE_ONE, METADATA_TWO, table1.content, null);
performGc(cutoffTime, null, expectedResult, Collections.singletonList(branch1.getName()), true, null);
}
Aggregations