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.hpp>
16 #include <boost/foreach.hpp>
17 #include <boost/tokenizer.hpp>
18 #include <boost/assign/list_of.hpp>
19 using namespace boost::assign;
25 const char response[] =
27 "Content-Type: text/html; charset=UTF-8\n"
28 "Content-Length: 45\n"
31 "<title>Server Status</title>\n"
34 session->
Send(reinterpret_cast<const u_int8_t *>(response),
35 sizeof(response), NULL);
42 const char response[] =
45 session->
Send(reinterpret_cast<const u_int8_t *>(response),
46 sizeof(response), NULL);
66 int stage,
int instNum,
72 LOG(DEBUG,
"Callback Stage " << stage <<
" has no data");
75 LOG(DEBUG,
"Callback Stage " << stage <<
" ctr " << mydata->
ctr);
77 if ((++mydata->
ctr) < 3 ) {
81 HttpRequestTestResp *resp =
new(HttpRequestTestResp);
82 resp->set_name(
"TestName");
84 resp->set_context(sr->
context());
93 HttpRequestTest::HandleRequest()
const{
94 LOG(DEBUG,
"Got HandleRequest! - i32Elem " << i32Elem <<
" descString " << descString <<
" ctx " << context());
112 ps.stages_= list_of(s1)(s2)(s3);
118 VNSwitchRouteReq::HandleRequest()
const{
120 LOG(DEBUG,
"Got HandleRequest! - " <<
121 " startRoutePrefix " << startRoutePrefix <<
122 " endRoutePrefix " << endRoutePrefix <<
123 " numRoutes " << numRoutes <<
126 VNSwitchRouteResp *vsrr =
new VNSwitchRouteResp();
127 vsrr->set_vnSwitchId(100);
130 vector<VNSRoute> lval;
132 vsnr.prefix = 2; vsnr.desc =
"two";
133 lval.push_back(vsnr);
134 vsnr.prefix = 3; vsnr.desc =
"three";
135 lval.push_back(vsnr);
136 vsnr.prefix = 4; vsnr.desc =
"four";
137 lval.push_back(vsnr);
138 vsrr->set_vnRoutes(lval);
145 vsnr.prefix = 0; vsnr.desc =
"zero";
146 vsrr->set_vnMarkerRoute(vsnr);
147 vsrr->set_context(context());
148 if (numRoutes > 5) vsrr->set_more(
true);
152 VNSContainTestResp *vctr =
new VNSContainTestResp();
153 vctr->set_desc(
"The Contained");
155 VNSContained vcd1, vcd2;
157 vcd1.set_magic1(887);
159 vcd2.set_magic1(998);
161 vector<VNSContained> vvcd;
162 vvcd.push_back(vcd1);
163 vvcd.push_back(vcd2);
165 VNSContainer vcr1,vcr2;
167 vcr1.set_vnCon(vcd1);
170 vvcd.push_back(vcd1);
172 vcr2.set_vnCon(vcd2);
176 vector<VNSContainer> vvc;
182 vctr->set_context(context());
183 vctr->set_more(
true);
186 VNSwitchRouteResp *vsrr2 =
new VNSwitchRouteResp();
187 vsrr2->set_vnSwitchId(155);
190 vsnr.prefix = 8; vsnr.desc =
"ate";
191 lval.push_back(vsnr);
192 vsrr2->set_vnRoutes(lval);
193 vsrr2->set_vnMarkerRoute(vsnr);
195 vsrr2->set_context(context());
203 main(
int argc,
char *argv[]) {
209 http.RegisterHandler(
"/server-status",
211 http.RegisterHandler(
"quitquitquit",
213 http.Initialize(8090);
std::vector< int > instances_
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)
EventManager * event_manager()
virtual bool Send(const uint8_t *data, size_t size, size_t *sent)
HttpRequestTestData * HttpRequestTestFactory(int stage)
bool HttpRequestTestCallback(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *dataInAndOut)
std::string context() const
static void ServerShutdown(HttpServer *http, HttpSession *session, const HttpRequest *request)
std::string ResolveCanonicalName()
void HandleRequest(HttpSession *session, const HttpRequest *request)
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())
#define LOG(_Level, _Msg)