Skip to content

Commit

Permalink
moved the scale activation test to service_options_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasgun committed Sep 2, 2022
1 parent cf89f53 commit a3f9f90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
15 changes: 14 additions & 1 deletion test/e2e/service_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestServiceOptions(t *testing.T) {
assert.NilError(t, it.Teardown())
}()

kubectl := test.NewKubectl(it.Namespace())
//kubectl := test.NewKubectl(it.Namespace())
r := test.NewKnRunResultCollector(t, it)

defer r.DumpIfFailed()
Expand Down Expand Up @@ -231,6 +231,10 @@ func TestServiceOptions(t *testing.T) {
test.ServiceDelete(r, "svc17")
_, err = kubectl.Run("delete", "-n", it.Namespace(), "configmap", "test-cm2")
assert.NilError(t, err)

t.Log("create and validate a service with scale activation")
serviceCreateWithOptions(r, "svc18", "--scale-activation", "2")
validateServiceActivation(r, "svc18", 2)
}

func serviceCreateWithOptions(r *test.KnRunResultCollector, serviceName string, options ...string) {
Expand Down Expand Up @@ -384,3 +388,12 @@ func validateServiceEnvVariables(r *test.KnRunResultCollector, serviceName strin
}
}
}

func validateServiceActivation(r *test.KnRunResultCollector, serviceName string, activation int) {
out := r.KnTest().Kn().Run("service", "describe", serviceName, "-o", "json")
r.AssertNoError(out)
var svc servingv1.Service
json.Unmarshal([]byte(out.Stdout), &svc)
activationStr := strconv.Itoa(activation)
assert.Check(r.T(), svc.Spec.Template.Annotations[autoscaling.ActivationScaleKey] == activationStr)
}
18 changes: 0 additions & 18 deletions test/e2e/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
"testing"

Expand All @@ -32,7 +31,6 @@ import (
"knative.dev/client/pkg/util"
network "knative.dev/networking/pkg/apis/networking"
pkgtest "knative.dev/pkg/test"
"knative.dev/serving/pkg/apis/autoscaling"
"knative.dev/serving/pkg/apis/serving"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
)
Expand Down Expand Up @@ -93,9 +91,6 @@ func TestService(t *testing.T) {

t.Log("create services with volume mounts and subpaths")
serviceCreateWithMount(r)

t.Log("create service with scale activation")
serviceCreateActivation(r, "svc1", 2)
}

func serviceCreatePrivate(r *test.KnRunResultCollector, serviceName string) {
Expand Down Expand Up @@ -279,16 +274,3 @@ func serviceDescribeMount(r *test.KnRunResultCollector, serviceName, hostPath, s
r.T().Log("check volume mount subpath is the same as given")
assert.Equal(r.T(), subPath, volumeMount.SubPath)
}

func serviceCreateActivation(r *test.KnRunResultCollector, serviceName string, activation int) {
out := r.KnTest().Kn().Run("service", "create", serviceName,
"--image", pkgtest.ImagePath("helloworld"), "--scale-activation", strconv.Itoa(activation))
r.AssertNoError(out)
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "service", serviceName, "creating", "namespace", r.KnTest().Kn().Namespace(), "ready"))

out = r.KnTest().Kn().Run("service", "describe", serviceName, "-o", "json")
r.AssertNoError(out)
var svc servingv1.Service
json.Unmarshal([]byte(out.Stdout), &svc)
assert.Check(r.T(), svc.Spec.Template.Annotations[autoscaling.ActivationScaleKey] == "2")
}

0 comments on commit a3f9f90

Please sign in to comment.