# Example: Run Chariot 2 locally using pubsub and storage emulators. ### Contents 1. Prerequisites 2. Starting Emulators 3. Demo Program 4. Running Chariot 5. Pictures 6. Stopping the Demo 7. Inspecting Data Produced by the Demo 8. Clean Up # Prerequisites 0. [Chariot RFC For Reference](https://github.com/ncr-swt-retail/edge-roadmap/blob/master/src/rfc/0004-chariot-v2.md) 1. Google Pubsub Emulator - The gcloud pubsub emulator command requires Java to work. - [Google Pubsub Emulator tutorial and setup guide](https://cloud.google.com/pubsub/docs/emulator) 2. Fake GCS Server - [Fake GCS Server Github Page](https://github.com/fsouza/fake-gcs-server) - Either build from source or download compiled binary. - Must be installed in a `$PATH` directory for scripts to work. # Starting Emulators The Pubsub & Storage emulators need to be running before the demo program or chariot is started. To start the pubsub emulator run the following: ```sh # env-init.sh sets the GOOGLE_CLOUD_PROJECT_ID env var $(./env-init.sh) gcloud beta emulators pubsub start --project=${GOOGLE_CLOUD_PROJECT_ID} ``` [screenshot of emulator running](./assets/images/img-start-pubsub-emulator.png) To start the fake-gcs-server, run the `start-fake-gcs-server.sh` script. ```sh ./start-fake-gcs-server.sh ``` [screenshot of fake-gcs-server running](./assets/images/img-start-fake-gcs-server-script-before-sending-requests.png) # Demo Program The 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)) To run the demo program, call the `run-demo.sh` script. If the demo is running before chariot, it will wait until a chariot subscription has been created before sending requests on the topic. ```sh # To simulate multiple concurrent producers/consumers, run this demo script in multiple shell windows. ./run-demo.sh ``` [screenshot of demo running](./assets/images/img-run-demo-script.png) # Running Chariot Chariot 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. ```sh ./run-chariot2.sh ``` [screenshot of chariot running](./assets/images/img-run-chariot2-script.png) # Pictures Before running the `run-chariot2.sh` script, your screen should look like the following. ![screenshot before chariot runs](./assets/images/chariot-demo-before-running-chariot.png) After running Chariot, you should see logs from the demo programs, chariot, and the emulators. ![screenshot after running chariot](./assets/images/chariot-demo-after-running-chariot.png) # Stopping the Demo Call `ctrl-c` to stop the emulators, demo program, and chariot. # Inspecting Data Produced by the Demo The Fake GCS Server script creates a directory that represents a `gs://bucket/object` url on the filesystem. ```sh ls ./fake-gcs-server-filesystem/demo ``` # Clean Up To clean up the data generated by this demo and its scripts, call the provided `cleanup.sh` script. ``` ./cleanup.sh ```