Feature/final backup#198
Conversation
|
create an HLD for this PR |
|
@copilot create an HLD for this PR |
Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/ae2d9fe3-d174-4c46-bcc3-54e2935ca097 Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/ae2d9fe3-d174-4c46-bcc3-54e2935ca097 Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com>
Created the HLD at
|
Code Coverage Summary |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (2)
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:136
- The variable names in the success/failure branches are swapped.
SCRIPT_SUCCESSis assigned the string"Debug Information Report upload Failed"andSCRIPT_FAILUREis assigned"Debug Information Report upload Success", but the print messages below treat a match onSCRIPT_SUCCESSas "Script execution success" and a match onSCRIPT_FAILUREas "Script execution failed". This means a failed upload will be reported as a success and vice versa. Swap the string values (or swap the variable names) so the names match the log content they are checking.
SCRIPT_SUCCESS = "Debug Information Report upload Failed"
SCRIPT_FAILURE = "Debug Information Report upload Success"
if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
print("Script execution success")
elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
print("Script execution failed")
else:
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:139
- Same swap as in the positive-case file:
SCRIPT_SUCCESSholds the "...upload Failed" string whileSCRIPT_FAILUREholds the "...upload Success" string, but the print branches treat them as their names suggest. The reporting will be inverted. Please swap the string values or the variable names.
SCRIPT_SUCCESS = "Debug Information Report upload Failed"
SCRIPT_FAILURE = "Debug Information Report upload Success"
if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
print("Script execution success")
elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
print("Script execution failed")
else:
| SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success" | ||
| assert SERVICE_START in grep_rrdlogs(SERVICE_START) | ||
|
|
||
| JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success" | ||
| assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) | ||
|
|
||
| SLEEP_TIME = "Sleeping with timeout" | ||
| assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) | ||
| sleep(20) | ||
|
|
||
| SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service" | ||
| assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) |
| ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') | ||
| else: | ||
| node = ISSUE_STRING | ||
| subnode = None | ||
|
|
||
| ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json" |
| on: | ||
| pull_request: | ||
| branches: [ develop ] | ||
| branches: [ develop, feature/final_backup] |
| if (rbuf->jsonPath != NULL) | ||
| { | ||
| free(rbuf->jsonPath); | ||
| rbuf->jsonPath = NULL; | ||
| } |
|
|
||
| /* Open debug_output.txt file*/ | ||
| filePointer = fopen(finalOutFile, "a+"); | ||
| filePointer = fopen(finalOutFile, "w+"); |
| char base[128] = {0}; | ||
| char local_suffix[128] = {0}; | ||
| split_issue_type(cmdMap[index], base, sizeof(base), local_suffix, sizeof(local_suffix)); |
| while (str[source] != '\0') | ||
| { | ||
| if (isalnum(str[source]) || str[source] == ',' || str[source] == '.') | ||
| if (isalnum(str[source]) || str[source] == ',' || str[source] == '.') |
Code Coverage Summary |
1 similar comment
Code Coverage Summary |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (5)
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:110
- The expected log message hard-codes
(12 > 10)butRRD_MAX_SUFFIX_LENis defined as 9 inrrdJsonParser.c, so the actual log emitted bysplit_issue_type()will beSuffix after 'Device.Info' exceeds max length (12 > 9); discarding. This assertion will never match and the test will always fail. Update the literal to(12 > 9)(or compute it from the constant) so it matches the format string insrc/rrdJsonParser.c.
SUFFIX_EXCEEDS = f"Suffix after 'Device.Info' exceeds max length (12 > 10); discarding"
assert SUFFIX_EXCEEDS in grep_rrdlogs(SUFFIX_EXCEEDS)
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:107
executeCommands()insrc/rrdRunCmdThread.cnow builds the systemd unit name asremote_debugger_<rfcvalue><epoch>and the start/journal/stop log lines no longer containremote_debugger_<rfcvalue>followed by a space andservice. WithISSUE_STRING = "Device.Info"the produced log is e.g.Starting remote_debugger_Device.Info1715600000 service success, while these asserts look for the substringStarting remote_debugger_Device.Info service success(and similarly forjournalctl ... service successandStopping ... service). None of these substrings will be present, so the asserts will fail. Either match the new format (e.g. anchor onremote_debugger_Device.Infoas a prefix only) or use a regex that tolerates the appended epoch. The same applies to the corresponding asserts in the negative-case file (lines 96–107).
SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success"
assert SERVICE_START in grep_rrdlogs(SERVICE_START)
JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success"
assert JOURNAL_START in grep_rrdlogs(JOURNAL_START)
SLEEP_TIME = "Sleeping with timeout"
assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME)
sleep(20)
SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service"
assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP)
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:116
- In the negative case the suffix is longer than
RRD_MAX_SUFFIX_LENand is therefore discarded, leavingcmdBuff->suffixasNULL. IncheckIssueNodeInfo()the uploadtarNameis then built as"%s"frombuff->mdataonly (no trailing_), so the generated upload filename will beAABBCCDDEEFF_DEVICE_INFO— without the trailing underscore. These asserts expectDEVICE_INFO_(trailing_) and will not match. Drop the trailing underscore from the expected strings, or test for the prefix only.
GENERATE_FILE = f"Generated filename: AABBCCDDEEFF_DEVICE_INFO_"
assert GENERATE_FILE in grep_rrdlogs(GENERATE_FILE)
START_UPLOAD = f"Starting upload - server: mockxconf, protocol: HTTP, file: AABBCCDDEEFF_DEVICE_INFO_"
assert START_UPLOAD in grep_rrdlogs(START_UPLOAD)
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:137
- These two log lookups are inverted:
SCRIPT_SUCCESSis assigned the string"Debug Information Report upload Failed"andSCRIPT_FAILUREis assigned"Debug Information Report upload Success", so the branches that print"Script execution success"and"Script execution failed"are swapped with respect to what they actually mean. Either swap the two constant values or swap the print messages to match.
SCRIPT_SUCCESS = "Debug Information Report upload Failed"
SCRIPT_FAILURE = "Debug Information Report upload Success"
if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
print("Script execution success")
elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
print("Script execution failed")
else:
print("Script execution not found in logs")
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:140
- Same swap as in the positive-suffix test:
SCRIPT_SUCCESSholds the "...Failed" string andSCRIPT_FAILUREholds the "...Success" string, so the messages printed for the two branches are inverted relative to their variable names. Please correct the assignment or the printed messages.
SCRIPT_SUCCESS = "Debug Information Report upload Failed"
SCRIPT_FAILURE = "Debug Information Report upload Success"
if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
print("Script execution success")
elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
print("Script execution failed")
else:
print("Script execution not found in logs")
| SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success" | ||
| assert SERVICE_START in grep_rrdlogs(SERVICE_START) | ||
|
|
||
| JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success" | ||
| assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) | ||
|
|
||
| SLEEP_TIME = "Sleeping with timeout" | ||
| assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) | ||
| sleep(20) | ||
|
|
||
| SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service" |
| ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') | ||
| else: | ||
| node = ISSUE_STRING | ||
| subnode = None |
| on: | ||
| pull_request: | ||
| branches: [ develop ] | ||
| branches: [ develop, feature/final_backup] |
| if(cmdBuff) | ||
| { | ||
| if (cmdBuff->suffix) | ||
| { | ||
| free(cmdBuff->suffix); | ||
| cmdBuff->suffix = NULL; | ||
| } | ||
| free(cmdBuff); | ||
| cmdBuff = NULL; | ||
| } |
| And the issuetype request should match between Send and Receive | ||
| When the remotedebugger received the message from webPA event | ||
| Then remotedebugger should read the Json file | ||
| And remotedebugger logs should contain the Json File Parse Failed |
| time_t epochTime = time(NULL); | ||
| snprintf(remoteDebuggerServiceStr, sizeof(remoteDebuggerServiceStr),"%s%s%ld", remoteDebuggerPrefix, cmdData->rfcvalue, (long)epochTime); |
| const char *underscore = strchr(input, '_'); | ||
| if (underscore) | ||
| { | ||
| /* Always split at the first underscore — base never contains '_' */ | ||
| size_t b_len = (size_t)(underscore - input); | ||
| if (b_len >= base_len) b_len = base_len - 1; | ||
| strncpy(base, input, b_len); | ||
| base[b_len] = '\0'; | ||
|
|
||
| /* Keep the suffix only when its total length (including '_') is | ||
| * within the allowed limit; longer tokens are discarded. */ | ||
| if (strlen(underscore) <= RRD_MAX_SUFFIX_LEN) | ||
| { | ||
| /* Sanitize: retain only [A-Za-z0-9_-] to prevent injection when | ||
| * the suffix is later embedded in file names or command arguments. */ | ||
| size_t si = 0, di = 0; | ||
| size_t max_copy = suffix_len - 1; | ||
| while (underscore[si] != '\0' && di < max_copy) | ||
| { | ||
| char ch = underscore[si]; | ||
| if (isalnum((unsigned char)ch) || ch == '_' || ch == '-') | ||
| { | ||
| suffix[di++] = ch; | ||
| } | ||
| si++; | ||
| } | ||
| suffix[di] = '\0'; | ||
| } | ||
| else | ||
| { | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Suffix after '%s' exceeds max length (%zu > %d); discarding\n", | ||
| __FUNCTION__, __LINE__, base, strlen(underscore), RRD_MAX_SUFFIX_LEN); | ||
| suffix[0] = '\0'; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| /* No underscore — full input is the base */ | ||
| strncpy(base, input, base_len - 1); | ||
| base[base_len - 1] = '\0'; | ||
| suffix[0] = '\0'; | ||
| } | ||
| } |
Code Coverage Summary |
Code Coverage Summary |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (2)
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py:137
- The variable names
SCRIPT_SUCCESSandSCRIPT_FAILUREare assigned to strings whose meanings are inverted:SCRIPT_SUCCESSis set to the "Failed" log message, andSCRIPT_FAILUREis set to the "Success" log message. As a result, the subsequent branches print "Script execution success" when the upload actually failed (and vice versa), making the test output misleading.
SCRIPT_SUCCESS = "Debug Information Report upload Failed"
SCRIPT_FAILURE = "Debug Information Report upload Success"
if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
print("Script execution success")
elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
print("Script execution failed")
else:
print("Script execution not found in logs")
test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py:140
- Same inversion as the positive-case test:
SCRIPT_SUCCESSpoints to the "Failed" log line andSCRIPT_FAILUREpoints to the "Success" log line, causing the printed status to be the opposite of reality.
SCRIPT_SUCCESS = "Debug Information Report upload Failed"
SCRIPT_FAILURE = "Debug Information Report upload Success"
if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS):
print("Script execution success")
elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE):
print("Script execution failed")
else:
print("Script execution not found in logs")
| node = ISSUE_STRING | ||
| subnode = None | ||
|
|
||
| ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json" |
| on: | ||
| pull_request: | ||
| branches: [ develop ] | ||
| branches: [ develop, feature/final_backup] |
|
|
||
| /* Open debug_output.txt file*/ | ||
| filePointer = fopen(finalOutFile, "a+"); | ||
| filePointer = fopen(finalOutFile, "w+"); |
| if(cmdBuff) | ||
| { | ||
| if (cmdBuff->suffix) | ||
| { | ||
| free(cmdBuff->suffix); | ||
| cmdBuff->suffix = NULL; | ||
| } | ||
| free(cmdBuff); | ||
| cmdBuff = NULL; | ||
| } |
| while (str[source] != '\0') | ||
| { | ||
| if (isalnum(str[source]) || str[source] == ',' || str[source] == '.') | ||
| if (isalnum(str[source]) || str[source] == ',' || str[source] == '.') |
| int cnt = 1, i = 0; | ||
| char *str = input_str; | ||
|
|
||
| removeSpecialCharacterfromIssueTypeList(str); | ||
| while (*str == delimeter) |
|
|
||
| ## Document Information | ||
|
|
||
| | Field | Value | |
No description provided.