opt_response_content += anna::functions::asString(id);
opt_response_content += ")";
}
+ else if(param1 == "run") {
+ if (numParams > 2)
+ throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION);
+
+ if(param2 == "") throw anna::RuntimeException("Missing id for test run operation", ANNA_FILE_LOCATION);
+ int id = atoi(param2.c_str());
+ if (testManager.runTestCase(id)) {
+ opt_response_content = "test executed for id provided (";
+ }
+ else {
+ opt_response_content = "cannot found test id (";
+ }
+ opt_response_content += anna::functions::asString(id);
+ opt_response_content += ")";
+ }
else if(param1 == "look") {
if (numParams > 2)
throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION);
**test|goto|<id>**
-Updates current test pointer position.
+Updates current test pointer position. Take into account, that 'test|next' will execute the next test case, not the one pointed with *goto*.
+
+**test|run|<id>**
+
+Run the test case selected.
**test|look[|id]**
**test|auto-reset|<soft|hard>**
-When cycling, current test cases can be soft (default) or hard reset. If no timeout has been configured for the test case, hard reset could prevent stuck on the next cycle for those test cases still in progress.
+When cycling, current test cases can be soft or hard reset. If no timeout has been configured for the test case, hard reset could prevent stuck on the next cycle for those test cases still in progress.
**test|initialized**
# HTTP Interface
All the operations described above can be used through the optional HTTP interface. You only have
- to define the http server at the command line with something like: '--httpServer localhost:9000'.
-To send the task, we shall build the http POST request json body with the operation string.
+ to define the http server at the command line with something like: '--httpServer localhost:8000'.
+REST API specification:
+
+## GET
+
+> curl -v --request GET localhost:8000<uri>
+
+HTTP2 is not served, so, you should use *nginx* reverse proxy or similar, to pass HTTP1 requests to the server, allowing the external use of HTTP2 clients like *nghttp*:
+
+> nghttp -v -H ":method: GET" "<uri>"
+
+### GET /xxxx
+
+
+
+## POST
+
+> curl -v --request POST -H "Content-Type: application/json" localhost:8000<uri> -d@test.json
- Json specification covers a subset for previous:
+HTTP2 is not served, so, you should use *nginx* reverse proxy or similar, to pass HTTP1 requests to the server, allowing the external use of HTTP2 clients like *nghttp*:
+> nghttp -v -H ":method: POST" -d test.json "<uri>"
\ No newline at end of file
void setInProgressLimit(unsigned int limit) throw() { a_inProgressLimit = limit; } // -1 = UINT_MAX (no limit)
bool gotoTestCase(unsigned int id) throw();
+ bool runTestCase(unsigned int id) throw();
TestCase *findTestCase(unsigned int id) const throw(); // id = -1 provides current test case triggered
TestCase *getTestCase(unsigned int id, const std::string &description = "") throw(); // creates/reuses a test case
bool TestManager::configureTTPS(int testTicksPerSecond) throw() {
- if (testTicksPerSecond == 0) {
+ if (testTicksPerSecond == 0) {
if (a_clock) {
a_timeController->cancel(a_clock);
LOGDEBUG(anna::Logger::debug("Testing timer clock stopped !", ANNA_FILE_LOCATION));
return false;
}
+bool TestManager::runTestCase(unsigned int id) throw() {
+ test_pool_it it = a_testPool.find(id);
+ if (it != a_testPool.end()) {
+ a_currentTestIt = it;
+
+ // execTestCases will get the next one, we must return 1 position:
+ if (a_currentTestIt == a_testPool.begin())
+ a_currentTestIt = a_testPool.end();
+ else
+ a_currentTestIt--;
+
+ return execTestCases(1);
+ }
+
+ return false;
+}
+
TestCase *TestManager::findTestCase(unsigned int id) const throw() { // id = -1 provides current test case triggered
if (!tests()) return NULL;