-
Notifications
You must be signed in to change notification settings - Fork 115
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
Allow specifying multiple clients for run_examples #1148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,13 @@ source "${SCRIPTS_DIR}/common" | |
|
||
server="base" | ||
application_language="rust" | ||
client_language="cpp" | ||
client_languages="cpp" | ||
buildargs="" | ||
serverargs="" | ||
while getopts "s:a:c:de:vh" opt; do | ||
case "${opt}" in | ||
h) | ||
echo -e "Usage: ${0} [-h] [-s base|logless|none] [-a rust|cpp] [-c rust|cpp|nodejs] [-d] [-v] -e EXAMPLE [-- CLIENT_ARGS] | ||
echo -e "Usage: ${0} [-h] [-s base|logless|none] [-a rust|cpp] [-c [rust|cpp|nodejs]...] [-d] [-v] -e EXAMPLE [-- CLIENT_ARGS] | ||
|
||
Build and run the given example Oak Application and client. | ||
|
||
|
@@ -26,7 +26,8 @@ Options: | |
-a Example application variant: | ||
- rust (used by default) | ||
- cpp | ||
-c Example client variant: | ||
-c Example client variants. Multiple clients can be specified by space | ||
seperating them. Eg -c \"rust cpp nodejs\". | ||
- rust | ||
- cpp (used by default) | ||
- nodejs | ||
|
@@ -37,7 +38,7 @@ Options after -- will be passed to the example client program." | |
a) | ||
application_language="${OPTARG}";; | ||
c) | ||
client_language="${OPTARG}";; | ||
client_languages="${OPTARG}";; | ||
s) | ||
case "${OPTARG}" in | ||
base|logless|none) | ||
|
@@ -97,28 +98,40 @@ fi | |
|
||
readonly CLIENT_ARGS=("${@-}") # Choose client args provided after '--'. | ||
|
||
# Run the application client. | ||
case "${client_language}" in | ||
rust) | ||
cargo run --release --target=x86_64-unknown-linux-musl --manifest-path="${SCRIPTS_DIR}/../examples/${EXAMPLE}/client/rust/Cargo.toml" -- \ | ||
--root-tls-certificate="${SCRIPTS_DIR}/../examples/certs/local/ca.pem" \ | ||
"${CLIENT_ARGS[@]-}" | ||
;; | ||
cpp) | ||
"./bazel-client-bin/examples/${EXAMPLE}/client/client" "${TLS_ARGS[@]}" "${ADDITIONAL_ARGS[@]-}" "${CLIENT_ARGS[@]-}" | ||
;; | ||
nodejs) | ||
nodejs_client="./examples/${EXAMPLE}/client/nodejs" | ||
if [[ -d "${nodejs_client}" ]]; then | ||
npm start --prefix "./examples/${EXAMPLE}/client/nodejs" | ||
else | ||
echo "The ${EXAMPLE} example does not contain a ${client_language} client." | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
echo "Invalid example client variant: ${client_language}" | ||
exit 1;; | ||
esac | ||
# Run the application clients. | ||
for client_language in $client_languages | ||
do | ||
case "${client_language}" in | ||
rust) | ||
rust_client_manifest="${SCRIPTS_DIR}/../examples/${EXAMPLE}/client/rust/Cargo.toml" | ||
if [[ -d "${rust_client_manifest}" ]]; then | ||
cargo run --release --target=x86_64-unknown-linux-musl --manifest-path="${rust_client_manifest}" -- \ | ||
--root-tls-certificate="${SCRIPTS_DIR}/../examples/certs/local/ca.pem" \ | ||
"${CLIENT_ARGS[@]-}" | ||
else | ||
echo "The ${EXAMPLE} example does not contain a ${client_language} client. Skipping this client." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC If we will run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is indeed correct. It will print a warning, but it won't fail. If we think it's important to fail in this case, we'd need to implement a slightly different approach, such as What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the checks for which client languages exist are working properly, and the fail-open nature of the checks means that our Cloudbuild is currently running almost none of the examples: % grep "example does not contain" log-bdcc0238-2511-4076-90da-4810b7719888.txt | grep -v ': +'
Step #9 - "run_examples": The abitest example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The abitest example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The abitest example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The translator example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The translator example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The translator example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The trusted_information_retrieval example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The trusted_information_retrieval example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The trusted_information_retrieval example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The hello_world example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The hello_world example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The chat example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The chat example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The chat example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The running_average example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The running_average example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The running_average example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The private_set_intersection example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The private_set_intersection example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The private_set_intersection example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The machine_learning example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The machine_learning example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The machine_learning example does not contain a nodejs client. Skipping this client.
Step #9 - "run_examples": The aggregator example does not contain a rust client. Skipping this client.
Step #9 - "run_examples": The aggregator example does not contain a cpp client. Skipping this client.
Step #9 - "run_examples": The aggregator example does not contain a nodejs client. Skipping this client.
Step #10 - "run_examples_cpp": The hello_world example does not contain a cpp client. Skipping this client.
Step #10 - "run_examples_cpp": The tensorflow example does not contain a cpp client. Skipping this client. @juliettepretot please could you take a look? |
||
fi | ||
;; | ||
cpp) | ||
cpp_client="./bazel-client-bin/examples/${EXAMPLE}/client/client" | ||
if [[ -d "${cpp_client}" ]]; then | ||
"${cpp_client}" "${TLS_ARGS[@]}" "${ADDITIONAL_ARGS[@]-}" "${CLIENT_ARGS[@]-}" | ||
else | ||
echo "The ${EXAMPLE} example does not contain a ${client_language} client. Skipping this client." | ||
fi | ||
;; | ||
nodejs) | ||
nodejs_client="./examples/${EXAMPLE}/client/nodejs" | ||
if [[ -d "${nodejs_client}" ]]; then | ||
npm start --prefix "${nodejs_client}" | ||
else | ||
echo "The ${EXAMPLE} example does not contain a ${client_language} client. Skipping this client." | ||
fi | ||
;; | ||
*) | ||
echo "Invalid example client variant: ${client_language}" | ||
exit 1;; | ||
esac | ||
done | ||
|
||
kill_bg_pids |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ source "${SCRIPTS_DIR}/common" | |
|
||
server="base" | ||
application_language="rust" | ||
while getopts "s:a:h" opt; do | ||
client_languages="cpp" | ||
while getopts "s:a:c:h" opt; do | ||
case "${opt}" in | ||
h) | ||
echo -e "Usage: ${0} [-s base|logless] [-a rust|cpp] | ||
|
@@ -16,10 +17,17 @@ while getopts "s:a:h" opt; do | |
-a Example application variant: | ||
- rust (default) | ||
- cpp | ||
-c Example client variants. Multiple clients can be specified by space | ||
seperating them. Eg -c \"rust cpp nodejs\". | ||
- rust | ||
- cpp (used by default) | ||
- nodejs | ||
-h Print Help (this message) and exit" | ||
exit 0;; | ||
a) | ||
application_language="${OPTARG}";; | ||
c) | ||
client_languages="${OPTARG}";; | ||
s) | ||
case "${OPTARG}" in | ||
base|logless) | ||
|
@@ -38,12 +46,12 @@ done | |
examples="$(find examples -mindepth 2 -maxdepth 4 -type d -regex '.*/module.*/'"${application_language}"'$' | cut -d'/' -f2 | uniq)" | ||
for example in ${examples}; do | ||
if [[ "${example}" == 'aggregator' ]]; then | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -e aggregator -- --bucket=test --data=1:10,2:20,3:30 | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -c "${client_languages}" -e aggregator -- --bucket=test --data=1:10,2:20,3:30 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think at this point we might have to implement all lang clients for all examples, since example folders are often exhaustive - so developers will have less time figuring out how to work with Oak. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe yes. |
||
elif [[ "${example}" == 'chat' ]]; then | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -e chat -- --test | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -c "${client_languages}" -e chat -- --test | ||
elif [[ "${example}" == 'trusted_information_retrieval' ]]; then | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -c rust -e trusted_information_retrieval -- --latitude 0.0 --longitude 0.0 | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -c "${client_languages}" -e trusted_information_retrieval -- --latitude 0.0 --longitude 0.0 | ||
else | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -e "${example}" | ||
"${SCRIPTS_DIR}/run_example" -s "${server}" -a "${application_language}" -c "${client_languages}" -e "${example}" | ||
fi | ||
done |
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 may be called
run_examples_with_cpp_app
, since it may be confusing whatcpp
stands for.