Skip to content

Commit

Permalink
update(fildesh): with new array syntax
Browse files Browse the repository at this point in the history
Also update other Bazel dependencies.
  • Loading branch information
grencez committed Jul 7, 2024
1 parent 3e8d7d6 commit df3c4ba
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 39 deletions.
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
common --experimental_enable_bzlmod
common --registry=https://raw.githubusercontent.com/rendezqueue/rendezqueue_bazel_registry/trunk
common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main
common --cxxopt=-std=c++17
Expand Down
23 changes: 14 additions & 9 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,38 @@ module(
version = "0.0.0",
)

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_license", version = "0.0.8")
bazel_dep(name = "rules_proto", version = "6.0.0.bcr.1")

bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(
name = "abseil-cpp",
version = "20240116.2",
repo_name = "com_google_absl")
repo_name = "com_google_absl",
)
bazel_dep(
name = "grpc",
version = "1.62.1.bcr.1",
repo_name = "com_github_grpc_grpc")
version = "1.63.1",
repo_name = "com_github_grpc_grpc",
)

bazel_dep(
name = "fildesh",
version = "0.1.9",
dev_dependency = True)
dev_dependency = True,
)
git_override(
module_name = "fildesh",
commit = "e9421ebbb546cf38bf2051d02fdc38dcf71f8216",
remote = "https://github.com/fildesh/fildesh.git",
commit="11ff65ed78103bc1b1caefb1deb8fa42110eea08",
)

bazel_dep(
name = "rules_sxproto",
version = "0.0.4",
dev_dependency = True)
dev_dependency = True,
)
git_override(
module_name = "rules_sxproto",
commit = "3b2c69cc8bc5e72b1da198551e16575a09513df9",
remote = "https://github.com/rendezqueue/rules_sxproto.git",
commit="c720229ebe571b470efc6b34fda182308e56c1c8",
)
2 changes: 1 addition & 1 deletion proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ cc_proto_library(
cc_grpc_library(
name = "rendezqueue_cc_grpc",
srcs = [":rendezqueue_proto"],
deps = [":rendezqueue_cc_proto"],
grpc_only = True,
deps = [":rendezqueue_cc_proto"],
)
6 changes: 3 additions & 3 deletions src/ccgrpc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

alias(
name = "grpc_cc_lib",
Expand All @@ -12,11 +13,11 @@ cc_library(
"swapstore.cc",
"swapstore.hh",
],
visibility = ["//test/scenario:__pkg__"],
deps = [
"//proto:rendezqueue_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
],
visibility = ["//test/scenario:__pkg__"],
)

cc_library(
Expand All @@ -25,10 +26,10 @@ cc_library(
"ssl_cred.cc",
"ssl_cred.hh",
],
visibility = ["//test/scenario:__pkg__"],
deps = [
":grpc_cc_lib",
],
visibility = ["//test/scenario:__pkg__"],
)

cc_binary(
Expand Down Expand Up @@ -71,4 +72,3 @@ cc_binary(
"@com_google_absl//absl/flags:parse",
],
)

3 changes: 0 additions & 3 deletions src/ccgrpc/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

This is a C++ / gRPC version of the server, but it doesn't actually do swapping yet so the binaries and deps are marked as testonly.
I'd like to actually use gRPC but JavaScript in a browser cannot talk to it directly, so what's the point?
Maybe grpc-web is a path forward, but it requires a proxy.

Anyway, this gRPC code shouldn't add too much extra to the build because JSON tests will rely on a protobuf schema for sanity.

You can test out the SSL authentication like this:

```shell
Expand Down
1 change: 1 addition & 0 deletions test/scenario/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@fildesh//tool/bazel:fildesh_test.bzl", "fildesh_test")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_sxproto//sxproto:defs.bzl", "sxproto_data")

Expand Down
28 changes: 14 additions & 14 deletions test/scenario/basic.sxpb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
((expectations)
(expectations (())

(()
(req (key "k") (id "Alice") (ttl 5) ((values) "aa"))
(req (key "k") (id "Alice") (ttl 5) (values (()) "aa"))
(res (key "k") (id "Alice") (ttl 5) (offset 1)))
(()
(delta_ms 1000)
Expand All @@ -10,48 +10,48 @@

(()
(delta_ms 1000)
(req (key "k") (id "Bob") (ttl 5) ((values) "bbbb"))
(res (key "k") (id "Bob") (offset 1) ((values) "aa")))
(req (key "k") (id "Bob") (ttl 5) (values (()) "bbbb"))
(res (key "k") (id "Bob") (offset 1) (values (()) "aa")))

; Both get a good response if they send their original values.
(()
(req (key "k") (id "Bob") ((values) "bbbb"))
(res (key "k") (id "Bob") (offset 1) ((values) "aa")))
(req (key "k") (id "Bob") (values (()) "bbbb"))
(res (key "k") (id "Bob") (offset 1) (values (()) "aa")))
(()
(req (key "k") (id "Alice") ((values) "aa"))
(res (key "k") (id "Alice") (offset 1) ((values) "bbbb")))
(req (key "k") (id "Alice") (values (()) "aa"))
(res (key "k") (id "Alice") (offset 1) (values (()) "bbbb")))

; But not nonsense.
(()
(req (key "k") (id "Alice") (offset 2))
(http_status_code 404))
(()
(req (key "k") (id "Alice") ((values) "ddddd"))
(req (key "k") (id "Alice") (values (()) "ddddd"))
(http_status_code 404))
(()
(req (key "k") (id "Bob") (offset 2))
(http_status_code 404))
(()
(req (key "k") (id "Bob") ((values) "ddddd"))
(req (key "k") (id "Bob") (values (()) "ddddd"))
(http_status_code 404))

; Wait 4 seconds. Data still there.
(()
(delta_ms 4000)
(req (key "k") (id "Alice") (offset 1))
(res (key "k") (id "Alice") (offset 1) ((values) "bbbb")))
(res (key "k") (id "Alice") (offset 1) (values (()) "bbbb")))
(()
(req (key "k") (id "Bob") (offset 1))
(res (key "k") (id "Bob") (offset 1) ((values) "aa")))
(res (key "k") (id "Bob") (offset 1) (values (()) "aa")))

; With 1 millisecond remaining, both still get a good response.
(()
(delta_ms 999)
(req (key "k") (id "Alice") (offset 1))
(res (key "k") (id "Alice") (offset 1) ((values) "bbbb")))
(res (key "k") (id "Alice") (offset 1) (values (()) "bbbb")))
(()
(req (key "k") (id "Bob") (offset 1))
(res (key "k") (id "Bob") (offset 1) ((values) "aa")))
(res (key "k") (id "Bob") (offset 1) (values (()) "aa")))

; After 1 more millisecond, the data expires.
(()
Expand Down
20 changes: 12 additions & 8 deletions test/stress/flood_grpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ n=$1
test -n "$n"
n=$(($n / 3))

parallelism=10
count_per_process=$((($n + $parallelism - 1) / $parallelism))
n=$(($count_per_process * $parallelism))
process_count=$2
if [ -z "${process_count}" ]; then
process_count=10
fi

count_per_process=$((($n + ${process_count} - 1) / ${process_count}))
n=$(($count_per_process * ${process_count}))

printf 'Sending %u * %u processes * 3 phases == %u requests\n' \
${count_per_process} ${parallelism} $((3 * $n))
${count_per_process} ${process_count} $((3 * $n))

xargs_cmd="xargs -n 1 -P ${parallelism} ./bazel-bin/src/ccgrpc/syncclient --count ${count_per_process}"
xargs_cmd="xargs -n 1 -P ${process_count} ./bazel-bin/src/ccgrpc/syncclient --count ${count_per_process}"

seq 1 "$parallelism" |
seq 1 "${process_count}" |
${xargs_cmd} --id Alice --key >/dev/null 2>&1

seq 1 "$parallelism" |
seq 1 "${process_count}" |
${xargs_cmd} --id Bob --key >/dev/null 2>&1

seq 1 "$parallelism" |
seq 1 "${process_count}" |
${xargs_cmd} --id Alice --key >/dev/null 2>&1

0 comments on commit df3c4ba

Please sign in to comment.