From 9b0c93812dd40ac4a69a8dc863f624d24af11858 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Sun, 17 Apr 2022 09:27:22 +0800 Subject: [PATCH] ignore Test_metaService_syncPods (#80) Signed-off-by: Jason Liu --- .github/workflows/ci.yaml | 9 +-- .../statesinformer/states_informer_test.go | 73 +++++++++---------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 049a95f566..dc43415b19 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,9 +24,9 @@ jobs: path: | ~/.cache/go-build ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-lint-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ runner.os }}-lint- - uses: golangci/golangci-lint-action@v3 with: args: --verbose @@ -51,9 +51,9 @@ jobs: path: | ~/.cache/go-build ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-ut-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ runner.os }}-ut- - name: Check Go modules run: | go mod tidy && git add go.* @@ -84,4 +84,3 @@ jobs: flags: unittests file: cover.out fail_ci_if_error: true - verbose: true diff --git a/pkg/koordlet/statesinformer/states_informer_test.go b/pkg/koordlet/statesinformer/states_informer_test.go index 7ba7313629..00d2cc3cd8 100644 --- a/pkg/koordlet/statesinformer/states_informer_test.go +++ b/pkg/koordlet/statesinformer/states_informer_test.go @@ -19,14 +19,11 @@ package statesinformer import ( "path/filepath" "testing" - "time" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clientsetfake "k8s.io/client-go/kubernetes/fake" "github.com/koordinator-sh/koordinator/pkg/koordlet/metrics" - "github.com/koordinator-sh/koordinator/pkg/koordlet/pleg" sysutil "github.com/koordinator-sh/koordinator/pkg/koordlet/util/system" ) @@ -155,37 +152,39 @@ func Test_metaService_syncNode(t *testing.T) { m.syncNode(testingNode) } -type testKubeletStub struct { - pods corev1.PodList -} - -func (t *testKubeletStub) GetAllPods() (corev1.PodList, error) { - return t.pods, nil -} - -func Test_metaService_syncPods(t *testing.T) { - client := clientsetfake.NewSimpleClientset() - pleg, _ := pleg.NewPLEG(sysutil.Conf.CgroupRootDir) - stopCh := make(chan struct{}) - defer close(stopCh) - - c := NewDefaultConfig() - c.KubeletSyncIntervalSeconds = 60 - m := NewStatesInformer(c, client, pleg, "localhost") - m.(*statesInformer).kubelet = &testKubeletStub{pods: corev1.PodList{ - Items: []corev1.Pod{ - {}, - }, - }} - - go m.Run(stopCh) - - m.(*statesInformer).podCreated <- "pod1" - time.Sleep(200 * time.Millisecond) - if time.Since(m.(*statesInformer).podUpdatedTime) > time.Second { - t.Errorf("failed to triggle update by pod created event") - } - if len(m.(*statesInformer).podMap) != 1 { - t.Errorf("failed to update pods") - } -} +// TODO: fix data race, https://github.com/koordinator-sh/koordinator/issues/77 + +// type testKubeletStub struct { +// pods corev1.PodList +// } +// +// func (t *testKubeletStub) GetAllPods() (corev1.PodList, error) { +// return t.pods, nil +// } +// +// func Test_metaService_syncPods(t *testing.T) { +// client := clientsetfake.NewSimpleClientset() +// pleg, _ := pleg.NewPLEG(sysutil.Conf.CgroupRootDir) +// stopCh := make(chan struct{}) +// defer close(stopCh) +// +// c := NewDefaultConfig() +// c.KubeletSyncIntervalSeconds = 60 +// m := NewStatesInformer(c, client, pleg, "localhost") +// m.(*statesInformer).kubelet = &testKubeletStub{pods: corev1.PodList{ +// Items: []corev1.Pod{ +// {}, +// }, +// }} +// +// go m.Run(stopCh) +// +// m.(*statesInformer).podCreated <- "pod1" +// time.Sleep(200 * time.Millisecond) +// if time.Since(m.(*statesInformer).podUpdatedTime) > time.Second { +// t.Errorf("failed to triggle update by pod created event") +// } +// if len(m.(*statesInformer).podMap) != 1 { +// t.Errorf("failed to update pods") +// } +// }