diff --git a/.gitignore b/.gitignore index ebaf8cbbd..956011512 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ RELEASENOTES.rst releasenotes/notes/reno.cache releasenotes/build cover/ +.venv/ +oslo.messaging.conf diff --git a/doc/source/contributor/index.rst b/doc/source/contributor/index.rst index 17ab89a10..3b4ecdf22 100644 --- a/doc/source/contributor/index.rst +++ b/doc/source/contributor/index.rst @@ -8,3 +8,4 @@ Contributing to oslo.messaging contributing driver-dev-guide supported-messaging-drivers + using-simulator diff --git a/doc/source/contributor/using-simulator.rst b/doc/source/contributor/using-simulator.rst new file mode 100644 index 000000000..1f6bc494d --- /dev/null +++ b/doc/source/contributor/using-simulator.rst @@ -0,0 +1,115 @@ +============================ +Oslo Messaging Simulator +============================ + +This guide explains how to set up and run the oslo messaging simulator for testing +different messaging scenarios. + +Prerequisites +------------- +* Python 3.x +* virtualenv +* wget (for Kafka scenarios) + +Environment Setup +----------------- +This assumes you have git cloned the oslo.messaging repository and are in the root +directory of the repository. + +Create and activate a virtual environment:: + + python -m venv .venv + source .venv/bin/activate + +Install required packages:: + + pip install pifpaf + pip install -e . + +Running the Simulator +--------------------- +The simulator supports different scenarios for testing messaging patterns. Below +are the common usage patterns. + +Basic Setup +^^^^^^^^^^^ +Before running the simulator, set up the messaging environment:: + + ./tools/setup-scenario-env.sh + +Available Scenarios +^^^^^^^^^^^^^^^^^^^ +The simulator supports two main scenarios: + +Scenario 01 (RabbitMQ only) +*************************** +This scenario uses RabbitMQ for both RPC and notifications:: + + export SCENARIO=scenario01 + ./tools/setup-scenario-env.sh + +Scenario 02 (RabbitMQ + Kafka) +****************************** +This scenario uses RabbitMQ for RPC and Kafka for notifications:: + + export SCENARIO=scenario02 + ./tools/setup-scenario-env.sh + +Running the Simulator +^^^^^^^^^^^^^^^^^^^^^ + +RPC Server Example +****************** +To start the RPC server:: + + python tools/simulator.py --url rabbit://pifpaf:secret@127.0.0.1:5682/ rpc-server + +RPC Client Example +****************** +To start the RPC client:: + + python tools/simulator.py --url rabbit://pifpaf:secret@127.0.0.1:5682/ rpc-client --exit-wait 15000 -p 64 -m 64 + +Optional Configuration +---------------------- +You can generate a sample configuration file using oslo-config-generator:: + + oslo-config-generator --namespace oslo.messaging > oslo.messaging.conf + +For reference on all available configuration options, visit: +https://docs.openstack.org/oslo.messaging/latest/configuration/opts.html + +To use a configuration file with the simulator, use the --config-file option:: + + python tools/simulator.py --config-file oslo.messaging.conf [other options] + +Command Line Options +-------------------- +The simulator supports various command line options: + +--url URL + The transport URL for the messaging service +--config-file PATH + Path to a configuration file +-d, --debug + Enable debug mode +-p PROCESSES + Number of processes (for client) +-m MESSAGES + Number of messages (for client) +--exit-wait MILLISECONDS + Wait time before exit (for client) + +Cleanup +------- +To clean up the environment, you can terminate the running processes:: + + pkill -f "RABBITMQ" + +Notes +----- +* The default scenario is scenario01 if not specified +* Kafka setup is automatic when using scenario02 +* The simulator uses pifpaf to manage the message broker processes +* Installing with ``pip install -e .`` allows for development mode installation +* Configuration options can be referenced in the official documentation diff --git a/tools/simulator.py b/tools/simulator.py index ec386cf75..a705897a8 100755 --- a/tools/simulator.py +++ b/tools/simulator.py @@ -55,9 +55,9 @@ USAGE = """ Usage: ./simulator.py [-h] [--url URL] [-d DEBUG]\ Usage example: python tools/simulator.py\ - --url rabbit://stackrabbit:secretrabbit@localhost/ rpc-server + --url rabbit://pifpaf:secret@127.0.0.1:5682/ rpc-server python tools/simulator.py\ - --url rabbit://stackrabbit:secretrabbit@localhost/ rpc-client\ + --url rabbit://pifpaf:secret@127.0.0.1:5682/ rpc-client\ --exit-wait 15000 -p 64 -m 64""" MESSAGES_LIMIT = 1000