-
Notifications
You must be signed in to change notification settings - Fork 390
/
agent_stats_collector_test.cc
110 lines (98 loc) · 4.26 KB
/
agent_stats_collector_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#include <db/db.h>
#include <cmn/agent_cmn.h>
#include <oper/interface_common.h>
#include <oper/interface.h>
#include <oper/mirror_table.h>
#include "vr_genetlink.h"
#include "vr_interface.h"
#include "vr_types.h"
#include "nl_util.h"
#include <uve/stats_collector.h>
#include <uve/vn_uve_table.h>
#include <uve/vm_uve_table.h>
#include <init/agent_param.h>
#include <uve/test/agent_stats_collector_test.h>
#include <uve/agent_uve_stats.h>
IoContext *AgentStatsCollectorTest::AllocateIoContext(char* buf, uint32_t buf_len,
StatsType type, uint32_t seq) {
switch (type) {
case InterfaceStatsType:
return (new InterfaceStatsIoContextTest(buf_len, buf, seq,
intf_stats_sandesh_ctx_.get(),
IoContext::UVE_Q_ID));
break;
case VrfStatsType:
return (new VrfStatsIoContextTest(buf_len, buf, seq,
vrf_stats_sandesh_ctx_.get(),
IoContext::UVE_Q_ID));
break;
case DropStatsType:
return (new DropStatsIoContextTest(buf_len, buf, seq,
drop_stats_sandesh_ctx_.get(),
IoContext::UVE_Q_ID));
break;
default:
return NULL;
}
}
void InterfaceStatsIoContextTest::Handler() {
InterfaceStatsIoContext::Handler();
AgentStatsSandeshContext *ctx = static_cast<AgentStatsSandeshContext *>
(ctx_);
AgentStatsCollectorTest *collector = static_cast<AgentStatsCollectorTest *>
(ctx->agent()->stats_collector());
collector->interface_stats_responses_++;
}
void InterfaceStatsIoContextTest::ErrorHandler(int err) {
InterfaceStatsIoContext::ErrorHandler(err);
AgentStatsSandeshContext *ctx = static_cast<AgentStatsSandeshContext *>
(ctx_);
AgentStatsCollectorTest *collector = static_cast<AgentStatsCollectorTest *>
(ctx->agent()->stats_collector());
collector->interface_stats_errors_++;
}
void VrfStatsIoContextTest::Handler() {
VrfStatsIoContext::Handler();
AgentStatsSandeshContext *ctx = static_cast<AgentStatsSandeshContext *>
(ctx_);
AgentStatsCollectorTest *collector = static_cast<AgentStatsCollectorTest *>
(ctx->agent()->stats_collector());
collector->vrf_stats_responses_++;
}
void VrfStatsIoContextTest::ErrorHandler(int err) {
VrfStatsIoContext::ErrorHandler(err);
AgentStatsSandeshContext *ctx = static_cast<AgentStatsSandeshContext *>
(ctx_);
AgentStatsCollectorTest *collector = static_cast<AgentStatsCollectorTest *>
(ctx->agent()->stats_collector());
collector->vrf_stats_errors_++;
}
void DropStatsIoContextTest::Handler() {
DropStatsIoContext::Handler();
AgentStatsSandeshContext *ctx = static_cast<AgentStatsSandeshContext *>
(ctx_);
AgentStatsCollectorTest *collector = static_cast<AgentStatsCollectorTest *>
(ctx->agent()->stats_collector());
collector->drop_stats_responses_++;
}
void DropStatsIoContextTest::ErrorHandler(int err) {
DropStatsIoContext::ErrorHandler(err);
AgentStatsSandeshContext *ctx = static_cast<AgentStatsSandeshContext *>
(ctx_);
AgentStatsCollectorTest *collector = static_cast<AgentStatsCollectorTest *>
(ctx->agent()->stats_collector());
collector->drop_stats_errors_++;
}
void AgentStatsCollectorTest::Test_DeleteVrfStatsEntry(int vrf_id) {
AgentUveStats *uve = static_cast<AgentUveStats *>
(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
StatsManager::VrfIdToVrfStatsTree::iterator it;
it = sm->vrf_stats_tree_.find(vrf_id);
if (it != sm->vrf_stats_tree_.end()) {
sm->vrf_stats_tree_.erase(it);
}
}