Commit Graph

249 Commits

Author SHA1 Message Date
Gareth Smith e7b219a333 Replace ApiServer.PathFinder with ApiServer.Path 2017-12-18 15:06:11 +00:00
Gareth Smith 3f26c08fd0 Replace Etcd.PathFinder with Etcd.Path 2017-12-18 14:41:49 +00:00
k8s-ci-robot 558408ce07
Merge pull request #183 from mengqiy/update_vendor
update vendor
2017-12-15 15:12:30 -08:00
ymqytw d59625a7b9 update vendor 2017-12-15 13:51:41 -08:00
k8s-ci-robot b2eef9aa4a
Merge pull request #181 from mengqiy/kinflate
check in kinflate
2017-12-15 12:32:29 -08:00
Jonathan Berkhahn c8581b7ccd Add framework to init config in a plugin 2017-12-15 12:03:25 -08:00
ymqytw 3f074d06cf create an instance of scheme 2017-12-15 11:42:48 -08:00
ymqytw 0428188ea6 add example 2017-12-15 11:20:37 -08:00
ymqytw 2a68351c95 implement initial kinflate 2017-12-15 11:20:37 -08:00
Gareth Smith 2b25091098 Add examples and more detailed docs
- Mostly documenting properties of APIServer (for the most part Etcd has
  the same properties).
- Adding executable examples, some off which run as additional test
  cases.
2017-12-15 16:19:50 +00:00
Gareth Smith 08cb5b2ee7 Give AddressManager responsibility for its host
You no longer have to pass a hostname to initialise the addressmanager.
The DefaultAddressManager always listens on localhost. If you want to
listen on some other interface, you can use a different AddressManager.
2017-12-15 16:07:24 +00:00
k8s-ci-robot 129504ba58
Merge pull request #178 from totherme/control-pane-process-timeouts
Control pane process timeouts
2017-12-14 20:40:29 -08:00
k8s-ci-robot 0e690228fc
Merge pull request #177 from hoegaarden/zero-conf-structs
Zero conf structs
2017-12-14 16:18:29 -08:00
k8s-ci-robot 9afcb2bc07
Merge pull request #176 from totherme/162-apiserver-sane-default-constructor
162 apiserver sane default constructor
2017-12-14 16:03:29 -08:00
k8s-ci-robot 2e18103b69
Merge pull request #168 from totherme/163-fixtures-sane-0-value-default
Finalize the interface of the Fixtures struct
2017-12-14 15:21:28 -08:00
Gareth Smith 57c5c42731 Backfil tests for apiserver and etcd start timeout 2017-12-14 15:22:31 +00:00
Hannes Hörl 0263f2b034 Return error for timeout on process stop
We now return an error when stopping of a process times out, before that
resulted in a panic. Now a caller of `Stop()` can catch an handle this
error.

Also, the timeouts for stopping and starting a process is now
configurable, for example by:
```
etcd := &test.APIServer{
  StartTimeout: 12 * time.Second,
  StopTimeout: 5 * time.Second,
}
```
2017-12-14 13:55:53 +00:00
Hannes Hörl 108b905a06 Update test to work on multiple systems
Our integrationy unit test now works on expecting of multiple, slightly
different errors -- different systems give slightly different errors.
2017-12-14 10:31:42 +00:00
Hannes Hörl 62adb52ec4 Remove dependencies
As separate commit, to make review easier
2017-12-14 10:02:26 +00:00
Hannes Hörl bb7eaaee6c Remove dependeny on govalidator 2017-12-14 10:00:17 +00:00
Hannes Hörl 8953c28b25 Guard against uninitialized AddressManager
In both Etcd and APIServer we return a descriptive Error when the
`URL()` method is called before `Start()` and thus the AddressManager is
not yet initialized.
2017-12-13 15:00:31 +00:00
Hannes Hörl e926d95717 Remove parallel starting of COntrolPlaneProcesses
Right now the ControlPlane is actually just a thin layer around
APIServer, this is the oly process we care for right now. Now that we
only have one process to start, we can remove the parallel starting
logic.

In case we bring in more processes again this commit can just be reverted.
2017-12-13 14:09:22 +00:00
Hannes Hörl 0df12db242 Move logic out of constructors
We can move all of the logic out of the constructors and psuh them into
`ensureInitialized()` of both APIServer and Etcd.
By doing so, the constructors are actually not needed anymore.

We however kept the constructor for the ControlPlane for convinience.
2017-12-13 13:59:09 +00:00
Hannes Hörl 519293f43b Rename "Fixtures" to "ControlPlane"
Updated all comments and other related occurances.
2017-12-13 13:59:08 +00:00
Hannes Hörl fd43bb888a Return an error when stopping a process fails
When an error occours on `Stop()` of either the APIServer or Etcd, that
error is propagated to the caller.
2017-12-13 13:59:06 +00:00
Hannes Hörl a49601db63 Remove PortFinder, use AddressManager
Nothing uses the PortFinder anymore. We can now remove the PortFinder,
and rename the files to make clear AddressManager is now the thing to
use.
2017-12-13 13:59:04 +00:00
Hannes Hörl 0683d7977a Test APIServer's CertDirManager 2017-12-13 13:59:02 +00:00
Hannes Hörl 0aa877d964 Remove EtcdConfig
Using the AddressManager in Etcd removes the need for EtcdConfig.
2017-12-13 13:58:55 +00:00
Hannes Hörl ffa8ee46e5 Give APIServer constructor sane defaults
The APIServer constructor previously required careful configuration. Now
it takes no arguments, and gives you an APIServer that you can
`.Start()`. If you want to configure it, you still can. For example, you
can set the environment variable `TEST_ASSET_KUBE_APISERVER` to the path
to your apiserver binary, or you can override the PathFinder in go code:

```
myAPIServer := test.NewAPIServer()
myAPIServer.PathFinder = func(_ string) string {
  return "/path/to/my/apiserver/binary"
}
```

Previously the responsibility of choosing a port that the APIServer
could listen on was left to the caller. Now APIServer delegates that
responsibility to an AddressManager. By default you get a random unused
port on localhost. If you want to customize that behaviour, you can
overwrite the AddressManager:

```
myAPIServer := test.NewAPIServer()
myAPIServer.AddressManager = myAddressManager
```

If this is a common request, then in future we might provide some common
custom AddressManagers.
2017-12-12 16:50:23 +00:00
Hannes Hörl 657963b319 Make APIServer manage its own port allocations
This means we will no longer need to pass a free port into the APIServer
constructor.
2017-12-12 15:46:53 +00:00
Hannes Hörl d62ff04228 Move APIServer path logic into Start()
Same as in previous commit for Etcd ( d4e9e90d86 )
2017-12-12 11:11:02 +00:00
Hannes Hörl d4e9e90d86 Move etcd path logic from constructor to Start()
This means that if you want to customize the path to your etcd, instead
of doing `etcd.Path = "/my/path"` you should do:

```
etcd.PathFinder = func(_ string) string {
  return "/my/path"
}
```

The advantage of this is that we move logic out of the constructor, so
we need less crazy dependancy injection logic in our tests, and we get
closer to being able to use the 0-value Etcd struct.
2017-12-11 17:18:25 +00:00
Hannes Hörl 85ac9f5969 Expose APIServers coordinates via APIServerURL()
Instead of exposing client configuration via the Fixtures struct, we now
expose the APIServer's coordinates via a method on Fixtures.
2017-12-11 13:54:52 +00:00
Hannes Hörl 1defd3c52e Make Fixtures constructor take 0 args
This is a natural consequence of cleaning up after the "APIServer is
responsible for Etcd" refactor.
2017-12-11 12:09:27 +00:00
Hannes Hörl fe4e62dc59 Remove EtcdURL from APIServer Config 2017-12-11 12:02:07 +00:00
Hannes Hörl b406414c2a Make ApiServer manage Etcd
Everything now works pretty much like before, so we're not yet feeling a
lot of the benefit. Still to do:

- Remove all vestiges of Etcd config etc from the Fixtures struct
- Remove duplicated config
- Make Fixtures and APIServer constructors take 0 params
2017-12-11 11:55:23 +00:00
Antoine Pelisse 588a6ac821
Merge pull request #166 from totherme/161-etcd-sane-0-value-default
Add a sane default constructor for the Etcd and EtcdConfig structs
2017-12-08 10:28:13 -08:00
Hannes Hörl a86b2f83fe Bugfix for BinPathFinder
We now sanitize the binary names from which we construct environment
variables to query for custom binary paths. This means we can now
customize the apiserver binary path with $TEST_ASSET_KUBE_APISERVER
2017-12-08 16:22:46 +00:00
Hannes Hörl ad04fd8972 Make Fixtures use pathless apiserver constructor
This is motivated by #162, but also involves changing the
NewFixtures(...) constructor which is the entry point to the whole
framework. We're removing the amount of config
you need to make it work, in line with #163.
2017-12-08 16:01:19 +00:00
Hannes Hörl e6b042840b Add APIServer constructor with default binary path 2017-12-08 15:59:49 +00:00
Hannes Hörl 3bdc1f4b9b Add a new default constructor for Etcd
- The default constructor for Etcd uses the DefaultBinPathFinder and the
  default EtcdConfig constructor internally
- The Fixtures still use the old constructor, which means it passes in a
  binary path and an EtcdConfig
2017-12-08 14:32:53 +00:00
Hannes Hörl 84e6727884 Add a default constructor for EtcdConfig 2017-12-08 14:13:56 +00:00
Hannes Hörl 08f495a8ee Add a simple Port Finder 2017-12-08 14:08:38 +00:00
Hannes Hörl a4b6e08b30 Add a simple Binary Path Finder 2017-12-08 10:59:29 +00:00
Antoine Pelisse e8f9c7d73a
Merge pull request #157 from hoegaarden/152-no_special_treatment_for_test_framework
No special treatment for test framework
2017-12-07 11:03:08 -08:00
Hannes Hörl 4d9d2ce534 Check errors even in defer blocks 2017-12-07 16:13:30 +00:00
Hannes Hörl 17daebfb1a Add dependencies
As a separate commit, to make review easier.
2017-12-06 14:46:02 +00:00
Hannes Hörl 5afb9ee6cc Validate configs
Brings in github.com/asaskevich/govalidator
2017-12-06 14:46:02 +00:00
Hannes Hörl 819ad8519f Move logic back into fixtures constructor
- Introduce a type for the fixture process configuration
2017-12-06 14:46:02 +00:00
Hannes Hörl 15d507fc83 Change overrides for test fixture paths
One can override the paths to the binaries (etcd, APIServer) to test
against by setting the environment variables
- TEST_ETCD_BIN
- TEST_APISERVER_BIN
2017-12-06 14:46:02 +00:00