Commit Graph

1349 Commits

Author SHA1 Message Date
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
Frank Schroeder c44e41a741
agent: replace goto with local function 2017-05-31 00:29:22 +02:00
Frank Schroeder 327401e7ee
agent: inline uiDir field
uiDir can be inlined as agent.config.UIDir
2017-05-31 00:29:22 +02:00
Frank Schroeder 8f381d62f6
agent: drop logOutput parameter
agent.logOutput is identical to logOutput
2017-05-31 00:29:22 +02:00
Frank Schroeder c47db2c922
agent: drop config argument
agent.config and config are identical.
2017-05-31 00:29:22 +02:00
Kyle Havlovitz 62f72f104c Add settings for upshifting to encrypted gossip (#3079) 2017-05-30 08:51:37 -07:00
James Phillips 385c9522b3 Removes obsolete agent API documentation. 2017-05-26 10:24:45 -07:00
Frank Schroeder 91c5c9a2d0
doc: update comments and run goimports 2017-05-24 10:20:28 +02:00
Michael Leow deb206b7d7
agent: add RetryJoin support for Azure
Pull #2978 from leowmjw/develop

Resolves #2978
2017-05-24 10:15:38 +02:00
Frank Schroeder 8ad66f4bea
agent: support custom check id and name
This patch adds support for a custom check id and name when
registering a service.

This is achieved by adding a CheckID and a Name field to the
CheckType structure which is used to register checks with a
service and when returning health check definitions.

CheckDefinition is a superset of CheckType which duplicates
some of the fields of CheckType. This patch decouples these
two structures by removing the embedding of CheckType in
CheckDefinition.

Fixes #3047
2017-05-17 20:17:08 +02:00
Frank Schroeder ad40a855bd agent: move isAddrANY to separate package 2017-05-15 22:44:43 +02:00
Frank Schroeder e2c37b47ee agent: Replace client/server with delegate interface
This patch adds a new internal interface clientServer
which defines the common methods of consul.Client and
consul.Server. This allows to replace the following
code

    if a.server != nil {
        a.server.do()
    } else {
        a.client.do()
    }

with

    a.delegate.do()

In case a specific type is required a type check can
be performed:

    if srv, ok := a.delegate.(*consul.Server); ok {
        srv.doSrv()
    }
2017-05-15 18:35:38 +02:00
Frank Schroeder 41f01a0cfc agent: allow "::" as IPv6 bind address
Fixes #2285
2017-05-15 17:51:33 +02:00
Frank Schroeder 65b5c51ec7 test: add helper for ioutil.TempDir/TempFile
This creates a simplified helper for temporary directories and files.
All path names are prefixed with the name of the current test.
All files and directories are stored either in /tmp/consul-test
or /tmp if the former could not be created.

Using the system temp dir breaks some tests on macOS where the unix
socket path becomes too long.
2017-05-12 22:12:47 +02:00
Frank Schroeder 98f6e3b7c5 test: suppress osx firewall warning
macOS displays a firewall warning dialog when an unsigned
application is trying to bind to a non-loopback address.

This patch updates some test configurations to ensure binding
to a loopback address where possible to suppress these warnings.
2017-05-12 22:12:47 +02:00
Frank Schroeder 3522a41bad test: include test name in temp file/dir
This helps identifying hanging tests by looking
at the process list.
2017-05-12 22:12:47 +02:00
Frank Schroeder 914a83cae0 agent: use bind address as src unless INADDR_ANY
Use the bind address as source address for outgoing
RPC connections unless it is INADDR_ANY.

The current code uses the advertise address which will
not work in certain environments where the advertise
address is not routable in the network of the agent,
e.g. NAT environment, container... After all, that is
the purpose of the advertise address.

See #2822
2017-05-11 00:34:14 +02:00
Frank Schroeder e6c6f8cedd agent: use helper for INADDR_ANY 2017-05-11 00:34:14 +02:00
Kyle Havlovitz 5bab68b9bb Add a path for transitioning to TLS on an existing cluster (#3001)
Fixes #1705
2017-05-10 14:25:48 -07:00
Frank Schroeder 6eba69fbfe agent: drop atlas/scada code 2017-05-10 23:06:36 +02:00
Frank Schroeder 5328609d59 test: refactor TestAgent_Leave_ACLDeny to use only one server 2017-05-10 17:42:38 +02:00
Frank Schroeder a60f508880 test: use isPermissionDenied 2017-05-10 17:42:38 +02:00
Frank Schroeder 66bc2cbabc test: replace blocks and comments with sub-tests 2017-05-10 17:42:38 +02:00
Frank Schroeder d711b9bba0 test: inline request body encoding 2017-05-10 17:42:38 +02:00
Frank Schroeder 82cb9c50ad test: add helper for permission denied check 2017-05-10 17:42:38 +02:00
Frank Schroeder 1e89692cc1 test: drop error check on http.NewRequest
Most URLs are static so the error check is redundant.
The subsequent test wouldn't work if the url is wrong.
2017-05-10 17:42:38 +02:00
Frank Schroeder 6fa76fd90f
agent: Disallow :: or [::] as advertise or advertise-wan address 2017-05-09 17:56:16 +02:00
Frank Schroeder 8ad52ee9b5
agent: Disallow :: and [::] as service address 2017-05-09 17:56:15 +02:00
Frank Schroeder e365ef12cf
agent: Disallow 0.0.0.0 as advertise or advertise-wan address
Fixes #2961
2017-05-09 17:56:15 +02:00
Frank Schroeder 73a31b9bfe
agent: Disallow 0.0.0.0 as service address
Fixes #2961
2017-05-09 17:56:15 +02:00
James Phillips 33a7b8e401
Tweaks some tests that were having a hard time in Travis CI and
bumps up the default retry time.
2017-05-09 06:48:26 -07:00
James Phillips efff41a8b2
Updates built-in static assets for web UI. 2017-05-08 19:50:54 -07:00
Frank Schroeder 2794db5aac
test: Fix badly formatted retry.Run tests 2017-05-05 17:07:03 +02:00
James Phillips ddfa57765c
retry: Removes the description parameter. 2017-05-05 17:07:03 +02:00
James Phillips 2de1cd5a4a
test: Turns off ACLs for catalog and health WAN translation tests.
Since this was doing registration to a foreign DC, it needs extra time
for the route to the ACL datacenter to be set up. ACLs aren't part of
this test, so by disabling them we make this more reliable and converge
faster than if we had added a retry.
2017-05-05 17:07:03 +02:00
James Phillips 888fa5cad6
test: Moves a variable closer to where it's used. 2017-05-05 17:07:03 +02:00
James Phillips 0daacfe5e5
test: Turns down server health interval for faster convergence.
This fixes the autopilot tests.
2017-05-05 17:07:02 +02:00
Frank Schroeder 21a82a0a16
test: Refactor WaitForResult tests with retry
Refactor tests that use testutil.WaitForResult to use retry.

Since this requires refactoring the test functions in general this patch
also shows the use of the github.com/pascaldekloe/goe/verify library
which provides a good mechanism for comparing nested data structures.
Instead of just converting the tests from testutil.WaitForResult to
retry the tests that performing a nested comparison of data structures
are converted to the verify library at the same time.
2017-05-05 17:07:02 +02:00
Frank Schroeder 8c2b261c61 Use bind address as source for outgoing connections (#2822)
This patch configures consul to use the bind address as the
source address for outgoing connections.

Fixes #2822
2017-05-04 01:41:47 +02:00
Frank Schroeder fb83790cb9 Do not modify config after creation II
Move code for finding the advertise address via a
template into consulConfig() so that the config
object is not modified after creation.
2017-05-04 01:41:47 +02:00
Frank Schroeder a235986a28 Do not modify config after creation
Make sure the RPCAdvertise address is always set
so that the configuration does not have to be modified
after creation.
2017-05-04 01:41:47 +02:00
Frank Schroeder a226edd4a9 Move GCE discovery code to command/agent/config_gce.go 2017-05-04 01:41:47 +02:00