forked from hswaw/hscloud
43 lines
804 B
Go
43 lines
804 B
Go
|
package kubenat
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"flag"
|
||
|
"net"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/golang/glog"
|
||
|
)
|
||
|
|
||
|
func TestPodWorker(t *testing.T) {
|
||
|
t.Skip("needs containerd running on host and unhardcoded test data")
|
||
|
flag.Set("logtostderr", "true")
|
||
|
|
||
|
r := &Resolver{
|
||
|
criPath: "/tmp/containerd.sock",
|
||
|
podInfoC: make(chan *podInfoReq),
|
||
|
}
|
||
|
|
||
|
ctx, ctxC := context.WithCancel(context.Background())
|
||
|
defer ctxC()
|
||
|
|
||
|
go func() {
|
||
|
err := r.runPodWorker(ctx)
|
||
|
if err != nil && err != ctx.Err() {
|
||
|
glog.Errorf("runPodWorker: %v", err)
|
||
|
}
|
||
|
}()
|
||
|
|
||
|
res, err := r.getPodInfo(ctx, net.IPv4(10, 10, 26, 23))
|
||
|
if err != nil {
|
||
|
t.Fatalf("got err: %v", err)
|
||
|
}
|
||
|
if res == nil {
|
||
|
t.Fatalf("got nil pod response")
|
||
|
}
|
||
|
|
||
|
if want, got := "matrix", res.namespace; want != got {
|
||
|
t.Errorf("namespace: got %q, wanted %q", want, got)
|
||
|
}
|
||
|
}
|