Skip to content

Commit

Permalink
Add ability to resolve GetCapabilities and bazel connect testing
Browse files Browse the repository at this point in the history
  • Loading branch information
allada committed Dec 25, 2020
1 parent 24dec02 commit 1aba20c
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

build -c dbg
build --test_output=errors

build:self_test --remote_instance_name=main
build:self_test --remote_cache=grpc://127.0.0.1:50051
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tonic = "0.3.1"

[dev-dependencies]
clap = "2.33.3"
stdext = "0.2.1"
prost-build = "0.6.1"
tonic-build = "0.3.1"
rustfmt-nightly = "1.4.21"
Expand Down
3 changes: 3 additions & 0 deletions cas/grpc_service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust_library(
"//proto",
"//third_party:tonic",
"//third_party:futures_core",
"//third_party:stdext",
],
visibility = ["//cas:__pkg__"]
)
Expand All @@ -16,6 +17,7 @@ rust_library(
srcs = ["ac_server.rs"],
deps = [
"//proto",
"//third_party:stdext",
"//third_party:tonic",
],
visibility = ["//cas:__pkg__"]
Expand All @@ -37,6 +39,7 @@ rust_library(
deps = [
"//proto",
"//third_party:tonic",
"//third_party:stdext",
"//third_party:futures_core",
],
visibility = ["//cas:__pkg__"]
Expand Down
10 changes: 8 additions & 2 deletions cas/grpc_service/ac_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ impl ActionCache for AcServer {
&self,
_request: Request<GetActionResultRequest>,
) -> Result<Response<ActionResult>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}

async fn update_action_result(
&self,
_request: Request<UpdateActionResultRequest>,
) -> Result<Response<ActionResult>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}
}
44 changes: 42 additions & 2 deletions cas/grpc_service/capabilities_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ use tonic::{Request, Response, Status};

use proto::build::bazel::remote::execution::v2::{
capabilities_server::Capabilities, capabilities_server::CapabilitiesServer as Server,
GetCapabilitiesRequest, ServerCapabilities,
digest_function::Value as DigestFunction,
symlink_absolute_path_strategy::Value as SymlinkAbsolutePathStrategy,
ActionCacheUpdateCapabilities, CacheCapabilities, ExecutionCapabilities,
GetCapabilitiesRequest, PriorityCapabilities, ServerCapabilities,
};

use proto::build::bazel::semver::SemVer;

#[derive(Debug, Default)]
pub struct CapabilitiesServer {}

Expand All @@ -22,6 +27,41 @@ impl Capabilities for CapabilitiesServer {
&self,
_request: Request<GetCapabilitiesRequest>,
) -> Result<Response<ServerCapabilities>, Status> {
Err(Status::unimplemented("Not yet implemented"))
let resp = ServerCapabilities {
cache_capabilities: Some(CacheCapabilities {
digest_function: vec![DigestFunction::Sha256.into()],
action_cache_update_capabilities: Some(ActionCacheUpdateCapabilities {
update_enabled: true,
}),
cache_priority_capabilities: Some(PriorityCapabilities { priorities: vec![] }),
max_batch_total_size_bytes: 0,
symlink_absolute_path_strategy: SymlinkAbsolutePathStrategy::Disallowed.into(),
}),
execution_capabilities: Some(ExecutionCapabilities {
digest_function: DigestFunction::Sha256.into(),
exec_enabled: false,
execution_priority_capabilities: Some(PriorityCapabilities { priorities: vec![] }),
supported_node_properties: vec![],
}),
deprecated_api_version: Some(SemVer {
major: 0,
minor: 0,
patch: 0,
prerelease: "".to_string(),
}),
low_api_version: Some(SemVer {
major: 2,
minor: 0,
patch: 0,
prerelease: "".to_string(),
}),
high_api_version: Some(SemVer {
major: 2,
minor: 1,
patch: 0,
prerelease: "".to_string(),
}),
};
Ok(Response::new(resp))
}
}
20 changes: 16 additions & 4 deletions cas/grpc_service/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,30 @@ impl ContentAddressableStorage for CasServer {
&self,
_request: Request<FindMissingBlobsRequest>,
) -> Result<Response<FindMissingBlobsResponse>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}

async fn batch_update_blobs(
&self,
_request: Request<BatchUpdateBlobsRequest>,
) -> Result<Response<BatchUpdateBlobsResponse>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}

async fn batch_read_blobs(
&self,
_request: Request<BatchReadBlobsRequest>,
) -> Result<Response<BatchReadBlobsResponse>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}

type GetTreeStream =
Expand All @@ -51,6 +60,9 @@ impl ContentAddressableStorage for CasServer {
&self,
_request: Request<GetTreeRequest>,
) -> Result<Response<Self::GetTreeStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}
}
10 changes: 8 additions & 2 deletions cas/grpc_service/execution_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ impl Execution for ExecutionServer {
&self,
_request: Request<ExecuteRequest>,
) -> Result<Response<Self::ExecuteStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}

type WaitExecutionStream =
Expand All @@ -38,6 +41,9 @@ impl Execution for ExecutionServer {
&self,
_request: Request<WaitExecutionRequest>,
) -> Result<Response<Self::WaitExecutionStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
use stdext::function_name;
let output = format!("{} not yet implemented", function_name!());
println!("{}", output);
Err(Status::unimplemented(output))
}
}
9 changes: 9 additions & 0 deletions third_party/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ alias(
],
)

alias(
name = "stdext",
actual = "@raze__stdext__0_2_1//:stdext",
tags = [
"cargo-raze",
"manual",
],
)

alias(
name = "tokio",
actual = "@raze__tokio__0_2_24//:tokio",
Expand Down
10 changes: 10 additions & 0 deletions third_party/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,16 @@ def raze_fetch_remote_crates():
build_file = Label("//third_party/remote:BUILD.stacker-0.1.12.bazel"),
)

maybe(
http_archive,
name = "raze__stdext__0_2_1",
url = "https://crates.io/api/v1/crates/stdext/0.2.1/download",
type = "tar.gz",
sha256 = "4a61b4ae487cb43d0479907e74d36f8813e9940bd3b1adcbecc69fe8a0cee3ec",
strip_prefix = "stdext-0.2.1",
build_file = Label("//third_party/remote:BUILD.stdext-0.2.1.bazel"),
)

maybe(
http_archive,
name = "raze__strsim__0_8_0",
Expand Down
53 changes: 53 additions & 0 deletions third_party/remote/BUILD.stdext-0.2.1.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
@generated
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

# buildifier: disable=load
load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_binary",
"rust_library",
"rust_test",
)

# buildifier: disable=load
load("@bazel_skylib//lib:selects.bzl", "selects")

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//third_party", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # MIT from expression "MIT"
])

# Generated Targets

rust_library(
name = "stdext",
srcs = glob(["**/*.rs"]),
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"manual",
],
version = "0.2.1",
# buildifier: leave-alone
deps = [
],
)

0 comments on commit 1aba20c

Please sign in to comment.