11 #include "sandesh/request_pipeline.h"
12 #include "http/http_message_test_types.h"
13 #include "http/route_test_types.h"
14 #include "config/uve/virtual_network_types.h"
15 #include <boost/bind/bind.hpp>
16 #include <boost/foreach.hpp>
17 #include <boost/tokenizer.hpp>
18 #include <boost/assign/list_of.hpp>
20 using namespace boost::assign;
22 using namespace boost::placeholders;
27 const char response[] =
29 "Content-Type: text/html; charset=UTF-8\n"
30 "Content-Length: 45\n"
33 "<title>Server Status</title>\n"
36 session->
Send(
reinterpret_cast<const u_int8_t *
>(response),
37 sizeof(response), NULL);
44 const char response[] =
47 session->
Send(
reinterpret_cast<const u_int8_t *
>(response),
48 sizeof(response), NULL);
68 int stage,
int instNum,
74 LOG(DEBUG,
"Callback Stage " << stage <<
" has no data");
77 LOG(DEBUG,
"Callback Stage " << stage <<
" ctr " << mydata->
ctr);
79 if ((++mydata->
ctr) < 3 ) {
83 HttpRequestTestResp *resp =
new(HttpRequestTestResp);
84 resp->set_name(
"TestName");
86 resp->set_context(sr->
context());
95 HttpRequestTest::HandleRequest()
const{
96 LOG(DEBUG,
"Got HandleRequest! - i32Elem " << i32Elem <<
" descString " << descString <<
" ctx " << context());
114 ps.stages_= list_of(s1)(s2)(s3);
120 VNSwitchRouteReq::HandleRequest()
const{
122 LOG(DEBUG,
"Got HandleRequest! - " <<
123 " startRoutePrefix " << startRoutePrefix <<
124 " endRoutePrefix " << endRoutePrefix <<
125 " numRoutes " << numRoutes <<
128 VNSwitchRouteResp *vsrr =
new VNSwitchRouteResp();
129 vsrr->set_vnSwitchId(100);
132 vector<VNSRoute> lval;
134 vsnr.prefix = 2; vsnr.desc =
"two";
135 lval.push_back(vsnr);
136 vsnr.prefix = 3; vsnr.desc =
"three";
137 lval.push_back(vsnr);
138 vsnr.prefix = 4; vsnr.desc =
"four";
139 lval.push_back(vsnr);
140 vsrr->set_vnRoutes(lval);
147 vsnr.prefix = 0; vsnr.desc =
"zero";
148 vsrr->set_vnMarkerRoute(vsnr);
149 vsrr->set_context(context());
150 if (numRoutes > 5) vsrr->set_more(
true);
154 VNSContainTestResp *vctr =
new VNSContainTestResp();
155 vctr->set_desc(
"The Contained");
157 VNSContained vcd1, vcd2;
159 vcd1.set_magic1(887);
161 vcd2.set_magic1(998);
163 vector<VNSContained> vvcd;
164 vvcd.push_back(vcd1);
165 vvcd.push_back(vcd2);
167 VNSContainer vcr1,vcr2;
169 vcr1.set_vnCon(vcd1);
172 vvcd.push_back(vcd1);
174 vcr2.set_vnCon(vcd2);
178 vector<VNSContainer> vvc;
184 vctr->set_context(context());
185 vctr->set_more(
true);
188 VNSwitchRouteResp *vsrr2 =
new VNSwitchRouteResp();
189 vsrr2->set_vnSwitchId(155);
192 vsnr.prefix = 8; vsnr.desc =
"ate";
193 lval.push_back(vsnr);
194 vsrr2->set_vnRoutes(lval);
195 vsrr2->set_vnMarkerRoute(vsnr);
197 vsrr2->set_context(context());
205 main(
int argc,
char *argv[]) {
211 http.RegisterHandler(
"/server-status",
213 http.RegisterHandler(
"quitquitquit",
215 http.Initialize(8090);
std::string ResolveCanonicalName()
std::string context() const
static bool InitGeneratorTest(const std::string &module, const std::string &source, const std::string &node_type, const std::string &instance_id, EventManager *evm, unsigned short http_port, SandeshContext *client_context=NULL, const SandeshConfig &config=SandeshConfig())
static void SetLoggingParams(bool enable_local_log, std::string category, std::string level, bool enable_trace_print=false, bool enable_flow_log=false, bool enable_session_syslog=false)
void HandleRequest(HttpSession *session, const HttpRequest *request)
EventManager * event_manager()
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
bool HttpRequestTestCallback(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *dataInAndOut)
HttpRequestTestData * HttpRequestTestFactory(int stage)
static void ServerShutdown(HttpServer *http, HttpSession *session, const HttpRequest *request)
#define LOG(_Level, _Msg)
std::vector< int > instances_