Skip to content

Commit dcc4fcb

Browse files
committed
test code: klog downgrade to 6 for some cases
1 parent 3ee9532 commit dcc4fcb

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/state_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package state
1818

1919
import (
20+
"flag"
2021
"fmt"
2122
"io/ioutil"
2223
"math"
@@ -28,6 +29,7 @@ import (
2829
"github.com/stretchr/testify/assert"
2930
"github.com/stretchr/testify/require"
3031
"k8s.io/apimachinery/pkg/util/sets"
32+
"k8s.io/klog/v2"
3133
pluginapi "k8s.io/kubelet/pkg/apis/resourceplugin/v1alpha1"
3234
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
3335
testutil "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state/testing"
@@ -1507,6 +1509,11 @@ func TestNewCheckpointState(t *testing.T) {
15071509
func TestClearState(t *testing.T) {
15081510
t.Parallel()
15091511

1512+
flagSet := flag.NewFlagSet("test", flag.ExitOnError)
1513+
klog.InitFlags(flagSet)
1514+
_ = flagSet.Parse([]string{"--v", "6"})
1515+
defer klog.InitFlags(nil)
1516+
15101517
as := require.New(t)
15111518

15121519
testName := "test"

pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package dynamicpolicy
1818

1919
import (
2020
"context"
21+
"flag"
2122
"fmt"
2223
"io/ioutil"
2324
"net"
@@ -2213,6 +2214,11 @@ func TestGenerateResourcesMachineStateFromPodEntries(t *testing.T) {
22132214
func TestHandleAdvisorResp(t *testing.T) {
22142215
t.Parallel()
22152216

2217+
flagSet := flag.NewFlagSet("test", flag.ExitOnError)
2218+
klog.InitFlags(flagSet)
2219+
_ = flagSet.Parse([]string{"--v", "6"})
2220+
defer klog.InitFlags(nil)
2221+
22162222
as := require.New(t)
22172223
cpuTopology, err := machine.GenerateDummyCPUTopology(16, 2, 4)
22182224
as.Nil(err)

pkg/agent/resourcemanager/reporter/cnr/cnrreporter_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package cnr
1919
import (
2020
"context"
2121
"encoding/json"
22+
"flag"
2223
"testing"
2324
"time"
2425

@@ -29,6 +30,7 @@ import (
2930
"k8s.io/apimachinery/pkg/api/resource"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
"k8s.io/apimachinery/pkg/runtime"
33+
"k8s.io/klog/v2"
3234

3335
nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1"
3436
apiconsts "github.com/kubewharf/katalyst-api/pkg/consts"
@@ -521,6 +523,11 @@ func Test_initializeCNRFields(t *testing.T) {
521523
func Test_cnrReporterImpl_Update(t *testing.T) {
522524
t.Parallel()
523525

526+
flagSet := flag.NewFlagSet("test", flag.ExitOnError)
527+
klog.InitFlags(flagSet)
528+
_ = flagSet.Parse([]string{"--v", "6"})
529+
defer klog.InitFlags(nil)
530+
524531
type fields struct {
525532
defaultCNR *nodev1alpha1.CustomNodeResource
526533
}

pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/advisor_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package cpu
1818

1919
import (
2020
"context"
21+
"flag"
2122
"io/ioutil"
2223
"os"
2324
"reflect"
@@ -32,6 +33,7 @@ import (
3233
"k8s.io/apimachinery/pkg/api/resource"
3334
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3435
k8stypes "k8s.io/apimachinery/pkg/types"
36+
"k8s.io/klog/v2"
3537
"k8s.io/kubelet/pkg/apis/resourceplugin/v1alpha1"
3638

3739
configapi "github.com/kubewharf/katalyst-api/pkg/apis/config/v1alpha1"
@@ -134,6 +136,11 @@ func makeContainerInfo(podUID, namespace, podName, containerName, qoSLevel, owne
134136
func TestAdvisorUpdate(t *testing.T) {
135137
t.Parallel()
136138

139+
flagSet := flag.NewFlagSet("test", flag.ExitOnError)
140+
klog.InitFlags(flagSet)
141+
_ = flagSet.Parse([]string{"--v", "6"})
142+
defer klog.InitFlags(nil)
143+
137144
type containerMetricItem struct {
138145
pod string
139146
container string

pkg/agent/sysadvisor/plugin/qosaware/server/cpu_server_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package server
1919
import (
2020
"context"
2121
"encoding/json"
22+
"flag"
2223
"fmt"
2324
"io/ioutil"
2425
"net"
@@ -37,6 +38,7 @@ import (
3738
k8stypes "k8s.io/apimachinery/pkg/types"
3839
"k8s.io/apimachinery/pkg/util/rand"
3940
"k8s.io/apimachinery/pkg/util/sets"
41+
"k8s.io/klog/v2"
4042

4143
"github.com/kubewharf/katalyst-api/pkg/consts"
4244
"github.com/kubewharf/katalyst-core/cmd/katalyst-agent/app/options"
@@ -354,6 +356,11 @@ type ContainerInfo struct {
354356
func TestCPUServerUpdate(t *testing.T) {
355357
t.Parallel()
356358

359+
flagSet := flag.NewFlagSet("test", flag.ExitOnError)
360+
klog.InitFlags(flagSet)
361+
_ = flagSet.Parse([]string{"--v", "6"})
362+
defer klog.InitFlags(nil)
363+
357364
type testCase struct {
358365
name string
359366
provision types.InternalCPUCalculationResult

0 commit comments

Comments
 (0)