Commit Graph

886 Commits

Author SHA1 Message Date
k8s-ci-robot 9b8afdfec9
Merge pull request #256 from droot/add-configmap
Add configmap
2018-02-05 20:12:08 -08:00
Sunil Arora 5518d5dfb9 kinflate: adds 'configmap' command
This change contributes configmap command to add a configmap to the
manifest.
2018-02-05 16:20:22 -08:00
Jeffrey Regan f5855945de add setprefixname command 2018-02-05 13:23:11 -08:00
Sunil Arora 2325bb8957 fixed manifest loader test 2018-02-05 10:48:17 -08:00
Antoine Pelisse bbb1fd0b65 kinflate: Create manifest loader
The manifest loader is used to read and write a manifest file to/from
disk.
2018-02-05 10:48:17 -08:00
k8s-ci-robot 1f4c1efbdf
Merge pull request #240 from apelisse/apelisse-droot-seans3
kinflate: Manifest type improvements
2018-02-05 10:28:11 -08:00
k8s-ci-robot d9ff92051a
Merge pull request #251 from hangyan/function-name-typo
Fix typo in function name and comment
2018-02-05 09:37:11 -08:00
Hang Yan fd1e5f18b5 Fix typo in function name and comment 2018-02-05 17:31:54 +08:00
Antoine Pelisse b6e4fe00ee kinflate: Update Manifest type for configmap and secrets
- Generic type is now named DataSources to remove ambiguity,
- NamePrefix is now just Name, since that's what it is,
- Secret have been split in GenericSecret and TLSSecret,

The code, test and examples have been updated to work with these new
types.
2018-02-02 21:31:26 -08:00
Sunil Arora 33bc00af62 Kinflate: added fs as a parameter 2018-02-02 17:02:17 -08:00
Sunil Arora 4a03e39222 Kinflate: refactoring inputs flags forn config/map to common datastructure 2018-02-02 17:02:17 -08:00
ymqytw e5ff878c1e fix a bug of nameprefix lost after applying patch 2018-02-02 16:45:19 -08:00
ymqytw 3d138d072a all Run functions should not depend on Cobra 2018-02-02 13:34:53 -08:00
ymqytw daa4a7f1d2 add a constructor for multitransformer 2018-02-02 09:43:08 -08:00
ymqytw 96624740b2 restructure the code a bit 2018-02-01 17:25:43 -08:00
ymqytw 3f225f926b multitransformer 2018-02-01 17:25:43 -08:00
k8s-ci-robot 6b8558525e
Merge pull request #239 from apelisse/apelisse-droot-seans3
Apelisse droot seans3
2018-01-31 14:40:05 -08:00
Antoine Pelisse 3506c4f9f9 kinflate: Adding configmap/secret cmds examples 2018-01-31 11:45:39 -08:00
Antoine Pelisse b21ff8e2d3 kinflate: Add tests and fix some bugs. 2018-01-31 11:34:54 -08:00
k8s-ci-robot 872d0ab69f
Merge pull request #238 from monopole/simplifyInit
Init writes only a manifest to the current dir.
2018-01-31 10:57:09 -08:00
k8s-ci-robot 0c40ddb53f
Merge pull request #235 from apelisse/kinflate-add-configmap
kinflate: Create AddConfigMap structure
2018-01-31 10:54:11 -08:00
Antoine Pelisse c398a3f462 kinflate: Create AddSecret command
This is empty and does nothing.
2018-01-31 10:21:49 -08:00
Antoine Pelisse 973a56222f kinflate: Create AddConfigMap structure
This is empty and does nothing.
2018-01-31 10:21:49 -08:00
Jeffrey Regan 0e4382bac8 Init writes only a manifest to the current dir. 2018-01-31 09:52:47 -08:00
Jeffrey Regan 79c13c8262 More addresource code 2018-01-30 16:21:28 -08:00
Jeffrey Regan a5ccaf6f6e start addresource command 2018-01-30 14:46:46 -08:00
ymqytw b273a61a86 real kinflate init 2018-01-30 13:08:46 -08:00
Jeffrey Regan d8d9157afc Tweak the fakes, add a test of fake. 2018-01-30 11:24:37 -08:00
ymqytw 8368d2e3ba mock fs and file for testing 2018-01-30 09:59:51 -08:00
Jeffrey Regan eebd1921d8 Add init command. 2018-01-29 15:46:38 -08:00
ymqytw 20faf5d931 delete dead code 2018-01-29 12:56:45 -08:00
ymqytw 333d6e8ddf fix name ref issue 2018-01-26 15:03:01 -08:00
ymqytw 553437f678 update test to ensure each layer of manifest will be applied 2018-01-26 11:40:38 -08:00
ymqytw 154242c1a0 update cm|secret and kinflate 2018-01-26 11:10:10 -08:00
ymqytw adfc372027 rebase kinflate on new utils and remove dead code 2018-01-25 12:02:50 -08:00
ymqytw e0d1ff954c support construct unstructured configmap and secret 2018-01-25 11:25:43 -08:00
ymqytw fc54207123 add util to update name reference 2018-01-24 14:43:56 -08:00
k8s-ci-robot f9dd21c734
Merge pull request #222 from mengqiy/format_nameprefix
fix golink and refactor test
2018-01-24 14:18:39 -08:00
k8s-ci-robot 66eb14fc83
Merge pull request #182 from jberkhahn/plugin_framework
Add framework to init config in a plugin
2018-01-24 13:38:39 -08:00
ymqytw 331dee4a7d fix golink and refactor test 2018-01-23 18:11:54 -08:00
ymqytw 9ab47fd44f add MapTransformer and constructor for labels and annotations 2018-01-23 16:58:01 -08:00
ymqytw eec253d14c fix golint, refactor test 2018-01-23 12:55:52 -08:00
ymqytw 808a43fad6 additional labels and annotations util 2018-01-22 15:50:47 -08:00
ymqytw 28ea59a0ee change transformer interface and pathconfig definition 2018-01-22 09:39:25 -08:00
ymqytw 1c14f2b735 prefix name util 2018-01-19 16:10:02 -08:00
ymqytw a5e7bc08ff encode and decode util 2018-01-19 11:09:44 -08:00
ymqytw 8fb1e1a267 update mutate func 2018-01-19 09:54:34 -08:00
Jonathan Berkhahn 734f4c193c minor fixes to plugin client 2018-01-17 16:38:08 -08:00
Jonathan Berkhahn 7bb3a0b2ea Refactor plugin utils 2018-01-17 13:32:47 -08:00
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 a656304e55 Fix formatting issues as suggested by gofmt 2018-01-15 17:15:58 +00:00
ymqytw bf2ba35a03 more support for configmap and secret 2018-01-10 14:23:07 -08:00
ymqytw 72bee8b87b add one more update helper function 2018-01-10 09:16:25 -08:00
ymqytw 611389d2a0 update helpers 2018-01-09 15:51:49 -08:00
ymqytw 627e10582f move update metadata function 2018-01-09 15:49:31 -08:00
ymqytw 603854a7a6 configmap and secret helper functions 2018-01-09 14:55:16 -08:00
ymqytw 56387b7189 update simple example 2018-01-08 16:53:35 -08:00
k8s-ci-robot 61ee51fef8
Merge pull request #199 from mengqiy/ptv
pod template visitor
2018-01-08 15:46:16 -08:00
k8s-ci-robot 5d2a97840d
Merge pull request #195 from mengqiy/types_comments
format comments for types.go
2018-01-08 15:27:10 -08:00
ymqytw 372384e412 pod template visitor 2018-01-08 14:49:06 -08:00
ymqytw 772e40be49 copy some pkgs for kinflate 2018-01-08 14:16:55 -08:00
k8s-ci-robot 143e500116
Merge pull request #196 from totherme/hide_internals
Hide test framework internals
2018-01-08 09:36:10 -08:00
k8s-ci-robot 6d8a68098e
Merge pull request #194 from hoegaarden/simplify_addr_handling
Simplify address handling
2018-01-08 09:35:11 -08:00
k8s-ci-robot a6e056c00e
Merge pull request #193 from hoegaarden/simplify_dir_handling
Simplify directory handling
2018-01-08 09:34:11 -08: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
ymqytw 5c9c85eed9 format comments for types.go 2018-01-05 16:42:03 -08: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
ymqytw 862066e7fb update manifest types 2018-01-03 13:56:26 -08:00
k8s-ci-robot a2ce8ed844
Merge pull request #184 from totherme/simplify-paths
Integration Framework: Simplify paths
2017-12-18 09:13:34 -08:00
k8s-ci-robot 8d29b4b462
Merge pull request #180 from hoegaarden/examples
Examples
2017-12-18 09:08:34 -08: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
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
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
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
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
Hannes Hörl 4d9d2ce534 Check errors even in defer blocks 2017-12-07 16:13:30 +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
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
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
Hannes Hoerl 677652447e Add etcd launcher to test framework
This can be started and stopped the same way as the apiserver.
2017-11-29 12:08:29 +00:00
Gareth Smith 9d271bf497 Add apiserver launcher to test framework
To start an apiserver:

```
apiServer := APIServer{Path: "/path/to/my/apiserver/binary"}
session, err := apiServer.Start("tcp://whereever.is.my.etcd:port")
Expect(err).NotTo(HaveOccurred())
```

When you're done testing against that apiserver:

```
session.Terminate().Wait()
```

...or if you prefer:

```
gexec.Terminate()
```

...which will terminate not only this apiserver, but also all other
command sessions you started in this test.
2017-11-29 12:08:29 +00:00
Gareth Smith 782bee8a6b Add dependencies
As a separate commit, to make review easier.
2017-11-29 12:08:29 +00:00
Gareth Smith 9096006cb0 Add help text and barebones integration test
We use [ginkgo](http://onsi.github.io/ginkgo/) and
[gomega](http://onsi.github.io/gomega/) for testing. We generate some
boilerplate with:
```
mkdir integration
cd integration
ginkgo bootstrap
ginkgo generate integration
```

We use
[gexec](http://onsi.github.io/gomega/#gexec-testing-external-processes)
to compile and run the CLI under test, and to inspect its output.

We use `dep ensure` to ensure that all our dependencies are properly
vendored. From now on, this will be our workflow with every commit.
2017-11-29 12:08:29 +00:00
Gareth Smith bedfd1e72a Add dependencies
As a separate commit, to make review easier.
2017-11-29 12:08:29 +00:00
Gareth Smith 240dad6009 Add help text and barebones integration test
We use [ginkgo](http://onsi.github.io/ginkgo/) and
[gomega](http://onsi.github.io/gomega/) for testing. We generate some
boilerplate with:
```
mkdir integration
cd integration
ginkgo bootstrap
ginkgo generate integration
```

We use
[gexec](http://onsi.github.io/gomega/#gexec-testing-external-processes)
to compile and run the CLI under test, and to inspect its output.

We use `dep ensure` to ensure that all our dependencies are properly
vendored. From now on, this will be our workflow with every commit.
2017-11-29 12:08:28 +00:00
Antoine Pelisse b4f3d605ca Comment unused function that depends on k8s.io/kubernetes 2017-11-28 14:35:06 -08:00
Jeffrey Regan 4b7a63c631 Tweak pre-commit to ignore vendor directory. 2017-11-20 17:21:59 -08:00
Jeffrey Regan e7cac07c74 Add travis CICD coverage.
Also, rename "kexpand" to "kinflate" to ease pronunciation.
2017-10-24 21:33:30 -07:00
ymqytw 2f2a39a77e kexpand util 2017-10-23 12:43:03 -07:00
Mengqi Yu cf1f7d72ab add types for descriptor and manifest 2017-09-28 22:25:14 +08:00