Commit Graph

110 Commits

Author SHA1 Message Date
Gareth Smith 24e13e5c03 Update and add documentation 2018-01-17 11:12:52 +00:00
Hannes Hörl e97a005ae8 Use internal function to generate Etcd's arguments 2018-01-16 14:22:58 +00:00
Hannes Hörl 7bced00e1f Have the APIServer take a *url.URL to Etcd
Instead of creating, starting and stopping Etcd from within APIServer,
the APIServer now only gets the coordinates of an Etcd handed in.

The setup and wiring of both Etcd and APIServer is implemented in the
ControlPlane.
2018-01-16 14:09:09 +00:00
Gareth Smith ca719c861d Remove obsolete tests, examples & fakes 2018-01-15 17:18:52 +00:00
Gareth Smith 01c1b7e190 Remove Start/Stop funcs in favour of methods 2018-01-15 17:18:52 +00:00
Gareth Smith 5f60d519e9 Make the start message a member of the ProcessState 2018-01-15 17:18:52 +00:00
Gareth Smith 29f17a4569 Introduce DefaultedProcessInput
This intermediate structure can be constructed without reference to
external URLs.
2018-01-15 17:18:52 +00:00
Hannes Hörl 2c1fea7616 Make Start/Stop methods of ProcessState 2018-01-15 17:18:52 +00:00
Hannes Hörl ba978619bc Move session to the ProcessState 2018-01-15 17:18:52 +00:00
Hannes Hörl 57dae09fc2 Test NewProcessState() function
... with some integrationy unit tests
2018-01-15 17:18:52 +00:00
Hannes Hörl 44fd7ffa55 Test Stop() function
... with some integrationy unit tests
2018-01-15 17:18:52 +00:00
Hannes Hörl 9ff0bc948a Test Start() function
... with some integrationy unit tests
2018-01-15 17:18:52 +00:00
Hannes Hörl 9990f29acd Rename CommonStuff to ProcessState 2018-01-15 17:18:52 +00:00
Hannes Hörl 4022e2b56f Convert methods to functions and remove Process{} 2018-01-15 17:18:52 +00:00
Gareth Smith ae971bb91e Deduplicate methods in Etcd & APIServer 2018-01-15 17:18:52 +00:00
Gareth Smith 12403c5eaf Simplify and clean more 2018-01-15 17:18:51 +00:00
Gareth Smith 284bf217da Ignore unit tests, simplify interfaces 2018-01-15 17:18:51 +00:00
Hannes Hörl 10ba636acd We no longer need Buffer() on APIServer or Etcd 2018-01-08 12:22:11 +00:00
Hannes Hörl a6eb5bc2f5 We no-longer need Exit() on APIServer or Etcd 2018-01-08 12:22:11 +00:00
Hannes Hörl 4e6d80ef73 Rename Directory to CleanableDirectory
... and refactor Etcd tests for the Etcd's data directory
2018-01-08 12:22:11 +00:00
Hannes Hörl b786202c38 Move AddressManager to an internal package 2018-01-08 12:22:11 +00:00
Hannes Hörl 40566a76e1 Hide the BinPathFinder in our internal package 2018-01-08 10:58:34 +00:00
Hannes Hörl 58961be445 Make go fmt happy 2018-01-07 12:40:02 +00:00
Hannes Hörl 6b036f740a Use Address instead of AddressManager for the APIServer 2018-01-05 16:34:47 +00:00
Hannes Hörl 32821b2077 Simplify Address handling for Etcd
For Etcd, make the address it should listen on configurable via
```
ectd := &Etcd{
  Address: &url.URL{Scheme: "http", Host: "localhost:12345"},
}
```

If not specified, it will internally use the `DefaultAddressManager` do
find a free port to listen on.
2018-01-05 13:25:54 +00:00
Hannes Hörl f370ccb496 Remove `TempDirManager` 2018-01-05 13:24:46 +00:00
Gareth Smith f5262c2954 Use new Directory management mechanism in Etcd
Instead of the `DataDirManager`...
2018-01-05 10:36:23 +00:00
Gareth Smith 4f380559fe Rename `CertDir` to `Directory` 2018-01-05 10:33:42 +00:00
Gareth Smith 3dcb758f8e Use `CertDir` instead of `CertDirManager` in APIServer
To make our framework easier to use, we now use a `CertDir` struct
instead of the `CertDirManager` to create and destroy (potentially
temporary) directories.

This `CertDir` holds either one of or both a path to a dir (as string)
and a function which can clean up the directory. In the default case a
temporary directory is created and cleaned up. For any other use case
users can just specify the path to an existing directory or override the
cleanup function.
2018-01-05 09:54:50 +00:00
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
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
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 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