Skip to content

Commit

Permalink
Work on abitest fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetr0v committed May 18, 2020
1 parent c9b1a04 commit ee309b6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/aggregator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Build and run the Client with the following command:
./scripts/build_example -e aggregator
./bazel-client-bin/examples/aggregator/client/client \
--address=127.0.0.1:8080 \
--ca_cert=./examples/certs/local/local.pem \
--ca_cert=./examples/certs/local/ca.pem \
--bucket=test \
--data=1:10,2:20,3:30
```
Expand Down
28 changes: 16 additions & 12 deletions examples/aggregator/scripts/run_example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ readonly SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=scripts/common
source "${GLOBAL_SCRIPTS_DIR}/common"

server="base"
server="rust"
buildargs=""
serverargs=""
while getopts "s:l:de:vh" opt; do
Expand All @@ -17,9 +17,9 @@ Build and run the given example Oak Application and client.
Options:
-s Server type used to run examples:
- base: base version of the server (default)
- base: base version of the server
- logless: base version of the server with debug logging compiled out
- rust: Rust version of the server
- rust: Rust version of the server (default)
- asan: server with address sanitizer
- tsan: server with thread sanitizer
- none: run an application client without a server
Expand Down Expand Up @@ -60,20 +60,24 @@ if [[ "${server}" == "tsan" ]]; then
fi

if [[ "${server}" != "none" ]]; then
# Run the Backend server in the background.
# cargo build --release --package=aggregator_backend
# "${SCRIPTS_DIR}/run_backend" &
# readonly BACKEND_PID=$!
# to_kill+=("${BACKEND_PID}")
# echo "----- Background server is running -----"

"${GLOBAL_SCRIPTS_DIR}/build_example" ${buildargs} -l rust -e aggregator

# Run a server in the background.
# The server is being built before running, so the build process will not happen in the
# background.
# # Run a server in the background.
# # The server is being built before running, so the build process will not happen in the
# # background.
"${GLOBAL_SCRIPTS_DIR}/build_server" -s "${server}"
"${GLOBAL_SCRIPTS_DIR}/run_server" ${serverargs} -s "${server}" -l rust -e aggregator &
# "${GLOBAL_SCRIPTS_DIR}/run_server" ${serverargs} -s "${server}" -l rust -e aggregator &
"${SCRIPTS_DIR}/run_server" ${serverargs} -s "${server}" -l rust -e aggregator &
readonly SERVER_PID=$!
to_kill+=("${SERVER_PID}")

# Run the Backend server in the background.
# "${SCRIPTS_DIR}/run_backend" &
# readonly BACKEND_PID=$!
# to_kill+=("${BACKEND_PID}")
echo "----- Oak server is running -----"

sleep 3 # Wait for the application to start.
fi
Expand Down
5 changes: 3 additions & 2 deletions examples/aggregator/scripts/run_server
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ source "${GLOBAL_SCRIPTS_DIR}/common"
"${GLOBAL_SCRIPTS_DIR}/build_server" -s rust
"${GLOBAL_SCRIPTS_DIR}/build_example" -e aggregator

readonly APPLICATION="${PWD}/bazel-client-bin/examples/aggregator/config/config_rust.bin"
readonly APPLICATION="${PWD}/bazel-client-bin/examples/aggregator/config/config.bin"
# exec cargo run --package=oak_loader \
exec ./bazel-clang-bin/oak/server/rust/oak_loader/oak_loader \
--application="${APPLICATION}" \
--grpc-tls-private-key="${GLOBAL_SCRIPTS_DIR}/../examples/certs/local/local.key" \
--grpc-tls-certificate="${GLOBAL_SCRIPTS_DIR}/../examples/certs/local/local.pem"
--grpc-tls-certificate="${GLOBAL_SCRIPTS_DIR}/../examples/certs/local/local.pem" \
--root-tls-certificate="${GLOBAL_SCRIPTS_DIR}/../examples/certs/local/ca.pem"
25 changes: 21 additions & 4 deletions oak/server/rust/oak_runtime/src/node/grpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,35 @@ impl GrpcClientNode {
let receiver = Receiver::<Invocation>::new(handle);
loop {
// Read a gRPC invocation from the [`Receiver`].
let invocation = receiver.receive(&runtime)?;
let invocation = receiver.receive(&runtime).map_err(|error| {
error!("Couldn't reveice the invocation: {:?}", error);
error
})?;

// Receive a request from the invocation channel.
let request = invocation.receive_request(&runtime)?;
let request = invocation.receive_request(&runtime).map_err(|error| {
error!(
"Couldn't reveice gRPC request from the invocation: {:?}",
error
);
error
})?;
debug!("Incoming gRPC request: {:?}", request);

// Send an unary request to an external gRPC service and wait for the response.
let response = self.handler.unary_request(request).await?;
let response = self.handler.unary_request(request).await.map_err(|error| {
error!("Couldn't send gRPC request: {:?}", error);
error
})?;

// Send a response back to the invocation channel.
debug!("Sending gRPC response: {:?}", response);
invocation.send_response(response, &runtime)?;
invocation
.send_response(response, &runtime)
.map_err(|error| {
error!("Couldn't send gRPC response to the invocation: {:?}", error);
error
})?;
}
}
}
Expand Down

0 comments on commit ee309b6

Please sign in to comment.