Skip to content

Commit

Permalink
fixup! more tests and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
simitt committed Jan 22, 2019
1 parent ca7a100 commit 81ebf66
Show file tree
Hide file tree
Showing 43 changed files with 341 additions and 27,166 deletions.
2 changes: 0 additions & 2 deletions libbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,5 @@ func GenRootCmdWithSettings(beatCreator beat.Creator, settings instance.Settings
rootCmd.AddCommand(rootCmd.TestCmd)
rootCmd.AddCommand(rootCmd.KeystoreCmd)

rootCmd.ExportCmd.RemoveCommand()

return rootCmd
}
17 changes: 17 additions & 0 deletions libbeat/ilm/conditions_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package ilm

import (
Expand Down
3 changes: 2 additions & 1 deletion libbeat/ilm/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package ilm
import (
"testing"

"github.com/elastic/beats/libbeat/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/common"
)

func TestConfig_Unpack(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions libbeat/ilm/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
"os"
"strings"

errw "github.com/pkg/errors"

"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
errw "github.com/pkg/errors"
)

//ESClient supporting methods necessary for ILM handling
Expand Down Expand Up @@ -135,7 +136,6 @@ func (l *ESLoader) shouldLoad(cfg Config) (bool, error) {
}

func (l *ESLoader) checkAliasExists(alias string) (bool, error) {
return false, nil
status, b, err := l.esClient.Request("HEAD", "/_alias/"+alias, "", nil, nil)
if err != nil && status != 404 {
return false, fmt.Errorf("%s: %v", err.Error(), string(b))
Expand Down
20 changes: 19 additions & 1 deletion libbeat/ilm/loader_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package ilm

import (
Expand All @@ -8,9 +25,10 @@ import (
"strings"
"testing"

"github.com/elastic/beats/libbeat/common"
"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"

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

Expand Down
3 changes: 2 additions & 1 deletion libbeat/ilm/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (
"io/ioutil"
"os"

"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/paths"
"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"
)
Expand Down
24 changes: 21 additions & 3 deletions libbeat/index/config_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package index

import (
Expand All @@ -8,10 +25,11 @@ import (

"github.com/elastic/go-ucfg/yaml"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/template"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/template"
)

func TestConfigs_ValidateConfig(t *testing.T) {
Expand Down Expand Up @@ -69,7 +87,7 @@ func TestConfigs_CompatibleIndexCfg(t *testing.T) {
}

func TestConfigs_DefaultConfig(t *testing.T) {
templateName := "%{[agent.name]}-%{[agent.version]}"
templateName := "%{[agent.type]}-%{[agent.version]}"
tmplCfg := template.DefaultTemplateCfg()
tmplCfg.Name = templateName
tmplCfg.Pattern = fmt.Sprintf("%s*", templateName)
Expand Down
140 changes: 1 addition & 139 deletions libbeat/index/testdata/beat.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,4 @@
###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common
# options. The metricbeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/metricbeat/index.html

#========================== Modules configuration ============================

metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml

# Set to true to enable config reloading
reload.enabled: false

# Period on which files under path should be checked for changes
#reload.period: 10s

#==================== Elasticsearch template setting ==========================

#setup.template.settings:
# index.number_of_shards: 1
# index.codec: best_compression
#_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
# env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
#host: "localhost:5601"

# Kibana Space ID
# ID of the Kibana Space into which the dashboards should be loaded. By default,
# the Default Space will be used.
#space.id:

#============================= Elastic Cloud ==================================

# These settings simplify using metricbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:
###################### Configuration Example #######################

#================================ Outputs =====================================

Expand All @@ -93,60 +9,6 @@ output.elasticsearch:
# Array of hosts to connect to.
hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.
#protocol: "https"
#username: "elastic"
#password: "changeme"

#----------------------------- Logstash output --------------------------------
#output.logstash:
# The Logstash hosts
#hosts: ["localhost:5044"]

# Optional SSL. By default is off.
# List of root certificates for HTTPS server verifications
#ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

# Certificate for SSL client authentication
#ssl.certificate: "/etc/pki/client/cert.pem"

# Client Certificate Key
#ssl.key: "/etc/pki/client/cert.key"

#================================ Processors =====================================

# Configure processors to enhance or manipulate events generated by the beat.

processors:
- add_host_metadata: ~
- add_cloud_metadata: ~

#================================ Logging =====================================

# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]

#============================== Xpack Monitoring ===============================
# metricbeat can export internal metrics to a central Elasticsearch monitoring
# cluster. This requires xpack monitoring to be enabled in Elasticsearch. The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#xpack.monitoring.enabled: false

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well. Any setting that is not set is
# automatically inherited from the Elasticsearch output configuration, so if you
# have the Elasticsearch output configured, you can simply uncomment the
# following line.
#xpack.monitoring.elasticsearch:

#============================== Indices =====================================

# Indices settings can define an index name, conditions which events should be sent to which index,
Expand Down
20 changes: 19 additions & 1 deletion libbeat/template/config_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package template

import (
Expand All @@ -7,8 +24,9 @@ import (

"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/common"
"github.com/stretchr/testify/assert"

"github.com/elastic/beats/libbeat/common"
)

func TestConfig(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion libbeat/template/loader.go → libbeat/template/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import (
"io/ioutil"
"os"

"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/asset"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/ilm"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/paths"
"github.com/pkg/errors"
)

// ESClient is a subset of the Elasticsearch client API capable of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ import (
"strconv"
"testing"

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

"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/ilm"
"github.com/elastic/beats/libbeat/outputs/elasticsearch/estest"
"github.com/elastic/beats/libbeat/version"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

type testTemplate struct {
Expand Down
3 changes: 2 additions & 1 deletion libbeat/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package template
import (
"testing"

"github.com/elastic/beats/libbeat/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/common"
)

func TestNumberOfRoutingShards(t *testing.T) {
Expand Down
Loading

0 comments on commit 81ebf66

Please sign in to comment.