```bash
➜ client git:(issue309) ✗ ./kn lol
Manage your Knative building blocks:
* Serving: Manage your services and release new software to them.
* Eventing: Manage event subscriptions and channels. Connect up event sources.
Usage:
...
Use "kn [command] --help" for more information about a command.
unknown sub-command or plugin "lol" for "kn"
```
* feature(testing): Introduce a Mock implementation for KnClient
Commands must only use the `KnClient` API and their unit tests should also
only use a mock implementation for this interface.
This commit introduces such a Mock implementation and works like in
the example below for creating a simple service in a synchronous
way
```
// New mock client
client := knclient.NewMockKnClient(t)
// Recording:
r := client.Recorder()
// Check for existing service --> no
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
// Create service (don't validate given service --> "Any()" arg is allowed)
r.CreateService(knclient.Any(), nil)
// Wait for service to become ready
r.WaitForService("foo", knclient.Any(), nil)
// Get for showing the URL
r.GetService("foo", getServiceWithUrl("foo", "http://foo.example.com"), nil)
// Testing:
output, err := executeCommand(client, "create", "foo", "--image", "gcr.io/foo/bar:baz")
assert.NilError(t, err)
assert.Assert(t, util.ContainsAll(output, "created", "foo", "http://foo.example.com", "Waiting"))
// Validate that all recorded API methods have been called
r.Validate()
```
Such tests have three phases:
* A recording phase where the mock client is prepared. In this phase a
recorder is called with the expected arguments and the return values
it can return. The arguments can be also functions with
signature `func (t *testing.T, actual interface{}, expected interface{})`
and will be called to verify a given argument. Such a function should
`t.Fail()` on its own if the validation fails.
A convenient `Any()` method is added to allow no validation on an argument
(see example below).
Method can be called multiple times, but the order needs to reflect
the actual calling order
* A playback phase where the test executed which in turn calls out to the
Mocks
* A validation phase to check the expected output. The recorder can be
also validated to verify that all recorded mock calls has been
used during the test.
See `service_create_mock_test.go` for a full example.
* chore: Test the mock client
* chore: Minor fixes
* chore: Cosmetic fixes
* Restructure E2E test suite
* move out more tests from the basic workflow and put them in separate
files, including tests for routes
* rename revision_workflow_test.go to revision_test.go
* Run all tests in parallel
When no current namespace is set in the config file, then using `kn` without -n fails:
```
invalid configuration: no configuration has been provided
```
Instead of failing in this case, assume the default namespace "namespace"
This version contains the following:
1. wraps the main root Kn command to support plugin
2. plugins are any executable in kn's config new pluginDir
variable which defaults to $PATH
3. plugins must have name kn-*
4. 'kn plugin list' sub-command to list found kn plugins
5. skips any kn plugins found with name that match core
commands, e.g., kn-service would be ignored
6. can execute any valid kn plugins found, e.g.,
`kn valid` where the plugin file `kn-valid` is in path
specified in 2.
7. unit tests (using gotest.tools)
And is missing:
1. integration tests
2. plugin install command
3. plugin repository command
4. plugin / Knative server version negotiation
5. anything else we agree on in plugin req doc
I plan to create issues for the things missing so we don't
end up with an even bigger PR. It's already big as is but is a
good MVP as per plugins requirement doc.
* test(service): Add e2e tests for min, max scale options
add e2e tests for min, max scale options for `service create` and
`service update` operations.
* Provision in tests for jsonpath to lookup old and new fields
- updates the validation of concurrency limits/targets with upcoming change to `service describe` output
- validation commands now returns specific field in output than returning complete output
- Renames service name used from hello to svc1
- Provision in tests for jsonpath to lookup old and new fields
- Consolidate once used helper method into test itself, as its checking for very specific test-case
* Add E2E tests for Service, revision, route
* service, revision, route describe and describe with print flags
* route list with print flags
* service create for a duplicate service
* Test serviceDeleteNonexistent and fixes
* Validate invalid container concurrency options
* Use assert package
* Use FlagSet.Changed and don't care about default values
* Update dependency
* Follow e2e test changes
* Return error if invalid value is specified by users
* Fix broken e2e test
* Add more unit tests
* Fix error message
* Fix comment statement
* Revert back unrelated changes
* Fix typo
1. refactors basic workflow (move code to common)
2. use different namespace accross test runs to isolate
3. include wait logic in CreateNamespace to allow multiple runs
4. include wait logic in DeleteNamespace to allow multiple runs
This is important since we need more integration tests and some of
these changes should allow `./test/e2e-tests-local.sh` to run on
local clusters (minikube or something other than test-infra) and
correctly behave during mutiple runs.
* chore(revision): Remove bogus log message
This showed up in the test run as single log message so I removed that.
* chore(revision): Revert back to wrong API group in test as its unrelated to this PR
* feature(service): Wait on update for service to become ready.
The behaviour is now the same as for `kn service create`. This should also fix some flakiness in the tests again.
* chore: Fixed changelog
* chore(service): Adapt help message for update
* fix(test): Updated renamed method
* Check that every generated file has been regenerated for CI
* No color when not on a tty which is useful for build logs
* Always do updates when called without args
* Removed -u option and added -c for codegen only (dep update, docs gen, formatting, license check)
* Clean up e2e test assertion
Heavily rely on assert package as well as unit tests
* Iterate over a line for ensuring valid output
* Use subtests for easily spotting the error location
* Add e2e tests for service with concurrency options
Check the behaviour of creating/updating service with concurrency options
* Move tests into separate test file and fix neats
* Use assert package for error check
* Change test function name
* fix(service update): Retry an update in case of a conflict.
Is related to #224 and should fix one flake.
* chore(service): Fixed retry-loop for kn service create/update
* fix(service): Pick up new field Address instead of Domain when listing service
Starting with 0.7.0 old fields are not populated anymore. Let's switch to the new fields then.
This fix should work with 0.6.0, too as the new fields already have been populated back then.
So we can unconditionally pick status.address.url which is accordance with
our policy to support the latest release and the release before.
Fixes#246.
* fix(service list): Use status.URL instead of status.Address in column
* chore: Rebase and update changelog
* chore: Rebase and test fix
* Adds Github issue and pull request templates
We might need to add few labels for knative/client repo as mentioned
in the template.
* Adds nightly build reference and swap client and serving section
* Asks user to paste output of kn version in bug report template
This puts all the console output to the command, where it belongs too.
One could add a ProgressHandler for more fine granular feedback (like suggested in #234) but for now this is not needed.
* fix(serving): Remove hardcoded GVK and look it up from schema
Fixes#133.
* chore(serving): Add test for "WaitForService()"
* refactor(service): Add listRoutes() to client + generic way for list options
* chore(serving): Fixing rebase conflicts
(and gofmt if goimports isn't available)
- Runs goimports on all packages except vendor dir and filter on only *.go files
- Runs gofmt on all dirs except vendor and filters on *.go files, also writes the results instead of printing diff
- Fixes typo s/insteat/insead
- Adds the changes after adding simply code step in hack/build.sh
- Uses source_dir var specifying the dirs to work on
- Combines gofmt commands into single command
* Adds custom comparison for checking multiple substrings
This changeset introduces custom comparison for checking if a target
string has given multiple substrings, namely `ContainsMultipleSubstrings`.
Also removes `commands.TestContains` function and replaces all references
of `commands.TestContains` with `gotest.tools/assert.Check` function and
uses `ContainsMultipleSubstrings` as comparison function.
* Renames and makes the compare function variadic
New name: ContainsAll
New location: pkg/util/compare.go
Also the function now takes target string as first arg,
and accepts any number of substrings to check.
Removed the message arg, the compare function composes the error message.
For eg:
```
Actual output: foo-abcd foo <unknown> 0 OK / 0 <unknown> <unknown>
Missing strings: foo-abcd1, foo1
```
* Adds tests for compare utility ContainsAll
* Update vendor/modules.txt
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.
Added a gotest.tools test for root.go.
* fix(servicing): Fix logic 'service create --force' and some bogus tests
Now a more meaningful error is returned when the user tries to create
a service that already exists. Until know the service is tried
to be created even if the client already knows that it exists.
Also some broken (broken in the sense that the test was nonsense) tests has been fixed.
* chore(serving): Use constant instead of string lateral in test
- Accepts an argument name for listing particular route
- Enables the machine readable output flags
- Updates docs for kn route command group
- Adds unit tests for route command group and route list
- Adds integration tests for route list in basic workflow test
- Updates tests and getting namespace
- Adds more unit tests for code in pkg/kn/commands/route/list_flags.go
- Adds route list command in smoke tests
- Updates vendor/modules.txt
- Clean up imports
- Addresses review comments
- replaces knative to Knative
- uses reflect.DeepEqual for slice comparison
- removes few code comments
- removes irrelevant tests modifications from the PR
* Removes pausing between e2e smoke tests
Removes time.Sleep as by default service create waits for it to
become ready. Also adds a command to create service in --async mode.
* Checks if service create in async mode is ready
also describes the async mode service and finally deletes it