Skip to content

Commit

Permalink
Fix ES 2.x integration test (elastic#3115)
Browse files Browse the repository at this point in the history
There was a test that was loading a mock template, and this template
was assuming 5.x.
  • Loading branch information
tsg authored and suraj-soni committed Dec 15, 2016
1 parent d5de9a9 commit a1f1a17
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libbeat/outputs/elasticsearch/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ func TestCheckTemplate(t *testing.T) {

func TestLoadTemplate(t *testing.T) {

// Setup ES
client := GetTestingElasticsearch()
err := client.Connect(5 * time.Second)
assert.Nil(t, err)

// Load template
absPath, err := filepath.Abs("../../tests/files/")
assert.NotNil(t, absPath)
assert.Nil(t, err)

templatePath := absPath + "/template.json"
if strings.HasPrefix(client.Connection.version, "2.") {
templatePath = absPath + "/template-es2x.json"
}
content, err := readTemplate(templatePath)
assert.Nil(t, err)

// Setup ES
client := GetTestingElasticsearch()
err = client.Connect(5 * time.Second)
assert.Nil(t, err)

templateName := "testbeat"

// Load template
Expand Down
43 changes: 43 additions & 0 deletions libbeat/tests/files/template-es2x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"mappings": {
"_default_": {
"_all": {
"enabled": true,
"norms": {
"enabled": false
}
},
"dynamic_templates": [
{
"template1": {
"mapping": {
"doc_values": true,
"ignore_above": 1024,
"index": "not_analyzed",
"type": "{dynamic_type}"
},
"match": "*"
}
}
],
"properties": {
"@timestamp": {
"type": "date"
},
"message": {
"type": "string",
"index": "analyzed"
},
"offset": {
"type": "long",
"doc_values": "true"
}
}
}
},
"settings": {
"index.refresh_interval": "5s"
},
"template": "mockbeat-*"
}

0 comments on commit a1f1a17

Please sign in to comment.