Skip to content

WAR-1255: response stored in data repository through response_ref get stored with control characters#72

Merged
bjrr merged 25 commits into
developfrom
bugfix/WAR-1255
Oct 30, 2017
Merged

WAR-1255: response stored in data repository through response_ref get stored with control characters#72
bjrr merged 25 commits into
developfrom
bugfix/WAR-1255

Conversation

@navvrnd

@navvrnd navvrnd commented Jul 14, 2017

Copy link
Copy Markdown
Contributor

response from cli commands stored through response_ref and pattern gets stored with control characters which is causing issues while retrieving later. This was tested with the local team facing the issue and was working fine. For testing, one can take a test case which will store data with control characters in data repository and then retrieve later without any issues.

@navvrnd navvrnd self-assigned this Jul 14, 2017
@kaheichan

Copy link
Copy Markdown
Contributor

@navvrnd Please provide title and description for this one, #73, #74, #75

@navvrnd navvrnd changed the title Bugfix/war 1255 Bugfix/war 1255: response stored in data repository through response_ref get stored with control characters Jul 18, 2017
@Annam16

Annam16 commented Jul 27, 2017

Copy link
Copy Markdown

@navvrnd can you add a detailed description in the JIRA ticket as well as how to test this fix in pull request description?

@Annam16

Annam16 commented Jul 31, 2017

Copy link
Copy Markdown

@navvrnd Can you add sample test case to test this fix in JIRA

@Annam16 Annam16 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add sample test case to test this fix in JIRA

@Annam16

Annam16 commented Aug 1, 2017

Copy link
Copy Markdown

@navvrnd Can you please add the below details in JIRA ticket.

  1. failed test case and it's related files.
  2. Failure log before this fix.
  3. Pass log after this fix.
  4. How you conclude that the test case failed due to control characters because in ticket description it is mentioned that "not able to retrieve it in another test step"

Comment thread warrior/Framework/Utils/cli_Utils.py Outdated
reobj = re.search(resp_pat_req, response)
response = reobj.group(0) if reobj is not None else ""
# removing non-ascii/control characters (line feed) from response
response = "".join([c for c in response if 31 < ord(c) < 127])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if you can use "rem_nonprintable_ctrl_chars" method from testcase_utils_class file for removing ascii control chars.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function "rem_nonprintable_ctrl_chars" only removes a subset of control characters. I wanted to make it generic. May be we can replace that with this code, but I don't what might break. Please do comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'rem_nonprintable_ctrl_chars' method removes chars with hex values other than 'x20-x7E, x09 & x0A' which is equivalent to accepting decimal values: 32-126, 9(horizontal tab) & 10(new line). I see the difference is only 2 chars(horizontal tab & new line) which we should allow IMO.

@Annam16 Annam16 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attached failure log in JIRA clearly says that, while converting a particular value to the data type "int", exception thrown. And this exception has to be handled in "Framework/Utils/data_Utils.py" "convert2type" method. So kindly add the changes in "convert2type" method.

Annam16
Annam16 previously approved these changes Aug 8, 2017
try:
cvalue = convert(value)
except Exception as exception:
print_exception(exception)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It would be better if we add the warning message instead of printing the whole exception.
  2. I see couple of exceptions , one is we are raising and the other one is because of returning "None". Do necessary changes.
  3. Multiple return statements inside single method. we can assign it to a variable called "status" and handle that value in all the methods where this method is been called already.

@navvrnd

navvrnd commented Aug 9, 2017

Copy link
Copy Markdown
Contributor Author

made the changes requested. Please review.

@navvrnd

navvrnd commented Aug 14, 2017

Copy link
Copy Markdown
Contributor Author

cli full regression log attached in the jira ticket. The following tests failed in the full regression which does not look like issues due to this change:

  1. connect: connect_call_connect_telnet_multi_subsys, connect_call_connect_telnet_custom_keystroke, connect_abort_as_error
  2. cli_global_attr: tc_global_title_no_subsys, tc_global_title_one_subsys, tc_global_title_multi_subsys
  3. cli_local_attr: tc_local_title_no_subsys
  4. cli_other_attr: tc_cmd_retry_attrib
  5. log_verify_on_suite: log_verify_on

Annam16
Annam16 previously approved these changes Aug 17, 2017

@Annam16 Annam16 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this pull request by testing it with "warrior_fnc_tests/warrior_tests/testcases/cli_tests/other_attr/tc_testdata_relations_verify.xml" by passing different inputs. Working fine.

venkat1077
venkat1077 previously approved these changes Aug 17, 2017
@kaheichan
kaheichan requested review from kaheichan and removed request for satyakrish September 26, 2017 18:32

@kaheichan kaheichan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions are raised in Jira ticket

@kaheichan

kaheichan commented Oct 4, 2017

Copy link
Copy Markdown
Contributor

Hi @navvrnd
More comment has been added in the Jira ticket
the TODO is:

  1. Have a better error message when substitution went wrong
  2. Add a testcase to test this error

Hi @kaheichan
addressed the first comment. For addressing the second comment, can you please let me know, how to create data with non-printable characters? The system where the issue was found is product team's system, which can not be used by us. And in our systems, this issue has not been reproduced. I am assuming that you need a test case to catch the non-printable characters issue if it does occur. Please let me know your comments.

10/5 Ka
Hi @navvrnd , you can use echo or touch in terminal to make file with non-printable content
https://stackoverflow.com/questions/35947715/how-can-i-create-a-file-with-a-non-printing-character-in-the-name
another way is using the function that you called in your fix, the
rem_nonprintable_ctrl_chars()
loop through the characters that need to be replaced in the replace function inside
and write those to a file in python

@kaheichan

Copy link
Copy Markdown
Contributor

Upon further investigation in the dummy-td file and the attached td file, I found out that in the dummy-td file
user specifies a regular expression resp_pat_req="[\d]+\s" to capture the response from server.
\s in the resp_pat_req captures the non-printable character “\n” in the response “2017041011\n”
When the user uses the response as an integer conditional value, Python tries to cast “2017041011\n” to an int, which fails because \n cannot be converted into integer.

This is a user input error that we cannot prevent.
What we can do is when we are trying to use the saved value as conditional value and converting it into integer, we should remove the non-printable character before the conversion.

The current fix in WAR-1255 will cause issues in the future when the user actually wants to capture non-printable character such as newline.
Since the fix removes all non-printable characters, a scenario where user wants to capture a multi-line response will be distorted because we remove the new-line character in this fix.
Please update the fix and let us know immediately so we can review and merge asap.

@navvrnd

navvrnd commented Oct 11, 2017

Copy link
Copy Markdown
Contributor Author

Hi @kaheichan addressed all the comments. Please check and approve.

10/12 -Ka
@navvrnd hello, have some small comments, please address. Code logic looks clear

10/13 - Arvind
@kaheichan done. Please check.

Comment thread warrior/Framework/Utils/data_Utils.py Outdated
except SyntaxError:
print_error("Syntax Error - " +
error_msg2.format(string, value))
from WarriorCore.Classes.testcase_utils_class import TestcaseUtils

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put import statement at the beginning of the file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment thread warrior/Framework/Utils/data_Utils.py Outdated
error_msg2.format(string, value))
from WarriorCore.Classes.testcase_utils_class import TestcaseUtils
tuc_obj = TestcaseUtils()
print_info("Checking after removing the illegal characters")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a more detailed message
"Cannot convert value: {} into correct format, removing non-printable characters, will attempt conversion again"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to "Cannot convert below value into correct format, removing non-printable characters, will attempt conversion again" and the actual value in next line, since it mangles the other characters in the string.

@kaheichan

kaheichan commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

Hi @navvrnd
The code looks good, I run the new testcase and verified it works
however cli_proj is failing and it shouldn't
please refer to the internal PR for more info

Hi @kaheichan
After the merge the regression passed except for tc_multiple_response_patterns.xml since its code base war-1156 is still yet to be merged.

@navvrnd war-1156 was merged. Please rerun regression and let us know it passed.

@kaheichan reran and attached in the ticket. Looks like the code for WAR-1439 is still not yet in which is causing one failure.

10/23 -Ka
Hi @navvrnd
I verified the test again and found out that the testcase doesn't actually found the response pattern in the response. I have added a warning message when it is not found. I have also changed the sample response in the server to actually test the \s part
We still need to discuss the question sent in the email

@bjrr bjrr changed the title Bugfix/war 1255: response stored in data repository through response_ref get stored with control characters WAR-1255: response stored in data repository through response_ref get stored with control characters Oct 24, 2017
@navvrnd

navvrnd commented Oct 24, 2017

Copy link
Copy Markdown
Contributor Author

Hi @kaheichan I have attached all pass full regression log in the ticket after commenting out list_range test case which was causing hang. Please let me know, what else to be done for this ticket.

@kaheichan

Copy link
Copy Markdown
Contributor

Saw the change and verified the fix, thank you @navvrnd

@bjrr
bjrr merged commit e15616c into develop Oct 30, 2017
@bjrr bjrr added this to the Warrior-3.5.0 milestone Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants