diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 528ffb6e9..3ebd5d990 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -10,6 +10,8 @@ include: - key: $CI_COMMIT_REF_SLUG paths: - .go/pkg/mod/ +variables: + GOVERSION: "1.16.9" stages: - lint @@ -156,3 +158,19 @@ build for darwin arm64: artifacts: paths: - featurebase_darwin_arm64 + +# Build a FB Docker image with CI/CD and push to the GitLab registry. +build container fb: + image: docker:stable + stage: build + needs: + - "build for linux amd64" + tags: + - shell + before_script: + - echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY} + script: + - tag=${CI_REGISTRY_IMAGE}/server:${CI_COMMIT_REF_SLUG} + - docker build --build-arg GO_VERSION=$GOVERSION -t $tag -f .gitlab/Dockerfile . + - docker push $tag + - echo Created docker featurebase image with tag "$tag" \ No newline at end of file diff --git a/.gitlab/Dockerfile b/.gitlab/Dockerfile new file mode 100644 index 000000000..b22392ce1 --- /dev/null +++ b/.gitlab/Dockerfile @@ -0,0 +1,23 @@ +FROM alpine:3.14.2 + +LABEL maintainer "dev@molecula.com" +LABEL org.opencontainers.image.authors="dev@molecula.com" + +WORKDIR /featurebase + +RUN apk add --no-cache curl jq + +COPY LICENSE . +COPY NOTICE . +COPY featurebase_linux_amd64 . + +RUN chmod ugo+x . +EXPOSE 10101 +VOLUME /data + +ENV PILOSA_DATA_DIR /data +ENV PILOSA_BIND 0.0.0.0:10101 +ENV PILOSA_BIND_GRPC 0.0.0.0:20101 + +ENTRYPOINT ["/featurebase"] +CMD ["server"] \ No newline at end of file diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 3d204ae92..5092cba73 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -15,6 +15,7 @@ package pilosa import ( + "context" "fmt" "math/rand" "reflect" @@ -625,3 +626,14 @@ func TestAE(t *testing.T) { } }) } + +func TestTranslateIndexKey(t *testing.T) { + c := newCluster() + node0 := &topology.Node{ID: "node0"} + c.addNodeBasicSorted(node0) + c.holder = newHolderWithTempPath(t, "rbf") + _, e := c.translateIndexKey(context.Background(), "i", "a", false) + if e == nil { + t.Fatal("expecting error") + } +} diff --git a/executor_test.go b/executor_test.go index c42d7eb14..24395df8c 100644 --- a/executor_test.go +++ b/executor_test.go @@ -8220,4 +8220,77 @@ func TestToRows(t *testing.T) { if x == nil { t.Fatal("Shouldn't be nil ") } + e = v.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + v.DecimalVal = &pql.Decimal{Value: 1, Scale: 1} + e = v.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + v.DecimalVal = nil + v.FloatVal = 3.0 + e = v.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + + pfi := &pilosa.PairField{ + Pair: pilosa.Pair{ID: 1, Count: 1}, + Field: "f", + } + z := pfi.Clone() + if z.Pair.ID != pfi.Pair.ID { + t.Fatal("Should be equal ", z, pfi) + } + e = pfi.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + pfk := &pilosa.PairField{ + Pair: pilosa.Pair{Key: "a", Count: 1}, + Field: "f", + } + o := pfk.Clone() + if o.Pair.Key != pfk.Pair.Key { + t.Fatal("Should be equal ") + } + e = pfk.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + pfs := &pilosa.PairsField{ + Pairs: []pilosa.Pair{{ID: 1, Count: 1}}, + Field: "f", + } + f := pfs.Clone() + if f.Pairs[0].ID != pfs.Pairs[0].ID { + t.Fatal("Should be equal ") + } + e = pfs.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + + r4 := server.ResultUint64(1) + e = r4.ToRows(func(*proto.RowResponse) error { + return nil + }) + if e != nil { + t.Fatal("Shouldn't be err ", e) + } + } diff --git a/rbf/cursor_test.go b/rbf/cursor_test.go index 9ed2b2209..6694cd026 100644 --- a/rbf/cursor_test.go +++ b/rbf/cursor_test.go @@ -18,6 +18,7 @@ import ( "io" "math/bits" "math/rand" + "os" "reflect" "sort" "strings" @@ -847,6 +848,25 @@ func (e *EasyWalker) String() string { return e.path.String() } +func TestDumpDot(t *testing.T) { + db := MustOpenDB(t) + defer MustCloseDB(t, db) + tx := MustBegin(t, db, true) + defer tx.Rollback() + if err := tx.CreateBitmap("x"); err != nil { + t.Fatal(err) + } + c, err := tx.Cursor("x") + if err != nil { + t.Fatal(err) + } + + _, err = c.Add(1) + if err != nil { + t.Fatal(err) + } + rbf.Dumpdot(tx, 0, " ", os.Stdout) +} func TestCursor_UpdateBranchCells(t *testing.T) { db := MustOpenDB(t) defer MustCloseDB(t, db) @@ -964,6 +984,9 @@ func TestCursor_SplitBranchCells(t *testing.T) { t.Fatalf("Expecting RBLL (a branch split) got %v", after.String()) } + // + c, _ := tx.Cursor("x") //added just for dot code coverage + c.Dump("ignore for coverage") } diff --git a/rbf/cursorx.go b/rbf/cursorx.go index 9b2a61111..5fcd2ae7c 100644 --- a/rbf/cursorx.go +++ b/rbf/cursorx.go @@ -106,7 +106,7 @@ func (c *Cursor) Dump(name string) { fmt.Fprintf(bufStdout, "rankdir=\"LR\"\n") fmt.Fprintf(bufStdout, "node [shape=record height=.1]\n") - dumpdot(c.tx, 0, " ", bufStdout) + Dumpdot(c.tx, 0, " ", bufStdout) fmt.Fprintf(bufStdout, "\n}") bufStdout.Flush() } diff --git a/rbf/dot.go b/rbf/dot.go index fa815805e..69ef11961 100644 --- a/rbf/dot.go +++ b/rbf/dot.go @@ -60,8 +60,8 @@ func dotCell(b []byte, parent string, writer io.Writer) { } } -// dumpdot recursively writes the tree representation starting from a given page to STDERR. -func dumpdot(tx *Tx, pgno uint32, parent string, writer io.Writer) { +// Dumpdot recursively writes the tree representation starting from a given page to STDERR. +func Dumpdot(tx *Tx, pgno uint32, parent string, writer io.Writer) { page, _, err := tx.readPage(pgno) if err != nil { panic(err) @@ -79,7 +79,7 @@ func dumpdot(tx *Tx, pgno uint32, parent string, writer io.Writer) { root := fmt.Sprintf("root%d", record.Pgno) fmt.Fprintf(writer, "%s[label=\"ROOT(%d)| %s\"]\n%s->%s\n", root, record.Pgno, record.Name, rr, root) p := fmt.Sprintf("root%d", record.Pgno) - dumpdot(tx, record.Pgno, p, writer) + Dumpdot(tx, record.Pgno, p, writer) } } @@ -96,7 +96,7 @@ func dumpdot(tx *Tx, pgno uint32, parent string, writer io.Writer) { for i, n := 0, readCellN(page); i < n; i++ { cell := readBranchCell(page, i) if cell.Flags&uint32(ContainerTypeBitmap) == 0 { // leaf/branch child page - dumpdot(tx, cell.ChildPgno, p, writer) + Dumpdot(tx, cell.ChildPgno, p, writer) } else { b := fmt.Sprintf("bm%d", cell.ChildPgno) fmt.Fprintf(writer, "%s[label=\"BITMAP(%d) key=%d \"]\n %s -> %s\n", b, cell.ChildPgno, cell.LeftKey, p, b)