-
Notifications
You must be signed in to change notification settings - Fork 6
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
113 Improve reporting of test failures for CQL tests, take two #159
base: master
Are you sure you want to change the base?
Conversation
While this is a great improvement over what we currently have in the new test framework, it's still not as easy to parse as
What do you think about comparing line by line instead? I think that's a minor change that would help a lot with debugging. |
Another issue I'm having is that my tox.ini file doesn't take effect anymore. I used to manually edit it before to set the correct python cli name for my local environment. |
… of lines fed into difflib include a trailing newline to avoid trivial mismatches. Shell redirection won't always give us a trailing newline so we manually make sure it's there.
* Shift to cleanup functions rather than an explicit tearDown * Add a few validation fns to linesWithNewline * Add test-adelphi CLI flag for preserving temp dirs
…e sure we take the keyspaces in order
Re: line-by-line diffs... I also wasn't super-happy with the display of diff output, so I finally just knuckled down and switched over to difflib. Given the following change to the 4.0 reference CQL file:
the output on test failure now looks like this:
|
Re: automated generation of tox.ini... this really should be in control of test-adelphi (since it needs to manipulate this file in order to set Cassandra version as well as several other options). The intent is that whatever features we want to expose for tox.ini would migrate to CLI args of test-adelphi itself... something like this is done in this PR for keeping temp directories around after a run. The big advantage of this approach is that it insulates users from having to know about tox, specifically about how to configure it... the app tries to hide as much of that as possible. For the moment I've added a CLI flag to disable auto-generation of tox.ini, but going forward I'd much rather identify whatever functionality we want to include there and move it into the CLI rather than managing tox.ini outside of test-adelphi. |
In addition to the changes addressing the specific comments in the earlier review I've also added a number of improvements/bug fixes discovered via testing. Most notably I've attempted to enforce a deterministic order on keyspaces and tables within keyspace objects themselves (and, by extension, in their generated output). We were seeing cases (especially with Python 2.7) where random ordering was messing with our difflib results in unpleasant ways. |
@@ -95,7 +95,8 @@ def make_tuple(ks): | |||
if props['anonymize']: | |||
anonymize_keyspace(ks) | |||
return KsTuple(ids[orig_name], ks) | |||
return {t.ks_obj.name : t for t in [make_tuple(ks) for ks in keyspaces]} | |||
tuples = sorted([make_tuple(ks) for ks in keyspaces], key=lambda ks: ks.ks_obj.name) | |||
return OrderedDict([(t.ks_obj.name,t) for t in tuples]) |
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.
Keyspaces returned via export should be handled in an orderly way. This is essential for legit compares of prior output to what's done by the current code, which in turn is an essential feature for our integration tests.
# Make sure tables are ordered (by table name) | ||
for ks_obj in all_keyspace_objs: | ||
ks_obj.tables = OrderedDict(sorted(ks_obj.tables.items(), key=lambda item: item[0])) | ||
|
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.
A similar problem to what's discussed above: tables should also follow a coherent order. Tests on Python 2.7 were seeing tables returned in an apparently random order, which in turn caused comparisons to a reference output to fail only because of the ordering of elements within the output.
@@ -20,7 +20,7 @@ import tox | |||
|
|||
|
|||
# Default C* versions to include in all integration tests | |||
DEFAULT_CASSANDRA_VERSIONS = ["2.1.22", "2.2.19", "3.0.23", "3.11.10", "4.0-rc1"] | |||
DEFAULT_CASSANDRA_VERSIONS = ["2.1.22", "2.2.19", "3.0.23", "3.11.10", "4.0.0"] |
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.
An update to 4.0.0... since I was already here :)
if "KEEP_LOGS" in os.environ: | ||
log.info("KEEP_LOGS env var set, preserving logs/output at {}".format(self.dirs.basePath)) | ||
else: | ||
shutil.rmtree(self.dirs.basePath) |
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.
Switched to cleanup functions rather than an explicit tearDown() when trying to diagnose a different problem but in the end I decided to keep the change. tearDown() does have some odd semantics; it's not called if setUp() doesn't succeed, for instance. Rather than worry about it in the future it seemed saner to just convert to cleanup methods directly.
cqlStr = "\n\n".join(open(schemas[ks]).read() for ks in sortedKeyspaces) | ||
allOutputFile.write(cqlStr) | ||
|
||
return allOutputPath |
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.
Another problem observed in testing: the ordering of individual keyspace schemas returned by the glob above isn't deterministic so there's no guarantee we'll get the right ordering of keyspaces when we reconstruct the "all" schema containing everything. To fix this we extract the keyspace name from each individual keyspace schema and traverse them in order when generating the "all" schema. Note that this assumes deterministic output of keyspace names as described above.
This reverts commit be94399.
No description provided.