diff --git a/test/e2e/service_options_test.go b/test/e2e/service_options_test.go new file mode 100644 index 000000000..7264d1c46 --- /dev/null +++ b/test/e2e/service_options_test.go @@ -0,0 +1,62 @@ +// Copyright 2019 The Knative Authors + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build e2e + +package e2e + +import ( + "fmt" + "testing" + + "github.com/knative/client/pkg/util" + "gotest.tools/assert" +) + +func TestServiceOptions(t *testing.T) { + teardown := Setup(t) + defer teardown(t) + + testServiceCreateWithOptions(t, k, "hello", []string{"--concurrency-limit", "250", "--concurrency-target", "300"}) + testServiceDescribeConcurrencyLimit(t, k, "hello", "250") + testServiceDescribeConcurrencyTarget(t, k, "hello", "300") + testServiceUpdate(t, k, "hello", []string{"--concurrency-limit", "300"}) + testServiceDescribeConcurrencyLimit(t, k, "hello", "300") + testServiceDelete(t, k, "hello") +} + +func testServiceCreateWithOptions(t *testing.T, k kn, serviceName string, options []string) { + command := []string{"service", "create", serviceName, "--image", KnDefaultTestImage} + command = append(command, options...) + out, err := k.RunWithOpts(command, runOpts{NoNamespace: false}) + assert.NilError(t, err) + + assert.Check(t, util.ContainsAll(out, "Service", serviceName, "successfully created in namespace", k.namespace, "OK")) +} + +func testServiceDescribeConcurrencyLimit(t *testing.T, k kn, serviceName, concurrencyLimit string) { + out, err := k.RunWithOpts([]string{"service", "describe", serviceName}, runOpts{NoNamespace: false}) + assert.NilError(t, err) + + expectedOutput := fmt.Sprintf("containerConcurrency: %s", concurrencyLimit) + assert.Check(t, util.ContainsAll(out, expectedOutput)) +} + +func testServiceDescribeConcurrencyTarget(t *testing.T, k kn, serviceName, concurrencyTarget string) { + out, err := k.RunWithOpts([]string{"service", "describe", serviceName}, runOpts{NoNamespace: false}) + assert.NilError(t, err) + + expectedOutput := fmt.Sprintf("autoscaling.knative.dev/target: \"%s\"", concurrencyTarget) + assert.Check(t, util.ContainsAll(out, expectedOutput)) +}