-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node: stress_object: strip off commas from value strings #543
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear why the locale is even involved in this code
I would remove it completely
I think that the intention was to try to match the locale settings cassandara-stress uses to print its output numbers. |
e4cc609
to
18dd715
Compare
Yup, setting the locale explicitly to en_US works well as it defines |
ccmlib/node.py
Outdated
start = True | ||
prev_locale, encoding = locale.getlocale(locale.LC_NUMERIC) | ||
# Set locale to en_US to simplify printing and parsing of numbers | ||
locale.setlocale(locale.LC_NUMERIC, 'en_US') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we hard code to a specific one,
we can just replace(',',''), and remove all locale related code
setting the locale like that, might break other code we aren't even aware of, like third party code.
@bhalevy this change also introduce 3 more items into the object, which the unittests doesn't know about (and fails) |
18dd715
to
265d8fe
Compare
Hmm
|
As I said, we don't know which locale are available where we're gonna run, we shouldn't be setting it inside a library code. |
Ok, I'll go back to square one |
Some resharding_test dtest, e.g. `test_resharding_counter` fails locally for me: ``` def _run_stress(self, op_cnt, stress_cmd): res = self.node.stress_object(stress_cmd) if not isinstance(res, dict): raise Exception('Error running cassandra-stress: {}'.format(res)) assert res['total errors'] == 0 > assert res['total partitions'] >= op_cnt E assert 10.0 >= 10000 ``` When printing the cassandra-stress stdout I saw that it uses a comma as a 1000s separator: ``` Total partitions : 10,000 [COUNTER_READ: 10,000] ``` This is probably related to the LOCALE on my machine. This change uses the current locale for locale.atof but it deletes any commas from the numbers. Signed-off-by: Benny Halevy <[email protected]>
265d8fe
to
feabd88
Compare
@fruch please merge |
Co-authored-by: Israel Fruchter <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Some resharding_test dtest, e.g.
test_resharding_counter
fails locally for me:When printing the cassandra-stress stdout I saw that it uses a comma as a 1000s separator:
This is probably related to the LOCALE on my machine.
This change explicitly sets the locale to en_US
tha defines comma as the thousands separator
and dot as the decimal point.
The origin local is reset when the function is done.