1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #ifndef example_diameter_launcher_EventOperation_hpp
10 #define example_diameter_launcher_EventOperation_hpp
18 //#include <sstream> // std::istringstream
19 //#include <iostream> // std::cout
20 //#include <math.h> // ceil
22 //#include <unistd.h> // chdir
26 //#include <anna/timex/Engine.hpp>
27 //#include <anna/statistics/Engine.hpp>
28 //#include <anna/diameter/codec/functions.hpp>
29 //#include <anna/diameter/codec/Engine.hpp>
30 //#include <anna/diameter/codec/EngineManager.hpp>
31 //#include <anna/http/Transport.hpp>
32 //#include <anna/diameter/stack/Engine.hpp>
33 //#include <anna/diameter/helpers/base/functions.hpp>
34 //#include <anna/time/functions.hpp>
35 //#include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
36 //#include <anna/testing/defines.hpp>
37 //#include <anna/xml/xml.hpp>
38 //#include <anna/diameter.comm/OriginHost.hpp>
39 //#include <anna/diameter.comm/OriginHostManager.hpp>
42 //#include <Launcher.hpp>
43 //#include <Procedure.hpp>
44 //#include <EventOperation.hpp>
45 //#include <MyDiameterEngine.hpp>
46 //#include <anna/testing/TestManager.hpp>
47 //#include <anna/testing/TestCase.hpp>
50 class EventOperation {
56 * EventOperation constructor
58 * @param http Indicates that HTTP interface is used.
60 * At signal interface, the response is written directly as output, but HTTP
63 * TODO: xml2json implementation (i.e., https://github.com/Cheedoong/xml2json).
64 * As only 3 operations are going to answer xml content:
65 * - working node report ('node')
66 * - diameter hex decode ('decode')
67 * - reinterpret json into xml ('loadmsg')
68 * the effort does not compensate having them responding full json representation.
70 * So, base64 encoding will be used for those xml representations.
72 * Anna Suite used xml natively for many things, json will be only used for
73 * REST API on requests and will be transformed internally.
75 EventOperation(bool http) : a_http(http) {;}
78 bool node(std::string &response, const std::string & name);
79 bool node_auto(std::string &response);
82 bool code(std::string &response, const std::string & diameterJson);
83 bool decode(std::string &response, const std::string & diameterHex);
84 bool loadmsg(std::string &response, const std::string & diameterJson);
87 bool services(std::string &response, const std::string & servicesJson);
88 bool diameterServerSessions(std::string &response, int sessions);
89 bool change_dir(std::string &response, const std::string & directory = "");
91 // Client sessions visibility
92 bool visibility(std::string &response, const std::string & action, const std::string &addressPort = "", int socket = -1);
95 bool collect(std::string &response);
96 bool context(std::string &response, const std::string & targetFile = "");
97 bool forceCountersRecord(std::string &response);
98 bool log_statistics_samples(std::string &response, const std::string & list);
99 bool show_oam(std::string &response);
100 bool show_stats(std::string &response);
103 bool sendmsg_hex_2e(std::string &response, const std::string & diameterJson_or_Hex, bool msg_or_hex);
104 bool sendmsg_hex_2c(std::string &response, const std::string & diameterJson_or_Hex, bool msg_or_hex);
105 bool answermsg_action_2e(std::string &response, const std::string & diameterJson_or_action, bool msg_or_action);
106 bool answermsg_action_2c(std::string &response, const std::string & diameterJson_or_action, bool msg_or_action);
109 // test_id__<command>
110 bool test_id__description(std::string &response, unsigned int id, const std::string & description);
111 bool test_id__ip_limit(std::string &response, unsigned int id, int amount = 1);
112 bool test_id__timeout(std::string &response, unsigned int id, int msecs);
113 bool test_id__sendmsg2e_2c(std::string &response, unsigned int id, bool _2e_or_2c, const std::string & diameterJson, int stepNumber = -1);
114 bool test_id__delay(std::string &response, unsigned int id, int msecs);
115 bool test_id__sh_command(std::string &response, unsigned int id, const std::string & script);
116 bool test_id__waitfefc_hex(std::string &response, unsigned int id, bool fe_or_fc, const std::string & hex, bool strict = false);
117 bool test_id__waitfefc_msg(std::string &response, unsigned int id, bool fe_or_fc, const std::string & diameterJson, bool strict = false);
118 bool test_id__waitfefc(std::string &response, unsigned int id, bool fe_or_fc,
119 const std::string & code,
120 const std::string & bitR,
121 const std::string & hopByHop,
122 const std::string & applicationId,
123 const std::string & sessionId,
124 const std::string & resultCode,
125 const std::string & msisdn,
126 const std::string & imsi,
127 const std::string & serviceContextId);
129 // Testcases execution
131 bool test__ttps(std::string &response, int amount);
132 bool test__next(std::string &response, int syncAmount = 1);
133 bool test__ip_limit(std::string &response, int amount = -2 /* show current ip-limit and in-progress test cases amount */);
134 bool test__goto(std::string &response, int id);
135 bool test__run(std::string &response, int id);
136 bool test__look(std::string &response, int id = -1 /* current */);
137 bool test__state(std::string &response, int id = -1 /* current */);
138 bool test__interact(std::string &response, int amount, unsigned int id = -1 /* current */);
139 bool test__reset(std::string &response, bool soft_hard = true, int id = -1 /* apply to all the tests */);
140 bool test__repeats(std::string &response, int amount);
141 bool test__auto_reset(std::string &response, bool soft_hard);
142 bool test__initialized(std::string &response);
143 bool test__finished(std::string &response);
144 bool test__clear(std::string &response);
145 bool test__junit(std::string &response, const std::string & targetFile);
146 bool test__summary_counts(std::string &response);
147 bool test__summary_states(std::string &response);
148 bool test__summary(std::string &response);
149 bool test__report(std::string &response,
150 const std::string & state = "all" /* initialized|in-progress|failed|success|[all]|none */, bool enable = true);
151 bool test__report_hex(std::string &response, bool enable = true);
152 bool test__dump_stdout(std::string &response, bool enable = true);