Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix set template.order to 1 by default. #12160

Merged
merged 4 commits into from
May 14, 2019
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
2 changes: 1 addition & 1 deletion CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
by `make` and `mage`. Example: `export PYTHON_EXE=python2.7`. {pull}11212[11212]
- Prometheus helper for metricbeat contains now `Namespace` field for `prometheus.MetricsMappings` {pull}11424[11424]
- Update Jinja2 version to 2.10.1. {pull}11817[11817]
- Reduce idxmgmt.Supporter interface and rework export commands to reuse logic. {pull}11777[11777], {pull}12065[12065], {pull}12067[12067]
- Reduce idxmgmt.Supporter interface and rework export commands to reuse logic. {pull}11777[11777],{pull}12065[12065],{pull}12067[12067],{pull}12160[12160]
- Update urllib3 version to 1.24.2 {pull}11930[11930]
- Add libbeat/common/cleanup package. {pull}12134[12134]
- Only Load minimal template if no fields are provided. {pull}12103[12103]
1 change: 1 addition & 0 deletions libbeat/template/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ func DefaultConfig() TemplateConfig {
return TemplateConfig{
Enabled: true,
Fields: "",
Order: 1,
}
}
7 changes: 4 additions & 3 deletions libbeat/template/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
func TestFileLoader_Load(t *testing.T) {
ver := "7.0.0"
prefix := "mock"
order := 1
info := beat.Info{Version: ver, IndexPrefix: prefix}
tmplName := fmt.Sprintf("%s-%s", prefix, ver)

Expand All @@ -41,21 +42,21 @@ func TestFileLoader_Load(t *testing.T) {
"load minimal config info": {
body: common.MapStr{
"index_patterns": []string{"mock-7.0.0-*"},
"order": 0,
"order": order,
"settings": common.MapStr{"index": nil}},
},
"load minimal config with index settings": {
settings: TemplateSettings{Index: common.MapStr{"code": "best_compression"}},
body: common.MapStr{
"index_patterns": []string{"mock-7.0.0-*"},
"order": 0,
"order": order,
"settings": common.MapStr{"index": common.MapStr{"code": "best_compression"}}},
},
"load minimal config with source settings": {
settings: TemplateSettings{Source: common.MapStr{"enabled": false}},
body: common.MapStr{
"index_patterns": []string{"mock-7.0.0-*"},
"order": 0,
"order": order,
"settings": common.MapStr{"index": nil},
"mappings": common.MapStr{
"_source": common.MapStr{"enabled": false},
Expand Down
8 changes: 5 additions & 3 deletions libbeat/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/common"
)
Expand Down Expand Up @@ -81,12 +82,13 @@ func TestTemplate(t *testing.T) {
beatVersion := "6.6.0"
beatName := "testbeat"
ver := common.MustNewVersion("6.6.0")
template, err := New(beatVersion, beatName, *ver, TemplateConfig{}, false)
assert.NoError(t, err)
template, err := New(beatVersion, beatName, *ver, DefaultConfig(), false)
require.NoError(t, err)

data := template.Generate(common.MapStr{}, nil)
assert.Equal(t, []string{"testbeat-6.6.0-*"}, data["index_patterns"])
assert.Equal(t, 1, data["order"])
meta, err := data.GetValue("mappings.doc._meta")
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, common.MapStr{"beat": "testbeat", "version": "6.6.0"}, meta)
}