Commit 888d6d8e2934a6076a858374eb216133deb0d6d5
1 parent
795c826a
Exists in
dev
AgentBasic cleanup with all error cases
Showing
2 changed files
with
44 additions
and
50 deletions
Show diff stats
privatedev/plugin/agent/AgentBasic.py
... | ... | @@ -36,9 +36,8 @@ class AgentBasic(Agent): |
36 | 36 | _AGENT_SPECIFIC_COMMANDS = [ |
37 | 37 | # Format : (“cmd_name”, timeout, exec_mode) |
38 | 38 | ("do_specific10", 10, 0), |
39 | - ("do_cmd_unimplemented", 3, 0), | |
40 | - ("cmd_badly_named_and_implemented", 3, 0), | |
41 | - ("cmd_badly_named_and_unimplemented", 3, 0), | |
39 | + ("do_cmd_unimplemented_and_declared", 3, 0), | |
40 | + ("cmd_badly_named_and_declared", 3, 0), | |
42 | 41 | #("set_specific2", 5, 0), |
43 | 42 | ("do_specific30", 3, 0), |
44 | 43 | ("do_cmd_raising_error_exec", 3, 0), |
... | ... | @@ -48,7 +47,7 @@ class AgentBasic(Agent): |
48 | 47 | # on DEV |
49 | 48 | #COMMIT_ONLY = False |
50 | 49 | # on commit only |
51 | - COMMIT_ONLY = False | |
50 | + COMMIT_ONLY = True | |
52 | 51 | |
53 | 52 | # @override |
54 | 53 | _TEST_COMMANDS_LIST = [ |
... | ... | @@ -57,18 +56,18 @@ class AgentBasic(Agent): |
57 | 56 | #("self do_stop now", 200, '', Agent.CMD_STATUS.CMD_EXECUTED), |
58 | 57 | |
59 | 58 | # do_stop |
60 | - | |
61 | 59 | #("self do_stop now", 200, 'STOPPING now', Agent.CMD_STATUS.CMD_EXECUTED), |
62 | 60 | #("self do_stop", 200, 'STOPPING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
63 | 61 | #("self do_stop asap", 200, 'STOPPING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
64 | 62 | |
65 | - | |
66 | - # Badly named command (not generic) => CMD_INVAlID | |
67 | - (True, "self cmd_badly_named_and_implemented", 200, "Command badly named, must start with do_, get_, or set_", Agent.CMD_STATUS.CMD_INVALID), | |
68 | - (True, "self cmd_badly_named_and_unimplemented", 200, None, Agent.CMD_STATUS.CMD_INVALID), | |
63 | + # get_specific_cmds | |
64 | + (True, " self get_specific_cmds ", 200, | |
65 | + None, | |
66 | + #'do_specific10(arg1:int,arg2:int,arg3:float,arg4:str,arg5:typing.Tuple[int, str, int],arg6:typing.List[int]);do_specific30();do_cmd_raising_error_exec();do_cmd_unimplemented(U)', | |
67 | + Agent.CMD_STATUS.CMD_EXECUTED | |
68 | + ), | |
69 | 69 | |
70 | 70 | # do_restart |
71 | - | |
72 | 71 | (COMMIT_ONLY, "self do_restart asap", 200, 'RESTARTING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
73 | 72 | #("self do_stop", 200, 'STOPPING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
74 | 73 | |
... | ... | @@ -76,21 +75,21 @@ class AgentBasic(Agent): |
76 | 75 | # ------ A - ERROR CASES - from PENDING status ------- |
77 | 76 | # ---------------------------------------------------- |
78 | 77 | |
79 | - # - Error case 1 - unimplemented command in agent specific commands list | |
80 | - (True, " self get_specific_cmds ", 200, | |
81 | - None, | |
82 | - #'do_specific10(arg1:int,arg2:int,arg3:float,arg4:str,arg5:typing.Tuple[int, str, int],arg6:typing.List[int]);do_specific30();do_cmd_raising_error_exec();do_cmd_unimplemented(U)', | |
83 | - Agent.CMD_STATUS.CMD_EXECUTED | |
84 | - ), | |
85 | 78 | |
86 | - # - Error case 2 - CMD_INVALID | |
87 | - # unknwon command | |
79 | + # - Error case 2 - Unimplemented command (in agent specific commands list) | |
80 | + | |
81 | + | |
82 | + # - Error case 1 - CMD_INVALID | |
83 | + # a) Badly named commands | |
84 | + (True, "self cmd_badly_named_and_declared", 200, "Command badly named, must start with do_, get_, or set_", Agent.CMD_STATUS.CMD_INVALID), | |
85 | + (COMMIT_ONLY, "self cmd_badly_named_and_undeclared", 200, None, Agent.CMD_STATUS.CMD_INVALID), | |
86 | + # b) Unknwon command | |
88 | 87 | ##FIXME: ("self unexisting_cmd", 200, '', Agent.CMD_STATUS.CMD_UNKNOWN), |
89 | - (COMMIT_ONLY, "self cmd_unexisting", 200, 'EXCEPTION on command cmd_unexisting: Unknown command', Agent.CMD_STATUS.CMD_INVALID), | |
90 | - # bad parameters (missing or too many, or bad type) | |
91 | - # missing args | |
88 | + (COMMIT_ONLY, "self do_cmd_unexisting", 200, 'EXCEPTION on command do_cmd_unexisting: Unknown command', Agent.CMD_STATUS.CMD_INVALID), | |
89 | + # c) Bad parameters (missing or too many, or bad type) | |
90 | + # - missing args | |
92 | 91 | (COMMIT_ONLY, "self do_specific10", 200, 'EXCEPTION on command do_specific10: Command has bad, missing, or too many argument(s)', Agent.CMD_STATUS.CMD_INVALID), |
93 | - # missing args | |
92 | + # - missing args | |
94 | 93 | (COMMIT_ONLY, "self do_specific10 2 ", 200, None, Agent.CMD_STATUS.CMD_INVALID), |
95 | 94 | # - too many args |
96 | 95 | (COMMIT_ONLY, "self do_specific10 2 2 3.5 titi (3,'titi',5) [1,3,5,7,9] 4", 200, None, Agent.CMD_STATUS.CMD_INVALID), |
... | ... | @@ -100,7 +99,7 @@ class AgentBasic(Agent): |
100 | 99 | #("self do_specific10 2 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 200, '16.5', Agent.CMD_STATUS.CMD_EXECUTED), |
101 | 100 | |
102 | 101 | # - Error case 3 - CMD_UNIMPLEMENTED |
103 | - (True, "self do_cmd_unimplemented", 200, None, Agent.CMD_STATUS.CMD_UNIMPLEMENTED), | |
102 | + (True, "self do_cmd_unimplemented_and_declared", 200, None, Agent.CMD_STATUS.CMD_UNIMPLEMENTED), | |
104 | 103 | |
105 | 104 | # - Error case 4 - CMD_EXPIRED |
106 | 105 | # This command has a validity of 0s and thus should be tagged as "expired" |
... | ... | @@ -377,8 +376,6 @@ class AgentBasic(Agent): |
377 | 376 | def do_specific30(self): |
378 | 377 | pass |
379 | 378 | |
380 | - def cmd_badly_named_and_implemented(self): | |
381 | - pass | |
382 | 379 | |
383 | 380 | """ |
384 | 381 | ================================================================= | ... | ... |
src/core/pyros_django/agent/AgentBasic.py
... | ... | @@ -36,9 +36,8 @@ class AgentBasic(Agent): |
36 | 36 | _AGENT_SPECIFIC_COMMANDS = [ |
37 | 37 | # Format : (“cmd_name”, timeout, exec_mode) |
38 | 38 | ("do_specific10", 10, 0), |
39 | - ("do_cmd_unimplemented", 3, 0), | |
40 | - ("cmd_badly_named_and_implemented", 3, 0), | |
41 | - ("cmd_badly_named_and_unimplemented", 3, 0), | |
39 | + ("do_cmd_unimplemented_and_declared", 3, 0), | |
40 | + ("cmd_badly_named_and_declared", 3, 0), | |
42 | 41 | #("set_specific2", 5, 0), |
43 | 42 | ("do_specific30", 3, 0), |
44 | 43 | ("do_cmd_raising_error_exec", 3, 0), |
... | ... | @@ -48,7 +47,7 @@ class AgentBasic(Agent): |
48 | 47 | # on DEV |
49 | 48 | #COMMIT_ONLY = False |
50 | 49 | # on commit only |
51 | - COMMIT_ONLY = False | |
50 | + COMMIT_ONLY = True | |
52 | 51 | |
53 | 52 | # @override |
54 | 53 | _TEST_COMMANDS_LIST = [ |
... | ... | @@ -57,18 +56,18 @@ class AgentBasic(Agent): |
57 | 56 | #("self do_stop now", 200, '', Agent.CMD_STATUS.CMD_EXECUTED), |
58 | 57 | |
59 | 58 | # do_stop |
60 | - | |
61 | 59 | #("self do_stop now", 200, 'STOPPING now', Agent.CMD_STATUS.CMD_EXECUTED), |
62 | 60 | #("self do_stop", 200, 'STOPPING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
63 | 61 | #("self do_stop asap", 200, 'STOPPING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
64 | 62 | |
65 | - | |
66 | - # Badly named command (not generic) => CMD_INVAlID | |
67 | - (True, "self cmd_badly_named_and_implemented", 200, "Command badly named, must start with do_, get_, or set_", Agent.CMD_STATUS.CMD_INVALID), | |
68 | - (True, "self cmd_badly_named_and_unimplemented", 200, None, Agent.CMD_STATUS.CMD_INVALID), | |
63 | + # get_specific_cmds | |
64 | + (True, " self get_specific_cmds ", 200, | |
65 | + None, | |
66 | + #'do_specific10(arg1:int,arg2:int,arg3:float,arg4:str,arg5:typing.Tuple[int, str, int],arg6:typing.List[int]);do_specific30();do_cmd_raising_error_exec();do_cmd_unimplemented(U)', | |
67 | + Agent.CMD_STATUS.CMD_EXECUTED | |
68 | + ), | |
69 | 69 | |
70 | 70 | # do_restart |
71 | - | |
72 | 71 | (COMMIT_ONLY, "self do_restart asap", 200, 'RESTARTING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
73 | 72 | #("self do_stop", 200, 'STOPPING asap', Agent.CMD_STATUS.CMD_EXECUTED), |
74 | 73 | |
... | ... | @@ -76,21 +75,21 @@ class AgentBasic(Agent): |
76 | 75 | # ------ A - ERROR CASES - from PENDING status ------- |
77 | 76 | # ---------------------------------------------------- |
78 | 77 | |
79 | - # - Error case 1 - unimplemented command in agent specific commands list | |
80 | - (True, " self get_specific_cmds ", 200, | |
81 | - None, | |
82 | - #'do_specific10(arg1:int,arg2:int,arg3:float,arg4:str,arg5:typing.Tuple[int, str, int],arg6:typing.List[int]);do_specific30();do_cmd_raising_error_exec();do_cmd_unimplemented(U)', | |
83 | - Agent.CMD_STATUS.CMD_EXECUTED | |
84 | - ), | |
85 | 78 | |
86 | - # - Error case 2 - CMD_INVALID | |
87 | - # unknwon command | |
79 | + # - Error case 2 - Unimplemented command (in agent specific commands list) | |
80 | + | |
81 | + | |
82 | + # - Error case 1 - CMD_INVALID | |
83 | + # a) Badly named commands | |
84 | + (True, "self cmd_badly_named_and_declared", 200, "Command badly named, must start with do_, get_, or set_", Agent.CMD_STATUS.CMD_INVALID), | |
85 | + (COMMIT_ONLY, "self cmd_badly_named_and_undeclared", 200, None, Agent.CMD_STATUS.CMD_INVALID), | |
86 | + # b) Unknwon command | |
88 | 87 | ##FIXME: ("self unexisting_cmd", 200, '', Agent.CMD_STATUS.CMD_UNKNOWN), |
89 | - (COMMIT_ONLY, "self cmd_unexisting", 200, 'EXCEPTION on command cmd_unexisting: Unknown command', Agent.CMD_STATUS.CMD_INVALID), | |
90 | - # bad parameters (missing or too many, or bad type) | |
91 | - # missing args | |
88 | + (COMMIT_ONLY, "self do_cmd_unexisting", 200, 'EXCEPTION on command do_cmd_unexisting: Unknown command', Agent.CMD_STATUS.CMD_INVALID), | |
89 | + # c) Bad parameters (missing or too many, or bad type) | |
90 | + # - missing args | |
92 | 91 | (COMMIT_ONLY, "self do_specific10", 200, 'EXCEPTION on command do_specific10: Command has bad, missing, or too many argument(s)', Agent.CMD_STATUS.CMD_INVALID), |
93 | - # missing args | |
92 | + # - missing args | |
94 | 93 | (COMMIT_ONLY, "self do_specific10 2 ", 200, None, Agent.CMD_STATUS.CMD_INVALID), |
95 | 94 | # - too many args |
96 | 95 | (COMMIT_ONLY, "self do_specific10 2 2 3.5 titi (3,'titi',5) [1,3,5,7,9] 4", 200, None, Agent.CMD_STATUS.CMD_INVALID), |
... | ... | @@ -100,7 +99,7 @@ class AgentBasic(Agent): |
100 | 99 | #("self do_specific10 2 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 200, '16.5', Agent.CMD_STATUS.CMD_EXECUTED), |
101 | 100 | |
102 | 101 | # - Error case 3 - CMD_UNIMPLEMENTED |
103 | - (True, "self do_cmd_unimplemented", 200, None, Agent.CMD_STATUS.CMD_UNIMPLEMENTED), | |
102 | + (True, "self do_cmd_unimplemented_and_declared", 200, None, Agent.CMD_STATUS.CMD_UNIMPLEMENTED), | |
104 | 103 | |
105 | 104 | # - Error case 4 - CMD_EXPIRED |
106 | 105 | # This command has a validity of 0s and thus should be tagged as "expired" |
... | ... | @@ -377,8 +376,6 @@ class AgentBasic(Agent): |
377 | 376 | def do_specific30(self): |
378 | 377 | pass |
379 | 378 | |
380 | - def cmd_badly_named_and_implemented(self): | |
381 | - pass | |
382 | 379 | |
383 | 380 | """ |
384 | 381 | ================================================================= | ... | ... |