-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add auto-disabling/enabling to the custom test runner #161
Conversation
@vmagro Could you take a look at this? Although I tested it using cargo to get the new When running this with a live Postgres server, we would need to pass in credentials in the CLI as part of the connection string. I don't have much experience dealing with this so let me know if this isn't the safest way to do it. |
conn: Option<String>, | ||
|
||
/// Commit SHA-1 used to update the test DB on stateful runs | ||
#[structopt(long = "commit", requires("conn"))] |
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.
Why not use --revision
for the cli arg?
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.
As it is currently, the CLI help message suggests using this option as --commit <revision>
, which I kind of prefer over --revision <revision>
. Also, I think "commit" makes it pretty clear we're writing to the DB, whereas "revision" not so much.
tools/testinfra/runner/src/main.rs
Outdated
list: bool, | ||
|
||
/// Path to generated test report in JUnit XML format | ||
#[structopt(long = "xml")] | ||
report: Option<PathBuf>, | ||
|
||
/// Connection string of the DB used in stateful test runs |
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.
This isn't entirely true though? Ideally we could have a default readonly connection so that non-recording runs (eg local users) can also get the list of disabled tests. Or are you planning to solve that separately?
If the disabled test feature only work on CI, that is fine for now, but it would be nice for non-stateful runs to still get the readonly info from the db
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.
I was using the term "stateful" to refer to any execution of the test runner that uses the DB.
The default behavior is read-only and writes are only enabled when the --commit
option is provided.
Summary: Needed for the new test state tracker tool the MLH Fellow is working on Differential Revision: D30546653 fbshipit-source-id: 1a983c671532000dc7a6a30b17080bdb6ff91e0c
df8792e
to
25d025c
Compare
After rebasing onto #162, this now uses MySQL instead of Postgres and I believe most of your previous comments were addressed @vmagro. As far as I'm aware, all functionalities described in this PR are working. That said, when moving it as a local project (using Cargo) to the buck-based build inside the project's source tree, I'm getting linking errors against the indirect dependencies How to test this once it is built:
|
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.
Nice!
I'll import this as-is (and just make the changes I suggested here for you).
I'll make the ci action build the runner with Cargo first, so that we can land this before I fix the linker issues you ran into
@@ -226,6 +295,129 @@ fn report<P: AsRef<Path>>(tests: Vec<TestResult>, path: P) -> Result<()> { | |||
return Ok(()); | |||
} | |||
|
|||
fn xml_escape_text(unescaped: String) -> String { | |||
fn xml_escape_text(unescaped: &String) -> String { |
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.
&str
would be more conventional, and String/&String
can be dereferenced as a &str
@vmagro has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Sadly all of this is incompatible with buck2 :( But I think some of the details might still be useful to incorporate later |
This PR closes #145 and adds optional state tracking to the custom test runner added in #147. It uses a MySQL-compatible DB to track test history and will automatically skip unit tests marked as auto-disabled in the DB provided through the
--db
CLI option.The default behavior is to only read from the test DB. Writes require a
--commit
option with a hash used as a unique identifier for this test run. This is meant to be used with git revision hashes when running this on the CI tool. When writing is enabled, all test results are logged and the auto-disabler/enabler runs.Auto-enabling is quite simple: any passing test which was previously auto-disabled will be re-enabled. Of course, if the test was disabled it wouldn't normally be executed, so a
--run-disabled
command line switch was added to force those tests to run.Auto-disabling takes place after the current run. It will auto-disable a test iff it failed the last 3 times it ran. This criterion is currently hard-coded but should be easy to change in the future.
This PR also includes an SQL script to initialize an empty DB with the table schemas assumed by the implementation.