You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/04/24 22:26:37 UTC

[GitHub] [kafka] vvcephei commented on a change in pull request #8546: MINOR: document how to escape json parameters to ducktape tests

vvcephei commented on a change in pull request #8546:
URL: https://github.com/apache/kafka/pull/8546#discussion_r414897161



##########
File path: tests/README.md
##########
@@ -36,6 +36,10 @@ TC_PATHS="tests/kafkatest/tests/client/pluggable_test.py::PluggableConsumerTest"
 ```
 TC_PATHS="tests/kafkatest/tests/client/pluggable_test.py::PluggableConsumerTest.test_start_stop" bash tests/docker/run_tests.sh
 ```
+* Run a specific test method with specific parameters
+```
+TC_PATHS="tests/kafkatest/tests/streams/streams_upgrade_test.py::StreamsUpgradeTest.test_metadata_upgrade" _DUCKTAPE_OPTIONS='--parameters '\''{"from_version":"0.10.1.1","to_version":"2.6.0-SNAPSHOT"}'\' bash tests/docker/run_tests.sh

Review comment:
       Haha, having just spent several hours settling on this exact sequence of characters, I can certify that it's correct ;) 
   
   Actually, I would like to get at least one other person to try it out. Do you mind?
   
   To answer your question, here's how it works:
   first string (wrapped in single quotes for consistency with the second string): `--parameters `
   first escaped single quote: `\'`
   second string (wrapped in single quotes to avoid evaluating the special characters): `{"from_version":"0.10.1.1","to_version":"2.6.0-SNAPSHOT"}`
   second escaped single quote: `\'`
   
   Following Bash rules, a sequence of strings and characters just get concatenated, so all of the above gets smashed together to form the desired final string:
   `--parameters '{"from_version":"0.10.1.1","to_version":"2.6.0-SNAPSHOT"}'`
   
   which will then be evaluated _again_ by Bash inside the docker container, so that the final argument to ducktape is the desired argument list: `--parameters`, followed by `{"from_version":"0.10.1.1","to_version":"2.6.0-SNAPSHOT"}`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org