Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ env:
- TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.6
- TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb:latest ALWAYS=1
- TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.7
- TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.8.0-beta.1
- TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.8.0-nightly
- TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:latest
- TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.6
- TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb:latest ALWAYS=1
- TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.7
- TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.8.0-beta.1
- TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.8.0-nightly
- TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.13.4-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:latest

script:
Expand Down
17 changes: 10 additions & 7 deletions revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,20 @@ type RevisionRanges struct {

// RevisionTreeNode is a leaf in Merkle tree with hashed Revisions and with count of documents in the leaf
type RevisionTreeNode struct {
Hash string `json:"hash"`
Count int64 `json:"count,int"`
Hash uint64 `json:"hash"`
Count uint64 `json:"count,int"`
}

// RevisionTree is a list of Revisions in a Merkle tree
type RevisionTree struct {
Version int `json:"version"`
MaxDepth int `json:"maxDepth"`
RangeMin RevisionUInt64 `json:"rangeMin,string" velocypack:"rangeMin"`
RangeMax RevisionUInt64 `json:"rangeMax,string" velocypack:"rangeMax"`
Nodes []RevisionTreeNode `json:"nodes"`
Version int `json:"version"`
MaxDepth int `json:"maxDepth"`
RangeMin RevisionUInt64 `json:"rangeMin,string" velocypack:"rangeMin"`
RangeMax RevisionUInt64 `json:"rangeMax,string" velocypack:"rangeMax"`
InitialRangeMin RevisionUInt64 `json:"initialRangeMin,string" velocypack:"initialRangeMin"`
Count uint64 `json:"count,int"`
Hash uint64 `json:"hash"`
Nodes []RevisionTreeNode `json:"nodes"`
}

var (
Expand Down
8 changes: 6 additions & 2 deletions test/revisions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestRevisionTree(t *testing.T) {
t.Skipf("Not a single")
}
c := createClientFromEnv(t, true)
skipBelowVersion(c, "3.7", t)
skipBelowVersion(c, "3.8", t)

db := ensureDatabase(nil, c, "revision_tree", nil, t)
col := ensureCollection(nil, db, "revision_tree", nil, t)
Expand Down Expand Up @@ -79,15 +79,19 @@ func TestRevisionTree(t *testing.T) {
require.NotEmpty(t, tree.Version)
require.NotEmpty(t, tree.RangeMin)
require.NotEmpty(t, tree.RangeMax)
require.NotEmpty(t, tree.InitialRangeMin)
require.NotEmpty(t, tree.Nodes)

branchFactor := 8
noOfLeavesOnLevel := 1
noOfLeaves := noOfLeavesOnLevel
for i := 1; i <= tree.MaxDepth; i++ {
noOfLeavesOnLevel *= branchFactor
noOfLeaves += noOfLeavesOnLevel
if i == tree.MaxDepth {
noOfLeaves = noOfLeavesOnLevel
}
}
require.Equalf(t, noOfDocuments, int(tree.Count), "Count value of tree is not correct")
require.Equalf(t, noOfLeaves, len(tree.Nodes), "Number of leaves in the revision tree is not correct")

getRanges := func() driver.Revisions {
Expand Down