Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-sheng authored Sep 11, 2024
2 parents 386f2af + 58422e3 commit daa3ad6
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 32 deletions.
46 changes: 46 additions & 0 deletions docs/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,49 @@ The BanyanDB server would be listening on the `0.0.0.0:17912` to access gRPC req
At the same time, the BanyanDB server would be listening on the `0.0.0.0:17913` to access HTTP requests. if no errors occurred. The HTTP server is used for CLI and Web UI.

The Web UI is hosted at `http://localhost:17913/`.

## Build and Push the Custom Docker image

The BanyanDB Docker image can be built from the source code. You can build the Docker image by running the following commands:

```shell
make generate
make release
HUB=<private_hub> IMG_NAME=<private_name> TAG=<private_tag> make docker.build
```

The `make release` command builds binaries and generates the necessary files for building the Docker image. The `make docker.build` command builds the Docker image with the architecture aligned with the host machine.

`HUB` is the Docker Hub username or the Docker Hub organization name. `IMG_NAME` is the Docker image name. `TAG` is the Docker image tag.

Note: You can't build other OS or architecture images not identical to the host machine. That's because the docker build command fails to load the image after the build process.

The `make docker.push` command pushes the Docker image to the Docker Hub. You need to log in to the Docker Hub before running this command.

```shell
docker login
make generate
make release
make docker.push
```

If you want to push other OS or architecture images, you can run the following commands:

```shell
docker login
make generate
TARGET_OS=linux PLATFORMS=linux/amd64,linux/arm64 make release
PLATFORMS=linux/amd64,linux/arm64 make docker.push
```

The `TARGET_OS` environment variable specifies the target OS. The `PLATFORMS` environment variable specifies the target architectures. The `PLATFORMS` environment variable is a comma-separated list of the target architectures.

If you want to build and publish slim images, you can run the following commands:

```shell
docker login
make generate
make release
BINARYTYPE=slim make docker.build
BINARYTYPE=slim make docker.push
```
4 changes: 2 additions & 2 deletions pkg/index/inverted/inverted_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func (s *store) BuildQuery(seriesMatchers []index.SeriesMatcher, secondaryQuery
q := bluge.NewPrefixQuery(match)
q.SetField(entityField)
qs[i] = q
primaryNode.Append(newPrefixNode(match, nil))
primaryNode.Append(newPrefixNode(match))
case index.SeriesMatcherTypeWildcard:
match := convert.BytesToString(seriesMatchers[i].Match)
q := bluge.NewWildcardQuery(match)
q.SetField(entityField)
qs[i] = q
primaryNode.Append(newWildcardNode(match, nil))
primaryNode.Append(newWildcardNode(match))
default:
return nil, errors.Errorf("unsupported series matcher type: %v", seriesMatchers[i].Type)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/index/inverted/inverted_series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func TestStore_Search(t *testing.T) {
}
t.Run(name, func(t *testing.T) {
query, err := s.BuildQuery(matchers, nil)
require.NotEmpty(t, query.String())
require.NoError(t, err)
got, err := s.Search(context.Background(), tt.projection, query)
require.NoError(t, err)
Expand Down Expand Up @@ -282,6 +283,7 @@ func TestStore_SearchWildcard(t *testing.T) {
},
}, nil)
require.NoError(t, err)
require.NotEmpty(t, query.String())
got, err := s.Search(context.Background(), tt.projection, query)
require.NoError(t, err)
assert.ElementsMatch(t, tt.want, got)
Expand Down Expand Up @@ -349,6 +351,7 @@ func TestStore_SearchPrefix(t *testing.T) {
},
}, nil)
require.NoError(t, err)
require.NotEmpty(t, query.String())
got, err := s.Search(context.Background(), tt.projection, query)
require.NoError(t, err)
assert.ElementsMatch(t, tt.want, got)
Expand Down
34 changes: 14 additions & 20 deletions pkg/index/inverted/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ func (t *termRangeInclusiveNode) MarshalJSON() ([]byte, error) {
builder.WriteString(")")
}
inner["range"] = builder.String()
inner["index"] = t.indexRule.Metadata.Name + ":" + t.indexRule.Metadata.Group
if t.indexRule != nil {
inner["index"] = t.indexRule.Metadata.Name + ":" + t.indexRule.Metadata.Group
}
data := make(map[string]interface{}, 1)
data["termRangeInclusive"] = inner
return json.Marshal(data)
Expand All @@ -385,7 +387,9 @@ func newTermNode(term string, indexRule *databasev1.IndexRule) *termNode {

func (t *termNode) MarshalJSON() ([]byte, error) {
inner := make(map[string]interface{}, 1)
inner["index"] = t.indexRule.Metadata.Name + ":" + t.indexRule.Metadata.Group
if t.indexRule != nil {
inner["index"] = t.indexRule.Metadata.Name + ":" + t.indexRule.Metadata.Group
}
inner["value"] = t.term
data := make(map[string]interface{}, 1)
data["term"] = inner
Expand Down Expand Up @@ -423,23 +427,18 @@ func (m *matchNode) String() string {
}

type prefixNode struct {
indexRule *databasev1.IndexRule
prefix string
prefix string
}

func newPrefixNode(prefix string, indexRule *databasev1.IndexRule) *prefixNode {
func newPrefixNode(prefix string) *prefixNode {
return &prefixNode{
indexRule: indexRule,
prefix: prefix,
prefix: prefix,
}
}

func (m *prefixNode) MarshalJSON() ([]byte, error) {
inner := make(map[string]interface{}, 1)
inner["index"] = m.indexRule.Metadata.Name + ":" + m.indexRule.Metadata.Group
inner["value"] = m.prefix
data := make(map[string]interface{}, 1)
data["prefix"] = inner
data["prefix"] = m.prefix
return json.Marshal(data)
}

Expand All @@ -448,23 +447,18 @@ func (m *prefixNode) String() string {
}

type wildcardNode struct {
indexRule *databasev1.IndexRule
wildcard string
wildcard string
}

func newWildcardNode(wildcard string, indexRule *databasev1.IndexRule) *wildcardNode {
func newWildcardNode(wildcard string) *wildcardNode {
return &wildcardNode{
indexRule: indexRule,
wildcard: wildcard,
wildcard: wildcard,
}
}

func (m *wildcardNode) MarshalJSON() ([]byte, error) {
inner := make(map[string]interface{}, 1)
inner["index"] = m.indexRule.Metadata.Name + ":" + m.indexRule.Metadata.Group
inner["value"] = m.wildcard
data := make(map[string]interface{}, 1)
data["wildcard"] = inner
data["wildcard"] = m.wildcard
return json.Marshal(data)
}

Expand Down
16 changes: 13 additions & 3 deletions test/cases/measure/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,33 @@ var VerifyFn = func(innerGm gm.Gomega, sharedContext helpers.SharedContext, args
innerGm.Expect(resp.DataPoints[i].Sid).Should(gm.BeNumerically(">", 0))
}
}
innerGm.Expect(cmp.Equal(resp, want,
success := innerGm.Expect(cmp.Equal(resp, want,
protocmp.IgnoreUnknown(),
protocmp.IgnoreFields(&measurev1.DataPoint{}, "timestamp"),
protocmp.IgnoreFields(&measurev1.DataPoint{}, "version"),
protocmp.IgnoreFields(&measurev1.DataPoint{}, "sid"),
protocmp.Transform())).
To(gm.BeTrue(), func() string {
j, err := protojson.Marshal(resp)
var j []byte
j, err = protojson.Marshal(resp)
if err != nil {
return err.Error()
}
y, err := yaml.JSONToYAML(j)
var y []byte
y, err = yaml.JSONToYAML(j)
if err != nil {
return err.Error()
}
return string(y)
})
if !success {
return
}
query.Trace = true
resp, err = c.Query(ctx, query)
innerGm.Expect(err).NotTo(gm.HaveOccurred())
innerGm.Expect(resp.Trace).NotTo(gm.BeNil())
innerGm.Expect(resp.Trace.GetSpans()).NotTo(gm.BeEmpty())
}

//go:embed testdata/*.json
Expand Down
16 changes: 13 additions & 3 deletions test/cases/stream/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,31 @@ var VerifyFn = func(innerGm gm.Gomega, sharedContext helpers.SharedContext, args
return strings.Compare(a.ElementId, b.ElementId)
})
}
innerGm.Expect(cmp.Equal(resp, want,
success := innerGm.Expect(cmp.Equal(resp, want,
protocmp.IgnoreUnknown(),
protocmp.IgnoreFields(&streamv1.Element{}, "timestamp"),
protocmp.Transform())).
To(gm.BeTrue(), func() string {
j, err := protojson.Marshal(resp)
var j []byte
j, err = protojson.Marshal(resp)
if err != nil {
return err.Error()
}
y, err := yaml.JSONToYAML(j)
var y []byte
y, err = yaml.JSONToYAML(j)
if err != nil {
return err.Error()
}
return string(y)
})
if !success {
return
}
query.Trace = true
resp, err = c.Query(ctx, query)
innerGm.Expect(err).NotTo(gm.HaveOccurred())
innerGm.Expect(resp.Trace).NotTo(gm.BeNil())
innerGm.Expect(resp.Trace.GetSpans()).NotTo(gm.BeEmpty())
}

func loadData(stream streamv1.StreamService_WriteClient, metadata *commonv1.Metadata, dataFile string, baseTime time.Time, interval time.Duration) {
Expand Down
16 changes: 13 additions & 3 deletions test/cases/topn/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,29 @@ var VerifyFn = func(innerGm gm.Gomega, sharedContext helpers.SharedContext, args
innerGm.Expect(err).NotTo(gm.HaveOccurred())
want := &measurev1.TopNResponse{}
helpers.UnmarshalYAML(ww, want)
innerGm.Expect(cmp.Equal(resp, want,
success := innerGm.Expect(cmp.Equal(resp, want,
protocmp.IgnoreUnknown(),
protocmp.IgnoreFields(&measurev1.TopNList{}, "timestamp"),
protocmp.Transform())).
To(gm.BeTrue(), func() string {
j, err := protojson.Marshal(resp)
var j []byte
j, err = protojson.Marshal(resp)
if err != nil {
return err.Error()
}
y, err := yaml.JSONToYAML(j)
var y []byte
y, err = yaml.JSONToYAML(j)
if err != nil {
return err.Error()
}
return string(y)
})
if !success {
return
}
query.Trace = true
resp, err = c.TopN(ctx, query)
innerGm.Expect(err).NotTo(gm.HaveOccurred())
innerGm.Expect(resp.Trace).NotTo(gm.BeNil())
innerGm.Expect(resp.Trace.GetSpans()).NotTo(gm.BeEmpty())
}
2 changes: 1 addition & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/banyandb.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Banyan DB</title>
<title>BanyanDB</title>
</head>
<body>
<div id="app"></div>
Expand Down

0 comments on commit daa3ad6

Please sign in to comment.