Auto-update dependencies (#156)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign n3wscott
This commit is contained in:
Matt Moore 2019-12-10 09:34:47 -08:00 committed by Knative Prow Robot
parent efe31127a8
commit da0344692b
11 changed files with 39 additions and 118 deletions

8
Gopkg.lock generated
View File

@ -931,7 +931,7 @@
[[projects]]
branch = "master"
digest = "1:925edc3f3c4fee0b52a097616ecead6ed222d43f07d32c254cc5789c8419abe1"
digest = "1:03e006a3d8b27f80596aef6ada367d5b08257d380fd7707cf5dfb28a12ffefee"
name = "knative.dev/pkg"
packages = [
"apis",
@ -950,18 +950,18 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "731f943e4f3d47632380d980bef53a4baeaccd29"
revision = "9681cde37b185d133b618e6e09dc30f559cbed45"
[[projects]]
branch = "master"
digest = "1:052dcbb5c89b1843e0f5130dc9a0e815a89079c0329bc93c86f7d8c8569b8132"
digest = "1:c20a6bc69c6e4299afa4e4cb6016451fc751c5bb14025a271f3436f212ae73f7"
name = "knative.dev/test-infra"
packages = [
"scripts",
"tools/dep-collector",
]
pruneopts = "UT"
revision = "f049c1efa7766df2044ccd02310407089a309864"
revision = "32d84d399e44c68470d2703a6de633ab0a826d49"
[[projects]]
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"

View File

@ -64,5 +64,7 @@ var (
"knative.dev/serving/autoscaler/panic_mode",
"knative.dev/internal/serving/revision/request_count",
"knative.dev/internal/serving/revision/request_latencies",
"knative.dev/internal/serving/controller/cert_expiration_durations",
"knative.dev/internal/serving/controller/cert_total_num",
)
)

View File

@ -22,7 +22,6 @@ You can use the test library in this dir to:
- [Use common test flags](#use-common-test-flags)
- [Output logs](#output-logs)
- [Emit metrics](#emit-metrics)
- [Ensure test cleanup](#ensure-test-cleanup)
### Use common test flags
@ -62,57 +61,6 @@ _, err = pkgTest.WaitForEndpointState(
_See [logging.go](./logging/logging.go)._
### Emit metrics
You can emit metrics from your tests using
[the opencensus library](https://github.com/census-instrumentation/opencensus-go),
which
[is being used inside Knative as well](https://github.com/knative/serving/blob/master/docs/telemetry.md).
These metrics will be emitted by the test if the test is run with
[the `--emitmetrics` option](#metrics-flag).
You can record arbitrary metrics with
[`stats.Record`](https://github.com/census-instrumentation/opencensus-go#stats)
or measure latency by creating a instance of
[`trace.Span`](https://github.com/census-instrumentation/opencensus-go#traces)
by using the helper method [`logging.GetEmitableSpan()`](../logging/logger.go)
```go
span := logging.GetEmitableSpan(context.Background(), "MyMetric")
```
- These traces will be emitted automatically by
[the generic crd polling functions](#check-knative-serving-resources).
- The traces are emitted by [a custom metric exporter](./logging/logging.go)
that uses the global logger instance.
#### Metric format
When a `trace` metric is emitted, the format is
`metric <name> <startTime> <endTime> <duration>`. The name of the metric is
arbitrary and can be any string. The values are:
- `metric` - Indicates this log is a metric
- `<name>` - Arbitrary string identifying the metric
- `<startTime>` - Unix time in nanoseconds when measurement started
- `<endTime>` - Unix time in nanoseconds when measurement ended
- `<duration>` - The difference in ms between the startTime and endTime
For example:
```bash
metric WaitForConfigurationState/prodxiparjxt/ConfigurationUpdatedWithRevision 1529980772357637397 1529980772431586609 73.949212ms
```
_The [`Wait` methods](#check-knative-serving-resources) (which poll resources)
will prefix the metric names with the name of the function, and if applicable,
the name of the resource, separated by `/`. In the example above,
`WaitForConfigurationState` is the name of the function, and `prodxiparjxt` is
the name of the configuration resource being polled.
`ConfigurationUpdatedWithRevision` is the string passed to
`WaitForConfigurationState` by the caller to identify what state is being polled
for._
### Check Knative Serving resources
_WARNING: this code also exists in
@ -147,9 +95,6 @@ err := test.WaitForConfigurationState(
}, "ConfigurationUpdatedWithRevision")
```
_[Metrics will be emitted](#emit-metrics) for these `Wait` method tracking how
long test poll for._
_See [kube_checks.go](./kube_checks.go)._
### Ensure test cleanup
@ -176,7 +121,6 @@ Tests importing [`knative.dev/pkg/test`](#test-library) recognize these flags:
- [`--cluster`](#specifying-cluster)
- [`--namespace`](#specifying-namespace)
- [`--logverbose`](#output-verbose-logs)
- [`--emitmetrics`](#metrics-flag)
### Specifying kubeconfig
@ -234,22 +178,6 @@ The `--logverbose` argument lets you see verbose test logs and k8s logs.
go test ./test --logverbose
```
### Metrics flag
Running tests with the `--emitmetrics` argument will cause latency metrics to be
emitted by the tests.
```bash
go test ./test --emitmetrics
```
- To add additional metrics to a test, see
[emitting metrics](https://github.com/knative/pkg/tree/master/test#emit-metrics).
- For more info on the format of the metrics, see
[metric format](https://github.com/knative/pkg/tree/master/test#emit-metrics).
[minikube]: https://kubernetes.io/docs/setup/minikube/
---
Except as otherwise noted, the content of this page is licensed under the

View File

@ -35,9 +35,6 @@ import (
)
const (
// e2eMetricExporter is the name for the metrics exporter logger
e2eMetricExporter = "e2e-metrics"
// The recommended default log level https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md
klogDefaultLogLevel = "2"
)
@ -57,7 +54,6 @@ type EnvironmentFlags struct {
Namespace string // K8s namespace (blank by default, to be overwritten by test suite)
IngressEndpoint string // Host to use for ingress endpoint
LogVerbose bool // Enable verbose logging
EmitMetrics bool // Emit metrics
ImageTemplate string // Template to build the image reference (defaults to {{.Repository}}/{{.Name}}:{{.Tag}})
DockerRepo string // Docker repo (defaults to $KO_DOCKER_REPO)
Tag string // Tag for test images
@ -84,9 +80,6 @@ func initializeFlags() *EnvironmentFlags {
flag.BoolVar(&f.LogVerbose, "logverbose", false,
"Set this flag to true if you would like to see verbose logging.")
flag.BoolVar(&f.EmitMetrics, "emitmetrics", false,
"Set this flag to true if you would like tests to emit metrics, e.g. latency of resources being realized in the system.")
flag.StringVar(&f.ImageTemplate, "imagetemplate", "{{.Repository}}/{{.Name}}:{{.Tag}}",
"Provide a template to generate the reference to an image from the test. Defaults to `{{.Repository}}/{{.Name}}:{{.Tag}}`.")
@ -134,10 +127,6 @@ func SetupLoggingFlags() {
printFlags()
}
logging.InitializeLogger(Flags.LogVerbose)
if Flags.EmitMetrics {
logging.InitializeMetricExporter(e2eMetricExporter)
}
})
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package actions
import (
"fmt"
"log"
"strconv"
@ -39,6 +40,8 @@ const (
projectKey = "E2E:Project"
)
// writeMetadata writes the cluster information to a metadata file defined in the request
// after the cluster operation is finished
func writeMetaData(cluster *container.Cluster, project string) {
// Set up metadata client for saving metadata
c, err := client.NewClient("")
@ -81,14 +84,15 @@ func writeMetaData(cluster *container.Cluster, project string) {
log.Println("Done writing metadata")
}
func Create(o *options.RequestWrapper) {
// Create creates a GKE cluster and configures gcloud after successful GKE create request
func Create(o *options.RequestWrapper) error {
o.Prep()
gkeClient := clm.GKEClient{}
clusterOps := gkeClient.Setup(o.Request)
gkeOps := clusterOps.(*clm.GKECluster)
if err := gkeOps.Acquire(); err != nil || gkeOps.Cluster == nil {
log.Fatalf("failed acquiring GKE cluster: '%v'", err)
return fmt.Errorf("failed acquiring GKE cluster: '%v'", err)
}
// At this point we should have a cluster ready to run test. Need to save
@ -100,9 +104,11 @@ func Create(o *options.RequestWrapper) {
// TODO(chaodaiG): this probably should also be part of clustermanager lib
if out, err := common.StandardExec("gcloud", "beta", "container", "clusters", "get-credentials",
gkeOps.Cluster.Name, "--region", gkeOps.Cluster.Location, "--project", gkeOps.Project); err != nil {
log.Fatalf("Failed connecting to cluster: %q, '%v'", out, err)
return fmt.Errorf("failed connecting to cluster: %q, '%v'", out, err)
}
if out, err := common.StandardExec("gcloud", "config", "set", "project", gkeOps.Project); err != nil {
log.Fatalf("Failed setting gcloud: %q, '%v'", out, err)
return fmt.Errorf("failed setting gcloud: %q, '%v'", out, err)
}
return nil
}

View File

@ -17,13 +17,15 @@ limitations under the License.
package actions
import (
"fmt"
"log"
clm "knative.dev/pkg/testutils/clustermanager/e2e-tests"
"knative.dev/pkg/testutils/clustermanager/prow-cluster-operation/options"
)
func Delete(o *options.RequestWrapper) {
// Delete deletes a GKE cluster
func Delete(o *options.RequestWrapper) error {
o.Request.NeedsCleanup = true
o.Request.SkipCreation = true
@ -31,12 +33,12 @@ func Delete(o *options.RequestWrapper) {
clusterOps := gkeClient.Setup(o.Request)
gkeOps := clusterOps.(*clm.GKECluster)
if err := gkeOps.Acquire(); err != nil || gkeOps.Cluster == nil {
log.Fatalf("Failed identifying cluster for cleanup: '%v'", err)
return fmt.Errorf("failed identifying cluster for cleanup: '%v'", err)
}
log.Printf("Identified project %q and cluster %q for removal", gkeOps.Project, gkeOps.Cluster.Name)
var err error
if err = gkeOps.Delete(); err != nil {
log.Fatalf("Failed deleting cluster: '%v'", err)
return fmt.Errorf("failed deleting cluster: '%v'", err)
}
// TODO: uncomment the lines below when previous Delete command becomes
// async operation
@ -47,4 +49,6 @@ func Delete(o *options.RequestWrapper) {
// if out, err := common.StandardExec("kubectl", "config", "unset", "current-context"); err != nil {
// common.StandardExec("kubectl", "config", "unset", "contexts."+string(out))
// }
return nil
}

View File

@ -20,10 +20,11 @@ import (
"knative.dev/pkg/testutils/clustermanager/prow-cluster-operation/options"
)
func Get(o *options.RequestWrapper) {
// Get gets a GKE cluster
func Get(o *options.RequestWrapper) error {
o.Prep()
o.Request.SkipCreation = true
// Reuse `Create` for getting operation, so that we can reuse the same logic
// such as protected project/cluster etc.
Create(o)
return Create(o)
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package main
import (
"errors"
"flag"
"log"
@ -31,6 +32,8 @@ var (
)
func main() {
var err error
flag.BoolVar(&create, "create", false, "Create cluster")
flag.BoolVar(&delete, "delete", false, "Delete cluster")
flag.BoolVar(&get, "get", false, "Get existing cluster from kubeconfig or gcloud")
@ -42,12 +45,16 @@ func main() {
}
switch {
case create:
actions.Create(o)
err = actions.Create(o)
case delete:
actions.Delete(o)
err = actions.Delete(o)
case get:
actions.Get(o)
err = actions.Get(o)
default:
log.Fatal("Must pass one of --create, --delete, --get")
err = errors.New("Must pass one of --create, --delete, --get")
}
if err != nil {
log.Fatal(err)
}
}

View File

@ -68,9 +68,7 @@ tests to be executed, in the right order (i.e., build, then unit, then
integration tests).
Use the flags `--build-tests`, `--unit-tests` and `--integration-tests` to run a
specific set of tests. The flag `--emit-metrics` is used to emit metrics when
running the tests, and is automatically handled by the default action for
integration tests (see above).
specific set of tests.
To run a specific program as a test, use the `--run-test` flag, and provide the
program as the argument. If arguments are required for the program, pass
@ -167,12 +165,7 @@ This is a helper script for Knative E2E test scripts. To use it:
(or `report_go_test()` if you need a more fine-grained control) and call
`fail_test()` or `success()` if any of them failed. The environment variable
`KO_DOCKER_REPO` and `E2E_PROJECT_ID` will be set according to the test
cluster. You can also use the following boolean (0 is false, 1 is true)
environment variables for the logic:
- `EMIT_METRICS`: true if `--emit-metrics` was passed.
All environment variables above are marked read-only.
cluster.
**Notes:**

View File

@ -81,7 +81,6 @@ function teardown_test_resources() {
function go_test_e2e() {
local test_options=""
local go_options=""
(( EMIT_METRICS )) && test_options="-emitmetrics"
[[ ! " $@" == *" -tags="* ]] && go_options="-tags=e2e"
report_go_test -v -race -count=1 ${go_options} $@ ${test_options}
}
@ -228,7 +227,6 @@ function create_test_cluster() {
echo "Test script is ${E2E_SCRIPT}"
# Set arguments for this script again
local test_cmd_args="--run-tests"
(( EMIT_METRICS )) && test_cmd_args+=" --emit-metrics"
(( SKIP_KNATIVE_SETUP )) && test_cmd_args+=" --skip-knative-setup"
[[ -n "${GCP_PROJECT}" ]] && test_cmd_args+=" --gcp-project ${GCP_PROJECT}"
[[ -n "${E2E_SCRIPT_CUSTOM_FLAGS[@]}" ]] && test_cmd_args+=" ${E2E_SCRIPT_CUSTOM_FLAGS[@]}"
@ -419,7 +417,6 @@ function fail_test() {
}
RUN_TESTS=0
EMIT_METRICS=0
SKIP_KNATIVE_SETUP=0
SKIP_ISTIO_ADDON=0
GCP_PROJECT=""
@ -455,7 +452,6 @@ function initialize() {
# Try parsing flag as a standard one.
case ${parameter} in
--run-tests) RUN_TESTS=1 ;;
--emit-metrics) EMIT_METRICS=1 ;;
--skip-knative-setup) SKIP_KNATIVE_SETUP=1 ;;
--skip-istio-addon) SKIP_ISTIO_ADDON=1 ;;
*)
@ -486,7 +482,6 @@ function initialize() {
(( SKIP_ISTIO_ADDON )) || GKE_ADDONS="--addons=Istio"
readonly RUN_TESTS
readonly EMIT_METRICS
readonly GCP_PROJECT
readonly IS_BOSKOS
readonly EXTRA_CLUSTER_CREATION_FLAGS

View File

@ -269,7 +269,6 @@ function run_integration_tests() {
function default_integration_test_runner() {
local options=""
local failed=0
(( EMIT_METRICS )) && options="--emit-metrics"
for e2e_test in $(find test/ -name e2e-*tests.sh); do
echo "Running integration test ${e2e_test}"
if ! ${e2e_test} ${options}; then
@ -283,7 +282,6 @@ function default_integration_test_runner() {
RUN_BUILD_TESTS=0
RUN_UNIT_TESTS=0
RUN_INTEGRATION_TESTS=0
EMIT_METRICS=0
# Process flags and run tests accordingly.
function main() {
@ -335,7 +333,6 @@ function main() {
--build-tests) RUN_BUILD_TESTS=1 ;;
--unit-tests) RUN_UNIT_TESTS=1 ;;
--integration-tests) RUN_INTEGRATION_TESTS=1 ;;
--emit-metrics) EMIT_METRICS=1 ;;
--all-tests)
RUN_BUILD_TESTS=1
RUN_UNIT_TESTS=1
@ -354,7 +351,6 @@ function main() {
readonly RUN_BUILD_TESTS
readonly RUN_UNIT_TESTS
readonly RUN_INTEGRATION_TESTS
readonly EMIT_METRICS
readonly TEST_TO_RUN
cd ${REPO_ROOT_DIR}