Commit Graph

94 Commits

Author SHA1 Message Date
James Phillips 6a6eadd8c7
Adds open source side of network segments (feature is Enterprise-only). 2017-08-30 11:58:29 -07:00
James Phillips 788dd255a1 Adds new config to make script checks opt-in, updates documentation. (#3284) 2017-07-17 11:20:35 -07:00
Frank Schroeder f0f00a1401 api: do not block in waitForLeader since the retry loop is handling this 2017-07-07 09:22:34 +02:00
James Phillips 26c8a9ad4c Adds a temporary band-aid to the API tests.
Once we can run the agent directly in-process with random ports from the kernel,
and the special retry just in memberlist, we shouldn't need this.
2017-07-07 09:22:34 +02:00
Frank Schroeder e203e10031 retry: relax timing for test a bit 2017-07-07 09:22:34 +02:00
Frank Schroeder 0f67ea550e
test: shutdown server properly 2017-05-31 00:29:22 +02:00
Frank Schroeder 111e197462
test: sanitize temp dir names since subtest names have slashes 2017-05-31 00:29:22 +02:00
Frank Schroeder bab25b1c84 test: fix go vet issue 2017-05-12 22:12:47 +02:00
Frank Schroeder afaf4431ee test: bump ReadyTimeout to 10s 2017-05-12 22:12:47 +02:00
Frank Schroeder eedf0f3ac5 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 15590a8446 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
Cyril Gaudin cef53ee906 test: Make testserver start timeout configurable. 2017-05-09 17:48:53 +02:00
James Phillips 6103198732
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
Frank Schroeder 0a7898f039
test: simplify tests that check for peers 2017-05-05 17:07:04 +02:00
Frank Schroeder 16a7b52026
test: Drop WaitForResult from testutil and testrpc 2017-05-05 17:07:03 +02:00
James Phillips 7007c89870
retry: Removes the description parameter. 2017-05-05 17:07:03 +02:00
Frank Schroeder 9f369c93c7
retry: add retry package for retriable tests
The current retry framework in testutil/testprc.WaitForResult uses
a func() (bool, error) callback until it succeeds or times out.
It captures the last error and returns it.

    if err := testutil.WaitForResult(t, func() (bool, error) {
	if err := foo(); err != nil {
	    return false, err
	}
	...
	return true, nil
    }); err != nil {
	t.Fatal(err)
    }

This makes the test functions more complex than they need to be since
both the boolean and the error indicate a success or a failure.

The retry.Run framework uses a an approach similar to t.Run()
from the testing framework.

    retry.Run(t, func(r *retry.R) {
	if err := foo(); err != nil {
	    r.Fatal(err)
	}
    })

The behavior of the Run function is configurable so that different
timeouts can be used for different tests.
2017-05-05 17:07:02 +02:00
Ethan Chu 90b67f115c
Add `AddAccessibleService` to testutil
`AddAccessibleService` works just like `AddService` but also passing
"address" and "port". It is helpfu when you need to prepare a
fakeService that will be accessed later in target source code.
2017-05-01 13:56:48 -07:00
Kyle Havlovitz b5ed2ba536 Add separate option for verifying incoming HTTPS traffic (#2974)
* Add separate option for verifying incoming HTTPS traffic
2017-04-28 16:15:55 -07:00
Frank Schroeder 36380826b0 test: Retry more aggressively 2017-04-27 10:34:30 -07:00
Frank Schroeder 9e2332f6a1 golint: Fix existing comments
This needs more work.
2017-04-25 09:26:13 -07:00
Frank Schroeder 9de4555c0c golint: Untangle if blocks with return in else 2017-04-25 09:26:13 -07:00
Frank Schroeder 8c7bb7b65a golint: Rename fields and structs 2017-04-25 09:26:13 -07:00
Frank Schroeder 9f8f258d4d Remove duplicate constants
This patch removes duplicate internal copies of constants in the structs
package which are also defined in the api package. The api.KVOp type
with all its values for the TXN endpoint and the api.HealthXXX constants
are now used throughout the codebase.

This resulted in some circular dependencies in the testutil package
which have been resolved by copying code and constants and moving the
WaitForLeader function into a separate testrpc package.
2017-04-20 09:54:49 -07:00
Kyle Havlovitz cdd8b5b880
Add tls client options to api/cli 2017-04-14 13:37:29 -07:00
James Phillips 424d70ba5d
Cleans up a stray mark and fixes unit tests.
Ended up removing the leader_test.go server address change test as part
of this. The join was failing becase we were using a new node name with
the new logic here, but realized this was hitting some of the memberlist
conflict logic and not working as we expected. We need some additional
work to fully support address changes, so removed the test for now.
2017-03-27 01:28:54 -07:00
James Phillips c553e1d93a
Changes verson 8 ACLs to opt-out. 2017-03-24 12:12:24 -07:00
James Phillips 4c1d31e934
Fixes test server startup returning wrong error.
Seen in https://travis-ci.org/hashicorp/consul/builds/214521317.
2017-03-23 21:40:14 -07:00
James Phillips 55b4446fbb
Makes WaitForResult always return an error if it times out. 2017-03-23 20:04:39 -07:00
Seth Vargo 6ffb801f1e
Add RPC 2017-03-23 18:41:20 -04:00
Seth Vargo 3077d0f68c
Reduce coupling with testing.T
This reduces the coupling with testing.T, allowing many of the
server's startup-related functions to return an error. This makes them
more re-usable.
2017-03-23 18:41:19 -04:00
Kyle Havlovitz 8130f9b1c1
Cleaned up and reorganized some autopilot-related code 2017-03-09 18:21:40 -08:00
Kyle Havlovitz 01fe3fb399
Fix up command and api tests 2017-02-28 14:12:55 -08:00
Jeff Mitchell 726590367f Update unix dial functions to use DialContext with new go-cleanhttp 2017-02-10 21:11:21 -05:00
James Phillips ae8edf78e9 Drop testutil wait to 2 seconds.
There's likely a race (related to https://github.com/hashicorp/consul/issues/2644) where the catalog update might be in but the leader tracking doesn't report a leader, so this blocks forever and then times out. As a workaround we can lower the query wait time to always allow for a few retries.
2017-02-06 11:52:00 -08:00
James Phillips ba9eb7fcb1
Adds a little wait after we get the event we were seeking. 2017-01-26 22:15:54 -08:00
James Phillips dd9ecbf440
Run the waited-for function before sleeping, and ramp up the sleep exponentially. 2017-01-26 17:11:16 -08:00
James Phillips 0a7aa91607
Drops the unit test wait time back down and turns initial wait into blocking query. 2017-01-26 16:57:44 -08:00
James Phillips ccd0c8e2bf Bumps the wait even more. 2017-01-26 09:15:29 -08:00
James Phillips 0adee272eb Bumps the wait a little more. 2017-01-26 08:20:43 -08:00
James Phillips 2fdcd250f2 Adds more time to WaitForResult.
The last change here made the time overall theoretically the same, but the overhead of running so quickly before probably meant that we were spending longer. Tests seemed marginal in Travis so doubling this to see how things go.
2017-01-26 08:04:48 -08:00
Seth Vargo efc1c8614b
Sleep for longer, but try less often
This fixes an issue where the system can quickly run out of file
descriptors because they are accumulating faster than the kernel can
release them.
2017-01-26 00:13:34 -05:00
Seth Vargo 4742adb36c
Check to see if TaggedAddresses have been populated
This ensures the node's anti-entropy checks have finished before
telling the client Consul is ready.
2017-01-26 00:13:03 -05:00
Seth Vargo 093fb59144 Omit empty node_meta 2017-01-17 20:17:20 -05:00
Kyle Havlovitz b3fdfb09d8
Minor formatting tweaks as a follow-up to #2654 2017-01-17 19:20:29 -05:00
Seth Vargo de0fa1a378 Do not skip tests when Consul is missing
This bit me on CI. The current behavior of the testutil server is to skip if consul isn't present. When lots of output is scrolling by, you're likely to miss the message that the test was skipped. Instead, I propose that we hard fatal if consul doesn't exist, and upstream consumers can skip the tests if they want.
2017-01-17 14:57:57 -05:00
Kyle Havlovitz 15f008b3e3
Update client api and docs for node metadata 2017-01-11 19:28:58 -05:00
Seth Vargo a3cd42bd68
Use a random port instead of idx in testutil
The testutil server uses an atomic incrementer to generate unique port
numbers. This works great until tests are run in parallel, _across
packages_. Because each package starts at the same "offset" idx, they
collide.

One way to overcome this is to run each packages' test in isolation, but
that makes the test suite much longer as it does not maximize
parallelization. Alternatively, instead of having "predictable" ports,
we can let the OS choose a random open port automatically.

This still has a (albeit smaller) race condition in that the OS could
return an open port twice, before the server has a chance to actually
start and occupy said port. In practice, I have not been able to hit
this race condition, so it either doesn't happen or it happens far less
frequently that the existing implementation.

I'm not sure how I feel about the panic, but this is just test code, so
I'm including to say it's okay?
2016-12-01 17:24:26 +02:00
Kyle Havlovitz dd05afb32e Add reload/leave http endpoints (#2516) 2016-11-30 13:29:42 -05:00
Kyle Havlovitz 2d37a07476 Add keyring http endpoints 2016-11-22 20:10:43 -05:00