mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 11:18:16 +00:00
Reconfiguring the logging infrastructure with a per-test output file mimicks the behavior of per-test output (log output captured only on failures) while still using the normal logging code, which is important for benchmarking. To enable this behavior, the ARTIFACT env variable must be set.
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
/*
|
|
Copyright 2017 The Kubernetes 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 implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package benchmark
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"k8s.io/component-base/logs"
|
|
logsapi "k8s.io/component-base/logs/api/v1"
|
|
_ "k8s.io/component-base/logs/json/register"
|
|
"k8s.io/kubernetes/test/utils/ktesting"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
// Run with -v=2, this is the default log level in production.
|
|
ktesting.SetDefaultVerbosity(DefaultLoggingVerbosity)
|
|
|
|
// test/integration/framework/flags.go unconditionally initializes the
|
|
// logging flags. That's correct for most tests, but in the
|
|
// scheduler_perf test we want more control over the flags, therefore
|
|
// here strip them out.
|
|
var fs flag.FlagSet
|
|
flag.CommandLine.VisitAll(func(f *flag.Flag) {
|
|
switch f.Name {
|
|
case "log-flush-frequency", "v", "vmodule":
|
|
// These will be added below ourselves, don't copy.
|
|
default:
|
|
fs.Var(f.Value, f.Name, f.Usage)
|
|
}
|
|
})
|
|
flag.CommandLine = &fs
|
|
|
|
flag.Var(LoggingFeatureGate, "feature-gate",
|
|
"A set of key=value pairs that describe feature gates for alpha/experimental features. "+
|
|
"Options are:\n"+strings.Join(LoggingFeatureGate.KnownFeatures(), "\n"))
|
|
|
|
// This would fail if we hadn't removed the logging flags above.
|
|
logsapi.AddGoFlags(LoggingConfig, flag.CommandLine)
|
|
|
|
flag.Parse()
|
|
|
|
logs.InitLogs()
|
|
if err := logsapi.ValidateAndApply(LoggingConfig, LoggingFeatureGate); err != nil {
|
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
m.Run()
|
|
}
|