Commit 7f530a6198ea34f95c89f1ce1069afa5124939ef
1 parent
1a6fd283
Exists in
dev
ajout des timeout dans le scenario test Agent
Showing
1 changed file
with
23 additions
and
20 deletions
Show diff stats
src/core/pyros_django/agent/Agent.py
... | ... | @@ -357,13 +357,15 @@ class Agent: |
357 | 357 | # |
358 | 358 | # It is a list of commands to be sent by this agent to other agents ("self" means himself) |
359 | 359 | # |
360 | - # Format : List of tuples (command, expected_res), with : | |
360 | + # Format : List of tuples (command, timeout, expected_res), with : | |
361 | 361 | # |
362 | 362 | # - command : the command format is "recipient cmd args", with : |
363 | 363 | # - recipient : name of the Agent that the command is to be sent to (use "self" to mean himself) |
364 | 364 | # - cmd : the command name |
365 | 365 | # - args : (optional) the list of command arguments, separated by blanks : arg1 arg2 arg3 ... |
366 | 366 | # |
367 | + # - timeout : the command timeout (max time allowed for execution, else it is aborted) | |
368 | + # | |
367 | 369 | # - expected_res : le résultat attendu |
368 | 370 | # |
369 | 371 | # Ex : |
... | ... | @@ -378,49 +380,50 @@ class Agent: |
378 | 380 | # ------------------------------------------------------------ |
379 | 381 | |
380 | 382 | # - Agent command, unknown => ko, UnknownCmdException |
381 | - #("self do_unknown", None), | |
383 | + #("self do_unknown", 1, None), | |
382 | 384 | |
383 | 385 | # - Agent general command malformed (missing arg) => ko, AgentCmdBadArgsException |
384 | - #("Agent set_mode", None), | |
386 | + #("Agent set_mode", 1, None), | |
385 | 387 | |
386 | 388 | # - Agent specific command, known but not implemented => ko, AgentCmdUnimplementedException |
387 | - #("self set_specific2", None), | |
389 | + #("self set_specific2", 1, None), | |
388 | 390 | |
389 | 391 | # - Agent specific command, implemented but missing args => ko, AgentCmdBadArgsException |
390 | - #(" self do_specific1 1 ", None), | |
392 | + #(" self do_specific1 1 ", 1, None), | |
391 | 393 | |
392 | 394 | |
393 | 395 | # 2) NORMAL CASES (test scenario) |
394 | 396 | # ------------------------------- |
395 | 397 | |
396 | 398 | # Agent general command |
397 | - ("Agent set_mode ATTENTIVE", "MODE = ATTENTIVE"), | |
399 | + ("Agent set_mode ATTENTIVE", 2, "MODE = ATTENTIVE"), | |
398 | 400 | # => should get "ATTENTIVE" |
399 | - ("self get_mode", "MODE = ATTENTIVE"), | |
401 | + ("self get_mode", 1, "MODE = ATTENTIVE"), | |
400 | 402 | |
401 | 403 | # => should get "7" |
402 | - ("self do_eval 3+5-1", 7), | |
404 | + ("self do_eval 3+5-1", 2, 7), | |
403 | 405 | |
404 | 406 | # END, will not go further |
405 | - ("self do_exit", "STOPPING"), | |
407 | + #("self do_exit", 2, "STOPPING"), | |
406 | 408 | |
407 | 409 | # Agent specific commands => should be executed |
408 | - ("self do_specific3", ), | |
409 | - ("self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 7), | |
410 | + ("self do_specific3", 2, None), | |
411 | + ("self do_exit", 5, "STOPPING"), | |
412 | + ("self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 2, 7), | |
410 | 413 | |
411 | - ("self set_mode ROUTINE", "MODE = ROUTINE"), | |
414 | + ("self set_mode ROUTINE", 2, "MODE = ROUTINE"), | |
412 | 415 | # => should get "ROUTINE" |
413 | - ("self get_mode", "MODE = ROUTINE"), | |
416 | + ("self get_mode", 2, "MODE = ROUTINE"), | |
414 | 417 | # Agent specific command => should be skipped (because not ATTENTIVE) |
415 | - ("self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", "SKIPPED"), | |
418 | + ("self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 2, "SKIPPED"), | |
416 | 419 | |
417 | 420 | # From now on, should not run anymore process_before/after |
418 | 421 | # => and should skip next specific commands |
419 | - ("self set_mode IDLE", "MODE = IDLE"), | |
422 | + ("self set_mode IDLE", 2, "MODE = IDLE"), | |
420 | 423 | # => should get "IDLE" |
421 | - ("self get_mode", "MODE = IDLE"), | |
424 | + ("self get_mode", 2, "MODE = IDLE"), | |
422 | 425 | # Agent specific command => should be skipped (because not ATTENTIVE) |
423 | - ("self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 'SKIPPED'), | |
426 | + ("self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 2, 'SKIPPED'), | |
424 | 427 | |
425 | 428 | # TODO: test priority commands : do_abort, do_flush_cmds, ... |
426 | 429 | # - Stop executing new commands (just let them accumulate) |
... | ... | @@ -437,10 +440,10 @@ class Agent: |
437 | 440 | ##("self do_resume_exec",), |
438 | 441 | |
439 | 442 | # Restart the restart loop (from init()) |
440 | - ("self do_restart_loop", "RESTARTING"), | |
443 | + ("self do_restart_loop", 2, "RESTARTING"), | |
441 | 444 | |
442 | 445 | # Now stop |
443 | - ("self do_exit", "STOPPING"), | |
446 | + ("self do_exit", 2, "STOPPING"), | |
444 | 447 | |
445 | 448 | ''' |
446 | 449 | # specific0 not_executed_because_idle |
... | ... | @@ -2130,7 +2133,7 @@ class Agent: |
2130 | 2133 | if self.TEST_MODE: log.info("in TEST MODE") |
2131 | 2134 | |
2132 | 2135 | def _TEST_get_next_command_to_send(self)->AgentCmd: |
2133 | - cmd_full_name, res_expected = next(self.TEST_COMMANDS, (None,None)) | |
2136 | + cmd_full_name, timeout, res_expected = next(self.TEST_COMMANDS, (None,None,None)) | |
2134 | 2137 | #print(cmd_full_name, res_expected) |
2135 | 2138 | #return cmd_name |
2136 | 2139 | if cmd_full_name is None: return None | ... | ... |