-
Notifications
You must be signed in to change notification settings - Fork 205
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
Wrap client instead of runner in daml-script compat test #12630
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 0 additions & 15 deletions
15
compatibility/bazel_tools/client_server/with-upload-dar/BUILD
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
compatibility/bazel_tools/client_server/with-upload-dar/Main.hs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,10 @@ $(location {daml}) build --project-root=$$TMP_DIR -o $$PWD/$(OUTS) | |
) | ||
|
||
def daml_script_test(compiler_version, runner_version): | ||
name = "daml-script-test-compiler-{compiler_version}-runner-{runner_version}".format( | ||
compiler_version = version_to_name(compiler_version), | ||
runner_version = version_to_name(runner_version), | ||
) | ||
compiled_dar = "//:script-example-dar-{version}".format( | ||
version = version_to_name(compiler_version), | ||
) | ||
|
@@ -66,43 +70,80 @@ def daml_script_test(compiler_version, runner_version): | |
server = "@daml-sdk-{version}//:sandbox-on-x".format(version = runner_version) | ||
server_args = ["--participant", "participant-id=sandbox,port=6865"] | ||
server_files = [] | ||
runner_files = ["$(rootpath {})".format(compiled_dar)] | ||
server_files_prefix = "" | ||
else: | ||
server = daml_runner | ||
server_args = ["sandbox"] | ||
server_files = ["$(rootpath {})".format(compiled_dar)] | ||
runner_files = [] | ||
server_files_prefix = "--dar=" if use_canton else "" | ||
|
||
client_server_test( | ||
name = "daml-script-test-compiler-{compiler_version}-runner-{runner_version}".format( | ||
compiler_version = version_to_name(compiler_version), | ||
runner_version = version_to_name(runner_version), | ||
native.genrule( | ||
name = "{}-client-sh".format(name), | ||
outs = ["{}-client.sh".format(name)], | ||
cmd = """\ | ||
cat >$(OUTS) <<'EOF' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
canonicalize_rlocation() {{ | ||
# Note (MK): This is a fun one: Let's say $$TEST_WORKSPACE is "compatibility" | ||
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. The amount of questionable comments that I wrote months ago that keep resurfacing now is somewhat disturbing |
||
# and the argument points to a target from an external workspace, e.g., | ||
# @daml-sdk-0.0.0//:daml. Then the short path will point to | ||
# ../daml-sdk-0.0.0/daml. Putting things together we end up with | ||
# compatibility/../daml-sdk-0.0.0/daml. On Linux and MacOS this works | ||
# just fine. However, on windows we need to normalize the path | ||
# or rlocation will fail to find the path in the manifest file. | ||
rlocation $$(realpath -L -s -m --relative-to=$$PWD $$TEST_WORKSPACE/$$1) | ||
}} | ||
runner=$$(canonicalize_rlocation $(rootpath {runner})) | ||
# Cleanup the trigger runner process but maintain the script runner exit code. | ||
trap 'status=$$?; kill -TERM $$PID; wait $$PID; exit $$status' INT TERM | ||
|
||
if [ {upload_dar} -eq 1 ] ; then | ||
$$runner ledger upload-dar \\ | ||
--host localhost \\ | ||
--port 6865 \\ | ||
$$(canonicalize_rlocation $(rootpath {dar})) | ||
fi | ||
$$runner script \\ | ||
--ledger-host localhost \\ | ||
--ledger-port 6865 \\ | ||
--wall-clock-time \\ | ||
--dar $$(canonicalize_rlocation $(rootpath {dar})) \\ | ||
--script-name ScriptExample:test | ||
EOF | ||
chmod +x $(OUTS) | ||
""".format( | ||
dar = compiled_dar, | ||
runner = daml_runner, | ||
upload_dar = "1" if use_sandbox_on_x else "0", | ||
), | ||
client = daml_runner, | ||
client_args = [ | ||
"script", | ||
"--ledger-host", | ||
"localhost", | ||
"--ledger-port", | ||
"6865", | ||
"--wall-clock-time", | ||
"--script-name", | ||
"ScriptExample:test", | ||
"--dar", | ||
exec_tools = [ | ||
compiled_dar, | ||
daml_runner, | ||
], | ||
client_files = [ | ||
"$(rootpath {})".format(compiled_dar), | ||
) | ||
native.sh_binary( | ||
name = "{}-client".format(name), | ||
srcs = ["{}-client.sh".format(name)], | ||
data = [ | ||
compiled_dar, | ||
daml_runner, | ||
], | ||
) | ||
|
||
client_server_test( | ||
name = name, | ||
client = "{}-client".format(name), | ||
client_args = [], | ||
client_files = [], | ||
data = [ | ||
compiled_dar, | ||
], | ||
runner = "//bazel_tools/client_server/with-upload-dar:runner", | ||
runner_args = ["--port=6865"], | ||
runner_files = runner_files, | ||
runner_files_prefix = "--dar=", | ||
runner = "//bazel_tools/client_server:runner", | ||
runner_args = ["6865"], | ||
server = server, | ||
server_args = server_args, | ||
server_files = server_files, | ||
server_files_prefix = "--dar=" if use_canton else "", | ||
server_files_prefix = server_files_prefix, | ||
tags = ["exclusive"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don’t quite understand why this needs to be a genrule instead of making the sh_binary accept an argument to figure out what it should do so it can be a non-generate bash file.
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 think the advantage of generating it is we don't have to rely on positional arguments. Not a very strong argument tho. (pun not intended)
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.
happy either way your choice