func TestSFlowAgent(t *testing.T) { helper.InitConfig(t, confAgentAnalyzer) router := mux.NewRouter().StrictSlash(true) server, err := analyzer.NewServerFromConfig(router) if err != nil { t.Fatal(err) } ts := NewTestStorage() server.SetStorage(ts) go server.ListenAndServe() defer server.Stop() agent := helper.StartAgent(t) defer agent.Stop() time.Sleep(1 * time.Second) for _, trace := range flowsTraces { fulltrace, _ := filepath.Abs("pcaptraces" + string(filepath.Separator) + trace.filename) helper.ReplayTraceHelper(t, fulltrace, "localhost:55000") /* FIXME (nplanel) remove this Sleep when agent.FlushFlowTable() exist */ time.Sleep(2 * time.Second) ts.Validate(t, &trace) } }
func TestPcap2SflowReplay(t *testing.T) { conn, err := sflowSetup(t) if err != nil { t.Fatal("SFlow setup failed", err.Error()) } defer conn.Close() laddr, err := net.ResolveUDPAddr(conn.LocalAddr().Network(), conn.LocalAddr().String()) if err != nil { t.Error("Can't read back the local address") } for _, trace := range packetsTraces { var wg sync.WaitGroup wg.Add(1) go asyncSflowListen(t, &wg, conn, &trace) fulltrace, _ := filepath.Abs("pcaptraces" + string(filepath.Separator) + trace.filename) helper.ReplayTraceHelper(t, fulltrace, fmt.Sprintf("localhost:%d", laddr.Port)) wg.Wait() } }