KAFKA-7793: Improve the Trogdor command line.#6133
Conversation
stanislavkozlovski
left a comment
There was a problem hiding this comment.
Lots of great changes! Thanks for the PR, @cmccabe!
I like the separation into .json specs a lot - it is more friendly for an abundance of examples rather than all the .sh scripts we had to duplicate logic in.
There was a problem hiding this comment.
Do we support templating now?
There was a problem hiding this comment.
Oops-- this was an oversight. Fixed.
There was a problem hiding this comment.
I'm wondering whether we should add a README.md under /tests/spec/ or rename to something similar to /tests/trogdor_specs - just to make it clearer for new users what these specs represent
There was a problem hiding this comment.
Good idea. I added an Apache header and a comment to the files, referring to TROGDOR.md
There was a problem hiding this comment.
nit: Might as well create an addWorkerIdArgument() to be consistent with the other shared args
There was a problem hiding this comment.
nit: probably not worth it to log an error, as another delete will be attempted. TestUtils.tempFile() calls file.deleteOnExit();
There was a problem hiding this comment.
Those two test cases are exactly the same, I assume you wanted to test one with spaces ( ) only?
There was a problem hiding this comment.
nit: extra space
There was a problem hiding this comment.
nit: extra space
There was a problem hiding this comment.
Could we add a shorthand --s or chance --show-status's shorthand to --s?
There was a problem hiding this comment.
Added -s as shorthand for --state
There was a problem hiding this comment.
Will this work with multiple task ids? The tasks() code does this:
uriBuilder.queryParam("taskId", (Object[]) request.taskIds().toArray(new String[0]));
I think that returns a single-element array only?
There was a problem hiding this comment.
List#toArray can return arrays with more than one element.
https://docs.oracle.com/javase/8/docs/api/java/util/List.html#toArray-T:A-
The array argument at the end is a little weird. TL;DR is that if you want to squeeze out some extra efficiency, you can pass something other than a zero-length array to that argument, to avoid object allocation.
There was a problem hiding this comment.
This is great functionality but would it be better if we had it in the coordinator server in order to leverage it from REST API clients in other languages? Otherwise we probably need to duplicate logic.
We could maybe open a JIRA to track this as a separate item
There was a problem hiding this comment.
We've been holding off on including regular expressions into APIs since we would like APIs to be language neutral, and Java regexps are not. They also change over time as Java changes (java 8 changed how some of them are interpreted).
I think we could open a follow-up JIRA for this, though. We can use re2 regular expressions to make the API language-neutral.
* Allow the Trogdor agent to be started in "exec mode", where it simply runs a single task and exits after it is complete. * For AgentClient and CoordinatorClient, allow the user to pass the path to a file containing JSON, instead of specifying the JSON object in the command-line text itself. This means that we can get rid of the bash scripts whose only function was to load task specs into a bash string and run a Trogdor command. * Print dates and times in a human-readable way, rather than as numbers of milliseconds. * When listing tasks or workers, output human-readable tables of information. * Allow the user to filter on task ID name, task ID pattern, or task state. * Support a --json flag to provide raw JSON output if desired.
| } | ||
|
|
||
| /** | ||
| * Determine if a string is a JSON object literal. |
There was a problem hiding this comment.
Do we have any use cases for lists of objects at the top level of a JSON string?
There was a problem hiding this comment.
That's a fair question. The answer here is that in all the cases where we're using this function, we want a JSON object as the top-level thing. We generally always make things objects in case we need to add more stuff later on. (For example, perhaps right now we want to configure X with a list of ints, but later we might want a list of ints and a float, etc.)
| /** | ||
| * Utilities for formatting strings. | ||
| */ | ||
| public class Formatter { |
There was a problem hiding this comment.
Sounds good. Renamed
mumrah
left a comment
There was a problem hiding this comment.
I don't see any examples of --exec usage in the README. Maybe we could add one?
Supplying the spec JSON in a file rather than having to do shell gymnastics is definitely an improvement. Human readable output is always nice (for us humans, at least).
|
retest this please |
stanislavkozlovski
left a comment
There was a problem hiding this comment.
JDK8 build test failure is unrelated - kafka.api.AdminClientIntegrationTest.testForceClose
LGTM! Working with Trogdor locally just got a heck of a lot better - thanks a lot for these changes @cmccabe!
* ak/trunk: MINOR: Update usage of deprecated API (apache#6146) KAFKA-4217: Add KStream.flatTransform (apache#5273) MINOR: Update Gradle to 5.1.1 (apache#6160) KAFKA-3522: Generalize Segments (apache#6170) Added quotes around the class path (apache#4469) KAFKA-7837: Ensure offline partitions are picked up as soon as possible when shrinking ISR (apache#6202) MINOR: In the MetadataResponse schema, ignorable should be a boolean KAFKA-7838: Log leader and follower end offsets when shrinking ISR (apache#6168) KAFKA-5692: Change PreferredReplicaLeaderElectionCommand to use Admin… (apache#3848) MINOR: clarify why suppress can sometimes drop tombstones (apache#6195) MINOR: Upgrade ducktape to 0.7.5 (apache#6197) MINOR: Improve IntegrationTestUtils documentation (apache#5664) MINOR: upgrade to jdk8 8u202 KAFKA-7693; Fix SequenceNumber overflow in producer (apache#5989) KAFKA-7692; Fix ProducerStateManager SequenceNumber overflow (apache#5990) MINOR: update copyright year in the NOTICE file. (apache#6196) KAFKA-7793: Improve the Trogdor command line. (apache#6133)
* Allow the Trogdor agent to be started in "exec mode", where it simply runs a single task and exits after it is complete. * For AgentClient and CoordinatorClient, allow the user to pass the path to a file containing JSON, instead of specifying the JSON object in the command-line text itself. This means that we can get rid of the bash scripts whose only function was to load task specs into a bash string and run a Trogdor command. * Print dates and times in a human-readable way, rather than as numbers of milliseconds. * When listing tasks or workers, output human-readable tables of information. * Allow the user to filter on task ID name, task ID pattern, or task state. * Support a --json flag to provide raw JSON output if desired. Reviewed-by: David Arthur <mumrah@gmail.com>, Stanislav Kozlovski <stanislav_kozlovski@outlook.com>
Allow the Trogdor agent to be started in "exec mode", where it simply
runs a single task and exits after it is complete.
For AgentClient and CoordinatorClient, allow the user to pass the path
to a file containing JSON, instead of specifying the JSON object in the
command-line text itself. This means that we can get rid of the bash
scripts whose only function was to load task specs into a bash string
and run a Trogdor command.
Print dates and times in a human-readable way, rather than as numbers
of milliseconds.
When listing tasks or workers, output human-readable tables of
information.
Allow the user to filter on task ID name, task ID pattern, or task
state.
Support a --json flag to provide raw JSON output if desired.
More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.
Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.
Committer Checklist (excluded from commit message)