Skip to content

Commit

Permalink
Add missing example manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiziano88 committed Jul 3, 2020
1 parent 6b85147 commit 2f9c55f
Show file tree
Hide file tree
Showing 24 changed files with 237 additions and 109 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/reproducibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ jobs:
# Build artifacts that are supposed to be reproducible.
- name: Build Rust server
run: ./scripts/docker_run ./scripts/build_server -s base
run: |
./scripts/docker_run ./scripts/runner build-server --server-variant=base
- name: Build examples
run: ./scripts/docker_run ./scripts/build_examples
run: |
./scripts/docker_run ./scripts/runner run-examples --run-clients=false --run-server=false
# Generate an index of the hashes of the reproducible artifacts.
- name: Generate Reproducibility Index
run: ./scripts/docker_run ./scripts/build_reproducibility_index
run: |
./scripts/docker_run ./scripts/build_reproducibility_index
# Remove all files from the "out" folder.
- name: Clear "out" folder
Expand Down
10 changes: 9 additions & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ steps:
waitFor: ['git_init']
timeout: 60m
entrypoint: 'bash'
args: ['./scripts/build_example', '-e', 'hello_world', '-i', 'base']
args:
[
'./scripts/runner',
'run-example',
'--example-name=hello_world',
'--run-server=false',
'--run-clients=false',
'--build-docker',
]

- name: 'gcr.io/oak-ci/oak:latest'
id: generate_root_ca_certs
Expand Down
8 changes: 4 additions & 4 deletions docs/INSTALL-OSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ retrieved from a Google Cloud Docker repository.
The Oak Runtime and its dependencies are built with the following script:

```bash
./scripts/build_server
./scripts/runner build-server
```

Build a particular example, say `hello_world`, with:

```bash
./scripts/build_example -e hello_world
./scripts/runner run-exammples --example-name=hello_world
```

Note that the Runtime server requires a particular Oak Application to run, and
so relies on the previous section.

```bash
./scripts/run_server -e hello_world
./scripts/runner run-examples --run-clients=false --example-name=hello_world
```

In a separate terminal, run an example client that connects to the Oak Runtime
Expand All @@ -84,7 +84,7 @@ needed, so the client will connect to the already-running server of the previous
step):

```bash
./scripts/run_example -s none -e hello_world
./scripts/runner run-examples --run-server=false --example-name=hello_world
```

## Codebase Tools
Expand Down
14 changes: 7 additions & 7 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To build and run one of the Oak example applications under Docker, run:

```bash
./scripts/docker_pull # retrieve cached Docker image for faster builds
./scripts/docker_run ./scripts/run_example -e hello_world
./scripts/docker_run ./scripts/runner run-examples --example-name=hello_world
```

This should build the Runtime, an Oak Application and a client for the
Expand Down Expand Up @@ -118,13 +118,13 @@ Running one of the example Oak applications will confirm that all core
prerequisites have been installed. Run one inside Docker with:

```bash
./scripts/docker_run ./scripts/run_example -e hello_world
./scripts/docker_run ./scripts/runner run-examples --example-name=hello_world
```

or, if all prerequisites are available on the local system, outside of Docker:

```bash
./scripts/run_example -e hello_world
./scripts/runner run-examples --example-name=hello_world
```

That script:
Expand All @@ -151,7 +151,7 @@ to a WebAssembly module and then serializes it into a binary application
configuration file to be loaded to the Oak Server:

```bash
./scripts/build_example -e hello_world
./scripts/runner run-examples --run-server=false --run-clients=false --example-name=hello_world
```

This binary application configuration file includes the compiled Wasm code for
Expand All @@ -172,7 +172,7 @@ The following command builds the Oak Runtime server. An initial build will take
some time, but subsequent builds should be cached and so run much faster.

```bash
./scripts/build_server
./scripts/runner build-server
```

### Run Runtime Server
Expand All @@ -182,7 +182,7 @@ Oak Application (which must already have been compiled into WebAssembly and
built into a serialized configuration, as [described above](#build-application).

```bash
./scripts/run_server -e hello_world
./scripts/runner run-examples --run-clients=false --example-name=hello_world
```

In the end, you should end up with an Oak server running, end with log output
Expand All @@ -202,7 +202,7 @@ client of an example Oak Application (as [described above](#build-application)),
and runs the client code locally.

```bash
./scripts/run_example -s none -e hello_world
./scripts/runner run-examples --run-server=false --logs --example-name=hello_world
```

The `-s none` option indicates that the script expects to find an
Expand Down
8 changes: 4 additions & 4 deletions docs/programming-oak.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,17 @@ Here:
configuration.
All these steps are implemented as a part of the
`./scripts/build_example -e hello_world` script.
`./scripts/runner run-examples --example-name=hello_world` script.
### Starting the Oak Application
The Oak Application is then loaded using the Oak Runner:
The Oak Application is then started using the Oak Loader:
```bash
./scripts/run_server -f "${PWD}/config.bin"
./oak/server/target/x86_64-unknown-linux-musl/release/oak_loader --application="${PWD}/config.bin"
```
The Oak Runner will launch an [Oak Runtime](concepts.md#oak-runtime), and this
The Oak Loader will launch an [Oak Runtime](concepts.md#oak-runtime), and this
Runtime will check the provided Wasm module(s) and application configuration.
Assuming everything is correct (e.g. the Nodes all have a main entrypoint and
only expect to link to the Oak [host functions](abi.md#host-functions)), the Oak
Expand Down
2 changes: 1 addition & 1 deletion examples/abitest/config/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ mkdir --parents "${OUT_DIR}"

bazel run //oak/common:app_config_serializer -- \
--textproto="${DIR}/config.textproto"\
--modules="frontend_module:${MODULES_DIR}/abitest_0_frontend.wasm","backend_module:${MODULES_DIR}/abitest_1_backend.wasm" \
--modules="frontend_module:${MODULES_DIR}/abitest_0_frontend.wasm,backend_module:${MODULES_DIR}/abitest_1_backend.wasm" \
--output_file="${OUT_DIR}/config.bin"
15 changes: 2 additions & 13 deletions examples/aggregator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ a Sparse Vector - a dictionary with integer keys.
Build and run the Aggregator with the following command:

```bash
./scripts/build_example -e aggregator
./scripts/build_server -s base
cargo run --release --target=x86_64-unknown-linux-musl --manifest-path=oak/server/rust/oak_loader/Cargo.toml -- \
--application=./examples/aggregator/bin/config.bin \
--grpc-tls-private-key=./examples/certs/local/local.key \
--grpc-tls-certificate=./examples/certs/local/local.pem \
--root-tls-certificate=./examples/certs/local/ca.pem
./scripts/runner run-examples --run-clients=false --example-name=aggregator
```

Aggregator code is in `common` and `module` directories (where `common` defines
Expand All @@ -56,12 +50,7 @@ Simple client that connects to the Aggregator and sends a data sample via gRPC.
Build and run the Client with the following command:

```bash
./scripts/build_example -e aggregator
./bazel-client-bin/examples/aggregator/client/client \
--address=localhost:8080 \
--ca_cert=./examples/certs/local/ca.pem \
--bucket=test \
--data=1:10,2:20,3:30
./scripts/runner run-examples --run-server=false --example-name=aggregator
```

A common use case is to keep running the client until the aggregation threshold
Expand Down
5 changes: 2 additions & 3 deletions examples/aggregator/scripts/docker_push
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/usr/bin/env bash

readonly GLOBAL_SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")/../../../scripts/"
readonly SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=scripts/common
source "${GLOBAL_SCRIPTS_DIR}/common"

readonly AGGREGATOR_DOCKER_IMAGE_NAME='gcr.io/oak-ci/oak-aggregator'
readonly BACKEND_DOCKER_IMAGE_NAME='gcr.io/oak-ci/oak-aggregator-backend'

declare -a image backend_image
declare image backend_image
image="$(find ./examples/aggregator/bin -name aggregator.tar)"
backend_image="$(find ./examples/aggregator/bin -name aggregator_backend.tar)"
if [[ -z ${image} || -z ${backend_image} ]]; then
echo "Docker images have not been built, run './scripts/build_example -e aggregator -i'"
exit 1
fi
if [[ ${#image[@]} > 1 || ${#backend_image[@]} > 1 ]]; then
if [[ ${#image[@]} -gt 1 || ${#backend_image[@]} -gt 1 ]]; then
echo "Too many Docker images: ${image}, ${backend_image}"
exit 0
fi
Expand Down
1 change: 0 additions & 1 deletion examples/aggregator/scripts/run_backend
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

readonly GLOBAL_SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")/../../../scripts/"
readonly SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=scripts/common
source "${GLOBAL_SCRIPTS_DIR}/common"

Expand Down
1 change: 0 additions & 1 deletion examples/aggregator/scripts/run_client
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

readonly GLOBAL_SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")/../../../scripts/"
readonly SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=scripts/common
source "${GLOBAL_SCRIPTS_DIR}/common"

Expand Down
1 change: 0 additions & 1 deletion examples/aggregator/scripts/run_server
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

readonly GLOBAL_SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")/../../../scripts/"
readonly SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=scripts/common
source "${GLOBAL_SCRIPTS_DIR}/common"

Expand Down
7 changes: 3 additions & 4 deletions examples/aggregator/scripts/undeploy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

readonly GLOBAL_SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")/../../../scripts/"
readonly SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=scripts/common
source "${GLOBAL_SCRIPTS_DIR}/common"

Expand All @@ -11,7 +10,7 @@ while getopts "mh" opt; do
case "${opt}" in
h)
echo -e "Usage: ${0} [-m]
Undeploy aggregator objects.
Undeploy aggregator objects.
-m In addition, undeploy metrics related objects.
-h Print Help (this message) and exit"
exit 0;;
Expand All @@ -27,9 +26,9 @@ gcloud container clusters get-credentials aggregator --zone=europe-west2-a

kubectl delete secret tls-private-key || true
kubectl delete service aggregator || true
kubectl delete deployment aggregator || true
kubectl delete deployment aggregator || true

if [[ $metrics == 1]]
if [[ $metrics == 1 ]]
then
kubectl delete service prometheus-k8s -n agg-metrics || true
kubectl delete deployment metrics-sidecar -n agg-metrics || true
Expand Down
29 changes: 4 additions & 25 deletions examples/chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ as bearer tokens:

## Command Line Operation

Initially, the chat example needs to be built:
Initially, the chat example needs to be built, and the server started:

```bash
./scripts/build_example -e chat
```

Next, let's start the server:

```bash
./scripts/run_server -e chat
./scripts/runner --logs run-examples --run-clients=false --example-name=chat
```

After this, one can run the first client, which connects to the Oak Application
and opens a first chat room inside it:

```bash
./scripts/run_example -s none -e chat
./scripts/runner --logs run-examples --run-server=false --example-name=chat --client-additional-args=--test=false
```

This will emit a trace line that holds the information needed to:
Expand All @@ -46,22 +40,7 @@ This will emit a trace line that holds the information needed to:
Another party can then join the same chat room by using these arguments:

```bash
./scripts/run_example -s none -e chat -- --address=localhost:8080 --room_id=NKsceNlg69UbcvryfzmFGnMv9qnZ0DYh6u6gJxujnPPxvHsxMehoD368sumKawVaq9WaSkzrcStoNYLvVNdzhA==
```

Alternatively, another party can create a new chat room running on the same Oak
Application by just copying the `--address` argument, but specifying a new room
name:

```bash
./scripts/run_example -s none -e chat -- --address=localhost:8080
```

This will again emit a trace line with the information needed to join this new
room (on the same server):

```log
2019-10-24 11:04:40 INFO chat.cc : 242 : Join this room with --address=localhost:8080 --room_id=msSGas1Ie2rtGIvG0bLa2Jh3ODjO35nix46R3j2iYjAcB8zDcJpn/P2DD7c0yB1NMmfoipBSAePJzlXjknm8gg==
./scripts/runner --logs run-examples --run-server=false --example-name=chat --client-additional-args=--test=false --client-additional-args=--room_id=NKsceNlg69UbcvryfzmFGnMv9qnZ0DYh6u6gJxujnPPxvHsxMehoD368sumKawVaq9WaSkzrcStoNYLvVNdzhA==
```

## CI Invocation
Expand Down
7 changes: 5 additions & 2 deletions examples/hello_world/client/nodejs/README.MD
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Node.js client example

Run this example with the following command:
`./scripts/docker_run ./scripts/run_example -e hello_world -c npm`

```bash
./scripts/docker_run --logs ./scripts/runner run-examples --example-name=hello_world
```

If everything works smoothly, you should then find `HELLO Node.js!` logged to
the console, alongside logs from the Oak application.
the console, alongside logs from the Oak application and from other clients.
2 changes: 1 addition & 1 deletion examples/hello_world/config/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ mkdir --parents "${OUT_DIR}"

bazel run //oak/common:app_config_serializer -- \
--textproto="${DIR}/config.textproto"\
--modules="app:${MODULES_DIR}/hello_world.wasm","translator:${MODULES_DIR}/translator.wasm" \
--modules="app:${MODULES_DIR}/hello_world.wasm,translator:${MODULES_DIR}/translator.wasm" \
--output_file="${OUT_DIR}/config.bin"
4 changes: 3 additions & 1 deletion examples/hello_world/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ out = "examples/hello_world/bin/config.bin"

[modules]
module = { Cargo = { cargo_manifest = "examples/hello_world/module/rust/Cargo.toml" } }
# Disabled by default, since it requires emsdk to be installed on the host.
# module_cpp = { Bazel = { bazel_target = "//examples/hello_world/module/cpp:all", config = "emscripten" } }
translator = { Cargo = { cargo_manifest = "examples/translator/module/rust/Cargo.toml" } }

[clients]
cpp = { Bazel = { bazel_target = "//examples/hello_world/client:client" } }
# nodejs = { Npm = { package_directory = "examples/hello_world/client/nodejs" } }
nodejs = { Npm = { package_directory = "examples/hello_world/client/nodejs" } }
11 changes: 11 additions & 0 deletions examples/private_set_intersection/example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "private_set_intersection"

[application]
build = { Shell = { script = "examples/private_set_intersection/config/build.sh" } }
out = "examples/private_set_intersection/bin/config.bin"

[modules]
module = { Cargo = { cargo_manifest = "examples/private_set_intersection/module/rust/Cargo.toml" } }

[clients]
cpp = { Bazel = { bazel_target = "//examples/private_set_intersection/client:client" } }
11 changes: 11 additions & 0 deletions examples/running_average/example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "running_average"

[application]
build = { Shell = { script = "examples/running_average/config/build.sh" } }
out = "examples/running_average/bin/config.bin"

[modules]
module = { Cargo = { cargo_manifest = "examples/running_average/module/rust/Cargo.toml" } }

[clients]
cpp = { Bazel = { bazel_target = "//examples/running_average/client:client" } }
Loading

0 comments on commit 2f9c55f

Please sign in to comment.