Commit Graph

3754 Commits

Author SHA1 Message Date
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
Hannes Hörl eee6a20808 Use fakes to get listening URLs for the fixtures 2017-12-06 14:46:02 +00:00
Hannes Hörl de3af899fc Refactor FixtureProcesses
- 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
2017-12-06 14:46:02 +00:00
Hannes Hörl 1513093427 Integrate test framework tests properly
The test framework can now run properly with `go test` and we can remove
- our test wrapper
- special handling of tests for the test framewoek
2017-12-06 14:46:02 +00:00
Hannes Hörl 98faa6a9dc Change handling of default test assets location
If $KUBE_ASSETS_DIR is set, we use that and try to run the binaries from
within that directory.
If it is not set, we try to determine the assets directory as a relative
path to the test suite.
2017-12-06 14:46:02 +00:00
Hannes Hörl 2d275663fe Use the exposed configuration of the fixtures
The fixtures now exposes the URL the API Server is listening on. We can
get this with from `Fixtures.Config.APIServerURL`.

When we start our client program in the test, we pass that API Server
URL in via a command line flag.
2017-12-06 14:46:02 +00:00
Hannes Hörl e8c6a13d49 Configure fixture processes with ports to listen on
- APIServer & Etcd get configured, from the outside, on which ports to
  listen on
- Configuration, the subjects under test might be interested in, is
  exposed by Fixtures.Config

Hint: Before we start any process, we get a random port and check if
that random port is acutally free to bind to. As it takes some time
until we actually start anything, we might run into cases, where another
process binds to that port while we are starting up. Even if we do the
port checking closer to actually binding, we still have the same issue.
For now, however, we take that risk - if we run into problems with that,
we are open to refactor that.
2017-12-06 14:46:02 +00:00
k8s-ci-robot 88e83f4286
Merge pull request #155 from hoegaarden/proper_fake_for_apiserver
Proper fake for apiserver
2017-12-05 13:28:30 -08:00
Antoine Pelisse d56d6ba9a1
Merge pull request #154 from hoegaarden/proper_fake_for_etcd
Proper fake for etcd
2017-12-05 13:23:47 -08:00
Hannes Hörl d9268017e3 Refactor APIServer
- Use a fake certificate directory manager
- Use a simpler CLI Session
2017-12-04 17:43:57 +00:00
Hannes Hörl 1923179219 Use a fake datadir manager in etcd tests 2017-12-04 17:32:03 +00:00
Hannes Hörl 9fa768de26 Refactor Etcd to use a simpler CLI Session
We introduced a SimpleSession interface which allows us to have better
fakes for unit testing. This Session is implemented by *gexec.Session.
2017-12-04 12:19:59 +00:00
Hannes Hörl 84b1e9b91f Rename test suites 2017-12-04 11:32:26 +00:00
k8s-ci-robot 4f1e692bec
Merge pull request #149 from totherme/test-framework
Beginnings of a test framework
2017-11-29 15:29:24 -08:00
Hannes Hörl a304d58fe5 Install ginkgo 2017-11-29 17:22:45 +00:00
Hannes Hörl 4d4026f5b0 Make the framework test bash3 compatible 2017-11-29 16:24:37 +00:00
Hannes Hörl ccb54d246a Make `pre-commit.sh` work with the test framework
Eventually we want our framework to work nicely with just `go test`. To
get there we need to
- inject KUBE_ASSETS_DIR
- make the framework work when run multiple times in parallel (port
  collitions, expose bound ports the the subject under test, ...)

We decided to make sure our tests are run in sequence (and not in
parallel to any other thing using etcd, for that matter) by making this
explicit in the `pre-commit.sh` - for now.

As soon as we are there, we can rollback the change to the
`pre-commit.sh` end have the test framework be tested the same as
everything else.

[#153248975]
2017-11-29 15:20:41 +00:00
Hannes Hörl 849d4f9e39 Switch to repo-global vendoring, move dependencies
Actually now put the dependencies into the global `vendor` direcotry.
2017-11-29 12:34:54 +00:00
Hannes Hörl d89f4c1cee Switch to repo-global vendoring 2017-11-29 12:30:11 +00:00
Hannes Hörl d88f71cc27 Change `.gitignore` strategy
- Use a `.gitignore` local to the test framework
- Remove some local only things (`.idea`) from the `.gitignore` and push
that to `.git/info/exclude`
2017-11-29 12:08:31 +00:00
Hannes Hörl c4e57df807 Create nicer names for temporary directories
[#153246098]
2017-11-29 12:08:31 +00:00
Hannes Hörl b7cfe0f868 Update comments on Start/Stop of the processes
[#153243856]
2017-11-29 12:08:31 +00:00
Gareth Smith ff9f027096 Drop privilages before running tests in CI 2017-11-29 12:08:31 +00:00
Gareth Smith f5b7280242 Make Etcd's DataDirManager interface private 2017-11-29 12:08:31 +00:00
Gareth Smith 7df93be2ab Use a temporary directory for the APIServer's certs
While doing that we found that we needed to refactor the fakes to handle
command line arguments which are not known up front; we do this by using
regular expresseions.
2017-11-29 12:08:31 +00:00
Hannes Hörl 63de385c65 Add test option to run performance tests
Performance tests are now skipped by default, but run in CI.
2017-11-29 12:08:31 +00:00
Gareth Smith 8523ad31f8 Start the fixture processes in parallel 2017-11-29 12:08:31 +00:00
Gareth Smith e2a217b37b Track the time it takes to start&stop the fixtures 2017-11-29 12:08:31 +00:00
Gareth Smith eca5aace13 Add dependencies
As a separate commit, to make review easier.
2017-11-29 12:08:31 +00:00
Gareth Smith 11eab48530 Implement first command talking to the APIServer
We use the standard go client for kubernetes `client-go`. To vendor it
and all its denpendecies we use
```
dep ensure -add k8s.io/client-go@5.0.0
```

We create a new cobra command with
```
cobra add listPods
```
Note: The new command in cmd/listPods.go uses [the "magic" function
init()](https://golang.org/ref/spec#Package_initialization) to register
itself.
2017-11-29 12:08:29 +00:00
Gareth Smith 2e5a83252e Remove {Etcd,APIServer}StartStopper interfaces
... as they have been unified into the FixtureProcess interface and thus
they are not needed anymore.
2017-11-29 12:08:29 +00:00
Gareth Smith d6f4cc6054 Refactor Etcd and APIServer, esp. Start() and Stop()
- Start() should only return when the process is actually up and
  listening
- It may take some time to tear down a process, so we increased the
  timeout for Stop() (to some random number)
- We make sure Std{Out,Err} is properly initialized, we should not rely
  on Ginkgo/Gomega to do that for us
2017-11-29 12:08:29 +00:00
Gareth Smith 5d670c4625 Refactor away anonymous functions in integration test 2017-11-29 12:08:29 +00:00
Hannes Hörl e2f4cd5a53 Allow more time to bring up the fixtures 2017-11-29 12:08:29 +00:00
Gareth Smith d99f3dcd56 Extract TempDirManager
We are now returning an error instead of using an Expectation inline.
2017-11-29 12:08:29 +00:00
Gareth Smith ddd0a5683f Unify fixture processes
Instead of the separate {Etcd,APIServer}StartStopper use the unified
interface FixtureProcess
2017-11-29 12:08:29 +00:00
Gareth Smith 940bec8b1c Refactor APIServer
- Store stdout,stderr in private buffers
- Configure the etcURL on construction instead of at start time
2017-11-29 12:08:29 +00:00
Gareth Smith 2fd15f82f9 Refactor Etcd
- 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
2017-11-29 12:08:29 +00:00
Gareth Smith a04f00234e Rework fakes to allow additional arguments 2017-11-29 12:08:29 +00:00
Gareth Smith e7bb1e8df9 Add fixtures tintegration tests
Testing the lifecycle of our fixtures with the real binaries. Test if we
can start the fixtures, the porcesses actually listen on the ports and
if we tear down all the parts successfully again.
2017-11-29 12:08:29 +00:00
Gareth Smith 8a92d310ba Make Stop() wait for the processes to exit 2017-11-29 12:08:29 +00:00
Hannes Hörl 0dfe20ef49 Use http:// as etcd URL scheme
Using tcp:// does not work.
2017-11-29 12:08:29 +00:00
Hannes Hörl 4e870ff442 Use ioutils.tempDir() to create temporary directories
os.tempDir() gives the path to the temporary directory, it does not
create a random temporary directory.
2017-11-29 12:08:29 +00:00
Hannes Hörl 8988075dad Wire the test framework in to the demo tests
We're not exercising the test framework yet, but it's in place.

Our democli expects its test assets to be in `./assets/bin`. We have a
script `./scripts/download-binaries.sh` which will populate that directory
from a google storage bucket.

Once those assets are in place, you can run tests with
`./scripts/run-tests.sh`.
2017-11-29 12:08:29 +00:00
Gareth Smith 1714b31d49 Add CI for local development
We're using concourse because we happen to have a concourse deployment
available. You can look at it here:

https://wings.concourse.ci/teams/k8s-c10s/
2017-11-29 12:08:29 +00:00
Gareth Smith fc5d4050b1 Add Fixtures struct, which can start+stop everything
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())
```
2017-11-29 12:08:29 +00:00