Pierre Souchay
fd98fb1449
Added support exposing metrics in Prometheus format
2018-04-06 09:18:06 +02:00
Guido Iaquinti
8cd11d5888
Add package name to log output
2018-03-21 15:56:14 +00:00
Frank Schroeder
9872475167
agent: fix TestRetryJoin
2017-10-24 20:35:37 +02:00
Frank Schroeder
7d3467176b
agent: fix TestRetryJoinFail
2017-10-24 20:35:37 +02:00
Frank Schroeder
96a584dee2
agent: fix TestRetryJoinWanFail
2017-10-24 20:35:36 +02:00
Frank Schroeder
b97ab367f4
config: return error on extra command line arguments ( #3397 )
...
The `consul agent` command was ignoring extra command line arguments
which can lead to confusion when the user has for example forgotten to
add a dash in front of an argument or is not using an `=` when setting
boolean flags to `true`. `-bootstrap true` is not the same as
`-bootstrap=true`, for example.
Since all command line flags are known and we don't expect unparsed
arguments we can return an error. However, this may make it slightly
more difficult in the future if we ever wanted to have these kinds of
arguments.
Fixes #3397
2017-10-23 08:07:48 +02:00
Frank Schroeder
b3292d13fb
commands: get HTTP API flags for usage automatically
2017-10-18 00:08:45 +02:00
Frank Schroeder
1b026de1db
commands: run all tests in parallel (again)
2017-10-18 00:08:45 +02:00
Frank Schroeder
56b24d3d4f
commands: cleanup help and synopsis.
...
* move Help and Synopsis to bottom
* make help and synopsis constants
* make sure help output is formatted
2017-10-18 00:08:45 +02:00
Frank Schroeder
d54a5ef8d8
commands: do not run cmd tests in parallel
...
Package level parallelization is sufficient.
2017-10-18 00:08:45 +02:00
Frank Schroeder
31d5fb7f47
commands: move agent command to separate pkg
2017-10-18 00:08:45 +02:00
Frank Schroeder
1c75cf1af5
pkg refactor
...
command/agent/* -> agent/*
command/consul/* -> agent/consul/*
command/agent/command{,_test}.go -> command/agent{,_test}.go
command/base/command.go -> command/base.go
command/base/* -> command/*
commands.go -> command/commands.go
The script which did the refactor is:
(
cd $GOPATH/src/github.com/hashicorp/consul
git mv command/agent/command.go command/agent.go
git mv command/agent/command_test.go command/agent_test.go
git mv command/agent/flag_slice_value{,_test}.go command/
git mv command/agent .
git mv command/base/command.go command/base.go
git mv command/base/config_util{,_test}.go command/
git mv commands.go command/
git mv consul agent
rmdir command/base/
gsed -i -e 's|package agent|package command|' command/agent{,_test}.go
gsed -i -e 's|package agent|package command|' command/flag_slice_value{,_test}.go
gsed -i -e 's|package base|package command|' command/base.go command/config_util{,_test}.go
gsed -i -e 's|package main|package command|' command/commands.go
gsed -i -e 's|base.Command|BaseCommand|' command/commands.go
gsed -i -e 's|agent.Command|AgentCommand|' command/commands.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/commands.go
gsed -i -e 's|base\.||' command/commands.go
gsed -i -e 's|command\.||' command/commands.go
gsed -i -e 's|command|c|' main.go
gsed -i -e 's|range Commands|range command.Commands|' main.go
gsed -i -e 's|Commands: Commands|Commands: command.Commands|' main.go
gsed -i -e 's|base\.BoolValue|BoolValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.DurationValue|DurationValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.StringValue|StringValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.UintValue|UintValue|' command/operator_autopilot_set.go
gsed -i -e 's|\bCommand\b|BaseCommand|' command/base.go
gsed -i -e 's|BaseCommand Options|Command Options|' command/base.go
gsed -i -e 's|base.Command|BaseCommand|' command/*.go
gsed -i -e 's|c\.Command|c.BaseCommand|g' command/*.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/*_test.go
gsed -i -e 's|base\.||' command/*_test.go
gsed -i -e 's|\bCommand\b|AgentCommand|' command/agent{,_test}.go
gsed -i -e 's|cmd.AgentCommand|cmd.BaseCommand|' command/agent.go
gsed -i -e 's|cli.AgentCommand = new(Command)|cli.Command = new(AgentCommand)|' command/agent_test.go
gsed -i -e 's|exec.AgentCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|exec.BaseCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|NewTestAgent|agent.NewTestAgent|' command/agent_test.go
gsed -i -e 's|= TestConfig|= agent.TestConfig|' command/agent_test.go
gsed -i -e 's|: RetryJoin|: agent.RetryJoin|' command/agent_test.go
gsed -i -e 's|\.\./\.\./|../|' command/config_util_test.go
gsed -i -e 's|\bverifyUniqueListeners|VerifyUniqueListeners|' agent/config{,_test}.go command/agent.go
gsed -i -e 's|\bserfLANKeyring\b|SerfLANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bserfWANKeyring\b|SerfWANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bNewAgent\b|agent.New|g' command/agent{,_test}.go
gsed -i -e 's|\bNewAgent|New|' agent/{acl_test,agent,testagent}.go
gsed -i -e 's|\bAgent\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bBool\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDefaultConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDevConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bMergeConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bReadConfigPaths\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bParseMetaPair\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfLANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfWANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|circonus\.agent|circonus|g' command/agent{,_test}.go
gsed -i -e 's|logger\.agent|logger|g' command/agent{,_test}.go
gsed -i -e 's|metrics\.agent|metrics|g' command/agent{,_test}.go
gsed -i -e 's|// agent.Agent|// agent|' command/agent{,_test}.go
gsed -i -e 's|a\.agent\.Config|a.Config|' command/agent{,_test}.go
gsed -i -e 's|agent\.AppendSliceValue|AppendSliceValue|' command/{configtest,validate}.go
gsed -i -e 's|consul/consul|agent/consul|' GNUmakefile
gsed -i -e 's|\.\./test|../../test|' agent/consul/server_test.go
# fix imports
f=$(grep -rl 'github.com/hashicorp/consul/command/agent' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/command/agent|github.com/hashicorp/consul/agent|' $f
goimports -w $f
f=$(grep -rl 'github.com/hashicorp/consul/consul' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/consul|github.com/hashicorp/consul/agent/consul|' $f
goimports -w $f
goimports -w command/*.go main.go
)
2017-06-10 18:52:45 +02:00
Frank Schroeder
9ceef2b32e
test: move discover tests
2017-06-10 18:52:45 +02:00
Frank Schroeder
902f4caff2
agent: move watch plans into agent
2017-06-10 18:52:45 +02:00
preetapan
2de032125b
Fixed regression with dns server start condition ( #3137 )
2017-06-09 15:50:06 -07:00
Seth Vargo
89f16984f9
Simplify
2017-06-09 14:55:04 -04:00
Seth Vargo
ee1b5d5024
Update comment
2017-06-09 14:51:34 -04:00
Seth Vargo
532f8d1435
Parse values given to ?passing in the API
...
This PR fixes GH-2212 in the most backwards-compatible way I can think
of. If the user does not pass a value for `?passing`, it's assumed to be
true, which mirrors the current behavior. However, if the user passes
any value for passing, that value is parsed as a bool using strconv.
It's important to note that this is technically a breaking change.
Previously using `?passing=false` would return only passing nodes. While
this behavior is obviously incorrect, it was the previous behavior. We
should call this out very clearly in the CHANGELOG.
2017-06-09 14:36:00 -04:00
James Phillips
86713c1b8a
Opens up timing bound on flaky test.
2017-06-08 21:37:52 -07:00
James Phillips
66ec9c7a7d
Fixes HTTP header compare by including standard headers.
2017-06-08 14:10:46 -07:00
Frank Schroeder
b5f8d6f9fd
agent: fix time.Duration parsing
...
The duration can be passed as a string, a float64 or a time.Duration
and this patch handles this properly.
2017-06-08 22:42:49 +02:00
Frank Schroeder
39d33c2fdc
agent: log events and exit code to the log file
...
This patch logs the signals, events, errors and the exit
code to the log file instead of printing it on the console.
This should provide a more complete picture for debugging.
2017-06-08 10:07:55 +02:00
Frank Schroeder
4a223111d2
log: use prefix [ERR] instead of [ERROR]
2017-06-08 09:50:47 +02:00
James Phillips
fa8a26ad54
Updates static assets to latest.
2017-06-07 21:16:59 -07:00
James Phillips
a09eed585e
Merge pull request #3121 from hashicorp/increase-graceful-timeout
...
agent: increase graceful shutdown timeout
2017-06-07 10:42:19 -07:00
Frank Schroeder
fe69de3bba
agent: increase graceful shutdown timeout
...
When triggering a leave through an INT/TERM signal the hard-coded
timeout of 5 seconds is too short to complete the leave successfully.
Therefore, the agent always times out.
This value should probably configurable.
2017-06-07 13:12:34 +02:00
Frank Schroeder
46c055d57b
agent: log differnt shutdown stages
...
Log the different code paths during shutdown.
2017-06-07 13:11:04 +02:00
Frank Schröder
825f72f5ef
agent: support custom header and method for http checks ( #3106 )
...
This patch adds support for custom headers and
method for HTTP checks.
Fixes #2474
Fixes #2657
Fixes #3106
2017-06-07 01:11:56 +02:00
Frank Schroeder
94b39557e8
test: refactor TestDecodeConfig test
...
This patch refactors the multiple tests for
DecodeConfig into a single table-driven test
that tests most fields individually.
2017-06-04 23:55:12 +02:00
Frank Schroeder
325f82972a
test: Fix TestAgent_Reload
...
This test was still referring to cmd.agent which has been removed.
2017-06-04 22:45:40 +02:00
James Phillips
240413f5d6
Merge pull request #3105 from hashicorp/test-stability
...
Tweaks things for better test stability.
2017-06-03 10:09:12 -07:00
Frank Schroeder
51e0e158f1
agent: fix graceful http server shutdown
2017-06-03 19:08:50 +02:00
Frank Schroeder
ae711c3b04
agent: cleanup run method
2017-06-03 19:08:50 +02:00
Frank Schroeder
b203ffab29
agent: move registerWatches out of the run method
2017-06-03 19:08:50 +02:00
Frank Schroeder
11245e53a7
agent: move telemetry out of the run method
2017-06-03 19:08:50 +02:00
Frank Schroeder
84f5e8c3ab
agent: move update check out of the run method
2017-06-03 19:08:50 +02:00
Frank Schroeder
96d8035adc
agent: simplify signal handling
2017-06-03 19:08:50 +02:00
Frank Schroeder
34fd31b7b1
agent: move config reloading into the agent
2017-06-03 19:08:50 +02:00
Frank Schroeder
aa1519c9f7
agent: move parseMetaPair to config and export
2017-06-03 19:08:50 +02:00
Frank Schroeder
cb98754cd6
agent: remove agent from command
...
Decouple command and agent a bit more.
2017-06-03 19:08:50 +02:00
Frank Schroeder
d977aa1fe7
agent: move retry join into agent
2017-06-03 19:08:50 +02:00
Frank Schroeder
55a513da2e
agent: add GossipEncrypted function
...
Remove dead code and expose a GossipEncrypted() method
on the agent instead of accessing the internal delegate.
2017-06-03 19:08:50 +02:00
James Phillips
b0b5df579f
Cleans up an unrelated vet error.
2017-06-02 21:07:15 -07:00
James Phillips
b4b5036dfb
Adds back the port shuffle on agent start retries.
2017-06-02 20:53:20 -07:00
Frank Schroeder
375825f34c
Do not recurse when the service address is a local cname
...
Fixes #2795
2017-06-01 18:20:31 +02:00
Frank Schroeder
9956bc9b47
agent: LastContact cannot be negative ( #3067 )
...
The X-Consul-LastContact header cannot be negative.
Fixes #3067
2017-06-01 18:20:12 +02:00
Frank Schroeder
dcc68f0f85
test: we will not use dev mode for testing for now
2017-05-31 11:34:00 +02:00
Frank Schroeder
f89ae9f7e7
test: stagger retry attempts of TestAgent.Start
2017-05-31 11:33:25 +02:00
Frank Schroeder
bdfed817ee
test: make TestAgent setup reusable
...
Pick the random ports only once and try starting with them
a number of times so that the configuration can be re-used.
This is because the ports are written into the data files
and a subsequent agent reading the files needs to have the
same ports.
For the same reason we do not remove the data directory on
every attempt since this makes it impossible to re-read the
data files.
2017-05-31 11:32:31 +02:00
Frank Schroeder
4034d0ac0b
agent: use agent logger for consul client and deps
2017-05-31 11:05:02 +02:00
Frank Schroeder
c1e6a77c75
test: start secondary agents also via TestAgent
2017-05-31 10:56:19 +02:00
Frank Schroeder
a9451d596f
agent: set tcpKeepAliveListener when there is no error
2017-05-31 10:24:32 +02:00
Frank Schroeder
345666bdb6
test: use test name as log prefix
2017-05-31 09:54:09 +02:00
Frank Schroeder
d6c7404b34
agent: simplify shutdown timeout logging
...
Note that we are currently timing out every time. This still
needs to be investigated.
2017-05-31 09:41:58 +02:00
Frank Schroeder
30ba712857
agent: set proto to http since we are logging it now
2017-05-31 09:41:16 +02:00
Frank Schroeder
ceda18366f
test: Use Bool() instead of &BoolTrue/False since
2017-05-31 09:21:01 +02:00
Frank Schroeder
ec729693d7
Address review comments
2017-05-31 01:05:21 +02:00
Frank Schroeder
26200929c1
agent: start HTTPS only if there is a cert and key
2017-05-31 00:29:29 +02:00
Frank Schroeder
b6c69ebf5d
agent: refactor DNS and HTTP server
...
* refactor DNS server to be ready for multiple bind addresses
* drop tcpKeepAliveListener since it is default for the HTTP servers
* add startup timeout watcher for HTTP servers identical to DNS server
2017-05-31 00:29:29 +02:00
Frank Schroeder
aa92adcdd5
test: increase sleep time for test
2017-05-31 00:29:28 +02:00
Frank Schroeder
f498f24032
test: allow tests to control anti-entropy syncs
2017-05-31 00:29:28 +02:00
Frank Schroeder
eea16e1640
test: run mock dns recursors on random ports
2017-05-31 00:29:28 +02:00
Frank Schroeder
6148910399
test: skip tests that use cmd.Run until signal handling is fixed
2017-05-31 00:29:28 +02:00
Frank Schroeder
56cf015117
test: add test for starting/stopping lots of agents
2017-05-31 00:29:28 +02:00
Frank Schroeder
7c5892a196
test: use UniqueID prefix for check tests to unify log output
2017-05-31 00:29:28 +02:00
Frank Schroeder
0a31094e06
test: improve TestAgent
...
* don't use retry to try restarting the agent
this caused some issues when the startup would fail in
a separate go routine
* clear out the data directory on every retry since the ports
are stored in the raft data files
* set a unique id for every agent to allow for tracking of
concurrent output
2017-05-31 00:29:28 +02:00
Frank Schroeder
10540f8d5f
agent: fix logging
...
* use agent logger for consul/serf/raft/dns/agent/...
* support optional id for concurrent tests
2017-05-31 00:29:27 +02:00
Frank Schroeder
fe777852cd
test: call t.Fatal() from main go routine
2017-05-31 00:29:27 +02:00
Frank Schroeder
3e39f04527
dns: do not log socket close during shutdown
2017-05-31 00:29:27 +02:00
Frank Schroeder
1df74e36bd
agent: print more useful shutdown message
2017-05-31 00:29:27 +02:00
Frank Schroeder
2e14c09447
test: start sync after agent start
2017-05-31 00:29:27 +02:00
Frank Schroeder
5b5566d916
test: add test name to output
2017-05-31 00:29:27 +02:00
Frank Schroeder
28ed8f1847
test: perform blocking query on agent
2017-05-31 00:29:27 +02:00
Frank Schroeder
ebc0c80f08
test: parallelize dns test
2017-05-31 00:29:26 +02:00
Frank Schroeder
c5f565ee1a
test: remove output to stdout
2017-05-31 00:29:26 +02:00
Frank Schroeder
8f943542b0
test: use cli.NewMockUi instead of new(cli.MockUi)
...
Use the constructor function to prevent a nil panic
if there was no write to the output buffers.
2017-05-31 00:29:26 +02:00
Frank Schroeder
0325a42089
test: fix data race with endpoints
2017-05-31 00:29:26 +02:00
Frank Schroeder
e16589c079
agent: shutdown delegate if created
...
When the TestAgent shuts down a half-started agent
the delegate may not have been created at this point.
2017-05-31 00:29:26 +02:00
Frank Schroeder
632f837c98
agent: shutdown dns servers on error
2017-05-31 00:29:26 +02:00
Frank Schroeder
8c1a668481
test: Shutdown half-started agent before retrying
2017-05-31 00:29:25 +02:00
Frank Schroeder
584693482d
test: fix data race in MockNotify
...
42 -> 32 data races
2017-05-31 00:29:25 +02:00
Frank Schroeder
3658d4d428
test: address pull request comments
2017-05-31 00:29:25 +02:00
Frank Schroeder
0f912c8aad
test: remove ACL options from default test config
2017-05-31 00:29:25 +02:00
Frank Schroeder
bc47972696
test: allocate ports in blocks of 10
2017-05-31 00:29:24 +02:00
Frank Schroeder
53c1c86ab3
test: refactor command tests to use TestAgent
2017-05-31 00:29:24 +02:00
Frank Schroeder
24eec373de
test: retry a bit more often
2017-05-31 00:29:24 +02:00
Frank Schroeder
659d7dbbde
agent: rename *Config vars to 'cfg'
2017-05-31 00:29:24 +02:00
Frank Schroeder
e86d34685f
agent: rename *Command vars to 'cmd'
...
'c' is ambigious and it conflicts with 'config'.
2017-05-31 00:29:24 +02:00
Frank Schroeder
141efd9588
test: rename *Config vars to 'cfg'
...
'c' is ambigous since Command also uses this
and we want to use 'config' as a package name.
2017-05-31 00:29:24 +02:00
Frank Schroeder
06677708cf
test: use less aggressive retry for agent startup
2017-05-31 00:29:24 +02:00
Frank Schroeder
47501309ae
test: use system temp dir for TestAgent
2017-05-31 00:29:24 +02:00
Frank Schroeder
0c905a0df8
test: a.config -> a.Config
2017-05-31 00:29:23 +02:00
Frank Schroeder
0be63d7060
test: refactor httpTest with TestAgent
2017-05-31 00:29:23 +02:00
Frank Schroeder
308f9929b3
test: run agent tests in parallel
...
This brings down the test run from 108 sec to 15 sec.
There is an occasional port conflict because of the nature
the next port is chosen. So far it seems rare enough to live
with it.
2017-05-31 00:29:23 +02:00
Frank Schroeder
23a6ff383c
agent: refactor tests for TestAgent
...
Refactored tests that use
* makeAgentXXX
* makeDNSServerXXX
* makeHTTPServerXXX
2017-05-31 00:29:23 +02:00
Frank Schroeder
b5b3aa1376
agent: add TestAgent to replace other mechanisms
...
TestAgent will replace the following mechanisms to
start test agents in subsequent requests:
* makeAgentXXX
* makeDNSServerXXX
* makeHTTPServerXXX
* testServer
* httpTest
2017-05-31 00:29:23 +02:00
Frank Schroeder
3865f14a25
agent: simplify agent creation
...
This patch creates an agent with just a config struct
and allows for other fields to be set as required.
2017-05-31 00:29:23 +02:00
Frank Schroeder
82650f73e3
agent: move http/dns endpoints into agent
...
Move the HTTP and DNS endpoints into the agent and control
their lifespan via the agent.
This removes the requirement to manage HTTP and DNS servers
indpendent of the agent since the agent is mostly useless
without an endpoint and the endpoints without the agent.
2017-05-31 00:29:23 +02:00
Frank Schroeder
74be791f9b
agent: fix comment
2017-05-31 00:29:22 +02:00
Frank Schroeder
b42916e1ff
agent: simplify socket address helper
2017-05-31 00:29:22 +02:00