Skip to content

Commit

Permalink
test: added test for the new skip failed outputs config
Browse files Browse the repository at this point in the history
  • Loading branch information
eran-gil2 committed Nov 16, 2021
1 parent c68533e commit ff6dc62
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 0 deletions.
15 changes: 15 additions & 0 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ func TestAgent_LoadOutput(t *testing.T) {
assert.NoError(t, err)
a, _ = NewAgent(c)
assert.Equal(t, 3, len(a.Config.Outputs))

c = config.NewConfig()
c.OutputFilters = []string{"influxdb"}
err = c.LoadConfig("../config/testdata/no_successful_output_plugins.toml")
assert.NoError(t, err)
a, err = NewAgent(c)
assert.Error(t, err)

c = config.NewConfig()
c.OutputFilters = []string{"influxdb"}
err = c.LoadConfig("../config/testdata/one_successful_output_plugin.toml")
assert.NoError(t, err)
a, err = NewAgent(c)
assert.NoError(t, err)

}

func TestWindow(t *testing.T) {
Expand Down
72 changes: 72 additions & 0 deletions config/testdata/no_successful_output_plugins.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Telegraf configuration

# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared inputs.

# Even if a plugin has no configuration, it must be declared in here
# to be active. Declaring a plugin means just specifying the name
# as a section with no variables. To deactivate a plugin, comment
# out the name and any variables.

# Use 'telegraf -config telegraf.toml -test' to see what metrics a config
# file would generate.

# One rule that plugins conform to is wherever a connection string
# can be passed, the values '' and 'localhost' are treated specially.
# They indicate to the plugin to use their own builtin configuration to
# connect to the local system.

# NOTE: The configuration has a few required parameters. They are marked
# with 'required'. Be sure to edit those to make this configuration work.

# Tags can also be specified via a normal map, but only one form at a time:
[global_tags]
dc = "us-east-1"

# Configuration for telegraf agent
[agent]
# Default data collection interval for all plugins
interval = "10s"

# run telegraf in debug mode
debug = false

# Override default hostname, if empty use os.Hostname()
hostname = ""

skip_failed_outputs = true


###############################################################################
# OUTPUTS #
###############################################################################

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
# The full HTTP endpoint URL for your InfluxDB instance
# Multiple urls can be specified for InfluxDB cluster support. Server to
# write to will be randomly chosen each interval.
urls = ["http://localhost:808"] # required.

# The target database for metrics. This database must already exist
database = "telegraf" # required.

# Configuration for the Kafka server to send metrics to
[[outputs.kafka]]
# URLs of kafka brokers
brokers = ["localhost:9099"]
# Kafka topic for producer messages
topic = "telegraf"
# Telegraf tag to use as a routing key
# ie, if this tag exists, its value will be used as the routing key
routing_tag = "host"


###############################################################################
# PLUGINS #
###############################################################################

# Read Apache status information (mod_status)
[[inputs.apache]]
# An array of Apache status URI to gather stats.
urls = ["http://localhost/server-status?auto"]
72 changes: 72 additions & 0 deletions config/testdata/one_successful_output_plugin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Telegraf configuration

# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared inputs.

# Even if a plugin has no configuration, it must be declared in here
# to be active. Declaring a plugin means just specifying the name
# as a section with no variables. To deactivate a plugin, comment
# out the name and any variables.

# Use 'telegraf -config telegraf.toml -test' to see what metrics a config
# file would generate.

# One rule that plugins conform to is wherever a connection string
# can be passed, the values '' and 'localhost' are treated specially.
# They indicate to the plugin to use their own builtin configuration to
# connect to the local system.

# NOTE: The configuration has a few required parameters. They are marked
# with 'required'. Be sure to edit those to make this configuration work.

# Tags can also be specified via a normal map, but only one form at a time:
[global_tags]
dc = "us-east-1"

# Configuration for telegraf agent
[agent]
# Default data collection interval for all plugins
interval = "10s"

# run telegraf in debug mode
debug = false

# Override default hostname, if empty use os.Hostname()
hostname = ""

skip_failed_outputs = true


###############################################################################
# OUTPUTS #
###############################################################################

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
# The full HTTP endpoint URL for your InfluxDB instance
# Multiple urls can be specified for InfluxDB cluster support. Server to
# write to will be randomly chosen each interval.
urls = ["http://localhost:8086"] # required.

# The target database for metrics. This database must already exist
database = "telegraf" # required.

# Configuration for the Kafka server to send metrics to
[[outputs.kafka]]
# URLs of kafka brokers
brokers = ["localhost:9099"]
# Kafka topic for producer messages
topic = "telegraf"
# Telegraf tag to use as a routing key
# ie, if this tag exists, its value will be used as the routing key
routing_tag = "host"


###############################################################################
# PLUGINS #
###############################################################################

# Read Apache status information (mod_status)
[[inputs.apache]]
# An array of Apache status URI to gather stats.
urls = ["http://localhost/server-status?auto"]

0 comments on commit ff6dc62

Please sign in to comment.