From 17447408f4c56bf192b827fca93717f30a06f5fe Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Mon, 5 Dec 2016 14:46:41 +0100 Subject: [PATCH] Fix ES 2.x integration test (#3115) There was a test that was loading a mock template, and this template was assuming 5.x. --- .../elasticsearch/client_integration_test.go | 13 +++--- libbeat/tests/files/template-es2x.json | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 libbeat/tests/files/template-es2x.json diff --git a/libbeat/outputs/elasticsearch/client_integration_test.go b/libbeat/outputs/elasticsearch/client_integration_test.go index 15683169bb04..6d81a547bc27 100644 --- a/libbeat/outputs/elasticsearch/client_integration_test.go +++ b/libbeat/outputs/elasticsearch/client_integration_test.go @@ -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 diff --git a/libbeat/tests/files/template-es2x.json b/libbeat/tests/files/template-es2x.json new file mode 100644 index 000000000000..93059edddfe0 --- /dev/null +++ b/libbeat/tests/files/template-es2x.json @@ -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-*" +} +