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.
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,
}
```
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.
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.
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.
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
- Remove the logic from the constructors
- Have start take a configuration map for the fixture processes
- Move the testing on open ports closer to the actual start
- Store stdout,stderr in private buffers
- Configure the etcURL on construction instead of at start time
- Handle the creation of the temporary directory (for the data
directory) internally
Create a new set of test fixtures by doing:
```
f := test.NewFixtures("/path/to/etcd", "/path/to/apiserver")
```
Before running your integration tests, start all your fixtures:
```
err := f.Start()
Expect(err).NotTo(HaveOccurred())
```
Now that you have started your etcd and apiserver, you'll find the
apiserver listening locally on the default port. When you're done with
your testing, stop and clean up:
```
err := f.Stop()
Expect(err).NotTo(HaveOccurred())
```