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(std::string &response, unsigned int id, const std::string & diameterJson, int stepNumber = -1);
114 bool test_id__sendmsg2c(std::string &response, unsigned int id, const std::string & diameterJson, int stepNumber = -1);
115 bool test_id__delay(std::string &response, unsigned int id, int msecs);
116 bool test_id__sh_command(std::string &response, unsigned int id, const std::string & script);
117 bool test_id__waitfe_hex(std::string &response, unsigned int id, const std::string & hex, bool strict = false);
118 bool test_id__waitfc_hex(std::string &response, unsigned int id, const std::string & hex, bool strict = false);
119 bool test_id__waitfe_msg(std::string &response, unsigned int id, const std::string & diameterJson, bool strict = false);
120 bool test_id__waitfc_msg(std::string &response, unsigned int id, const std::string & diameterJson, bool strict = false);
121 bool test_id__waitfe(std::string &response, unsigned int id, const std::string & condition);
122 bool test_id__waitfc(std::string &response, unsigned int id, const std::string & condition);
124 // Testcases execution
126 bool test__ttps(std::string &response, int amount);
127 bool test__next(std::string &response, int syncAmount = 1);
128 bool test__ip_limit(std::string &response, int amount = -2 /* show current ip-limit and in-progress test cases amount */);
129 bool test__goto(std::string &response, int id);
130 bool test__run(std::string &response, int id);
131 bool test__look(std::string &response, int id = -1 /* current */);
132 bool test__state(std::string &response, int id = -1 /* current */);
133 bool test__interact(std::string &response, int amount, unsigned int id = -1 /* current */);
134 bool test__reset(std::string &response, bool soft_hard = true, unsigned int id = -2 /* apply to all the tests */);
135 bool test__repeats(std::string &response, int amount);
136 bool test__auto_reset(std::string &response, bool soft_hard);
137 bool test__initialized(std::string &response);
138 bool test__finished(std::string &response);
139 bool test__clear(std::string &response);
140 bool test__junit(std::string &response, const std::string & targetFile);
141 bool test__summary_counts(std::string &response);
142 bool test__summary_states(std::string &response);
143 bool test__summary(std::string &response);
144 bool test__report(std::string &response,
145 const std::string & state = "all" /* initialized|in-progress|failed|success|[all]|none */, bool enable = true);
146 bool test__report_hex(std::string &response, bool enable = true);
147 bool test__dump_stdout(std::string &response, bool enable = true);