...

Text file src/edge-infra.dev/pkg/edge/chariot/example/README.md

Documentation: edge-infra.dev/pkg/edge/chariot/example

     1# Example: Run Chariot 2 locally using pubsub and storage emulators.
     2
     3### Contents
     4
     51. Prerequisites
     62. Starting Emulators
     73. Demo Program
     84. Running Chariot
     95. Pictures
    106. Stopping the Demo
    117. Inspecting Data Produced by the Demo
    128. Clean Up
    13
    14# Prerequisites
    15
    160. [Chariot RFC For Reference](https://github.com/ncr-swt-retail/edge-roadmap/blob/master/src/rfc/0004-chariot-v2.md)
    171. Google Pubsub Emulator
    18  - The gcloud pubsub emulator command requires Java to work.
    19  - [Google Pubsub Emulator tutorial and setup guide](https://cloud.google.com/pubsub/docs/emulator)
    202. Fake GCS Server
    21  - [Fake GCS Server Github Page](https://github.com/fsouza/fake-gcs-server)
    22  - Either build from source or download compiled binary.
    23  - Must be installed in a `$PATH` directory for scripts to work.
    24
    25# Starting Emulators
    26
    27The Pubsub & Storage emulators need to be running before the demo program or chariot is started.
    28
    29To start the pubsub emulator run the following:
    30
    31```sh
    32# env-init.sh sets the GOOGLE_CLOUD_PROJECT_ID env var
    33$(./env-init.sh) 
    34
    35gcloud beta emulators pubsub start --project=${GOOGLE_CLOUD_PROJECT_ID}
    36```
    37
    38[screenshot of emulator running](./assets/images/img-start-pubsub-emulator.png)
    39
    40To start the fake-gcs-server, run the `start-fake-gcs-server.sh` script.
    41
    42```sh
    43./start-fake-gcs-server.sh
    44```
    45
    46[screenshot of fake-gcs-server running](./assets/images/img-start-fake-gcs-server-script-before-sending-requests.png)
    47
    48
    49# Demo Program
    50
    51The demo program in `main.go` is a simple demonstration of multiple producers to the request topic and multiple consumers on the responses topic.  It loops forever producing random requests and awaiting their responses.  Unfortunately subscription filtering is not implemented in the pubsub emulator, so the demo program must filter responses itself (see issue: [170471468](https://issuetracker.google.com/issues/170471468))
    52
    53To run the demo program, call the `run-demo.sh` script.
    54If the demo is running before chariot, it will wait until a chariot subscription has been created before sending requests on the topic.
    55
    56```sh
    57# To simulate multiple concurrent producers/consumers, run this demo script in multiple shell windows.
    58./run-demo.sh
    59```
    60
    61[screenshot of demo running](./assets/images/img-run-demo-script.png)
    62
    63# Running Chariot
    64
    65Chariot works out of the box on this demo when your environment is configured correctly. To build, run, and configure the correct environment for chariot, call the `run-chariot2.sh` script.
    66
    67```sh
    68./run-chariot2.sh
    69```
    70
    71[screenshot of chariot running](./assets/images/img-run-chariot2-script.png)
    72
    73# Pictures
    74
    75Before running the `run-chariot2.sh` script, your screen should look like the following.
    76
    77![screenshot before chariot runs](./assets/images/chariot-demo-before-running-chariot.png)
    78
    79After running Chariot, you should see logs from the demo programs, chariot, and the emulators.
    80
    81![screenshot after running chariot](./assets/images/chariot-demo-after-running-chariot.png)
    82
    83# Stopping the Demo
    84
    85Call `ctrl-c` to stop the emulators, demo program, and chariot.
    86
    87# Inspecting Data Produced by the Demo
    88
    89The Fake GCS Server script creates a directory that represents a `gs://bucket/object` url on the filesystem.
    90
    91```sh
    92ls ./fake-gcs-server-filesystem/demo
    93```
    94
    95# Clean Up
    96
    97To clean up the data generated by this demo and its scripts, call the provided `cleanup.sh` script.
    98
    99```
   100./cleanup.sh
   101```

View as plain text