@@ -5,22 +5,20 @@ package process
5
5
6
6
import (
7
7
"testing"
8
- "time"
9
8
10
9
"github.com/cilium/tetragon/api/v1/tetragon"
11
10
"github.com/cilium/tetragon/pkg/watcher"
12
11
"github.com/stretchr/testify/assert"
13
- "github.com/stretchr/testify/require"
14
12
"google.golang.org/protobuf/proto"
15
13
"google.golang.org/protobuf/types/known/wrapperspb"
16
14
v1 "k8s.io/api/core/v1"
17
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18
- "k8s.io/client-go/kubernetes/fake"
19
16
)
20
17
21
18
func TestK8sWatcher_GetPodInfo (t * testing.T ) {
22
19
controller := true
23
- pod := v1.Pod {
20
+ var pods []interface {}
21
+ pod := & v1.Pod {
24
22
ObjectMeta : metav1.ObjectMeta {
25
23
Name : "test-pod" ,
26
24
Namespace : "kube-system" ,
@@ -48,14 +46,11 @@ func TestK8sWatcher_GetPodInfo(t *testing.T) {
48
46
},
49
47
},
50
48
}
49
+ pods = append (pods , pod )
51
50
52
- k8sClient := fake .NewSimpleClientset (& pod )
53
- k8sWatcher := watcher .NewK8sWatcher (k8sClient , nil , time .Hour )
54
- err := watcher .AddPodInformer (k8sWatcher , true )
55
- require .NoError (t , err )
56
- k8sWatcher .Start ()
51
+ podAccessor := watcher .NewFakeK8sWatcher (pods )
57
52
pid := uint32 (1 )
58
- podInfo := getPodInfo (k8sWatcher , "abcd1234" , "curl" , "cilium.io" , 1 )
53
+ podInfo := getPodInfo (podAccessor , "abcd1234" , "curl" , "cilium.io" , 1 )
59
54
assert .True (t , proto .Equal (podInfo , & tetragon.Pod {
60
55
Namespace : pod .Namespace ,
61
56
Workload : pod .OwnerReferences [0 ].Name ,
0 commit comments