From f69bd99c61cf3381dcee85d1bf2eff023a54dce9 Mon Sep 17 00:00:00 2001 From: Robert Roskam Date: Fri, 2 Sep 2016 11:09:01 -0400 Subject: [PATCH] Many changes to the test project (#333) * Added in simple locust file * Correcting the file name * Updated to latest version of daphne * moving settings up * Moved over channels settings * Removed channels settings * Removed settings file * Moved around files * Made a file for normal wsgi * Changed regular wsgi to point to channels settings * Create __init__.py * Added in the appropriate import * Named it right * Create urls_no_channels.py * Delete urls_no_channels.py * Doing this so I don't have to have multiple urls * Update urls.py * Update urls.py * Added in fabric cmd for installing nodejs loadtest * Added in git dependency * Added in a symlink for loadtest * Made run_loadtest command * Added in argument for time * Changed to format on string * Updated arguments * Fixed typo for argument * Made some comments and moved around some tasks * Edits to readme * Add a lot more documentation * Adjusted formatting * Added a comment * Made formatting cahnges * Slight language change * Changed name for testing * Changed name for testing * Update asgi.py * Added in alternate ChannelLayer * Rename chanells_inmemory.py to chanels_inmemory.py * Rename chanels_inmemory.py to channels_inmemory.py * Create asgi_inmemory * Rename asgi_inmemory to asgi_inmemory.py * Added in routing * Switching to instantiated class * Update channels_inmemory.py * Update channels_inmemory.py * Altered the fabric testing tasks * Update and rename asgi_inmemory.py to asgi_ipc.py * Update and rename channels_inmemory.py to channels_ipc.py * Updated to include asgi_ipc * Updated environment setup task * Spelling * Updated channel layer * Update asgi_ipc.py * Rename asgi_ipc.py to asgi_for_ipc.py * Update asgi_for_ipc.py * Trying something * Trying something else * Changed it back * changed back --- testproject/fabfile.py | 10 ++++++++-- testproject/requirements.txt | 3 ++- testproject/testproject/asgi.py | 2 +- testproject/testproject/asgi_for_ipc.py | 6 ++++++ testproject/testproject/settings/channels_ipc.py | 14 ++++++++++++++ .../settings/{channels.py => channels_redis.py} | 0 testproject/testproject/wsgi.py | 2 +- 7 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 testproject/testproject/asgi_for_ipc.py create mode 100644 testproject/testproject/settings/channels_ipc.py rename testproject/testproject/settings/{channels.py => channels_redis.py} (100%) diff --git a/testproject/fabfile.py b/testproject/fabfile.py index 6238405..3bab83d 100644 --- a/testproject/fabfile.py +++ b/testproject/fabfile.py @@ -13,7 +13,7 @@ def setup_redis(): def setup_channels(): sudo("apt-get update && apt-get install -y git python-dev python-setuptools python-pip") sudo("pip install -U pip") - sudo("pip install -U asgi_redis git+https://github.com/andrewgodwin/daphne.git@#egg=daphne") + sudo("pip install -U asgi_redis asgi_ipc git+https://github.com/andrewgodwin/daphne.git@#egg=daphne") sudo("rm -rf /srv/channels") sudo("git clone https://github.com/andrewgodwin/channels.git /srv/channels/") with cd("/srv/channels/"): @@ -43,7 +43,13 @@ def setup_load_tester(src="https://github.com/andrewgodwin/channels.git"): # Run current loadtesting setup # example usage: $ fab run_loadtest:http://127.0.0.1,rps=10 -i "id_rsa" -H ubuntu@example.com @task -def run_loadtest(host, t=90, rps=200): +def run_loadtest(host, t=90): + sudo("loadtest -c 10 -t {t} {h}".format(h=host, t=t)) + +# Run current loadtesting setup +# example usage: $ fab run_loadtest:http://127.0.0.1,rps=10 -i "id_rsa" -H ubuntu@example.com +@task +def run_loadtest_rps(host, t=90, rps=200): sudo("loadtest -c 10 --rps {rps} -t {t} {h}".format(h=host, t=t, rps=rps)) diff --git a/testproject/requirements.txt b/testproject/requirements.txt index 3bb2297..900d067 100644 --- a/testproject/requirements.txt +++ b/testproject/requirements.txt @@ -1,4 +1,5 @@ -asgi-redis==0.13.1 +asgi_redis==0.13.1 +asgi_ipc==1.1.0 asgiref==0.13.3 autobahn==0.14.1 channels==0.14.2 diff --git a/testproject/testproject/asgi.py b/testproject/testproject/asgi.py index ae1640f..73591ef 100644 --- a/testproject/testproject/asgi.py +++ b/testproject/testproject/asgi.py @@ -1,5 +1,5 @@ import os from channels.asgi import get_channel_layer -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings.channels") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings.channels_redis") channel_layer = get_channel_layer() diff --git a/testproject/testproject/asgi_for_ipc.py b/testproject/testproject/asgi_for_ipc.py new file mode 100644 index 0000000..78421fb --- /dev/null +++ b/testproject/testproject/asgi_for_ipc.py @@ -0,0 +1,6 @@ +import os +from channels.asgi import get_channel_layer +import asgi_ipc + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings.channels_ipc") +channel_layer = get_channel_layer() diff --git a/testproject/testproject/settings/channels_ipc.py b/testproject/testproject/settings/channels_ipc.py new file mode 100644 index 0000000..6098a12 --- /dev/null +++ b/testproject/testproject/settings/channels_ipc.py @@ -0,0 +1,14 @@ +# Settings for channels specifically +from testproject.settings.base import * + + +INSTALLED_APPS += ( + 'channels', +) + +CHANNEL_LAYERS = { + "default": { + "BACKEND": "asgi_ipc.IPCChannelLayer", + "ROUTING": "testproject.urls.channel_routing", + }, +} diff --git a/testproject/testproject/settings/channels.py b/testproject/testproject/settings/channels_redis.py similarity index 100% rename from testproject/testproject/settings/channels.py rename to testproject/testproject/settings/channels_redis.py diff --git a/testproject/testproject/wsgi.py b/testproject/testproject/wsgi.py index 9dcfd86..91daa15 100644 --- a/testproject/testproject/wsgi.py +++ b/testproject/testproject/wsgi.py @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings.channels") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings.channels_redis") application = get_wsgi_application()